PISA Pakistan β€” Community CERT

← βš™οΈ Blue Team & Defense Engineering

50. Nmap Network Scanning and Vulnerability Assessment for Pakistani Enterprise Defenders

⏱ 10 min

Network Reconnaissance: The Defender's Perspective

Understanding attacker methodology is fundamental to effective defense. Nmap remains the industry-standard tool for network reconnaissance, and Pakistani SOC analysts must master both its offensive use (for authorized penetration testing) and defensive interpretation (to anticipate adversary actions). This lesson provides hands-on Nmap skills with Pakistani enterprise network scenarios, emphasizing legal compliance and responsible disclosure.

Legal Framework: Always obtain written authorization before scanning. Under Pakistan's Prevention of Electronic Crimes Act 2016, unauthorized scanning constitutes a cybercrime. Coordinate with your organization's legal team and consider PK-CERT coordination for critical infrastructure.

Essential Nmap Scanning Techniques

Basic Host Discovery:

# Discover live hosts in your DMZ (192.168.1.0/24)
nmap -sn 192.168.1.0/24 -oA dmz_discovery

# Aggressive discovery with OS detection (authorized testing only)
nmap -A -T4 10.10.50.0/24 -oA internal_assets

Service Version Detection:

# Identify services running on critical assets
nmap -sV --version-intensity 5 -p 22,80,443,3306,5432 10.10.50.100 -oA service_enum

For Pakistani banking networks, prioritize scanning for:

  • SWIFT Alliance Access connections (port 1500)
  • easypaisa/JazzCash API endpoints
  • NADRA verification service integrations
  • Internal banking core systems

Vulnerability Assessment Workflows

Nmap Scripting Engine (NSE):

# Run vulnerability scripts on web servers
nmap --script vuln -p 80,443,8080 10.10.50.0/24 -oA vuln_scan

# Specific checks for common Pakistani enterprise vulnerabilities
nmap --script 'smb-vuln-*' --script-args smbuser=admin,smbpass=password 10.10.50.50

Practical Lab Scenario:

A Pakistani e-commerce company running Daraz-style marketplace needs to audit their infrastructure:

  1. Asset Identification: Discover all 254 hosts in 192.168.100.0/24
  2. Service Cataloging: Enumerate all listening services and versions
  3. Vulnerability Mapping: Run NSE vuln scripts against web-facing systems
  4. Configuration Audit: Use http-enum script to discover admin panels
  5. Report Generation: Export to XML, import into TheHive for ticketing

Detecting Living-Off-the-Land (LotL) Techniques

Pakistani threat actors, including those targeting SBP-regulated institutions, increasingly use LotL techniques. Use Nmap to audit for:

  • PowerShell remoting (port 5985/5986) β€” often abused post-compromise
  • WMI lateral movement (port 135)
  • SMB lateral movement (ports 139, 445)
# Detect potentially dangerous services
nmap -p 135,139,445,3389,5985,5986 --script smb-security-mode 192.168.100.0/24

Defensive Countermeasures and SIEM Integration

Firewall Auditing:

# Test firewall rule effectiveness
nmap -Pn --badsum -p 80,443 10.10.50.1
nmap -p 80,443 -sA 10.10.50.1  # ACK scan to test filtering

Sigma Rule for Nmap Detection:

Create detection rules for network scanning patterns in Suricata:

title: Nmap SYN Scan Detection
logsource:
  product: suricata
event_type: flow
detection:
  scan_signature:
    - ip.src: 192.168.100.0/24
    - tcp.flags: 'SYN'
    - tcp.window: 1024
  condition: scan_signature

Do / Don't:

  • Do maintain asset inventory by regularly scanning authorized ranges
  • Do integrate Nmap outputs with vulnerability management ticketing
  • Don't scan 0.0.0.0/0 or ranges outside your authorization
  • Don't use aggressive timing (-T5) on production systems without change advisory board approval

Building a Vulnerability Assessment Pipeline

Integrate Nmap with your ELK Stack for continuous monitoring:

  1. Schedule weekly scans of critical subnets using cron
  2. Parse Nmap XML output with Logstash
  3. Correlate findings with existing asset CMDB
  4. Auto-create tickets in TheHive for findings above CVSS 7.0
  5. Generate executive reports for CISO review

Takeaway Today: Run an authorized host discovery scan on your immediate network segment and document all discovered assets. Compare results against your CMDB β€” gaps indicate either shadow IT or scanning blind spots.

← PrevNext β†’