Skip to content

karankessy/Nmap-Automation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

AutoNmap - Enhanced Nmap Automation Tool

Introduction

autonmap.py is a Python script that enhances the Nmap scanning experience by providing a user-friendly interface to automate various Nmap scans. It simplifies the process of network exploration by guiding users through scan type selection, IP address input, and port range configuration. Key features include robust error handling, improved output formatting, and the ability to save scan results to an XML file.

Features

  • User-Friendly Interface: Interactive prompts for specifying scan parameters.
  • Multiple Scan Types:
    • SYN ACK Scan (Stealthy port discovery)
    • UDP Scan (For UDP-based services)
    • Comprehensive Scan (In-depth analysis including OS detection, version scanning, script scanning, and traceroute)
  • Configurable Port Ranges: Users can specify custom port ranges (e.g., 80-100, 22,80,443) or use the default range (1-1024).
  • Structured Output: Presents scan results in a clear, readable format, detailing open ports, services, versions, and (for comprehensive scans) OS information and NSE script outputs.
  • Save Scan Results: Option to save the complete Nmap XML output to a file for later analysis or use with other tools.
  • Error Handling: Improved validation for user inputs (IP address, scan choices, port ranges) and robust error catching during scan execution.

Installation

  1. Python 3: Ensure Python 3 is installed on your system.
  2. python-nmap library: This script relies on the python-nmap library. Install it using pip:
    pip install python-nmap
  3. Nmap: The Nmap utility itself must be installed on your system and accessible in your PATH. Installation methods vary by operating system (e.g., apt-get install nmap on Debian/Ubuntu, yum install nmap on Fedora/CentOS, or download from nmap.org).

Usage

  1. Run the script from your terminal:

    python3 autonmap.py
  2. Enter IP Address: Provide a valid IP address when prompted.

    Enter a valid IP address (e.g., 192.168.1.1): <your_target_ip>
    
  3. Choose Scan Type: Select one of the available scan options.

    Choose scan type:
        1) SYN ACK Scan
        2) UDP Scan
        3) Comprehensive Scan
    Enter option number (1, 2, or 3): <1, 2, or 3>
    
  4. Specify Port Range (Optional): Decide if you want to use a custom port range or the default (1-1024).

    Do you want to specify a port range? (yes/no, default: no, e.g., '1-1024', '80', '22,80'): <yes/no>
    

    If 'yes', enter your desired port range:

    Enter port range (e.g., '22-80', '80,443', '1000-2000', or a single port like '80'): <your_port_range>
    
  5. View Results: The script will execute the Nmap scan and display formatted results, including:

    • Nmap version used
    • The exact Nmap command executed
    • Host status
    • Detected protocols
    • Open ports with details (state, service, product, version, CPE)
    • For comprehensive scans: OS guesses and NSE script outputs.
  6. Save Results (Optional): After the scan, you'll be asked if you want to save the full Nmap XML output.

    Do you want to save the full Nmap XML output to a file? (yes/no): <yes/no>
    

    If 'yes', provide a filename:

    Enter filename to save results (e.g., scan_results): <your_filename>
    

    The results will be saved with an .xml extension.

Example Interaction Flow

Welcome, It's a simple nmap automation tool....
<<-------------------------------------------->>
Enter a valid IP address (e.g., 192.168.1.1): 192.168.1.100
IP you've entered is 192.168.1.100

Choose scan type:
    1) SYN ACK Scan
    2) UDP Scan
    3) Comprehensive Scan
Enter option number (1, 2, or 3): 3
You have selected option 3
Do you want to specify a port range? (yes/no, default: no, e.g., '1-1024', '80', '22,80'): yes
Enter port range (e.g., '22-80', '80,443', '1000-2000', or a single port like '80'): 22,80,443
Nmap Version: (7, 80)
Scanning 192.168.1.100 on ports 22,80,443 with options: -v -sS -sV -sC -A -O...

Nmap Command Executed: nmap -oX - -p 22,80,443 -v -sS -sV -sC -A -O 192.168.1.100
IP Status: up

Protocol: TCP
  Port: 22/tcp
    State: open
    Service: ssh
    Product: OpenSSH
    Version: 8.2p1 Ubuntu 4ubuntu0.1
    Extra Info: Ubuntu Linux; protocol 2.0
    CPE: cpe:/o:linux:linux_kernel
  Port: 80/tcp
    State: open
    Service: http
    Product: Apache httpd
    Version: 2.4.41
    Extra Info: (Ubuntu)
    CPE: cpe:/a:apache:http_server:2.4.41
... (other results) ...

--- Comprehensive Scan Details ---

  Operating System Guesses:
    - Name: Linux 4.15 - 5.6, Accuracy: 100%
      - Class: Type: general purpose, Vendor: Linux, OS Family: Linux, OS Gen: 4.X
... (other OS details) ...

  NSE Script Outputs:
    - Script: http-title
      Output: Apache2 Ubuntu Default Page: It works
... (other script outputs) ...

----------------------------------

Do you want to save the full Nmap XML output to a file? (yes/no): yes
Enter filename to save results (e.g., scan_results): my_scan_192_168_1_100
Scan results saved to my_scan_192_168_1_100.xml

Important Notes

  • Permissions: Ensure you have the necessary (often root or sudo) permissions to execute Nmap scans, especially for certain scan types like SYN scans (-sS).
  • Legality and Ethics: Use this tool responsibly. Only scan networks and systems for which you have explicit, authorized permission. Unauthorized scanning can be illegal and unethical.
  • Nmap Installation: This script is a wrapper around the Nmap tool. Nmap itself must be installed on your system and accessible in your system's PATH.

About

Python automated Nmap scanning tool.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages