-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrand_nc.pl
executable file
·85 lines (69 loc) · 2.28 KB
/
rand_nc.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/perl
#-------------------------------------------------------------------
# FILE: rand_nc.pl
# AUTH: Daniel Berry - [email protected]
# VERS: 1.0 beta 4/07/04
# DESC: Simple perl script to generate random arguments for nc
# TCP port connections.
#
# Command line arguments: None
#
# There are 3 arrays controlling target execution
#
# @targ = for storage of IP addresses or FQDN
# $targs = set to number of targets in @targ
#
# @srcIP = for storage of source IP addresses
# $srcIps = set to number of source IP addresses
#
# @port = for storage of the target TCP ports
# $ports = set to the number of ports in @port
#
#
#-------------------------------------------------------------------
# Target array - either IP address format or FQDN
@targ = ('box1.target.net','box2.target.net');
$targs = 2;
# Source IP address to use--should be assigned to system
@srcIP = ('10.1.1.1','10.1.1.2','10.1.1.3','10.1.1.4');
$srcIPs = 4;
# TCP port to connect to
@port = ('25','110','111','135','143','161','389','514','515','1080','1433','1521','8080');
$ports = 13;
# Set pause length for timing - seconds
$pausemin = 5;
$pausemax = 90;
#
# Create output log
`echo "Netcat random TCP connection script..." >/tmp/nc_exe.log`;
`date >>/tmp/nc_exe.log`;
#
# 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 IP address
my $sIPn = int(rand($srcIPs));
$sIP = $srcIP[$sIPn];
#
# Select target TCP port
my $eport = int(rand($ports));
$tport = $port[$eport];
# Execute netcat connection from source IP to target IP and TCP port
print "nc TCP Connect TARG: $i \t Src_IP: $sIP \t IP: $tgtip \t PORT: $tport \n";
`echo "nc TCP Connect TARG: $i \t Src_IP: $sIP \t IP: $tgtip \t PORT: $tport">>/tmp/nc_exe.log`;
`echo "^d"|/usr/bin/nc -v -w5 -s $sIP $tgtip $tport >>/tmp/nc_exe.log`;
$i++;
$pause = $pausemin + int(rand($pausemax));
print "Sleeping $pause ...\n";
sleep $pause;
}
#
# End - script will terminate normally if all works correctly
#
#-------------------------------------------------------------------