public void when_Target_constructed_with_IPAddresses_then_ToString_should_yield_space_separated_target()
 {
     var t =
         new Target(new[]
             {IPAddress.Parse("127.0.0.1"), IPAddress.Parse("127.0.0.2"), IPAddress.Parse("127.0.0.3")});
     Assert.AreEqual("127.0.0.1 127.0.0.2 127.0.0.3", t.ToString());
 }
Example #2
0
        private static void Main(string[] args)
        {
            Console.Write("Enter an IP or subnet: ");
            var target = new Target(Console.ReadLine().Trim());
            Console.WriteLine("Initializing scan of {0}", target);
            ScanResult result = new Scanner(target).PortScan();
            Console.WriteLine("Detected {0} host(s), {1} up and {2} down.", result.Total, result.Up, result.Down);
            foreach (Host i in result.Hosts)
            {
                Console.WriteLine("Host: {0}", i.Address);
                foreach (Port j in i.Ports)
                {
                    Console.Write("\tport {0}", j.PortNumber);
                    if (!string.IsNullOrEmpty(j.Service.Name))
                    {
                        Console.Write(" is running {0}", j.Service.Name);
                    }

                    if (j.Filtered)
                    {
                        Console.Write(" is filtered");
                    }

                    Console.WriteLine();
                }

                if (i.OsMatches.Any())
                {
                    Console.WriteLine("and is probably running {0}", i.OsMatches.First().Name);
                }
            }

            Console.Read();
        }
 public void when_Target_constructed_with_IPAddress_then_ToString_should_yield_target()
 {
     var t = new Target(IPAddress.Parse("127.0.0.1"));
     Assert.AreEqual("127.0.0.1", t.ToString());
 }
 public void when_Target_constructed_with_string_then_ToString_should_yield_target()
 {
     var t = new Target("this is a test");
     Assert.AreEqual("this is a test", t.ToString());
 }
 public void when_Target_constructed_with_strings_then_ToString_should_yield_space_separated_target()
 {
     var t = new Target(new[] {"this", "is", "a", "test"});
     Assert.AreEqual("this is a test", t.ToString());
 }
Example #6
0
 /// <summary>
 ///     Create a new scanner with an intended target
 /// </summary>
 /// <param name="target">Intended target</param>
 public Scanner(Target target)
 {
     Target = target;
 }