Advertisement
AZZATSSINS_CYBERSERK

OpenPort

Apr 27th, 2016
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.50 KB | None | 0 0
  1. <?
  2. $rstart = (isset($_POST['rstart']) and is_numeric($_POST['rstart']) and $_POST['rstart'] >= 1) ? $_POST['rstart'] : 1 ;
  3.         $rend = (isset($_POST['rend']) and is_numeric($_POST['rend']) and $_POST['rend'] > 1) ? $_POST['rend'] : 999999 ;
  4.         echo("<script type=\"text/javascript\">");
  5.         echo("function Show(SelectValue){");
  6.         echo("document.getElementById('RangeDiv').style.display=\"none\";");
  7.         echo("document.getElementById('SpecificDiv').style.display=\"none\";");
  8.         echo("if(SelectValue == \"range\")");
  9.         echo("document.getElementById('RangeDiv').style.display=\"inline\";");
  10.         echo("if(SelectValue == \"specific\")");
  11.         echo("document.getElementById('SpecificDiv').style.display=\"inline\";");
  12.         echo("}</script>");
  13.         echo("<span class=\"PageTitle\">Open Ports Scanner</span><br /><br />");
  14.         echo('<form method="post">');
  15.         echo('<u>Ports:</u><br /><br />');
  16.         echo('<select id="port" name="port" onchange="javascript:Show(this.value);">');
  17.         echo('<option value="automatic">Automatic - All Ports</option>');
  18.         echo('<option value="range">Range of Ports</option>');
  19.         echo('<option value="specific">Specific Ports</option>');
  20.         echo('</select><br /><br />');
  21.         echo('<div id="RangeDiv" style="display:none;">From: <input type="text" id="rstart" name="rstart" value="'.$rstart.'" /> To: <input type="text" id="rend" name="rend" value="'.$rend.'" /><br /><br /></div>');
  22.         echo('<div id="SpecificDiv" style="display:none;"><textarea rows="5" cols="50" id="specific" name="specific" />'.@htmlspecialchars($_POST['specific']).'</textarea><br />Use space (not new line!) to separate between the ports.<br /><br /></div>');
  23.         echo('<input type="submit" id="submit" name="submit" value="Scan" />');
  24.         echo('</form>');
  25.         if(isset($_POST['submit'])){
  26.             $first = "yes";
  27.             echo("<br /><br /><u>Results</u>:<br />\n");
  28.  
  29.             if($_POST['port'] == "range"){
  30.                 if($rend > $rstart){
  31.                     for($i=$rstart;$i<$rend;$i++){
  32.                         if(@fsockopen($_SERVER['SERVER_ADDR'],$i) == TRUE){
  33.                             if($first == "no")
  34.                                 echo(", ");
  35.                             echo $i;
  36.                             $first = "no";
  37.                         }
  38.                     }
  39.                     echo(".");
  40.                 }
  41.                 else{
  42.                     echo("Range start number can't be bigger than the end number.");
  43.                 }
  44.             }
  45.             else if($_POST['port'] == "specific"){
  46.                 $list = explode(" ",$_POST['specific']);
  47.                 foreach($list as $i){
  48.                     if(is_numeric($i)){
  49.                         if(@fsockopen($_SERVER['SERVER_ADDR'],$i) == TRUE){
  50.                             if($first == "no")
  51.                                 echo(", ");
  52.                             echo $i;
  53.                             $first = "no";
  54.                         }
  55.                     }
  56.                 }
  57.                 echo(".");
  58.             }
  59.             else{
  60.                 for($i=0;$i>=0;$i++){
  61.                     if(@fsockopen($_SERVER['SERVER_ADDR'],$i) == TRUE){
  62.                         if($first == "no")
  63.                             echo(", ");
  64.                         echo $i;
  65.                         $first = "no";
  66.                     }
  67.                 }
  68.                 echo(".");
  69.             }
  70.         }
  71.         ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement