예제 #1
0
        /// <summary>
        ///     Perform a TCP port scan on the specified ports with service detection and OS detection.
        /// </summary>
        /// <param name="scanType">The type of scan to perform</param>
        /// <param name="ports">A list of ports to scan</param>
        /// <returns>A ScanResult object detailing the results of the port scan</returns>
        public ScanResult PortScan(ScanType scanType, IEnumerable <int> ports)
        {
            NmapContext ctx = _portScanCommon(scanType,
                                              string.Join(",",
                                                          ports.Select(x => x.ToString(CultureInfo.InvariantCulture))));

            return(new ScanResult(ctx.Run()));
        }
예제 #2
0
        /// <summary>
        ///     Perform host discovery and OS detection on the intended target (preferably a subnet or IP range)
        /// </summary>
        /// <returns>A collection of Hosts detailing the results of the discovery</returns>
        public IEnumerable <Host> HostDiscovery()
        {
            NmapContext ctx = GetContext();

            ctx.Options.AddAll(new[]
            {
                NmapFlag.TcpSynScan,
                NmapFlag.OsDetection
            });

            return(new ScanResult(ctx.Run()).Hosts);
        }
예제 #3
0
        /// <summary>
        ///     Perform CVE Vulnerability Scan for potential vulnerabilities
        /// </summary>
        /// <returns>A collection of Hosts detailing the results of the discovery</returns>
        public IEnumerable <Host> VulnerabilityDiscovery()
        {
            NmapContext ctx = GetContext();

            ctx.Options.AddAll(new[]
            {
                NmapFlag.TreatHostsAsOnline,
                NmapFlag.ScriptVuln
            });

            return(new ScanResult(ctx.Run()).Hosts);
        }
예제 #4
0
        /// <summary>
        ///     Perform host discovery and OS detection on the intended target (preferably a subnet or IP range)
        /// </summary>
        /// <returns>A collection of Hosts detailing the results of the discovery</returns>
        public IEnumerable <Host> HostDiscovery()
        {
            NmapContext ctx = GetContext();

            ctx.Options.AddAll(new[]
            {
                NmapFlag.HostScan,
                NmapFlag.AggressiveTiming,
            });

            return(new ScanResult(ctx.Run()).Hosts);
        }
예제 #5
0
        /// <summary>
        ///     Determine whether the intended target is firewalled.
        /// </summary>
        /// <returns>Returns true if the intended targer is firewalled and false otherwise. If used on a subnet or IP range, this determines if any host has a firewall.</returns>
        public bool FirewallProtected()
        {
            NmapContext ctx = GetContext();

            ctx.Options.AddAll(new[]
            {
                NmapFlag.AckScan,
                NmapFlag.FragmentPackets
            });

            var sr = new ScanResult(ctx.Run());

            return
                (sr.Hosts.Any(
                     x =>
                     (x.ExtraPorts.First().Count > 0 && x.ExtraPorts.First().State == "filtered") ||
                     x.Ports.Any(y => y.Filtered)));
        }
예제 #6
0
        /// <summary>
        ///     Perform a TCP port scan on the specified ports with service detection and OS detection.
        /// </summary>
        /// <param name="scanType">The type of scan to perform</param>
        /// <param name="ports">A string detailing which ports to scan (e.g., "10-20,33")</param>
        /// <returns>A ScanResult object detailing the results of the port scan</returns>
        public ScanResult PortScan(ScanType scanType, string ports)
        {
            NmapContext ctx = _portScanCommon(scanType, ports);

            return(new ScanResult(ctx.Run()));
        }
예제 #7
0
        /// <summary>
        ///     Perform the desired scan with service detection and OS detection.
        /// </summary>
        /// <returns>A ScanResult object detailing the results of the port scan</returns>
        public ScanResult PortScan(ScanType scanType)
        {
            NmapContext ctx = _portScanCommon(scanType, null);

            return(new ScanResult(ctx.Run()));
        }