2016-12-25 3 views
0

저는 보안 취약점에 대해 배우기 위해 DVWA를 사용하고 있습니다. 아래와 같이 지령 분사량의 부분에서, 백 엔드 코드는 내 이해 가입일명령 인젝션 DVWA 난이도

enter image description here

<?php 

if(isset($_POST[ 'Submit' ] )) { 
    // Get input 
    $target = trim($_REQUEST[ 'ip' ]); 

    // Set blacklist 
    $substitutions = array(
     '&' => '', 
     ';' => '', 
     '| ' => '', 
     '-' => '', 
     '$' => '', 
     '(' => '', 
     ')' => '', 
     '`' => '', 
     '||' => '', 
    ); 

    // Remove any of the charactars in the array (blacklist). 
    $target = str_replace(array_keys($substitutions), $substitutions, $target); 

    // Determine OS and execute the ping command. 
    if(stristr(php_uname('s'), 'Windows NT')) { 
     // Windows 
     $cmd = shell_exec('ping ' . $target); 
    } 
    else { 
     // *nix 
     $cmd = shell_exec('ping -c 4 ' . $target); 
    } 

    // Feedback for the end user 
    echo "<pre>{$cmd}</pre>"; 
} 

?> 

난 다음 코드 ''|| 교체해야 입력 || ls 같이 주면되므로 주입 안 작업. 아래 그림과 같이 놀랍게도에 주입 파일의 출력을 생성했다 있지만 :

After

+0

그냥 하나 개의 작은 함정해야 || 전에 | 단일 문자 앞에 이중 문자로 대체해야합니다. 재미있는 작은 버크입니다! – TimBrownlaw

+0

@ TimBrownlaw 답변으로 입력하고 기꺼이 받아 들일 수 있으면 :) –

+0

좋아, 대답을 만들었습니다. 건배 – TimBrownlaw

답변

0

그냥 하나 개의 작은 함정을 교체 배열과 함께 ... 당신은 정의 할 필요가 || 전에 | 단일 문자 앞에 이중 문자로 대체해야합니다. 재미있는 작은 버크입니다!

그래서 배열

// Set blacklist 
$substitutions = array(
    '&' => '', 
    ';' => '', 
    '| ' => '', 
    '-' => '', 
    '$' => '', 
    '(' => '', 
    ')' => '', 
    '`' => '', 
    '||' => '', 
); 

... 당신은 정의 할 필요가 교체 배열로

// Set blacklist 
$substitutions = array(
    '&' => '', 
    ';' => '', 
    '||' => '', 
    '| ' => '', 
    '-' => '', 
    '$' => '', 
    '(' => '', 
    ')' => '', 
    '`' => '', 
);