nerve 0.1.1

Cross-platform security scan library
Documentation
nerve-0.1.1 has been yanked.

nerve Crates.io License

Security scan library with the aim of being lightweight and fast.
nerve provides a cross-platform API for network / security scan using Rust.
It is currently in alpha stage.

Features

  • PORT SCAN
  • HOST SCAN
  • URI SCAN
  • DOMAIN SCAN(planned)

Usage

  • Structs that provide each function
    • PortScanner
    • HostScanner
    • UriScanner
  • In each struct
    • ::new returns a Scanner.
    • ::run_scan() Run scan with current settings.
    • Results are stored in ::scan_result
    • ::get_result returns a scan resut.

Example

Add some crate to your dependencies:

nerve = "0.1"
#For host scan example
ipnet = "2.3"
#For uri scan example
tokio = { version = "0.2", features = ["full"] }

PORT SCAN
In this example, target ports are 1 to 1000.

extern crate nerve;
use nerve::PortScanner;
use nerve::PortScanType;
fn main() {
    let mut port_scanner = match PortScanner::new(None, None){
        Ok(scanner) => (scanner),
        Err(e) => panic!("Error creating scanner: {}", e),
    };
    port_scanner.set_target_ipaddr("192.168.1.92");
    port_scanner.set_range(1, 1000);
    port_scanner.set_scan_type(PortScanType::SynScan);
    port_scanner.run_scan();
    let result = port_scanner.get_result();
    println!("Open Ports:");
    for port in result.open_ports {
        println!("{}", port);
    }
    println!("Scan Time: {:?}", result.scan_time)
}

HOST SCAN
In this example, targeting a host address in the network.

extern crate nerve;
use nerve::HostScanner;
use std::net::Ipv4Addr;
use ipnet::Ipv4Net;

fn main(){
    let mut host_scanner = match HostScanner::new(){
        Ok(scanner) => (scanner),
        Err(e) => panic!("Error creating scanner: {}", e),
    };
    //Get network address
    let net: Ipv4Net = Ipv4Net::new(Ipv4Addr::new(192, 168, 1, 2), 24).unwrap();
    assert_eq!(Ok(net.network()), "192.168.1.0".parse());
    let nw_addr = Ipv4Net::new(net.network(), 24).unwrap();
    //Get host list
    let hosts: Vec<Ipv4Addr> = nw_addr.hosts().collect();
    for host in hosts{
        host_scanner.add_ipaddr(&host.to_string());
    }
    host_scanner.run_scan();
    let result = host_scanner.get_result();
    println!("Up Hosts:");
    for host in result.up_hosts {
        println!("{}", host);
    }
    println!("Scan Time: {:?}", result.scan_time);
}

URI SCAN
In this example, common.txt is used as the word list.

extern crate nerve;
use nerve::UriScanner;
use tokio;
use std::fs::read_to_string;

#[tokio::main]
async fn main(){
    let mut uri_scanner = match UriScanner::new(){
        Ok(scanner) => (scanner),
        Err(e) => panic!("Error creating scanner: {}", e),
    };
    let base_uri = String::from("http://192.168.1.18/xvwa/");
    uri_scanner.set_base_uri(base_uri);
    let data = read_to_string("common.txt");
    let text = match data {
        Ok(content) => content,
        Err(e) => {panic!("Could not open or find file: {}", e);}
    };
    let word_list: Vec<&str> = text.trim().split("\n").collect();
    for word in word_list {
        uri_scanner.add_word(word.to_string());
    }
    uri_scanner.run_scan().await;
    let result = uri_scanner.get_result();
    println!("URI Scan Result:");
    for (uri, status) in result.responses {
        println!("{} {}", uri, status);
    }
    println!("Scan Time: {:?}", result.scan_time);
}

Supported platform

  • Linux
  • macOS(OS X)
  • Windows

Additional Notes

This library requires the ability to create raw sockets. Execute with root user privileges.