#!/usr/bin/perl # # Script: extras.pl # # Project: AWLP - Alptekin's Wireless Linux Project # http://awlp.sourceforge.net/ # # Version: 1.2 # # Author: Alptekin Cakircali # http://www.cakircali.com/alptekin # (alptekin@cakircali.com) # # Date: August 24, 2005 # # Purpose: This script is part of AWLP. This script provides ASCII to HEX, # HEX to ASCII conversion tools, DHCP lease table and Error # Codes display functionality. # # Modification History: # v1.2 - August 24, 2005: o Added Captive Portal - NoCatAuth v0.82 # o Included 'links' Slackware package in tag files # # v1.1 - August 15, 2005: o Updated for the latest versions of Slackware 10.1 # o Incorporated latest releases of hostap-driver (v0.3.9), # hostap-utils (v0.3.7) and bridge-utils (v1.0.6) # o Updated IEEE Organizationally Unique Identifier # file (oui_filtered.txt) content # # v1.0 - December 20, 2004: o Initial code release # # # # Copyright and License: # ---------------------- # # Copyright (c) 2005 Alptekin Cakircali # Released under the GNU GPL - see http://www.gnu.org/copyleft/gpl.html # # This file is part of AWLP. # # AWLP is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # AWLP is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with AWLP; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Adding /var/www/cgi-bin to @INC BEGIN { push @INC, '/var/www/cgi-bin/awlp' } # Include the global_configuration.pl, engines1.pl, engines2.pl and error_messages.pl require("global_configuration.pl"); require("engines1.pl"); require("engines2.pl"); require("error_messages.pl"); use CGI; $TheQuery = new CGI; $FORM_Action1 = $TheQuery->param('Action1'); $CurrentDateTime = &show_date_time(0); # Check form Action1 value if ($FORM_Action1 eq "ASCIItoHEX") { my $FORM_Action2 = $TheQuery->param('Action2'); my $ASCIIText = $TheQuery->param('ASCIIText'); my $ConvertedHEX; if ($FORM_Action2 eq "CONVERT") { $ConvertedHEX = unpack(H32,"${ASCIIText}"); } print STDOUT "Content-type: text/html\nCharset: ${CHARACTER_SET}\nPragma: no-cache\n\n"; print STDOUT < ${ASCIItoHEX_TITLE}
${FONT2}
${FONT2} ASCII:   ${FONTC} ${FONT2}          ${FONTC}
${FONT2} HEX:   ${FONTC} ${FONT2} ${ConvertedHEX}   ${FONTC}

${FONT2} ${FONTC}



