π± Mobile Security Tips
Mike Torres — Android Security Engineer
What is Nmap?
Nmap (Network Mapper) is an open-source tool used for network discovery and security auditing. It is one of the most popular tools among security professionals for identifying devices on a network, discovering services those devices are offering, and detecting vulnerabilities.
Installation
Nmap can be installed on various operating systems including Windows, macOS, and Linux. Hereβs how to install it:
- **Windows:** Download the installer from the official website and follow the installation instructions.
- **macOS:** Use Homebrew by running
brew install nmap. - **Linux (Debian-based):** Run
sudo apt install nmap.
Basic Syntax
The basic syntax for Nmap is:
nmap [options] [target]
Discovery
To discover hosts within a network, use the following commands:
nmap -sn 192.168.1.0/24 // Ping scan to discover hosts nmap -Pn 192.168.1.1 // Disable ping to scan even if hosts do not respond
Scanning
For service and version detection, use:
nmap -sV 192.168.1.1 // Service version detection nmap -sS 192.168.1.1 // Stealth SYN scan
Exploitation
While Nmap is primarily a scanning tool, it can aid in exploits by identifying open ports:
nmap --script=http-shellshock 192.168.1.1 // Check for Shellshock vulnerability nmap --script=vuln 192.168.1.1 // Run vulnerability scripts on the target
Analysis
To analyze the output, use:
nmap -oN output.txt 192.168.1.1 // Output to a file nmap -oX output.xml 192.168.1.1 // Output to XML
Evasion
To evade detection by firewalls or IDS:
nmap -D RND:10 192.168.1.1 // Decoy scanning to hide source nmap -f 192.168.1.1 // Fragment packets to evade filtering
Reporting
For reporting purposes, use:
nmap -oA full_scan 192.168.1.0/24 // Output in all formats (normal, XML, grepable)
Quick Reference Table
| Flag | Description |
|---|---|
| -sP | Ping scan (no port scan) |
| -sV | Service version detection |
| -O | OS Detection |
| -oN | Normal output |
| -oX | XML output |
Pro Tips
- Combine options: Use
nmap -sS -sV -oG result.gnmap 192.168.1.0/24for stealth scan and service detection. - Use scripts: Nmap has a scripting engine that can enhance scanning capabilities. Check for available scripts using
nmap --script-help. - Regularly update Nmap to use the latest scripts and features.
Real-World Examples
1. **Find all active devices on a LAN:**
nmap -sn 192.168.1.0/24
2. **Scan for open ports and services on a specific device:**
nmap -sS -sV 192.168.1.10
3. **Check for vulnerabilities in web applications:**
nmap --script=http-vuln* 192.168.1.1
4. **Scan silently to evade detection:**
nmap -D RND:10 -sS 192.168.1.0/24