Untitled


SUBMITTED BY: Guest

DATE: May 31, 2015, 5:50 a.m.

FORMAT: Text only

SIZE: 4.7 kB

HITS: 1303

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>Port Scanner</title>
  5. <style type="text/css">
  6. body
  7. {
  8. color: #ffffff;
  9. text-shadow: 2px 2px #000000;
  10. background-color: #282828;
  11. font-family: Arial, Helvetica, sans-serif;
  12. }
  13. pre
  14. {
  15. background-color: #353535;
  16. border: solid 1px #505050;
  17. }
  18. input
  19. {
  20. font-family: Arial, Helvetica, sans-serif;
  21. }
  22. .Button
  23. {
  24. padding: 5px 10px;
  25. background: #303030;
  26. border: solid #101010 1px;
  27. color: #fff;
  28. cursor: pointer;
  29. font-weight: bold;
  30. border-radius: 5px;
  31. -moz-border-radius: 5px;
  32. -webkit-border-radius: 5px;
  33. text-shadow: 1px 1px #000;
  34. }
  35. .Input
  36. {
  37. border: solid #101010 1px;
  38. color: white;
  39. font-weight: bold;
  40. padding: 3px;
  41. background-color: #252525;
  42. }
  43. </style>
  44. </head>
  45. <body>
  46. <div align="center">
  47. <pre>
  48. ___________.__ _____ .__ .__ .__ __
  49. \__ ___/| |__ ____ / _ \ | | ____ | |__ ____ _____ |__| _______/ |_
  50. | | | | \ _/ __ \ / /_\ \ | | _/ ___\ | | \ _/ __ \ / \ | | / ___/\ __\
  51. | | | Y \\ ___/ / | \| |__\ \___ | Y \\ ___/ | Y Y \| | \___ \ | |
  52. |____| |___| / \___ > \____|__ /|____/ \___ >|___| / \___ >|__|_| /|__|/____ > |__|
  53. \/ \/ \/ \/ \/ \/ \/ \/
  54. Port Scanner
  55. </pre>
  56. <form action="" method="POST">
  57. Enter URL or IP : <input type="text" class="Input" name="target" value="<?php if(isset($_POST['target']))
  58. {echo htmlentities($_POST['target']);} else { echo 'http://example.com';}?>" size="50" />
  59. Enter lower limit : <input type="text" class="Input" name="lower" value="<?php if(isset($_POST['lower']))
  60. {echo htmlentities($_POST['lower']);} else { echo 1;}?>" size="5" />
  61. Enter upper limit : <input type="text" class="Input" name="upper" value="<?php if(isset($_POST['upper']))
  62. {echo htmlentities($_POST['upper']);} else { echo 100;}?>" size="5" />
  63. <input type="submit" name="submit" class="Button" value="Port Scan" />
  64. </form>
  65. <br />
  66. <br />
  67. <?php
  68. set_time_limit(0);
  69. if(isset($_POST['target']) && isset($_POST['upper']) && isset($_POST['lower'])
  70. && isset($_POST['submit']) && is_numeric($_POST['upper']) && is_numeric($_POST['lower'])
  71. && (filter_var($_POST['target'],FILTER_VALIDATE_IP) || filter_var($_POST['target'],FILTER_VALIDATE_URL)))
  72. {
  73. $target = $_POST['target'];
  74. $flag = 0;
  75. $lower = $_POST['lower']; //set lower limit
  76. $upper = $_POST['upper']; //set upper limit
  77. if($lower <= 0)
  78. {
  79. $lower = 1;
  80. }
  81. if($upper >= 65536)
  82. {
  83. $upper = 65535;
  84. }
  85. $numberof = ($upper - $lower) + 1; //number of parallel requests
  86. $ar = range($lower,$upper); //putting all the ports in an array
  87. for($i=0 ; $i < $numberof ; $i++)
  88. {
  89. $ch[$i] = curl_init($target);
  90. curl_setopt($ch[$i], CURLOPT_PORT, $ar[$i]);
  91. curl_setopt($ch[$i], CURLOPT_RETURNTRANSFER, true);
  92. }
  93. $mh = curl_multi_init();
  94. // Thanks to PeopleUnderTheStairs for the idea of using multi cURL
  95. for($i=0 ; $i < $numberof ; $i++)
  96. {
  97. curl_multi_add_handle($mh,$ch[$i]);
  98. }
  99. $running = NULL;
  100. do
  101. {
  102. curl_multi_exec($mh,$running);
  103. }while($running);
  104. for($i = 0 ; $i < $numberof ; $i++)
  105. {
  106. if(!curl_error($ch[$i]))
  107. {
  108. $flag = 1;
  109. echo '<span style="color: #F00;">Port '.$ar[$i].' is open</span><br />';
  110. }
  111. curl_multi_remove_handle($mh,$ch[$i]);
  112. curl_close($ch[$i]);
  113. }
  114. curl_multi_close($mh); //All the curl handlers and multi curl handlers are closed
  115. if($flag == 0)
  116. {
  117. echo '<span style="color: #F00;">No open ports found between '.$lower.' and '.$upper.'</span>';
  118. }
  119. }
  120. ?>
  121. </div>
  122. </body>
  123. </html>

comments powered by Disqus