Example #1
0
        private static void receiver(Packet packet)
        {
            //if (packet.IpV4.Icmp == null || packet.IpV4.Icmp.MessageType != IcmpMessageType.EchoReply) return;
            IP source = new IP(packet.Ethernet.IpV4.Source.ToString());

            if (!TCPMode)
            {
                Console.WriteLine("icmp reply from {0}", source.ToString());
            }
            else
            {
                Console.WriteLine("SYN reply from {0}", source.ToString());
            }
            File.AppendAllText(outPath, source.ToString() + "\n");
        }
Example #2
0
        static void Main(string[] args)
        {
            if (!parseArgs(args))
            {
                return;
            }
            preparePcap();

            new Thread(() => { communicator.ReceivePackets(0, receiver); }).Start();
            if (!RandomMode)
            {
                var end = endIP++;
                for (IP i = startIP; i < end; i++)
                {
                    if (!TCPMode)
                    {
                        Console.WriteLine("Sending ICMP to {0}", i);
                        SendICMP(i.ToString());
                    }
                    else
                    {
                        Console.WriteLine("Sending TCP SYN to {0}", i);
                        SendSYN(i.ToString());
                    }
                    Thread.Sleep(delay);
                }
            }
            else
            {
                for (int x = 0; x < RandomLimit; x++)
                {
                    string i = string.Format("{0}.{1}.{2}.{3}", rand.Next(1, 240), rand.Next(1, 255), rand.Next(1, 255), rand.Next(1, 255));
                    if (!TCPMode)
                    {
                        Console.WriteLine("Sending ICMP to {0}", i);
                        SendICMP(i);
                    }
                    else
                    {
                        Console.WriteLine("Sending TCP SYN to {0}", i);
                        SendSYN(i);
                    }
                    Thread.Sleep(delay);
                }
            }
            Thread.Sleep(1000);
            Console.WriteLine("Done.");
        }
Example #3
0
 private static bool parseArgs(string[] args)
 {
     if (args.Length < 4)
     {
         Console.WriteLine("Usage: discovery <start ip> <end ip> <delay (ms)> <output>");
         Console.WriteLine("Example: discovery 1.1.1.1 1.1.2.1 100 out.txt");
         Console.WriteLine("For Random Scanning:");
         Console.WriteLine("Example: discovery R <Number Of IPs> 100 out.txt");
         Console.WriteLine("For TCP Scanning:");
         Console.WriteLine("Example: discovery 1.1.1.1 1.1.2.1 100 out.txt <port> -t");
         return(false);
     }
     try
     {
         if (args[0].ToLower().StartsWith("r"))
         {
             RandomMode  = true;
             RandomLimit = int.Parse(args[1]);
         }
         else
         {
             startIP = new IP(args[0]);
             endIP   = new IP(args[1]);
         }
         delay   = int.Parse(args[2]);
         outPath = args[3];
         if (args.Length == 6)
         {
             TCPMode = true;
             TCPPort = int.Parse(args[4]);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Invalid args. {0}\n", ex.Message);
         return(false);
     }
     return(true);
 }
Example #4
0
 private static void receiver(Packet packet)
 {
     //if (packet.IpV4.Icmp == null || packet.IpV4.Icmp.MessageType != IcmpMessageType.EchoReply) return;
     IP source = new IP(packet.Ethernet.IpV4.Source.ToString());
     if (!TCPMode)
     {
         Console.WriteLine("icmp reply from {0}", source.ToString());
     }
     else
     {
         Console.WriteLine("SYN reply from {0}", source.ToString());
     }
     File.AppendAllText(outPath, source.ToString() + "\n");
 }
Example #5
0
        private static bool parseArgs(string[] args)
        {
            if (args.Length < 4)
            {
                Console.WriteLine("Usage: discovery <start ip> <end ip> <delay (ms)> <output>");
                Console.WriteLine("Example: discovery 1.1.1.1 1.1.2.1 100 out.txt");
                Console.WriteLine("For Random Scanning:");
                Console.WriteLine("Example: discovery R <Number Of IPs> 100 out.txt");
                Console.WriteLine("For TCP Scanning:");
                Console.WriteLine("Example: discovery 1.1.1.1 1.1.2.1 100 out.txt <port> -t");
                return false;
            }
            try
            {

                if (args[0].ToLower().StartsWith("r"))
                {
                    RandomMode = true;
                    RandomLimit = int.Parse(args[1]);
                }
                else
                {
                    startIP = new IP(args[0]);
                    endIP = new IP(args[1]);
                }
                delay = int.Parse(args[2]);
                outPath = args[3];
                if (args.Length == 6)
                {
                    TCPMode = true;
                    TCPPort = int.Parse(args[4]);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Invalid args. {0}\n", ex.Message);
                return false;
            }
            return true;
        }