Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: .php networking tools , ping  (Read 4195 times)

0 Members and 1 Guest are viewing this topic.

diablo416

    Topic Starter


    Hopeful
    .php networking tools , ping
    « on: July 23, 2008, 01:06:26 PM »
    hey

    i have a script that pings a host .. im using php to do this and need a way to modify the packet size?? i could post the script if you need it.. but i didnt see a point its all really simple and strait forward, Another way i could ask is.. i need a way to send fragmented packets using .php can anybody explain how?

    kpac

    • Web moderator
    • Moderator


    • Hacker

    • kpac®
    • Thanked: 184
      • Yes
      • Yes
      • Yes
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 7
    Re: .php networking tools , ping
    « Reply #1 on: July 27, 2008, 09:13:28 AM »
    Can you post the full script, please. You can attach it if it is too big (long).

    diablo416

      Topic Starter


      Hopeful
      Re: .php networking tools , ping
      « Reply #2 on: August 06, 2008, 02:51:48 PM »
      <!DOCTYPE html PUBLIC "-//IETF//DTD HTML 2.0//EN">
      <html>
      <head>
      <title></title>
      </head>
      <?php
      //-------------------------
      $max_count = 10; //maximum count for ping command
      $unix      =  1; //set this to 1 if you are on a *unix system     
      $windows   =  0; //set this to 1 if you are on a windows system
      // -------------------------
      // nothing more to be done.
      // -------------------------
      //globals on or off ?
      $register_globals = (bool) ini_get('register_gobals');
      $system = ini_get('system');
      $unix = (bool) $unix;
      $win  = (bool)  $windows;
      //
      If ($register_globals)
      {
         $ip = getenv(REMOTE_ADDR);
         $self = $PHP_SELF;
      }
      else
      {
         $submit = $_GET['submit'];
         $count  = $_GET['count'];
         $host   = $_GET['host'];
         $ip     = $_SERVER['REMOTE_ADDR'];
         $self   = $_SERVER['PHP_SELF'];
      };
      // form submitted ?
      If ($submit == "Ping!")
      {
         // over count ?
         If ($count > $max_count)
         {
            echo 'Maximum for count is: '.$max_count;
            echo '<a href="'.$self.'">Back[/url]';
         }
         else
         {
            // replace bad chars
            $host= preg_replace ("/[^A-Za-z0-9.-]/","",$host);
            $count= preg_replace ("/[^0-9]/","",$count);
            echo '<body bgcolor="#FFFFFF" text="#000000"></body>';
            echo("Ping Output:
      ");
            echo '
      ';           
            //check target IP or domain
            if ($unix)
            {
               system ("ping -c$count -w$count $host");
               system("killall ping");// kill all ping processes in case there are some stalled ones or use echo 'ping' to execute ping without shell
            }
            else
            {
               system("ping -n $count $host");
            }
            echo '
      ';
          }
      }
      else
      {
          echo '<body bgcolor="#FFFFFF" text="#000000"></body>';
          echo '<p><font size="2">Your IP is: '.$ip.'</font></p>';
          echo '<form methode="post" action="'.$self.'">';
          echo '   Enter IP or Host <input type="text" name="host" value="'.$ip.'"></input>';
          echo '   Enter Count <input type="text" name="count" size="2" value="4"></input>';
          echo '   <input type="submit" name="submit" value="Ping!"></input>';
          echo '</form>';
          echo '
      '.$system.'';
          echo '</body></html>';
      }
      ?>