-1

我已经编写了一个脚本,用于对主机/IP 进行跟踪路由,由于某种原因,它是从我的服务器而不是从使用它的本地用户跟踪出来的。如果我在终端中拉出跟踪路由,则输出完全不同。

可以在这里尝试 http://beta.tracert.us 我试图弄乱代码但似乎无法得到它。我只是想把它作为一个工作实用程序,对于那些会使用它的人来说,因为其他实用程序在工作中有点滞后。
非常感谢任何和所有帮助

<!DOCTYPE html>
<html lang="en">
<head>

<meta charset="utf-8" />

<title>TraceRoutes For ALL</title>
<link href='http://fonts.googleapis.com/css?family=Geo' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Josefin+Sans">
<style type="text/css">

 input.fname {
    border-radius: 10px;
    border: true;
    font-size: 80px;
    font-family: Josefin Sans;
    border-color:#111111 #111111 #111111 #111111;
 }
body {
        border-radius: 10px;
    border: true;
    font-size: 60px;
    font-family: Josefin Sans;
    border-color:#111111 #111111 #111111 #111111;
}
div.traced {
        font-size: 20px;
        font-family: Josefin Sans;
</style>

<?php 
// Get Variable from form via register globals on/off 
//------------------------- 
$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']; 
   $host   = $_GET['host']; 
   $ip     = $_SERVER['REMOTE_ADDR']; 
   $self   = $_SERVER['PHP_SELF']; 
}; 
// form submitted ? 
If ($submit == "Traceroute!")  
{ 
      // replace bad chars 
      $host= preg_replace ("/[^A-Za-z0-9.]/","",$host); 
      echo '<center>';
      echo '<body bgcolor="#FFFFFF" text="#000000"></body>'; 
      echo("Trace Output:<br>");  
      echo '<pre>';            
      echo '<form name="test" action="ses.php" method="post">';
      echo '<textarea rows="30" cols="120" readonly name="form">';
      //check target IP or domain 
      if ($unix)  
      { 
         system ("traceroute $host"); 
         system("killall -q traceroute");// kill all traceroute processes in case there are some stalled ones or use echo 'traceroute' to execute without shell 
      } 
      else 
      { 
         system("tracert $host"); 
      } 

      echo '</textarea>';
      echo '</pre>'; 
      echo '</form>';
      echo '<div class="traced">';
      echo '<a href="http://beta.tracert.us">Need to trace again?</a></br>';
      echo '</br>Email this or send it</br>';   
      echo '<a href="http://gmail.com" target="_blank">Gmail</a> | <a href="http://yahoomail.com" target="_blank">Yahoo</a> | <a href="http://hotmail.com" target="_blank">Hotmail</a></br>';
      echo 'Traceroute complete</br><hr>';
      echo '<a href="http://coinchat.org/r:mrmuffins">Chat for Bitcoins</a>';
      echo '</div>';
}  
else  
{ 
    echo '<body bgcolor="#FFFFFF" text="#000000"></body>'; 
    echo '<center>';
    echo '<p><font size="30">Your IP is: </font><font size="25" color="red">'.$ip.'</font></p>'; 
    echo '<div id="form1">';
    echo '<form methode="post" action="'.$self.'">'; 
    echo '   Enter IP or Host </br><input type="text" class="fname" name="host" placeholder="Enter domain/IP"></input>'; 
    echo '  </br> <input type="submit" name="submit" value="Traceroute!"></input>'; 
    echo '</form>'; 
    echo '</div>';
    echo '<br><b>'.$system.'</b>'; 
    echo 'This may take up to 30 seconds to output.  Please be patient.';
    echo '<center>';
    echo '</body></html>'; 
} 
?>
4

1 回答 1

1

traceroute 只能从运行代码的机器上执行。

客户端是否在运行代码?可能不是,你的服务器是。所以你无法得到你想要的。

更重要的是:你有一个非常糟糕的代码执行漏洞!您必须验证包含 IP 地址的字符串是否包含其他内容。

请不要在线使用该脚本。你会被黑客入侵。

于 2013-09-07T10:46:36.230 回答