Exemple #1
0
        public static int Main(String[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("[!] You must provide a listening server.");
                return(-1);
            }

            IList <ScannedPort> portResults = null;

            try
            {
                IPAddress ip = IpAddressResolver.ResolveIpAddress(args[0]);
                if (ip == null)
                {
                    Console.WriteLine("[!] Listening server IP address could not be resolved.");
                    return(-1);
                }

                PortScanController controller = new PortScanController();
                portResults = controller.ScanPorts(ip.ToString(), "1", "65535").ToList();
            }
            catch (Exception e)
            {
                Console.WriteLine("[!] Error: {0}", e.ToString());
            }
            return(0);
        }
Exemple #2
0
        public IEnumerable <ScannedPort> ScanPorts(string target, string startPort, string endPort)
        {
            if (InputValuesAcceptable(target, startPort, endPort))
            {
                return(MultiPortScanner.ScanPorts(IpAddressResolver.ResolveIpAddress(target),
                                                  ushort.Parse(startPort), ushort.Parse(endPort)));
            }

            throw new ArgumentException("[!] Unable to perform port scan. One or more arguments are invalid.");
        }