Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
IP scanner, give it range of IPs and it'll return the website title
* @Script: IP Scanner
* @Version: 0.1
* @Author: Emad Elsaid
* @Email:
* @Website:
* @What is that ?:
* that is a ip acanner script
* you can give it a range of IP addresses and it'll
* get the website title of that page or notify that
* this is not a website at all
* i developed it becase when we made a 2011 revolution in Egypt
* i cannot access any nameserver but i can access one website
* then i made a nslookup command to get the ip of that website and then
* created that script to get the available website for me.
* i really don't know how to get the ip address using that script
* @How to use ?
* you need to modify the $range variable
* every octet could be written as 1 number like : 1, 3, 5
* or you can specify a whole range to enumerate between : 1-255, 24-26
* then fire it from terminal not browser, to get a continual output.
$range = '';
$range = explode('.', $range );
foreach( $range as $index=>$octet )
$range[$index] = array_map( 'intval', explode('-',$octet) );
// 4 for loops to generate the ip address 4 octets
for( $octet1=$range[0][0]; $octet1<=(($range[0][1])? $range[0][1]:$range[0][0]); $octet1++ )
for( $octet2=$range[1][0]; $octet2<=(($range[1][1])? $range[1][1]:$range[1][0]); $octet2++ )
for( $octet3=$range[2][0]; $octet3<=(($range[2][1])? $range[2][1]:$range[2][0]); $octet3++ )
for( $octet4=$range[3][0]; $octet4<=(($range[3][1])? $range[3][1]:$range[3][0]); $octet4++ )
// assemble the IP address
$ip = $octet1.".".$octet2.".".$octet3.".".$octet4;
// initialise the URL
$x = curl_init( $ip );
// output buffer start becase it damn output the page HTML
// get page HTML
curl_exec( $x );
// get HTML from output buffer
$buffer = ob_get_contents();
// clean buffer
// get the title position
$title_start = strpos( $buffer, '<title>')+strlen('<title>');
$title_end = strpos( $buffer, '</title>');
// print the result for that IP address
echo $ip." : ";
if( $title_end!==false ) // if title tag exists
echo trim(substr( $buffer, $title_start, $title_end-$title_start ))."\n"; // print title
else if( strlen($buffer)>0 ) // if there is a response
echo "Cannot get title\n";
echo "[Not a site]\n"; // if the isn't any response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.