Jump to content

[PHP] Port Scanner with Form

- - - - -

  • Please log in to reply
No replies to this topic

#1
Impulser

Impulser

    Newbie

  • Members
  • Pip
  • 5 posts
<?php
/**
 * @author Impulser
 * Please don't release this as your own work repect the author.
 * You may use this on your site and share the code if you want but please keep these comments.
*/
?>
<table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
	<tr>
		<form id="form" name="form" method="post" action"">
			<td>
				<table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
					<tr>
						<td width="100">IP Address:</td>
						<td><input name="ip" type="text" id="ip" size="30"/></td>
					</tr>
					<tr>
						<td width="100">Port:</td>
						<td><input name="port" type="text" id="port" size="30"/></td>
					</tr>
					<tr>
						<td>
							<input type="submit" name="submit" value="Scan"/> 
						</td>
					</tr>
				</table>
			</td>
		</form>
	</tr>
</table>
<?php
if (isset($_POST['submit'])) {
	scan();
}
function scan(){
	$ip = $_POST['ip'];
	$port = $_POST['port'];

	$fp = fsockopen($ip, $port, $errno, $errstr, 1);
	if($fp){
		echo '<center><strong>Port '.$port.' on '.$ip.' is open!</center></strong>';
	} else {
		echo '<center><strong>Port '.$port.' on '.$ip.' is closed!</center></strong>';
	}
}
?>

Please share your tips and thoughts I'm a beginner at programming PHP and HTML and would love to learn.

Enjoy the code please don't use the code for anything that may harm other websites. Please use this for development only.

Thanks, Impulser




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users