protected override void OnReceiveResponse() { if (ResponseStatusLine.StatusCode != HttpStatus.OK || !ResponseHeaders.Headers.ContainsKey("content-type")) { return; } if (RequestLine.Method != "POST" || !_requestUri.AbsoluteUri.Contains("api/gateway_c2")) { return; } var response = GetContent(); State.NextStep = null; string content; using (var sr = new StreamReader(GetResponseMessageStream(response))) { content = sr.ReadToEnd(); } SendResponseStatusAndHeaders(); SocketBP.TunnelDataTo(TunnelBP, response); if (SocketBP != null) { SocketBP.CloseSocket(); SocketBP = null; } if (SocketPS != null) { SocketPS.CloseSocket(); SocketPS = null; } State.bPersistConnectionBP = false; State.bPersistConnectionPS = false; var stringResponse = Decrypt.DecryptResponse(content); var json = JObject.Parse(stringResponse); MainWindow.Instance.HandleNewPacket(json); // Temp. saving all commands content to file using (var file = new StreamWriter($@"D:/SW-Commands/{json["command"].ToString()}.txt")) { file.WriteLine(json); file.Close(); } Debug.WriteLine($"Proxy Command: {json["command"].ToString()}"); Debug.WriteLine($"ts: {json["ts_val"].ToString()} / {Ut3()}"); }
private void OnExpire(object state) { #if DEBUG Console.ForegroundColor = ConsoleColor.DarkBlue; Console.WriteLine(System.Threading.Thread.CurrentThread.ManagedThreadId + " -- " + this.requestUri.Host + " Expired"); Console.ForegroundColor = ConsoleColor.Gray; #endif if (SocketBP != null) { SocketBP.CloseSocket(); SocketBP = null; } if (SocketPS != null) { SocketPS.CloseSocket(); SocketPS = null; } State.bPersistConnectionBP = false; State.bPersistConnectionPS = false; State.NextStep = null; }