2013-09-07 1 views
-1

호스트/IP에 대한 traceroute를 수행하기위한 스크립트를 작성했으며이를 사용중인 로컬 사용자가 아닌 내 서버에서 추적하는 것으로 나옵니다. 내 터미널에서 traceroute를 당기면 출력은 완전히 다릅니다.Traceroute 스크립트가 잘못된 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>'; 
} 
?> 
+1

사용자 컴퓨터에서 명령을 실행할 수 없습니다. 그렇지 않으면 ** 거대한 보안 구멍이 될 것입니다. – zerkms

답변

1

평가되는 경로 추적은 코드를 실행중인 시스템에서 실행할 수 있습니다.

클라이언트가 코드를 실행하고 있습니까? 서버가 아닌 것 같습니다. 그래서 당신은 당신이 원하는 것을 얻을 수 없습니다.

더 중요한 점 : 매우 나쁜 코드 유출 취약점이 있습니다! IP 주소를 포함하는 문자열에는 다른 것을 포함하고 있는지 확인해야합니다.

해당 스크립트를 온라인으로 사용하지 마십시오. 너 해킹 당할거야.

+0

잠깐만, 내가 나쁜 코드 실행을 사용하고 있다고 말하면서, 내 취약점이 정확히 어디에 있는지, 나를 알지 못해서 용서해주십시오. (그냥 시작했습니다.) "IP 주소를 포함하는 문자열에 아무것도 포함되어 있지 않다는 것을 확인해야합니다 . "그 밖의 다른 의미는 무엇입니까? @sven – mrmuffins

+0

코드에 숨겨져 있습니다. $ 호스트 = preg_replace ("/[^A-Za-z0-9.]/ "," ", $ host);'나는 왜 당신이 IP로 텍스트 문자를 받아들이 는가? '라고 생각하고 있지만, 효과적으로 이것은 보호 장치 역할을한다. 예. 질문은 : 쉘 명령을 사용 하시겠습니까? 아마 그렇지 않을 것입니다 .'escapehellarg()'를 사용하여 http://de3.php.net/escapeshellarg을 확인하십시오. 그런 식으로 저는 불안정에 대해 불평하지 않을 것이고 정규 표현식은 IP 주소에 대한 유효성 검사로서 만 작용할 것입니다. 도메인 이름 부분을 수정하면 보안을 "해제"할 수 없습니다. – Sven

+0

예 그렇기 때문에 도메인을 사용하기 때문에 글자가 허용됩니다. http://ideone.com/1732Kc 저는이 글을 갈래 쳤습니다. 54 줄을 추가하고 62 줄을 수정했습니다. 그것을 구현하는 올바른 방법일까요? @sven – mrmuffins