what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

webmap.pl

webmap.pl
Posted Aug 17, 1999

webmap.pl

tags | tool, nmap, patch
systems | unix
SHA-256 | 1e4147d39e655ad220449ff47faabe169ca0d9482c8643448f1cd6fbeeb30245

webmap.pl

Change Mirror Download
Date: Fri, 19 Feb 1999 14:16:28 -0500 (EST)
From: Fyodor <fyodor@dhp.com>
To: ajax <ajax@mobis.com>
Cc: MadHat <madhat@unspecific.com>, "'nmap-hackers@insecure.org'" <nmap-hackers@insecure.org>
Subject: Re: nmap..... via web

On Thu, 18 Feb 1999, ajax wrote:

> anyway, www.mobis.com/ajax/code/nmap/webmap.cgi is my seven minute
> rendering of what i think it should look like, complete with sanity
> checking of the user input variable,

You mean this sanity checking?

# sanity check
if ($query->param('ip_address') =~ /[~`\#\$\!\%\^\&\*()\|\[\]\{\}\:\;\?]/ )
{ print "<H1><tt>Sorry, Try again. </H1>";
exit;
}

and then later you call:

$output = `$nmap $ipaddress 2>&1`;

This doesn't look very sufficent to me. For example, the banned chars
don't include space or '-'. So what is to stop someone from giving an IP
address of '-o/etc/passwd mymachine' and thus overwriting your password
file? There are a lot of other command lines which could cause damage.
And what if they include a newline and a second command? Remember our
favorite phf.cgi? Anyone who writes one of these needs to be very very
careful to ONLY allow what is known to be safe -- don't try to ban the
stuff you know is unsafe (because you won't catch everything).

Note that I havent' actually tested that my 'exploits' work. Those are
just some of the things that look like problems at first glance.

Cheers,
Fyodor


--
Fyodor 'finger pgp@www.insecure.org | pgp -fka'
Frustrated by firewalls? Try nmap: http://www.insecure.org/nmap/
In a free and open marketplace, it would be surprising to have such an
obviously flawed standard generate much enthusiasm outside of the criminal
community. --Mitch Stone on Microsoft ActiveX

------------------------------------------------------------------------------

#!/usr/bin/perl
# webmap: cheezy front end to nmap written by ajax@mobis.com
# for all the marketing people
#
# its best to either use suidperl, or make nmap suid-root

use CGI qw/:standard :html3 :fatalsToBrowser/;
use CGI::Carp; #qw(fatalsToBrowser);

# configuration options
$allow_bans = 0; # should we ban any hosts?
@banned = ('example.com',
'example.com',
'example.com',
'example.com'); # these hosts are banned
$restrict_hosts = 0; # should we restrict hosts?
@only_allow = ('example.com'); # only allow these hosts
$send_email = 0; # send mail upon usage of this program?
$email_address = "root\@example.com"; # email address to send email to
$nmap = "/usr/local/bin/nmap -sS -O"; # nmap program and options which will
# be executed followed by dest IP



$query = new CGI;
print $query->header;
if (!($query->param('ip_address'))) { &print_prompt($query); }
&security_check($query);
&do_nmap($query);
print $query->end_html;
exit;

sub security_check
{
$not_allowed = 0;
if ($allow_bans) {
foreach $host (@banned) {
if ($ENV{'REMOTE_HOST'} =~ /$host/) {
print "<H1>Sorry, Your host is banned.";
exit;
}
}
}
if($restrict_hosts) {
foreach $host (@only_allow) {
if (!($ENV{'REMOTE_HOST'} =~ /$host/)) {
$not_allowed++;
}
}
}
# sanity check
if ($query->param('ip_address') =~ /[~`\#\$\!\%\^\&\*()\|\[\]\{\}\:\;\?]/ )
{ print "<H1><tt>Sorry, Try again. </H1>";
exit;
}

if ($not_allowed) {
print "<h1>Sorry, You are not connected from one of the allowed hosts.</h1>\n";
exit;
}
return 0;
}

sub do_nmap {
my($query) = @_;
my(@values,$key);

if ($query->param('ip_address') ne "") {
$ipaddress = $query->param('ip_address');
print "<b>Results (this may take a minute):</b><br><tt>",
$output = `$nmap $ipaddress 2>&1`;
print "<p><PRE>$output</PRE>";

if ($send_email) {
#send email whenever this program was ran
$hostname = $ENV{'REMOTE_HOST'};
open (MAIL, "|/usr/bin/sendmail -t") || die "Can't open /usr/bin/sendmail\n";
print MAIL "To: <",$email_address,">\n";
print MAIL "From: <",$hostname,">\n";
print MAIL "Subject: usage of webmap.cgi\n\n";
print MAIL "------------------------------------------------------\n";
# print the entire http environment for this session
foreach $key ($query->param) {
print MAIL "$key -> ";
@values = $query->param($key);
print MAIL join(", ",@values),"\n";
}
foreach $key (sort keys %ENV) {
print MAIL "$key=$ENV{$key}\n";
}
print MAIL "------------------------------------------------------\n";
close (MAIL);
return 0;

}
}
return 0;
}


return 0;
sub print_prompt {
my($query) = @_;

print $query->start_html,
"<FONT COLOR=\"#000000\" SIZE=\"3\" FACE=\"\">",
$query->start_form,
"<H1>K-RAD ELITE NMAP SCANNER</H1><br>\n",
"<h5><EM>destinationIP </EM>",
$query->textfield(-name=>'ip_address',
-size=>15),"<BR>",
"<P>",$query->reset,
$query->submit('Action','Submit'),
$query->endform;
}
Login or Register to add favorites

File Archive:

April 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Apr 1st
    10 Files
  • 2
    Apr 2nd
    26 Files
  • 3
    Apr 3rd
    40 Files
  • 4
    Apr 4th
    6 Files
  • 5
    Apr 5th
    26 Files
  • 6
    Apr 6th
    0 Files
  • 7
    Apr 7th
    0 Files
  • 8
    Apr 8th
    22 Files
  • 9
    Apr 9th
    14 Files
  • 10
    Apr 10th
    10 Files
  • 11
    Apr 11th
    13 Files
  • 12
    Apr 12th
    14 Files
  • 13
    Apr 13th
    0 Files
  • 14
    Apr 14th
    0 Files
  • 15
    Apr 15th
    30 Files
  • 16
    Apr 16th
    10 Files
  • 17
    Apr 17th
    22 Files
  • 18
    Apr 18th
    45 Files
  • 19
    Apr 19th
    0 Files
  • 20
    Apr 20th
    0 Files
  • 21
    Apr 21st
    0 Files
  • 22
    Apr 22nd
    0 Files
  • 23
    Apr 23rd
    0 Files
  • 24
    Apr 24th
    0 Files
  • 25
    Apr 25th
    0 Files
  • 26
    Apr 26th
    0 Files
  • 27
    Apr 27th
    0 Files
  • 28
    Apr 28th
    0 Files
  • 29
    Apr 29th
    0 Files
  • 30
    Apr 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close