Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Starts the packet diversion with the given number of threads.
        /// </summary>
        /// <param name="numThreads">
        /// The number of threads to use for diversion. If equal to or less than zero, will default
        /// to Environment.ProcessorCount.
        /// </param>
        /// <remarks>
        /// The number of threads ought not to exceed Environment.ProcessorCount but this is not
        /// enforced with a bounds check.
        /// </remarks>
        public void Start(int numThreads)
        {
            lock (m_startStopLock)
            {
                if (m_running)
                {
                    return;
                }

                if (numThreads <= 0)
                {
                    numThreads = Environment.ProcessorCount;
                }

                m_diversionThreads = new List <Thread>();

#if ENGINE_NO_BLOCK_TOR
                string mainFilterString = "outbound and tcp and ((ip and ip.SrcAddr != 127.0.0.1) or (ipv6 and ipv6.SrcAddr != ::1))";
#else
                string mainFilterString = "outbound and tcp";
#endif
                string QUICFilterString = "udp and (udp.DstPort == 80 || udp.DstPort == 443)";

                m_diversionHandle = WinDivertMethods.WinDivertOpen(mainFilterString, WINDIVERT_LAYER.WINDIVERT_LAYER_NETWORK, -1000, 0);

                if (m_diversionHandle == new IntPtr(-1) || m_diversionHandle == IntPtr.Zero)
                {
                    // Invalid handle value.
                    throw new Exception(string.Format("Failed to open main diversion handle. Got Win32 error code {0}.", Marshal.GetLastWin32Error()));
                }

                m_QUICDropHandle = WinDivertMethods.WinDivertOpen(QUICFilterString, WINDIVERT_LAYER.WINDIVERT_LAYER_NETWORK, -999, WinDivertConstants.WINDIVERT_FLAG_DROP);

                if (m_QUICDropHandle == new IntPtr(-1) || m_QUICDropHandle == IntPtr.Zero)
                {
                    // Invalid handle value.
                    throw new Exception(string.Format("Failed to open QUIC diversion handle. Got Win32 error code {0}.", Marshal.GetLastWin32Error()));
                }

                WinDivertMethods.WinDivertSetParam(m_diversionHandle, WINDIVERT_PARAM.WINDIVERT_PARAM_QUEUE_LEN, 8192);
                WinDivertMethods.WinDivertSetParam(m_diversionHandle, WINDIVERT_PARAM.WINDIVERT_PARAM_QUEUE_TIME, 2048);

                m_running = true;

                for (int i = 0; i < numThreads; ++i)
                {
                    m_diversionThreads.Add(new Thread(() =>
                    {
                        RunDiversion();
                    }));

                    m_diversionThreads.Last().Start();
                }
            }
        }
Esempio n. 3
0
        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);
            }
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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);
            }
        }