Link: Github Repository
Reach me out via LinkedIn, Portfolio Contact Form or mail@pascal-nehlsen.de
My Nmap - Portscanner Tool
This repository contains the source code for my custom implementation of the nmap tool. This lightweight implementation focuses on port scanning and service detection, offering a basic feature set to identify open ports and running services on a target machine.
This tool is intended for educational and authorized penetration testing purposes only. Unauthorized use of this tool against systems that you do not have explicit permission to test is illegal and unethical.
Table of Contents
Features
This implementation covers the following features/options:
- Port Scanning: Scans specified ports or all ports on a target machine.
- Service Detection: Identifies common services running on open ports (for the first 100 ports).
- Configurable Parameters: Allows customization of port ranges for scanning.
- DNS and IP Support: Supports both numerical IP addresses and DNS names.
Getting Started
To get started with this nmap implementation, follow these steps:
- Clone the Repository:
git clone https://github.com/yourusername/nmap.git
cd nmap
Usage Examples
Options
| Option | Shorthand | Description | Required |
|---|---|---|---|
--ports | -p | Specify port range or -p- for all ports | x |
-s | - | Target IP address or DNS name | x |
Scanning Ports
To scan specific ports or all ports on a target machine, use the following commands:
Scan Specific Port Range
python nmap.py -s <target> -p <port_range>
target: The IP address or DNS name of the target machine.port_range: The range of ports to scan (e.g.,22,80,443or1-1000).
Example:
python nmap.py -s 10.0.2.41 -p 22,80,443
Scan all Ports
python nmap.py -s <target> -p-
target: The IP address or DNS name of the target machine.
Example:
python nmap.py -s 10.0.2.41 -p-
Service Detection
For the first 100 ports, the tool will also attempt to identify the running services.
Creating DNS Name
To use a DNS name like yourtarget.abc instead of an IP address, you need to add this name to your system's hosts file. This file maps hostnames to IP addresses.
On Windows
- Open the
hostsFile as Administrator:
- Search for Notepad in the Windows search bar.
- Right-click on Notepad and select Run as administrator.
- In Notepad, go to File > Open and navigate to
C:\Windows\System32\drivers\etc\hosts. - Ensure the file type is set to All Files to see the
hostsfile.
- Add the DNS Entry:
<IP_ADDRESS> yourtarget.abc
- Replace
<IP_ADDRESS>with the actual IP address of your target machine. - Save and close the file.
On Linux/MacOS
- Open the
hostsFile with Root Permissions:
- Open a terminal.
- Use the following command to edit the file with a text editor like
nanoorvi:
sudo nano /etc/hosts
or
sudo vi /etc/hosts
- Add the DNS Entry:
<IP_ADDRESS> yourtarget.abc
- Replace
<IP_ADDRESS>with the actual IP address of your target machine. Save and exit the editor (Ctrl+XthenYfornano, or:wqforvi).