Copy Link
Add to Bookmark
Report

xine-2.020

eZine's profile picture
Published in 
Xine
 · 26 Apr 2019

  


/-----------------------------\
| Xine - issue #2 - Phile 020 |
\-----------------------------/

#!/usr/bin/perl

# IP scanner - b0z0/iKx
# Scans a range of IPs and tries to determinate if the hosts are
# alive. It can also do name server queries to see if something
# respondes to those scanned IPs. FPing is needed!
#
#
# Sample usage:
# ipscan -H 123.10.10.4 -e 20
# Will scan IPs from 123.10.10.4 up to 123.10.10.20
# Run without command line parameters for more help!
#

require "getopt.pl";
$|=1;

&Getopt('Hetz'); # Get command line options
$host=$opt_H;
$endipscan=$opt_e;
$pingto=$opt_t;
$dohost=$opt_z;


# default options
$pingto=5000 if (($pingto eq '') || ($pingto <= 250));
$dohost=0 if ($dohost eq '');


print "\nIPScan - by b0z0/iKx\n";
if (($host eq '') || ($endipscan eq ''))
{
print "usage: ipscan\n";
print " -H [first ip] => first IP from we will start thescan\n";
print " -e [last nr] => last IP that we will scan\n";
print " -t [msecs] => timeout in milisecs\n";
print " -z 1 => do also a host name search with host\n";
print "\n\n Example: ipscan -H 123.123.123.3 -e 12\n";
exit();
}


($high,$second,$third,$start)=split('\.',$host);

for ($last=$start;$last<=$endipscan;$last++)
{
$host=join('.',$high,$second,$third,$last);
printf ("Looking for %s ..... ",$host);
$pinging=`fping -a -t $pingto $host`;
chop($pinging);
if ($pinging eq '')
{
print "Seems unreachable\n";
}
else
{
print "Seems reachable\n";
}
if ($dohost == 1)
{
$host=join('.',$last,$third,$second,$high);
$|=1;
open(HOST,"host -t ptr $host.in-addr.arpa 2>& 1 |");
while (<HOST>) { print; }
close (HOST);
printf("\n");
}
}

← previous
next →
loading
sending ...
New to Neperos ? Sign Up for free
download Neperos from Google Play

Let's discover also

Recent Articles

Recent Comments

Neperos cookies
This website uses cookies to store your preferences and improve the service. Cookies authorization will allow me and / or my partners to process personal data such as browsing behaviour.

By pressing OK you agree to the Terms of Service and acknowledge the Privacy Policy

By pressing REJECT you will be able to continue to use Neperos (like read articles or write comments) but some important cookies will not be set. This may affect certain features and functions of the platform.
OK
REJECT