Cheatsheets/nmap-cheatsheet.md

118 lines
2.5 KiB
Markdown
Raw Normal View History

2023-10-14 23:37:04 +01:00
Certainly, here's your Nmap cheat sheet in Markdown format. You can copy this and upload it to your GitHub repository.
2023-10-14 22:26:11 +01:00
2023-10-14 23:37:04 +01:00
```markdown
# NMAP Cheat Sheet
2023-10-14 22:30:14 +01:00
2023-10-14 22:26:11 +01:00
## Table of Contents
2023-10-14 23:37:04 +01:00
1. [Ping Scanning](#ping-scanning)
2. [ARP Scanning](#arp-scanning)
3. [SYN Scanning](#syn-scanning)
4. [UDP Scanning](#udp-scanning)
5. [Useful Nmap Switches](#useful-nmap-switches)
6. [Identifying OS and Applications](#identifying-os-and-applications)
7. [Nmap Scripts](#nmap-scripts)
8. [Batch Script for Nmap](#batch-script-for-nmap)
2023-10-14 22:30:14 +01:00
---
2023-10-14 23:37:04 +01:00
## Ping Scanning
2023-10-14 22:30:14 +01:00
2023-10-14 23:37:04 +01:00
- `nmap -sn 192.168.10.1`
- `nmap -sP 192.168.10.2`
2023-10-14 22:26:11 +01:00
---
2023-10-14 23:37:04 +01:00
## ARP Scanning
2023-10-14 22:26:11 +01:00
2023-10-14 23:37:04 +01:00
`nmap -sP -PR 192.168.10.1`
2023-10-14 22:30:14 +01:00
2023-10-14 23:37:04 +01:00
> **Note**: Press the spacebar to show the current progression of the scan.
2023-10-14 22:26:11 +01:00
2023-10-14 22:30:14 +01:00
---
2023-10-14 23:37:04 +01:00
## SYN Scanning
2023-10-14 22:26:11 +01:00
2023-10-14 23:37:04 +01:00
`nmap -sS 192.168.10.1`
2023-10-14 22:26:11 +01:00
2023-10-14 22:30:14 +01:00
---
2023-10-14 23:37:04 +01:00
## UDP Scanning
2023-10-14 22:30:14 +01:00
2023-10-14 23:37:04 +01:00
`nmap -sU 192.168.10.1`
2023-10-14 22:26:11 +01:00
2023-10-14 22:30:14 +01:00
---
2023-10-14 23:37:04 +01:00
## Useful Nmap Switches
2023-10-14 22:26:11 +01:00
2023-10-14 23:37:04 +01:00
- `-h` : Help
- `-v` : Verbose
- `-vv` : Very Verbose
- `-n` : No DNS Reverse Lookup
- `-T` : Sets the speed of the scan (`-T5` being the fastest, `-T0` the slowest)
- `-p` : Specify ports
- `-p 80` : Specific port
- `-p 1-10` : Range of ports
- `-p-` : All ports
- `-o` : To output a file
2023-10-14 22:26:11 +01:00
2023-10-14 22:30:14 +01:00
---
2023-10-14 23:37:04 +01:00
## Identifying OS and Applications
2023-10-14 22:30:14 +01:00
2023-10-14 23:37:04 +01:00
- `-sV` : Enable Version Detection
- `-O` : Enable OS Detection
- `-A` : Enable OS Detection, Version Detection, Script Scanning, and Traceroute
- `--osscan-guess` : Aggressive OS guessing
2023-10-14 22:30:14 +01:00
---
2023-10-14 22:26:11 +01:00
2023-10-14 23:37:04 +01:00
## Nmap Scripts
2023-10-14 22:26:11 +01:00
2023-10-14 23:37:04 +01:00
**Syntax**: `nmap —script scriptname targetIP`
2023-10-14 22:30:14 +01:00
2023-10-14 23:37:04 +01:00
Examples:
2023-10-14 22:30:14 +01:00
2023-10-14 23:37:04 +01:00
- `nmap —script http-headers 192.168.10.1`
- `nmap —script smtp-commands 192.168.10.1`
- `nmap -sV --script=banner 192.168.10.1`
- `nmap -sV --script=smb* 192.168.10.1`
- `nmap --script=http-title 192.168.10.1`
- `nmap --script=http-enum 192.168.10.0/24`
2023-10-14 22:26:11 +01:00
2023-10-14 23:37:04 +01:00
> [How to Use Nmap Script Engine (NSE) Scripts in Linux](https://www.tecmint.com/use-nmap-script-engine-nse-scripts-in-linux/)
2023-10-14 22:26:11 +01:00
2023-10-14 23:37:04 +01:00
---
2023-10-14 22:30:14 +01:00
2023-10-14 23:37:04 +01:00
## Batch Script for Nmap
2023-10-14 22:26:11 +01:00
2023-10-14 23:37:04 +01:00
1. First, download Neovim or your favorite text editor.
2. Create a file named `nmapScan.sh`.
2023-10-14 22:30:14 +01:00
2023-10-14 23:37:04 +01:00
```bash
#!/bin/bash
2023-10-14 22:26:11 +01:00
2023-10-14 23:37:04 +01:00
nmap -sT -p 1-10000 -v -v -T5 -sV -O --osscan-guess --script=banner -oN 192.168.10.1TCP.txt 192.168.10.1
nmap -sU -p 1-500 -v -v --scan-delay 1s -sV --script=banner -oN 192.168.10.1UDP.txt 192.168.10.1
nmap -sT -p 1-10000 -v -v -T5 -sV -O --osscan-guess --script=banner -oN 192.168.10.2TCP.txt 192.168.10.2
nmap -sU -p 1-500 -v -v --scan-delay 1s -sV --script=banner -oN 192.168.10.2UDP.txt 192.168.10.2
```
2023-10-14 22:30:14 +01:00
2023-10-14 23:37:04 +01:00
3. Save and exit.
4. Make the script executable:
2023-10-14 22:26:11 +01:00
2023-10-14 23:37:04 +01:00
```bash
sudo chmod +x nmapScan.sh
```
2023-10-14 22:26:11 +01:00
2023-10-14 23:37:04 +01:00
5. Run the script:
2023-10-14 22:26:11 +01:00
2023-10-14 23:37:04 +01:00
```bash
sudo ./nmapScan.sh
```
2023-10-14 22:26:11 +01:00
2023-10-14 23:37:04 +01:00
---
```
2023-10-14 22:26:11 +01:00
2023-10-14 23:37:04 +01:00
Feel free to modify or add any additional information!