示例#1
0
 public void Validate()
 {
     if (Ports != null && Ports.Any())
     {
         foreach (var port in Ports)
         {
             if (port < 0 || port > ushort.MaxValue)
             {
                 Console.Error.WriteLine($"Port {port} je mimo rozsah platných portů.");
                 Environment.Exit(AppCodes.InvalidInputPort);
             }
         }
     }
 }
示例#2
0
        private void UpdateDeviceList()
        {
            List <SerialPortInfo> ports = GetPortInformations();

            List <SerialPortInfo> added = (from p in ports
                                           where !Ports.Any(m => m.Device == p.Device)
                                           select p).ToList();

            List <SerialPortInfo> deleted = (from p in Ports
                                             where !ports.Any(m => m.Device == p.Device)
                                             select p).ToList();

            added.ForEach(m => AddPort(m));
            deleted.ForEach(m => RemovePort(m));
        }
示例#3
0
        protected override bool PortsValidate(out string message)
        {
            bool hasInlet = Ports.Any(
                x => x.Value is CapeMaterialPort &&
                ((CapeMaterialPort)x.Value).direction == CapePortDirection.CAPE_INLET &&
                ((CapeMaterialPort)x.Value).IsConnected());
            bool hasOutlet = Ports.Any(
                x => x.Value is CapeMaterialPort &&
                ((CapeMaterialPort)x.Value).direction == CapePortDirection.CAPE_OUTLET &&
                ((CapeMaterialPort)x.Value).IsConnected());

            message = "";
            if (!hasInlet)
            {
                message = "Inlet material missing. ";
            }
            if (!hasOutlet)
            {
                message += "Outlet material missing.";
            }
            return(hasInlet && hasOutlet);
        }
示例#4
0
 private bool IsNumberExist(string number)
 {
     return(Ports.Any(item => item.Number == number));
 }
        public async Task Start()
        {
            _PortRetryPolicy.Execute(() =>
            {
                if (!Ports.Any())
                {
                    var port = FreeTcpPort();
                    Ports.Add(new ServerPort(_Host, port, _ServerCredentials));
                }

                if (_Options != null)
                {
                    _ServerInstance = new Server(_Options);
                }
                else
                {
                    _ServerInstance = new Server();
                }

                foreach (var port in Ports)
                {
                    _ServerInstance.Ports.Add(port);
                }


                foreach (var srv in Services)
                {
                    _ServerInstance.Services.Add(srv);
                }

                // Add health check service
                _ServerInstance.Services.Add(Health.BindService(new HealthCheckImpl(this)));

                _ServerInstance.Start();

#if DEBUG
                Debug.WriteLine("Server running");
                Debug.WriteLine("Endpoints:");
                Debug.WriteLine($"   {string.Join(",", _ServerInstance.Ports.Select(a => $"{a.Host}:{a.Port}"))}");
#endif
            });

            ServerRunning = true;

            foreach (var adress in _ServerInstance.Ports)
            {
                var uriBuilder = new UriBuilder();
                uriBuilder.Host   = adress.Host;
                uriBuilder.Port   = adress.Port;
                uriBuilder.Scheme = string.Empty;

                var adressString = uriBuilder.Uri.ToString();

                var id = $"{nameof(GrpcMiddlewareServer)}_{Guid.NewGuid().ToString()}";

                _ServerIds.Add(id);

                await _ServiceDiscovery.RegisterService(new ServiceDescription()
                {
                    Adress = adressString,
                    Id     = id,
                    Port   = adress.Port,
                    Name   = nameof(GrpcMiddlewareServer),
                });
            }
        }