HTMLCODE } elsif ($FORM_Action1 eq "HEXtoASCII") { my $FORM_Action2 = $TheQuery->param('Action2'); my $HEXNumber = $TheQuery->param('HEXNumber'); my $ConvertedASCII; if ($FORM_Action2 eq "CONVERT") { foreach($i=0;$i ${HEXtoASCII_TITLE}
${FONT2}
${FONT2} HEX:   ${FONTC} ${FONT2}          ${FONTC}
${FONT2} ASCII:   ${FONTC} ${FONT2} ${ConvertedASCII}   ${FONTC}

${FONT2} ${FONTC}



HTMLCODE } elsif ($FORM_Action1 eq "DHCPLeaseTable") { my $DHCPLeaseTableShow, $MACAddressShow, $Key; my @Temp_1; my %DHCPLeaseTable, $ClientDetails; %DHCPLeaseTable = &get_dhcpd_lease_info("${DHCPD_LEASES_PATH}", "", 2); # Construct the DHCP Leases Table foreach $Key (sort keys %DHCPLeaseTable) { if ($Key =~ m/^\d+\.\d+\.\d+\.\d+$/) { @Temp_1 = split(/,/, $DHCPLeaseTable{$Key}); $MACAddressShow = uc($Temp_1[2]); # Check if the client is connected %ClientDetails = &proc_get_client_mac_details("$Temp_1[2]", "$ProcWLANDir"); if ($ClientDetails{'supported_rates'}) { $DHCPLeaseTableShow .= < ${FONT2} ${Key} ${FONTC} ${FONT2} ${MACAddressShow} ${FONTC} ${FONT2} $Temp_1[3] ${FONTC} ${FONT2} $Temp_1[0] ${FONTC} ${FONT2} $Temp_1[1] ${FONTC} HTMLCODE } @Temp_1 = (); } } if (!$DHCPLeaseTableShow) { $DHCPLeaseTableShow .= < ${FONT2} 
${ERROR_MESSAGES_SHOW[130]}
 ${FONTC} HTMLCODE } print STDOUT "Content-type: text/html\nCharset: ${CHARACTER_SET}\nPragma: no-cache\nrefresh: ${DHCP_LEASE_TABLE_REFRESH_INTERVAL}\n\n"; print STDOUT < ${DHCP_LEASE_TABLE_TITLE}
${FONT2}${CurrentDateTime}${FONTC}


${FONT2} ${DHCPLeaseTableShow}
${FONT2} IP: ${FONTC} ${FONT2} MAC: ${FONTC} ${FONT2} Hostname: ${FONTC} ${FONT2} Starts: ${FONTC} ${FONT2} Ends: ${FONTC}



HTMLCODE } elsif ($FORM_Action1 eq "CheckUpdates") { my $UpdateResultsShow; my $UpdatesContent; my $UpdateVersion, $UpdateReleaseDate, $UpdateDetails; # First, delete the temp file unlink("${CHECK_FOR_UPDATES_PATH}"); # Store the version information in a temp file system("wget -q -t 1 -T 15 -O ${CHECK_FOR_UPDATES_PATH} ${CHECK_FOR_UPDATES_URL}"); # Grab that temp file and parse its content $UpdatesContent =`cat /tmp/CheckForUpdates.txt`; $UpdatesContent =~ s/^\s+//; $UpdatesContent =~ s/\s+$//; ($UpdateVersion, $UpdateReleaseDate, $UpdateDetails) = split(/\:\:\:/, $UpdatesContent); # Construct the Update Results Shown section if (!$UpdateVersion) { $UpdateResultsShow =< ${FONT2}
   There was a problem connecting to the server
   for checking the updates. Please try again later.   

http://awlp.sourceforge.net

${FONTC} HTMLCODE } elsif (${UpdateVersion} <= ${PROJECT_VERSION}) { $UpdateResultsShow =< ${FONT2}
   Your version ${PROJECT_VERSION} is the latest version.   

http://awlp.sourceforge.net

${FONTC} HTMLCODE } else { $UpdateResultsShow =< ${FONT2}   A newer version is found! 
${FONTC} ${FONT2} Your Version: ${FONTC} ${FONT2}${PROJECT_VERSION}${FONTC} ${FONT2} New Version: ${FONTC} ${FONT2}${UpdateVersion}${FONTC} ${FONT2} Release Date: ${FONTC} ${FONT2}${UpdateReleaseDate}${FONTC} ${FONT2} Details: ${FONTC} ${FONT2}${UpdateDetails}${FONTC} ${FONT2}  http://awlp.sourceforge.net  ${FONTC} HTMLCODE } unlink("${CHECK_FOR_UPDATES_PATH}"); print STDOUT "Content-type: text/html\nCharset: ${CHARACTER_SET}\nPragma: no-cache\n\n"; print STDOUT < ${CHECK_UPDATES_TITLE}
${FONT2}
${UpdateResultsShow}
${FONTC}


HTMLCODE } elsif ($FORM_Action1 eq "ErrorCodesList") { my $ErrorCodesListShow; my $ErrorMessage, $ErrorDescription, $i; # Construct Error Codes List for ($i=100;$i<@ERROR_MESSAGES_SHOW;$i++) { if ($ERROR_MESSAGES_SHOW[$i] && $ERROR_MESSAGES_DESCRIPTION[$i]) { $ErrorMessage = $ERROR_MESSAGES_SHOW[$i]; $ErrorDescription = $ERROR_MESSAGES_DESCRIPTION[$i]; $ErrorMessage =~ s/\\s*\(\:$i\)\s*\<\/B\>//i; $ErrorCodesListShow .= < ${FONT2} :${i} ${FONTC} ${FONT2}${ErrorMessage}${FONTC} ${FONT2}${ErrorDescription}${FONTC} HTMLCODE } } print STDOUT "Content-type: text/html\nCharset: ${CHARACTER_SET}\nPragma: no-cache\n\n"; print STDOUT < ${ERROR_CODES_LIST_TITLE}
${FONT2}
${ErrorCodesListShow}
${FONT2} :Code ${FONTC} ${FONT2}< Error Message >${FONTC}
${FONT2}< Error Description >${FONTC}
${FONTC}


HTMLCODE } else { # If we come here, then it means the FORM_Action1 value is invalid. &possible_intruder_attack("${ERROR_MESSAGES_SHOW[128]}", 1); } exit; # # Subroutines # sub possible_intruder_attack() { my $ErrorMessage = $_[0], $TerminateProgram = $_[1]; print "Content-type: text/html\nCharset: ${CHARACTER_SET}\nPragma: no-cache\n\n"; print < ($ErrorMessage)


HTMLCODE if ($TerminateProgram) { exit; } }