Post: Simple TCP Port Scanner
10-18-2015, 07:08 PM #1
Octolus
I defeated!
(adsbygoogle = window.adsbygoogle || []).push({});
You must login or register to view this content.



This is a very 'basic' port scanner in written by me in PHP. If you have any ideas to how we can improve it, then feel free to edit/reply your own port scanner version. To fresh it up, I've added bootstrap, so we can use bootstrap design for the tables.

Basically, we store the ports and their information in Array's. Then use fsock to check if we can make a connection to them, php is not really the best way to check if tools are open. Tools such as nmap should always be used, if available.

    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" integrity="sha256-MfvZlkHCEqatNoGiOXveE8FIwMzZg4W85qfrfIFBfYc= sha512-dTfge/zgoMYpP7QbHy4gWMEGsbsdZeCXz7irItjcC3sPUFtf0kuFbDz/ixG7ArTxmDjLXDmezHubeNikyKGVyQ==" crossorigin="anonymous">
<div class="container" style="padding-top:50px">
<?php
if (isset($_GET['ip'])) {

if (!filter_var($_GET['ip'], FILTER_VALIDATE_IP) === false) {

$ports = ['SSH' => 21, 'FTP' => 22, 'Awesome faceNS' => 53, 'HTTP' => 80, 'HTTPS' => 443, 'HTTP Proxy' => 8080, 'SMTP' => 25, 'Memcached' => 11211, 'MySQL' => 3306, 'Windows RDP' => 3389];


echo '<table class="table table-bordered">';

foreach($ports as $name => $port) {
$fp = fsockopen($_GET['ip'], $port, $errno, $errstr, 0.5);
if (!$fp) {
echo '<tr><td>'.$name.' ('.$port.'Winky Winky</td><td><font color="red">Closed</font></td></tr>';
} else {
echo '<tr><td>'.$name.' ('.$port.'Winky Winky</td><td><font color="green">Open</font></td></tr>';
fclose($fp);
}
}

echo '</table>';
} else {
echo 'The IP Address you submitted is invalid.';
}

} else {
echo 'The ?ip= get parameter is missing.';
}
?>
</div>
Last edited by Octolus ; 10-18-2015 at 08:05 PM.

The following 4 users say thank you to Octolus for this useful post:

Kam, Kryptus, RTE

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo