Version: 0.2
Type: Full Script
Category: Networking
License: BSD License
Description: Very short and basic TCP port scanner. Not very well commented, but everything is self-explanatory.
<!-- nanoScanner 0.2 Copyright (c) 2002, Maciej Plewa All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Maciej Plewa nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --> <html> <head> <title>nanoScanner</title> <style type="text/css"> <!-- #shadowHeading {font : bold; font-size: 40px; position: relative;} #foregrnd {top : 0px; left : 0px; color : #000000; z-index : 2; position : relative; } #shadow {top : 2px; left : 2px; color: #999999; z-index:1; position : absolute; } --> </style> </head> <body bgcolor="#ffffff"> <center> <table><tr><td> <div id="shadowHeading"> <span ID="foregrnd">nanoScanner</span> <span ID="shadow">nanoScanner</span> </div> </td></tr></table> <font size="-1">Lightweight TCP port scanner v0.2<br> <i>written in PHP by Maciej Plewa</i></font> <?php if ($_POST["scan"] == "yes") performScan(); else askForPorts(); function askForPorts() { echo("<br/><br/>"); echo("<p>Before we can begin you have to provide the range of the ports to be scanned:</p>"); echo("<form action="nanoscanner.php" method="POST">"); echo("<table><tr>"); echo("<td><b>Start</b> <input type="text" name="tcpstart" value="0"></td>"); echo("<td><b>Finish</b> <input type="text" name="tcpend" value="1024"></td>"); echo("</tr></table>"); echo("<input type="hidden" name="scan" value="yes">"); echo("<br/><input type="submit" value="Scan">"); echo("<p><b>Tip:</b> Scanning a large range can take a long of time. Remember that the maximum range is <code>0</code> - <code>65536</code></p>"); echo("</form>"); } function performScan() { set_time_limit(0); $count = 0; echo("<h3>Open TCP ports:</h3>"); echo("<table>"); echo("<tr><th align="left">Port</th><th width=30></th><th align="left">Service</th></tr>"); /* Port scanning starts here */ for ($index = $_POST["tcpstart"]; $index <= $_POST["tcpend"]; $index++) { flush(); $socket = fsockopen($_SERVER["REMOTE_ADDR"], $index, $errno, $errstr, 1); if ($socket) { $service = getservbyport($index, "tcp"); fclose($socket); $count++; echo("<tr><td>$index</td><td width="30"></td><td>$service</td></tr>"); } } echo "</table>"; if ($count == 0) echo("<p>All scanned ports are closed: your system <b>seems</b> to be secure!</p>"); else if ($count <= 6) echo("<p>With $count ports open you should install a firewall to secure your system.</p>"); else if ($count > 6) echo("<p>You have $count ports open. I strongly suggest you install a good quality firewall!</p>"); } ?> <hr> <font size="-2">Copyright 2002 by Maciej Plewa. Download <a href="http://home.iprimus.com.au/maciejpl/nanoscanner0.2.tar.gz">source code</a>. </center> </body> </html>