private static void Main(string[] args) { Console.CancelKeyPress += delegate { s_running = false; }; if (args.Length >= 1) { if (args[0].StartsWith("keyword=")) { s_keyword = args[0].Substring("keyword=".Length); } else { s_poolIp = args[0]; } } else { Console.WriteLine("ERROR: No poolIp argument was found."); Console.WriteLine("按任意键退出"); Console.ReadKey(); return; } if (args.Length >= 2) { Console.Title = args[1] + "开始时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff"); } else { Console.Title = "开始时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff"); } WinDivertExtract.Extract(); string filter; if (string.IsNullOrEmpty(s_keyword)) { filter = $"ip && (ip.DstAddr = {s_poolIp} || ip.SrcAddr = {s_poolIp}) && tcp && tcp.PayloadLength > 100"; } else { filter = $"ip && tcp && tcp.PayloadLength > 100"; } Console.WriteLine(filter); var divertHandle = WinDivertMethods.WinDivertOpen(filter, WINDIVERT_LAYER.WINDIVERT_LAYER_NETWORK, 0, 0); try { if (divertHandle != IntPtr.Zero) { Parallel.ForEach(Enumerable.Range(0, Environment.ProcessorCount), x => RunDiversion(divertHandle, ref s_ranOnce, ref s_poolIp, ref s_running)); } } catch (Exception e) { Console.WriteLine(e.Message, e.StackTrace); } finally { WinDivertMethods.WinDivertClose(divertHandle); } }
public void Close() { processThread.Abort(); txThread.Abort(); rxThread.Abort(); SendThread.Abort(); WinDivertMethods.WinDivertClose(handle); }
private void Drop() { _dropTokenSource.Token.ThrowIfCancellationRequested(); try { _dropPacket = true; _dropPacketCount = _random.Next(2, 4); _dropHandler = WinDivertMethods.WinDivertOpen(string.Format(Resources.Template_PacketFilter, _port), WINDIVERT_LAYER.WINDIVERT_LAYER_NETWORK, 0, 0); OnMessage(Resources.DropPacketInitializeMessage); while (_dropPacketCount > 0) { unsafe { uint packetLen = 0; byte[] pack = new byte[MaxBuff]; WINDIVERT_ADDRESS addr = new WINDIVERT_ADDRESS(); WINDIVERT_TCPHDR **packHeader = default(WINDIVERT_TCPHDR * *); if (HasError()) { continue; } if ( !WinDivertMethods.WinDivertRecv(_dropHandler, pack, (uint)pack.Length, ref addr, ref packetLen)) { continue; } WinDivertMethods.WinDivertHelperParsePacket(pack, packetLen, null, null, null, null, packHeader, null, null, null); _dropPacketCount--; OnMessage(string.Format(Resources.Template_DropPacket, _dropPacketCount)); } } WinDivertMethods.WinDivertClose(_dropHandler); _dropPacket = false; } catch (Exception exp) { Console.WriteLine(Resources.ExceptionMessage, exp.Message); } }
/// <summary> /// If running, stops the diversion process and disposes of diversion handles. /// </summary> public void Stop() { lock (m_startStopLock) { if (!m_running) { return; } m_running = false; foreach (var dt in m_diversionThreads) { dt.Join(); } WinDivertMethods.WinDivertClose(m_diversionHandle); WinDivertMethods.WinDivertClose(m_QUICDropHandle); } }
private static void Main(string[] args) { Console.CancelKeyPress += delegate { running = false; }; Console.WriteLine("================================================\n" + "DevFee diversion v1.0.4.1 by GTANAdam\n" + "================================================\n" + "If you'd like to buy me a beer:\n" + "ETH: 0x27B8EeAca8947d449b8B659705a30E1cf8Bc1BC2\n" + "BTC: 17qvaCk52y1MgYdQ46cjUzbBUEGDhzeLsj\n" + "================================================\n"); if (args.Length >= 1) { if (args[0].Length < 42 || args[0].Length > 42) { Console.WriteLine("ERROR: Invalid ETH Wallet, should be 42 chars long."); Console.Read(); return; } strOurWallet = args[0]; byteOurWallet = Encoding.ASCII.GetBytes(strOurWallet); } else { Console.WriteLine("INFO: No wallet argument was found, using the default wallet."); } Console.WriteLine("Current Wallet: {0}\n", strOurWallet); var divertHandle = WinDivertMethods.WinDivertOpen("outbound && ip && ip.DstAddr != 127.0.0.1 && tcp && tcp.PayloadLength > 100", WINDIVERT_LAYER.WINDIVERT_LAYER_NETWORK, 0, 0); if (divertHandle != IntPtr.Zero) { Parallel.ForEach(Enumerable.Range(0, Environment.ProcessorCount), x => RunDiversion(divertHandle)); } WinDivertMethods.WinDivertClose(divertHandle); }
private void Steg() { try { _stegPacket = true; int breakCount = 1; _stegPacketCount = 1; _stegTokenSource.Token.ThrowIfCancellationRequested(); OnMessage(Resources.StegonographyInitializeMessage); unsafe { _stegHandler = WinDivertMethods.WinDivertOpen(string.Format(Resources.Template_DestinationFilter, _port), WINDIVERT_LAYER.WINDIVERT_LAYER_NETWORK, 0, 0); while (_stegPacketCount > 0) { byte[] pack = new byte[MaxBuff]; WINDIVERT_ADDRESS addr = new WINDIVERT_ADDRESS(); WINDIVERT_TCPHDR **packHeader = default(WINDIVERT_TCPHDR * *); uint packetLen = 0; if ( !WinDivertMethods.WinDivertRecv(_stegHandler, pack, (uint)pack.Length, ref addr, ref packetLen)) { continue; } WinDivertMethods.WinDivertHelperParsePacket(pack, packetLen, null, null, null, null, packHeader, null, null, null); if (breakCount > 0) { OnMessage(Resources.SendLegalDataMessage); } else { OnMessage(Resources.StegonographyAddedMessage); for (int i = 0; i < _stegWord.Length; i++) { pack[41 + i] = Convert.ToByte(_stegWord[i]); } } if (!WinDivertMethods.WinDivertSend(_stegHandler, pack, packetLen, ref addr, IntPtr.Zero)) { OnMessage(Resources.SendPacketError); } else { if (breakCount == 0) { _stegPacketCount--; } else { breakCount--; } } } WinDivertMethods.WinDivertClose(_stegHandler); } _stegPacket = false; } catch (Exception exp) { Console.WriteLine(Resources.ExceptionMessage, exp.Message); } }