Reconnaissance & Scanning

πŸ“ Concept Note β€” EHPT Unit II | Source: MCA Sem III Syllabus


The Problem It Solves

Before attacking a target, an ethical hacker needs to understand it β€” what systems exist, what services run, what vulnerabilities are present. Reconnaissance and scanning provide this intelligence.


Passive Reconnaissance (OSINT)

Information gathered without directly touching the target β€” the target has no idea you’re researching them.

Google Dorking

OperatorPurposeExample
site:Restrict to domainsite:example.com login
filetype:Find specific filesfiletype:pdf site:example.com
intitle:Search page titlesintitle:"index of" passwords
inurl:Search URLsinurl:admin login
cache:View Google’s cached versioncache:example.com
-Exclude termssite:example.com -www

Dangerous dorks (for authorised testing):

filetype:sql "INSERT INTO" password
intitle:"index of" "wp-config.php"
inurl:"/phpinfo.php"
filetype:env "DB_PASSWORD"

WHOIS Lookups

Reveals domain registration info β€” registrant name, email, registrar, creation/expiry dates, name servers.

whois example.com

DNS Reconnaissance

# Query A records
dig example.com A
 
# Query mail servers
dig example.com MX
 
# Query name servers
dig example.com NS
 
# Query all TXT records (SPF, DKIM)
dig example.com TXT
 
# Attempt zone transfer (reveals ALL records if misconfigured)
dig @ns1.example.com example.com AXFR

⚠️ A successful zone transfer is a critical security finding β€” it exposes the entire DNS structure.

Shodan β€” Search Engine for IoT

Searches for internet-connected devices β€” webcams, servers, routers, industrial control systems.

# Find Apache servers in India
apache country:IN

# Find open MongoDB instances
port:27017

# Find exposed RDP
port:3389 country:IN

theHarvester

Automated email and subdomain harvesting:

theHarvester -d example.com -b google,bing,linkedin -l 500

Maltego Community Edition

Visual link analysis tool β€” maps relationships between domains, IPs, emails, people, social profiles.

LinkedIn OSINT

  • Employee names β†’ usernames (often firstname.lastname)
  • Technologies mentioned in job postings β†’ tech stack
  • Organisational structure β†’ target for social engineering

Recon-NG Framework

Modular reconnaissance framework (like Metasploit for recon):

recon-ng
[recon-ng] > marketplace search
[recon-ng] > modules load recon/domains-hosts/google_site_web
[recon-ng] > options set SOURCE example.com
[recon-ng] > run

Active Scanning

Nmap Scan Types

ScanFlagHow It WorksStealthUse
TCP SYN-sSSends SYN, reads SYN-ACK or RST, never completesHighDefault, stealthy
TCP Connect-sTFull TCP 3-way handshakeLow (logged)When no root
UDP-sUSends UDP packets, waits for ICMP unreachableMediumDNS, SNMP
Stealth FIN-sFSends FIN flag onlyHighBypass simple firewalls
Xmas-sXSends FIN+PSH+URG flagsHighBypass simple firewalls
Null-sNSends no flagsHighBypass simple firewalls
Aggressive-AOS + version + scripts + tracerouteNoneFull enumeration

Version & OS Detection

# Service version detection
nmap -sV 192.168.1.10
 
# OS fingerprinting
sudo nmap -O 192.168.1.10
 
# Both + scripts
sudo nmap -A 192.168.1.10

NSE Scripts (Nmap Scripting Engine)

# Default scripts
nmap --script=default 192.168.1.10
 
# Vulnerability scripts
nmap --script=vuln 192.168.1.10
 
# Specific script
nmap --script=http-enum 192.168.1.10

Timing Templates

TemplateNameUse Case
T0ParanoidIDS evasion (very slow)
T1SneakyIDS evasion
T2PoliteReduced bandwidth
T3NormalDefault
T4AggressiveFast, reliable network
T5InsaneVery fast, may miss results
# Connect to service and read banner
nc -v 192.168.1.10 22
# Output: SSH-2.0-OpenSSH_7.6p1
 
nc -v 192.168.1.10 80
# Then type: HEAD / HTTP/1.0
# Output: Server: Apache/2.4.29

Network Enumeration

SMB Enumeration

# Comprehensive SMB enumeration
enum4linux -a 192.168.1.10
 
# Discovers: users, shares, groups, OS info, password policy

SNMP Walking

# Walk SNMP tree (if community string is known/default)
snmpwalk -v2c -c public 192.168.1.10

SMTP User Enumeration

# Verify if user exists via VRFY command
telnet 192.168.1.10 25
VRFY admin
# 250 = user exists, 550 = doesn't exist

Vulnerability Scanning β€” Nessus

What is Nessus?

Automated vulnerability scanner that checks systems against a database of known vulnerabilities.

πŸ”— Deep dive: Nessus

Nessus vs Nmap

  • Nmap: β€œWhat ports and services are running?” (discovery)
  • Nessus: β€œWhat known vulnerabilities exist?” (assessment)

CVSS v3.1 Score Components

MetricValuesMeaning
Attack Vector (AV)Network / Adjacent / Local / PhysicalHow attacker reaches target
Attack Complexity (AC)Low / HighDifficulty of exploitation
Privileges Required (PR)None / Low / HighAuth needed before exploit
User Interaction (UI)None / RequiredDoes victim need to do something?
Scope (S)Unchanged / ChangedDoes exploit affect other components?
Confidentiality (C)None / Low / HighImpact on data secrecy
Integrity (I)None / Low / HighImpact on data accuracy
Availability (A)None / Low / HighImpact on system uptime

CVSS Score Ranges

ScoreRatingExample
0.0NoneInformational finding
0.1–3.9LowMinor information disclosure
4.0–6.9MediumStored XSS
7.0–8.9HighSQL injection
9.0–10.0CriticalRemote code execution, no auth

CVE Lookup

  • CVE = Common Vulnerabilities and Exposures
  • Format: CVE-YYYY-NNNNN (e.g., CVE-2021-44228 = Log4Shell)
  • Lookup: https://nvd.nist.gov/

False Positive Concept

  • Scanner reports a vulnerability that doesn’t actually exist
  • Must be verified manually before reporting to client
  • Common with version-based detection (patched but version unchanged)