public string ProfileTransform(ProfileTransformAssembly ProfileTransformAssembly, byte[] bytes) { Assembly TransformAssembly = Assembly.Load(ProfileTransformAssembly.ProfileTransformBytes); Type t = TransformAssembly.GetType("HttpMessageTransform"); return((string)t.GetMethod("Transform").Invoke(null, new object[] { bytes })); }
public byte[] ProfileInvert(ProfileTransformAssembly ProfileTransformAssembly, string str) { Assembly TransformAssembly = Assembly.Load(ProfileTransformAssembly.ProfileTransformBytes); Type t = TransformAssembly.GetType("HttpMessageTransform"); return((byte[])t.GetMethod("Invert").Invoke(null, new object[] { str })); }
public async Task Configure(APIModels.Profile profile, string ListenerGuid, string CovenantToken) { _transform = new ProfileTransformAssembly { ProfileTransformBytes = Compiler.Compile(new Compiler.CompilationRequest { Language = Grunts.ImplantLanguage.CSharp, Source = profile.MessageTransform, TargetDotNetVersion = Common.DotNetVersion.NetCore21, References = Common.DefaultReferencesCore21 }) }; X509Certificate2 covenantCert = new X509Certificate2(Common.CovenantPublicCertFile); HttpClientHandler clientHandler = new HttpClientHandler { ServerCertificateCustomValidationCallback = (sender, cert, chain, errors) => { return(cert.GetCertHashString() == covenantCert.GetCertHashString()); } }; _client = new CovenantAPI( new Uri("https://localhost:7443"), new TokenCredentials(CovenantToken), clientHandler ); _connection = new HubConnectionBuilder() .WithUrl("https://localhost:7443/gruntHub", options => { options.AccessTokenProvider = () => { return(Task.FromResult(CovenantToken)); }; options.HttpMessageHandlerFactory = inner => { var HttpClientHandler = (HttpClientHandler)inner; HttpClientHandler.ServerCertificateCustomValidationCallback = clientHandler.ServerCertificateCustomValidationCallback; return(HttpClientHandler); }; }) .Build(); _connection.Closed += async(error) => { await Task.Delay(new Random().Next(0, 5) * 1000); await _connection.StartAsync(); }; _connection.On <string>("NotifyListener", (guid) => { InternalRead(guid).Wait(); }); try { await Task.Delay(5000); await _connection.StartAsync(); } catch (Exception e) { Console.Error.WriteLine("InnerListener SignalRConnection Exception: " + e.Message + Environment.NewLine + e.StackTrace); } await _connection.InvokeAsync("JoinGroup", ListenerGuid); }