Skip to content

Kangaroo is a network Ip scanner library designed to be utilized inside of a C# application.

License

Notifications You must be signed in to change notification settings

CodeOutput/kangaroo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Readme Image

kangaroo Network Scanner

GitHub GitHub all releases Nuget GitHub issues GitHub Repo stars GitHub forks

Kangaroos have large, powerful hind legs, large feet adapted for leaping and so does the Kangaroo network scanner.

The kangaroo network scanner supports (or will support) the following features.

Static Badge
Static Badge Static Badge
Static Badge

Readme GIF

Table of Contents

  1. Building Scanners
  2. Scanning Networks

Building

Kangaroo leverages the builder pattern to ensure its always configured correctly before usage.

begin with a ScannerBuilder.Configure() method

// IScanner implements IDisposable so optionally use a using statement
using var scanner = ScannerBuilder.Configure()

If no additional options are provided the kangaroo will grab your first network interface that is up and use that subnet for scans. (lies, not yet)

Begin chaining addition options together as depicted.

using var scanner = ScannerBuilder
    .Configure()
    .WithAddresses([ip1, ip2, ip3...])
    .WithParallelism(numberOfBatches: 10)
    .WithNodeTimeout(TimeSpan.FromMilliseconds(250))
    .WithLogging(
        LoggerFactory.Create(builder =>
        {
            builder.AddConsole();
        }))
    .Build();

var nodes = await scanner.QueryNetwork();
Console.WriteLine(nodes.Dump());

IP Configuration

Optionally kangaroo can use specific IPs, a range of IPs, or scan an entire subnet

ip address collection

using var scanner = ScannerBuilder
    .Configure()
    .WithAddresses([ip1, ip2, ip3...]) // provide an IEnerable of IP addresses
    .Build();

subnetmask

using var scanner = ScannerBuilder
    .Configure()
    .WithSubnet("10.0.0.0", "255.255.255.0") // provide an ip subnet to scan
    .Build();

network interface

using var scanner = ScannerBuilder
    .Configure()
    .withInterface(ethernet2) // provide an adapter to determine a subnet (optinal string name)
    .Build();

range of ips

using var scanner = ScannerBuilder
    .Configure()
    .WithRange(startIpAddress, endIpAddress) // provide a start and end address to scan a range of IPs 
    .Build();

Parellel Configuration

After the ips are determined you can optionally execute the scans using the TPL, add the WithParallelism method and provide a batch size. Each batch of IP addresses will be scanned in parellel. Each batch will contsin the number of IP addresses divided by the size of the provided addresses.

using var scanner = ScannerBuilder
    .Configure()
    .WithAddresses(ips)
    .WithParallelism(numberOfBatches: 10) // of 254 addresses 25 batches of 10 addresses will be scanned.  
    .Build();

Ping Configuration

The ping can be configured as well. optional timeout and TTL can be provided to effectively speed up or slow down each query. A shorter timeout will allow kangaroo to fail faster on an unknown address. The TTL can be configured to ensure you are only scanning IP addresses within a physical boundary. A TTL of 1 would only ping devices on the physical switch.

using var scanner = ScannerBuilder.Configure()
  .WithIpAddresses(ips)
  .WithMaxTimeout(TimeSpan.FromSeconds(1))
.Build();
using var scanner = ScannerBuilder.Configure()
  .WithIpAddresses(ips)
  .WithMaxHops(2)
.Build();

Logging Configuration

BYOL(Logger)

using var scanner = ScannerBuilder.Configure()
  .WithIpAddresses(ips)
  .WithLogging(_logger)  //Provide a logger
.Build();
using var scanner = ScannerBuilder.Configure()
  .WithIpAddresses(ips)
  .WithLogging(() => ILogger)  //Provide a logger func
.Build();

Scanning Networks

So now you have a new Kangaroo Scanner. lets scan, await a call to QueryAddresses(optionalCtx) to return a ScanResult containing a list of network nodes, and scan results.

var nodes = await scanner.QueryNetwork();
Console.WriteLine(nodes.Dump());

IP Scanning

Await a call to the QueryAddresses to query all the IP addresses provided. Depending on the ocnfiguration each query could take anywhere from 5 seconds to several minutes.

Nodes

Individual nodes can be queried as well.

var node = await scanner.CheckNetworkNode();
Console.WriteLine(node.Dump());

Scan Results

The results of each scan will include the elapsed time and other properties.

Port Scanner

(Future!)

About

Kangaroo is a network Ip scanner library designed to be utilized inside of a C# application.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%