#!/usr/local/bin/perl # Script to print on port services and trojans # Called from ports.html # Written by Robert G. Ferrell (rgferrell@direcway.com) # Revised 4/28/2000 RGF: Fix trojan field reporting problem # Revised 8/11/2000 RGF: Fix error message when 0 selected # Revised 5/21/2001 RGF: Change if to unless in trojan field test require qq(INSERT CGI LIBRARY HERE); &ReadParse; $rootdir = qq(INSERT DOCUMENT DIRECTORY HERE); $dbase = qq($rootdir/ports.db); $port_in = $in{'port_no'}; $port_in =~ s/^\s//; $keywd = $in{'keyword'}; $keywd =~ s/^\s//; $p_stat = 0; $k_stat = 0; $k_inc = 0; $count = 0; $port_match = 0; $key_match = 0; print "Content-type: text/html\n\n"; if ($port_in =~ /^\d{1,5}$/) { $p_stat = 1; $search = qq(Port); $term = $port_in; &print_results; } elsif ($keywd ne "") { $k_stat = 1; $search = qq(Keyword); $term = $keywd; &print_results; } else { &no_data; } sub bad_port { print <<"End_of_print1";
Your port entry was $port_in. Make sure port number is an integer from 0 to 65536.
Please use the BACK button on your browser to return to the search page and try again.
No Port Number or Keyword Provided!
Please use the BACK button on your browser to return to the search page and try again.
$search: $term
Search Results
End_of_print3
open(DB, $dbase);
while(defined($line = PORT PROTOCOL
SERVICE DESCRIPTION
TROJAN(S) ";
}
} elsif (($p_stat == 0) && ($k_stat == 1)) {
$key_match = grep (/$keywd/i, $line);
if ($key_match != 0) {
$count++;
print "$port $prot ";
print "$serv $desc ";
print "$troj ";
$k_inc++;
}
}
}
close(DB);
if (($k_stat == 1) && ($key_match == 0) && ($k_inc == 0)) {
print "$port $prot ";
print "$serv $desc ";
print "$troj Keyword Not Found ";
} elsif (($p_stat == 1) && ($port_match == 0)) {
print "No Assigned Services ";
}
print <<"End_of_print6";
Total Returns = $count