exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

nmap.stealth.wrapper

nmap.stealth.wrapper
Posted Aug 17, 1999
Authored by spinux

Nmap wrapper that allows for stealthier scanning routines. Features: creating a host/port table and then randomizing it, scanning each host/port combination in a random sequence, easy creation of decoy addresses, parallel scanning with child process management, consolidation of log files into a nlog-style db or MySQL

tags | tool, nmap
systems | unix
SHA-256 | de4db57bedd850aa95e7a496ac44fc4bcb695572e422d61bedb054836beeda34

nmap.stealth.wrapper

Change Mirror Download
Date: Mon, 12 Apr 1999 12:43:55 -0500
From: HD Moore <nlog@ings.com>
To: nmap-hackers@insecure.org
Subject: nwrap -- nmap stealth wrapper
Parts/Attachments:
1 Shown 34 lines Text
2 Shown 171 lines Text
----------------------------------------

I started working on some scripts to 'wrap' nmap and allow for
stealthier scanning routines. The goals for this script include:

Creating a host/port table and then randomizing it.
Scanning each host/port combination in a random sequence.
Easy creation of decoy addresses.
Parallel scanning with child process management.
Consolidation of log files into a nlog-style db or MySQL.

There are still a number of issues I am working on, if you have any
suggestions/complaints email me:

Delay between scans should be a random number within a user-defined range.

Decoy addresses should remain the same during each scan to eliminate chance
of detection by coordinating traffic logs from each scanned host and finding
the real address in each.

Log file consolidation (maybe use -m - and read it all from an open pipe?)

Better option set for the nwrap script.

Attached is the protoype perl script, I wanted to get some feedback
about what stealth options/techniques people wanted to see implemented
in a nmap wrapper script.


-HD aka spinux

http://nlog.ings.com
http://www.trinux.org
[ Part 2: "Attached Text" ]

#!/usr/bin/perl

use Getopt::Long;

sub exitclean {
my ($msg) = @_;
print "$msg\n";
exit 2;
}


$SIG{INT}=\&sig_catch;

&GetOptions("debug", \$OPTdebug,
"p:s", \$OPTports,
"i:s", \$OPTinput);

open (INPUT,"<".$OPTinput) || exitclean("Could not open host input file: $!");
@targets = (<INPUT>);
close(INPUT) || debugprint("close() failed on INPUT: $!");


# create a host/port list and shuffle it

@targets = shuffle(\@targets);
@ports = parse_ports($OPTports);
@ports = shuffle(\@ports);

foreach $host (@targets)
{
chomp($host);
@ports = shuffle(\@ports);
foreach $port (@ports)
{
push @output, "$host $port";
}
}
@output = shuffle(\@output);


# now do something with that host/port list
foreach $out (@output)
{
($nmaptarget,$nmapport) = split(/\s+/,$out);
$logfile = "$nmaptarget.$nmapport.log";
print "Scanning port $nmapport on $nmaptarget...\n";
system ("nmap -sS -m $logfile -P0 $nmaptarget -p$nmapport -D" . rdecoys(getpppip()))
|| print "Could not launch nmap: $!\n";

}

exit(0);


#
# Functions
#

sub getpppip {
my $DATA=`ifconfig | grep P-t-P | awk \'\{ print \$2 \}\'`;
my $crap;
my $ip;
chomp($DATA);
($crap,$ip) = split(/\:/,$DATA);
return $ip;
}

sub rdecoys {
my ($ip) = @_;
my @octets = split(/\./,$ip);
my $count;
my @decoys = ();
my $decoy;
my $output;

for ($count = 0; $count < 6 ; $count++)
{ $decoys[$count] = int(rand()*255); }

foreach $decoy (@decoys)
{
$output .= "$octets[0].$octets[1].$octets[2].$decoy,";
}
$output .="ME";
return $output;
}

sub debugprint {
($msg) = @_;
print "[debug] $msg\n" unless (!$OPTdebug);
}

sub sig_catch {
my $signame = shift;
print "\nRecieved SIG$signame, exiting...\n";
exit 2;
}


###############################################################################
#
# Function: shuffle
# Purpose: Randomize an array
# To-Do: Done
# Date: 04/09/99
#
# Comments: This routine was pretty much ripped from 'Perl Cookbook' pg 121-122
#
###############################################################################


sub shuffle {
my $array = shift;
my $i = scalar(@$array);
my $j;
foreach $item (@$array )
{
--$i;
$j = int rand ($i+1);
next if $i == $j;
@$array [$i,$j] = @$array[$j,$i];
}
return @$array;
}



###############################################################################
#
# Function: parse_ports
# Purpose: Take in an nmap style port list and return an array
# To-Do: Add a check to make sure all the ports added are numeric
# Date: 04/09/99
#
###############################################################################

sub parse_ports {
my ($portstring) = @_;
my $splitter = ",";
my @portlist = ();
my @portsplit = ();
my $port;

@portsplit = split($splitter,$portstring);
foreach $port (@portsplit)

{
@range = split(/\-/,$port);
if (scalar(@range) > 1)
{
if ($range[0] > $range[1] || $range[0] < 0 || $range[0] > 65535 || $range[1] < 0 || $range[1] > 65535)
{
print "Your range of $range[0] -> $range[1] is invalid!\n";
exit(1);
}
for ($i = $range[0]; $i < $range[1] + 1; $i++)
{
if ($i > 0 && $i < 65536)
{
push @portlist, $i;
}
}

} else {
push @portlist, $port;
}
}

return @portlist;
}

Login or Register to add favorites

File Archive:

June 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Jun 1st
    0 Files
  • 2
    Jun 2nd
    0 Files
  • 3
    Jun 3rd
    18 Files
  • 4
    Jun 4th
    21 Files
  • 5
    Jun 5th
    0 Files
  • 6
    Jun 6th
    57 Files
  • 7
    Jun 7th
    6 Files
  • 8
    Jun 8th
    0 Files
  • 9
    Jun 9th
    0 Files
  • 10
    Jun 10th
    12 Files
  • 11
    Jun 11th
    27 Files
  • 12
    Jun 12th
    38 Files
  • 13
    Jun 13th
    16 Files
  • 14
    Jun 14th
    14 Files
  • 15
    Jun 15th
    0 Files
  • 16
    Jun 16th
    0 Files
  • 17
    Jun 17th
    16 Files
  • 18
    Jun 18th
    26 Files
  • 19
    Jun 19th
    15 Files
  • 20
    Jun 20th
    18 Files
  • 21
    Jun 21st
    8 Files
  • 22
    Jun 22nd
    0 Files
  • 23
    Jun 23rd
    0 Files
  • 24
    Jun 24th
    0 Files
  • 25
    Jun 25th
    0 Files
  • 26
    Jun 26th
    0 Files
  • 27
    Jun 27th
    0 Files
  • 28
    Jun 28th
    0 Files
  • 29
    Jun 29th
    0 Files
  • 30
    Jun 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