Practice dvwa!

Source: Internet
Author: User

Dvwa vulnerability training system.

 

 

 

 

1. First, I tried the command execution vulnerability Command Execution of dvwa, which was tested at the low level and included the low level code:

<? PHP

If (isset ($ _ post ['submit ']) {// isset () function. If the variable is not null or null, true is returned.

$ Target = $ _ request ['IP']; // $ _ request [] obtain the content in the IP address tag <input id = "ip" type = "text">

// Determine OS and execute the ping command.
If (stristr (php_uname ('s '), 'windows nt') {// stristr () function, paste an example to determine whether it is windows or Linux, and php_uname () returns the description of the operating system that runs PHP,'S': Operating System name.
 /*<? PHP
$ Email = '[email protected]';
Echo stristr ($ email, 'E'); // output [email protected]
Echo stristr ($ email, 'E', true); // output from PhP 5.3.0
?>*/

$ Cmd = shell_exec ('ping'. $ target); // shell_exec () function invocation command
Echo '<PRE>'. $ cmd. '</PRE> ';

} Else {

$ Cmd = shell_exec ('Ping-C 3'. $ target); // run the Linux Command
Echo '<PRE>'. $ cmd. '</PRE> ';

}

}
?>
It is found that $ target directly receives unfiltered values. In Windows and Linux, you can use & and; to execute multiple commands. Therefore, submit 127.0.0.1 & net user for testing.


Next is the medium-level code.
<? PHP

If (isset ($ _ post ['submit ']) {

$ Target = $ _ request ['IP'];

// Remove any of the charactars in the array (blacklist ).
$ Substitutions = array (// create a PHP array ('key' => 'value ')
'&' => '',
';' => '',
);

$ Target = str_replace (array_keys ($ substitutions), $ substitutions, $ target );
/* Array_keys returns the array key name. The search parameter str_replace (search, replace, subject) matches the characters in the subject. If the match matches, replace is used instead */

// Determine OS and execute the ping command.
If (stristr (php_uname ('s '), 'windows nt') {// determines if it is Windows

$ Cmd = shell_exec ('ping'. $ target );
Echo '<PRE>'. $ cmd. '</PRE> ';

} Else {

$ Cmd = shell_exec ('Ping-C 3'. $ target );
Echo '<PRE>'. $ cmd. '</PRE> ';

}
}

?>

Medium is filtered out, but you can try to submit 1 | net user | it means that if the previous execution is not successful

========================================================== = Not complete ==================================================== ========================

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.