示例#6
0
        static void Main(string[] args)
        {
            DateTime startDate = DateTime.Now;

            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("Reecon - Version 0.25c ( https://github.com/Reelix/Reecon )");
            Console.ForegroundColor = ConsoleColor.White;
            if (args.Length == 0)
            {
                Console.WriteLine("Usage");
                Console.WriteLine("-----");
                Console.WriteLine("Basic Scan:\tReecon IPHere (Optional: -noping to skip the online check)");
                Console.WriteLine("Display IP:\tReecon -ip");
                Console.WriteLine("NMap-Load Scan:\tReecon outfile.nmap (Requires -oG on a regular nmap scan)");
                Console.WriteLine("Binary Pwn:\tReecon -pwn FileName (Very buggy)");
                Console.WriteLine("Searchsploit:\tReecon -searchsploit nameHere (Beta)");
                Console.WriteLine("Shell Gen:\tReecon -shell");
                Console.WriteLine("SMB Brute:\tReecon -smb-brute (Linux Only)");
                Console.WriteLine("WinRM Brute:\tReecon -winrm-brute IP UserList PassList");
                Console.WriteLine("LFI Test:\tReecon -lfi (Very buggy)");
                Console.WriteLine("Web Info:\tReecon -web url (Very buggy)");
                Console.ResetColor();
                return;
            }

            // Check if it's anything custom
            if (args.Contains("-ip") || args.Contains("--ip"))
            {
                General.GetIP();
                Console.ResetColor();
                return;
            }
            else if (args.Contains("-lfi") || args.Contains("--lfi"))
            {
                LFI.Scan(args);
                Console.ResetColor();
                return;
            }
            else if (args.Contains("-pwn") || args.Contains("--pwn"))
            {
                Pwn.Scan(args);
                Console.ResetColor();
                return;
            }
            else if (args.Contains("-searchsploit") || args.Contains("--searchsploit"))
            {
                Searchsploit.Search(args);
                Console.ResetColor();
                return;
            }
            else if (args.Contains("-shell") || args.Contains("--shell"))
            {
                Shell.GetInfo(args);
                Console.ResetColor();
                return;
            }
            else if (args.Contains("-smb-brute"))
            {
                SMB.SMBBrute(args);
                Console.ResetColor();
                return;
            }
            else if (args.Contains("-winrm-brute"))
            {
                WinRM.WinRMBrute(args);
                Console.ResetColor();
                return;
            }
            else if (args.Contains("-web") || args.Contains("--web"))
            {
                Web.GetInfo(args);
                Console.ResetColor();
                return;
            }
            else if (args.Contains("-osint") || args.Contains("--osint"))
            {
                OSINT.GetInfo(args);
                Console.ResetColor();
                return;
            }

            // Check if you should check if the target is up
            bool mustPing = true;

            if (args.Contains("-noping") || args.Contains("--noping"))
            {
                mustPing = false;
                args     = args.Where(x => !x.Contains("noping")).ToArray();
            }
            // A common typo
            if (args.Contains("-nopign"))
            {
                Console.WriteLine("You typo'd noping");
                Console.ResetColor();
                return;
            }

            // Everything below here has a maximum of 2 args
            if (args.Length > 2)
            {
                Console.WriteLine("You probably typo'd something");
                Console.ResetColor();
                return;
            }

            // Target
            if (args[0].EndsWith(".nmap"))
            {
                string fileName = args[0];
                var(Target, Ports) = Nmap.ParseFile(fileName, false);
                target             = Target;
                if (!Ports.Any())
                {
                    Console.WriteLine("Error: Empty file - Bug Reelix!");
                }
                else
                {
                    portList.AddRange(Ports);
                }
            }
            else
            {
                target = args[0];
            }

            if (target.StartsWith("http"))
            {
                Console.WriteLine("Cannot do a standard scan on a URL - Try a -web scan");
                Console.ResetColor();
                return;
            }

            // Custom ports
            if (args.Length == 2)
            {
                string portArg = args[1];
                try
                {
                    portList.AddRange(portArg.Split(',').ToList().Select(x => int.Parse(x)));
                }
                catch
                {
                    // Not a list of ports - Probably a name
                }
            }

            // First check if it's actually up
            if (mustPing)
            {
                Console.WriteLine("Checking if target is online...");
                bool?isHostOnline = General.IsUp(target);
                General.ClearPreviousConsoleLine();

                if (isHostOnline == null)
                {
                    Console.WriteLine("Invalid target: " + target);
                    return;
                }
                if (!isHostOnline.Value)
                {
                    Console.WriteLine("Host is not responding to pings :(");
                    Console.WriteLine("If you are sure it's up and are specifying ports, you can use -noping");
                    return;
                }
            }

            if (portList.Count == 0)
            {
                // Scan the target
                string fileName = Nmap.DefaultScan(args, mustPing);
                fileName += ".nmap";

                // Parse the ports
                var(Target, Ports) = Nmap.ParseFile(fileName, false);
                target             = Target;
                portList.AddRange(Ports);
            }

            // Everything parsed - Down to the scanning!
            PortInfo.LoadPortInfo();

            // Ports have been defined (Either nmap or custom)
            if (portList.Count != 0)
            {
                Console.Write("Scanning: " + target);
                Console.Write(" (Port");
                if (portList.Count > 1)
                {
                    Console.Write("s");
                }
                Console.WriteLine(": " + string.Join(",", portList) + ")");
                ScanPorts(portList);
            }
            else
            {
                // All parsing and scans done - But still no ports
                Console.WriteLine("No open ports found to scan :<");
                return;
            }

            // Everything done - Now for some helpful info!
            Console.WriteLine("Finished - Some things you probably want to do: ");
            if (portList.Count == 0)
            {
                // Something broke, or there are only UDP Ports :|
                Console.WriteLine("- nmap -sC -sV -p- " + target + " -oN nmap.txt");
                Console.WriteLine("- nmap -sU " + target + " -oN nmap-UDP.txt");
            }
            else
            {
                postScanList.Add($"- Nmap Script+Version Scan: nmap -sC -sV -p{string.Join(",", portList)} {target} -oN nmap.txt" + Environment.NewLine);
                postScanList.Add($"- Nmap UDP Scan: sudo nmap -sU {target}" + Environment.NewLine);
                foreach (string item in postScanList)
                {
                    // They already have newlines in them
                    Console.Write(item);
                }
            }
            DateTime endDate = DateTime.Now;
            TimeSpan t       = endDate - startDate;

            Console.WriteLine("Done in " + string.Format("{0:0.00}s", t.TotalSeconds) + " - Have fun :)");
            Console.ResetColor();
        }