-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrand_nmap.pl
executable file
·70 lines (59 loc) · 1.81 KB
/
rand_nmap.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/perl
#-------------------------------------------------------------------
# FILE: rand_nmap.pl
# AUTH: Daniel Berry - [email protected]
# VERS: 1.2 beta 3/08/04
# DESC: Simple perl script to generate random arguments for nmap
# scans.
#
# NOTE: For use with LANforge 4-port traffic generators using
# standard nmap executable.
#
# Command line arguments: None
#
# There are 2 arrays controlling target execution
#
# @targ = for storage of IP addresses of FQDN
# $targs = set to number of targets in @targ
#
# @port = for storage of the local ethernet ports
# $ports = set to the number of ports in @port
#
#
#-------------------------------------------------------------------
# Target array - either IP address format or FQDN
@targ = ('10.1.1.1-254','10.1.2.1-254');
$targs = 2;
# Ethernet port to use (eth1-4)
@port = ('eth4#1','eth4#2','eth4#3');
$ports = 3;
# Set pause length for timing - seconds
$pause = 1800;
#
# Setup loop -- loop is continious until terminated
#
my $i = 0;
while (1) {
#
# Random selection of target
my $tgt = int(rand($targs));
$tgtip = $targ[$tgt];
#
# Select source eth port
my $eport = int(rand($ports));
$srcport = $port[$eport];
# Execute nmap TCP Connect scan from source port to target
print "nmap TCP Connect scan TARG: $i \t IP: $tgtip \t ETH: $srcport \n";
$stuff = `/usr/bin/nmap -e $srcport -sT -o /tmp/nmap_exe.log $tgtip`;
# Write output of execution to log
open (FILE, ">/tmp/nmap.log");
print FILE $stuff;
close (FILE);
$i++;
print "Sleeping $pause ...\n";
sleep $pause;
}
#
# End - script will terminate normally if all works correctly
#
#-------------------------------------------------------------------