Visit our newest sister site!
Hundreds of free aircraft flight manuals
Civilian • Historical • Military • Declassified • FREE!


TUCoPS :: Hacking Techniques :: sps.pl

Simple Ping Sweep 1.0b sps is a basic ping sweep utility you can ping a single host, hosts from a file, or a range of ip addresses.




#!usr/bin/perl
#---Simple Ping Sweep by Mb---
use Net::Ping;
use Getopt::Std;

getopts('h:f:t:s:e:l:');
unless($opt_h || $opt_f || $opt_s && $opt_e){
die("---Simple Ping Sweep By Mb---\n   Usage:\n   -h IP Address/Hostname to ping\n   -f hostfile\n   -t timeout(s) default is 5 sec. !!must be greater than 0!!\n   -l logfile\n   For multiple IP scans\n   -s starting ip\n   -e ending octect\n");
}
print "+-+-Simple Ping Sweep by Mb\n+-+-Beginning ping sweep...\n\n";
$log=$opt_l;
if($opt_h){
$host=$opt_h;
if(! $opt_t){
$p=Net::Ping->new('icmp');
}
else{
$p=Net::Ping->new('icmp',$opt_t);
}
if ($p->ping($host)){
print "Response from $host...\n";
if ($opt_l){
&printlog($host,2);
}
}
else{
die("No response from $host\n");
if ($opt_l){
&printlog($host,1);
}
}
}

if($opt_f){
$hf=$opt_f;
open(HOSTFILE,$hf) || die("Cant open $hf\n");
while(<HOSTFILE>){
	chomp($_);
	if(! $opt_t){
	$p=Net::Ping->new('icmp');
	}
	else{
	$p=Net::Ping->new('icmp',$opt_t);
	}
	if ($p->ping($_)){
	print "**Response from $_...\n";
	if ($opt_l){
	&printlog($_,2);
	}
	}
	else{
	print "!!No response from $_...\n";
	if($opt_l){
	&printlog($_,1);
	}
	}
}
close HOSTFILE;
}

if ($opt_s && $opt_e){
$host="";
@parts = split(/\./,$opt_s);
if($parts[3] <= $opt_e){
for($end=$parts[3];$end <= $opt_e; $end++){
	$host=$parts[0] . "." . $parts[1] . "." . $parts[2] . "." . $end;
	if(! $opt_t){
	$p=Net::Ping->new('icmp');
	}
	else{
	$p=Net::Ping->new('icmp',$opt_t);
	}
	if ($p->ping($host)){
	print "**Response from $host...\n";
	if ($opt_l){
	&printlog($host,2);
	}
	}
	else{
	print "!!No response from $host\n";
	if ($opt_l){
	&printlog($host,1);
	}
	}
}
}
else{
die("!Ack!..ending octect is less than beginning\n");
}
}
sub printlog{
$ip=$_[0];
$md=$_[1];
if($md==1){
	open(OUT,">>$log") || die("Error opening log file: $log...\n");
	print OUT "!!No response from $ip\n";
	close OUT;
}
if($md==2){
	open(OUT,">>$log") || die("Error opening log file: $log...\n");
	print OUT "**Response from $host...\n";
	close OUT;
}
}







TUCoPS is optimized to look best in Firefox® on a widescreen monitor (1440x900 or better).
Site design & layout copyright © 1986-2014 AOH