Jump to content

Simple Port Scanner in PHP

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
robertiptv

robertiptv

    Newbie

  • Members
  • Pip
  • 1 posts
A simple port scan in php:
<?php
$host = $_SERVER['REMOTE_ADDR'];
for($i=80;$i<90;$i++) {
$fp = fsockopen($host,$i,$errno,$errstr,10);
if($fp)
{
echo "port " . $i . " open on " . $host . "\n";
fclose($fp);
}
else
{
echo "port " . $i . " closed on " . $host . "\n";
}
flush();
}


?>

Edited by WingedPanther, 31 October 2008 - 08:35 PM.
add code tags


#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Please use code tags (the # button), especially when posting tutorials.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
supercow

supercow

    Newbie

  • Members
  • Pip
  • 1 posts
Thanks!

#4
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Moved to correct forum.

#5
phpforfun

phpforfun

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,236 posts
I think john made a tutorial like this, and Jordan did too, only jordans was more of a port monitor than a scanner
Checkout my new forum! http://adminreference.com/