Skip to content

Nanitor Network Scanner

A comprehensive network scanner for security assessments and discovery. A standalone scanner written in Python that produces a text file in json format. Optionally import into your Nanitor instance. Recommend running this on a Linux or macOS machine.

Features

  • Network discovery using ping sweep
  • TCP and UDP port scanning
  • MAC address and vendor resolution
  • Web server detection and fingerprinting
  • SSL/TLS certificate analysis
  • SNMP information gathering
  • Colorized terminal output
  • JSON results for further analysis
  • Nanitor import: Importing scan results into Nanitor

System Requirements

  • Python 3.11

  • Nmap is installed on your system

  • macOS: brew install nmap
  • Linux: sudo apt-get install nmap (Ubuntu/Debian) or sudo yum install nmap (RHEL/CentOS)
  • Others: Download from Nmap's official website

  • httpx installed on your system

  • Releases can be downloaded from httpx's GitHub releases

  • gobuster is installed on your system

  • Releases can be downloaded from gobuster's GitHub releases

Installation

  1. Clone the repository:

    git clone https://github.com/nanitor/nanitor-scanner.git
    cd nanitor-scanner
    

  2. Create a virtual environment:

    python -m venv venv
    source venv/bin/activate
    

  3. Install dependencies:

    pip install -r requirements.txt
    

  4. Install the needed dependencies (nmap, gobuster, httpx).

  5. Run the scanner:

    sudo -E python nanscan.py
    

Usage

Scan the local network:

sudo -E python nanscan.py

Scan a specific network with verbose output:

sudo -E python nanscan.py -n 192.168.1.0/24 -v

Import the results into Nanitor through the API. Make sure to set the environment variables and specify the correct organization ID. The data will be imported into the organization specified.

export NANITOR_API_URL=https://my.nanitor.net/system_api
export NANITOR_API_KEY=MySecretAPIKeywithWritePermissionHere
python api.py import scan_results/nanitor_import.json -org-id 123

Dependencies and External Tools

Python environment

The Nanitor scanner is built in Python. The required Python configuration is specified in pyproject.toml. It has several dependencies, as specified in requirements.txt. For a complete list of the packages and their licensing, see the DEPENDENCIES.md file.

External tools

The Nanitor scanner depends on some external tools to enhance scanning capabilities. These tools need to be installed and ready to run in the environment. Each tool serves a specific purpose and is referenced directly for transparency and attribution:

Output

Results are saved to the scan_results directory in the following structure:

  • scan_results/nanitor_import.json: Scan results ready for import via Nanitor API
  • scan_results/summary.json: Overall scan summary
  • scan_results/{ip}: Detailed scan results for each host and tool outputs
  • scan_results/{ip}/scan_results.json: Detailed scan results for each host

To change the output folder, use --out-dir.

Importing the results into Nanitor

To import the scan results into Nanitor, after running, you need to Set the environment variables pointing to your Nanitor instance's API and API key, for example:

export NANITOR_API_URL="https://my.nanitor.net/system_api"
export NANITOR_API_KEY="Your API key with write permissions"
and then simply run
python api.py import scan_results/nanitor_import.json --org-id <YOUR_ORGANIZATION_ID>
This will import the results into the specified organization.

For more information on API keys and obtaining them, see https://help.nanitor.com/97-rest-api/

Feedback

If you have any feedback, feel free to contact us or submit an Issue. If you have anything to contribute, you can open a pull request. All pull requests will be looked at, though we may not accept everything.