Php implements online port scan instance code

Source: Internet
Author: User
Tags php online
& Lt ;? Php $ youip $ HTTP_SERVER_VARS [REMOTE_ADDR]; $ remoteip $ HTTP_POST_VARS [remoteip];? & Gt; & lt; html & gt; & lt; head & gt; & lt; title & gt; php online Port detection & lt;/title & gt; & lt; metahttp-
  1. $ Youip = $ HTTP_SERVER_VARS ["REMOTE_ADDR"];
    $ Remoteip = $ HTTP_POST_VARS [remoteip];
    ?>
  2. Online Port detection using php
  3. If (! Empty ($ remoteip )){
    Function err (){
    Die ("Sorry, this IP address is illegal

    Click here to return ");
    }
    // Defines the prompt message for an incorrect IP address submission.
    $ Ips = explode (".", $ remoteip );
    // Use. to separate IP addresses
    If (intval ($ ips [0]) <1 or intval ($ ips [0])> 255 or intval ($ ips [3]) <1 or intval ($ ips [3]> 255) err ();
    // If the number of the first and last IP segments is smaller than 1 or greater than 255, an error is returned.
    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 addresses is less than 0 or greater than 255, an error is returned.
    $ Closed = This port is currently closed .;
    $ Opened = This port is currently open !;
    $ Close = "close ";
    $ Open = "open ";
    $ Port = array (80,110,135,137,138,139,143,443,445,143, 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 the IP format, use an array to define the service name and status of each port.
    Echo"





    ";Echo" ";Echo" ";Echo" ";Echo"
    IP address you scanned: ". $ remoteip ."
    ";
    Echo"







    {
    $ Fp = @ fsockopen ($ remoteip, $ port [$ I], & $ errno, & $ errstr, 1 );
    If (! $ Fp ){
    Echo"






    ";Echo" ";Echo" ";Echo" ";Echo" ";Echo" ";Echo" ";// Output the displayed tableFor ($ I = 0; $ I ";} Else {Echo" ";}}// Use the for statement to connect the port of the remote host using the fsockopen function and output the result.Echo" ";Echo"Echo"
    PortServiceDetection resultDescription
    ". $ 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;

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.