PHP implementation of online port scanning instance Code _php tutorial

Source: Internet
Author: User

  1. $youip = $HTTP _server_vars["REMOTE_ADDR"];
    $REMOTEIP = $HTTP _post_vars[remoteip];
    ?>
  2. PHP implements port on-line detection

  3. if (!empty ($REMOTEIP)) {
    function Err () {
    Die ("Sorry, this IP address is not valid

    Click here to return ");
    }
    //define the prompt to submit the wrong IP
    $ips =explode (".", $remoteip);
    //use. Split IP address
    if (intval ($ips [0]) <1 or intval ($ips [0]) >255 or Intval ($ips [3]) <1 or intval ($ips [3]>255)) Err ();
    //If the first and last IP numbers are less than 1 or greater than 255, an error is prompted
    if (Intval ($ips [1]) <0 or Intval ($ips [1]) >255 or Intval ($ips [2]) <0 or intval ($ips [2]>255)) Err ();
    //If the number of the second and third IP is less than 0 or greater than 255, an error is prompted
    $closed = This port is currently in a closed state.;
    $opened = This port is currently open!;
    $close = "Off";
    $open = "open";
    $port =array (21,23,25,79,80,110,135,137,138,139,143,443,445,1433,3306,3389);
    $msg =array (ftp,telnet,smtp,finger,http,pop3,location Service,netbios-ns,netbios-dgm,netbios-ssn,imap,https, Microsoft-ds,mssql,mysql,terminal Services);
    //After checking by IP format, define the service name and status of each port with an array
    echo "


    echo "
    echo "
    echo "
    echo " "; "; "; ";
    The IP you scanned: ". $remoteip."
    ";
    echo "
    echo "
    echo "
    echo "
    echo "
    echo "
    echo "
    //Output display table
    For ($i =0; $i < span="">
    {
    $fp = @fsockopen ($remoteip, $port [$i], & $errno, & $errstr, 1);
    if (! $fp) {
    echo "
    } else {
    echo "
    }
    }
    //Use the Fsockopen function to connect the relevant port of the remote host with the For statement, and output the result
    echo "
    echo "
    echo " "; "; "; "; "; "; "; "; "; ";
    PortServiceTest resultsDescribe
    ". $port [$i]." ". $msg [$i]." ". $close." ". $closed."
    ". $port [$i]." ". $msg [$i]." ". $open." ". $opened."
    ";
    echo "Continue scanning >>>
    ";
    echo "
    echo "
    echo "
    echo "
    echo " "; "; "; ";
    Port scan
    ";
    echo "";
    echo "";
    echo "";
    exit;

    http://www.bkjia.com/PHPjc/486202.html www.bkjia.com true http://www.bkjia.com/PHPjc/486202.html techarticle php $youip = $HTTP _server_vars["REMOTE_ADDR"]; $remoteip = $HTTP _post_vars[remoteip]; HTML head titlephp implements port online detection/ Title Meta http-equiv= "Content-type" content= "text/h ...

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.