-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path013-Net-Ping-ScanTCP.pl
44 lines (35 loc) · 1.05 KB
/
013-Net-Ping-ScanTCP.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
#!/usr/bin/perl
use Socket;
use Net::Ping;
@HLIST=qw/
10.8.110.170
10.8.110.173
/;
$ssh=Net::Ping->new("tcp",2);
$ssh->port_number(22);
$tel=Net::Ping->new("tcp",2);
$tel->port_number(23);
$web=Net::Ping->new("tcp",2);
$web->port_number(80);
$sec=Net::Ping->new("tcp",2);
$sec->port_number(443);
$icmp=Net::Ping->new("icmp");
#open $FH,"<","hlist.txt" or die "No 'hlist.txt' found !\n";
#while ($HNAME=<$FH>) {
foreach $HNAME (@HLIST) {
#chomp $HNAME;
#next if $HNAME=~/^\s*$/;
#next if $HNAME=~/^\s*#/;
#$HNAME=~s/\s+//g;
#if(my $BINIP=gethostbyname($HNAME)) {
# $DEVIP=inet_ntoa($BINIP);
#} else { $DEVIP=""; }
$DEVIP=$HNAME;
if($ssh->ping($HNAME)) { print "${HNAME}(${DEVIP}) via SSH\n"; }
if($tel->ping($HNAME)) { print "${HNAME}(${DEVIP}) via Telnet\n"; }
if($web->ping($HNAME)) { print "${HNAME}(${DEVIP}) via HTTP\n"; }
if($sec->ping($HNAME)) { print "${HNAME}(${DEVIP}) via HTTPS\n"; }
if($icmp->ping($HNAME)) { print "${HNAME}(${DEVIP}) via ICMP\n"; }
}
#close $FH;
print "#done\.\n";