Ejemplo n.º 1
0
        public override ECheck Check()
        {
            NetworkSniffer s = null;

            try
            {
                //if (!SystemHelper.IsAdministrator())
                //    WriteError("Require admin rights");

                IPayloadSniffer pay = (IPayloadSniffer)Payload;
                if (!pay.Check())
                {
                    return(ECheck.Error);
                }

                s = new NetworkSniffer(Interface);
                s.Start();

                return(ECheck.Ok);
            }
            catch { return(ECheck.Error); }
            finally
            {
                if (s != null)
                {
                    s.Dispose();
                }
            }
        }
Ejemplo n.º 2
0
        public override ECheck Check()
        {
            NetworkSniffer s = null;

            try
            {
                if (!SystemHelper.IsAdministrator())
                {
                    WriteError("Require admin rights");
                }

                if (!DumpFolder.Exists)
                {
                    WriteError("DumpFolder must exists");
                    return(ECheck.Error);
                }

                s        = new NetworkSniffer(LocalAddress);
                s.Filter = new SnifferPortFilter(this.LocalPort);
                s.Start();

                return(ECheck.Ok);
            }
            catch { return(ECheck.Error); }
            finally
            {
                if (s != null)
                {
                    s.Dispose();
                }
            }
        }
Ejemplo n.º 3
0
        public override bool Run()
        {
            IPayloadSniffer pay = (IPayloadSniffer)Payload;

            //if (!SystemHelper.IsAdministrator())
            //    WriteError("Require admin rights");
            if (!pay.Check())
            {
                return(false);
            }
            if (FilterOnlyTorRequest)
            {
                TorHelper.UpdateTorExitNodeList(true);
            }

            NetworkSniffer s = new NetworkSniffer(Interface)
            {
                Timeout     = TcpTimeout,
                TimeoutSync = TcpTimeoutSync
            };

            s.StartTcpStreamMethod = StartTcpStreamMethod;
            s.OnDequeue           += pay.Dequeue;

            if (!string.IsNullOrEmpty(Filter))
            {
                s.Filter = Filter;
            }
            if (pay.CaptureOnTcpStream)
            {
                s.OnTcpStream += pay.OnTcpStream;
            }
            if (pay.CaptureOnPacket)
            {
                s.OnPacket += pay.OnPacket;
            }

            List <IIpPacketFilter> filters = new List <IIpPacketFilter>();

            if (FilterOnlyTorRequest)
            {
                filters.Add(new SnifferTorFilter());
            }
            if (FilterPorts != null && FilterPorts.Length > 0)
            {
                filters.Add(new SnifferPortFilter(FilterPorts));
            }
            if (FilterProtocols != null && FilterProtocols.Length > 0)
            {
                filters.Add(new SnifferProtocolFilter(FilterProtocols));
            }

            s.Filters        = filters.ToArray();
            s.OnCaptureStop += S_OnCaptureStop;
            s.Start();

            CreateJob(s, "IsDisposed");
            return(true);
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            // Creamos el sniffer, que capturará el puerto 3306 en tcp
            using (NetworkSniffer ns = new NetworkSniffer("Ethernet"))
            {
                ns.Filter  = "tcp";
                ns.Filters = new IIpPacketFilter[] { new SnifferPortFilter(3306) };

                ns.OnPacket += Ns_OnPacket;

                ns.Start();

                Console.WriteLine("Press any key for exit");
                Console.ReadKey();
            }
        }
Ejemplo n.º 5
0
        public override bool Run()
        {
            if (!SystemHelper.IsAdministrator())
            {
                WriteError("Require admin rights");
            }

            if (!DumpFolder.Exists)
            {
                return(false);
            }

            NetworkSniffer s = new NetworkSniffer(LocalAddress);

            s.OnTcpStream += s_OnTcpStream;
            s.Filter       = new SnifferPortFilter(this.LocalPort);
            s.Start();

            CreateJob(s);
            return(true);
        }