Knowledge / Information Technology / Ethical hacking and penetration testing

Ethical hacking and penetration testing

Information Technology (B.E./B.Tech) · Information security · free study notes for exams, placements and interviews

In short

Ethical hacking is the authorised, documented act of attacking an organisation's own systems the way a real attacker would, so that weaknesses are found and fixed before a criminal finds them. A penetration test is the structured engagement that does this — scoped, time-boxed, contracted, and ending in a report with risk ratings and remediation advice. In India it is mandatory practice in banking (RBI cyber-security framework), insurance, telecom, UIDAI/Aadhaar ecosystems and any CERT-In-regulated body, and it is routinely assessed in university Information Security papers, in GATE CS/IT security questions, and in interviews at TCS, Infosys, Wipro, HCLTech, Accenture, Deloitte, KPMG, EY, Paladion/Atos, Lucideus/SAFE Security, CloudSEK and the big product companies. The one thing that separates ethical hacking from a cybercrime is written authorisation — the techniques are identical.

Explained

Definitions, intent and legal basis

Types of testing and engagement models

The five-phase methodology (standard exam answer)

  1. Reconnaissance / footprinting — collect information. Passive: WHOIS, DNS records, certificate transparency logs, Google dorks (site:, filetype:, inurl:), Shodan/Censys, LinkedIn and job ads for the tech stack, leaked-credential dumps, archived pages. Active: ping sweeps, banner grabbing, DNS zone transfer attempts. Tools: whois, dig, nslookup, theHarvester, Maltego, Amass, Recon-ng, OSINT framework. Output: domains, subdomains, IP ranges, employee names, email format, technologies.
  2. Scanning — find live hosts, open ports, services, versions and known vulnerabilities. Nmap for host discovery and port/service/OS detection; Nessus / OpenVAS / Qualys / Nexpose for vulnerability scanning; Nikto, WhatWeb for web servers. Distinguish port states: open, closed, filtered.
  3. Enumeration and vulnerability analysis — extract usernames, shares, SNMP data, SMB/NetBIOS info, LDAP entries, directory structures; map findings to CVE identifiers and verify they are real, not scanner noise (false positives). Tools: enum4linux, smbclient, ldapsearch, snmpwalk, dirsearch/gobuster, Burp Suite, SQLMap.
  4. Exploitation / gaining access — prove impact. Metasploit Framework, custom exploits, Hydra/Medusa for credential attacks, Responder for LLMNR/NBT-NS poisoning and NTLM hash capture (Impacket's ntlmrelayx for relaying), BeEF for browser attacks, SQL injection and command injection by hand. Keep within ROE: no destructive payloads, no ransomware simulation unless explicitly contracted.
  5. Post-exploitation, privilege escalation and persistence — local privilege escalation (kernel exploits, SUID binaries, misconfigured sudo, unquoted service paths, token impersonation, Mimikatz credential dumping, Kerberoasting in AD), lateral movement (pass-the-hash, RDP, WMI, SSH key reuse), pivoting through a compromised host, data-access proof. Covering tracks is a real attacker phase that an ethical hacker does NOT perform — logs are left intact; instead the tester records timestamps so the blue team can correlate.
  6. Reporting and retest — the deliverable. Executive summary, scope and dates, methodology, each finding with description, affected asset, evidence (screenshot, request/response), severity and CVSS vector, business impact, reproducible steps, remediation; then an appendix of out-of-scope observations. A retest/closure report after fixes is normally contracted.
  7. Clean-up is a formal step: remove uploaded shells, test accounts, cron jobs, added SSH keys; hand over a written list of every artefact created.

Frameworks, standards and tooling

Scoring, prioritisation and reporting quality

Key points

Formulas and examples

Risk = Likelihood × Impact (qualitative scale 1-5 each → 1-25 risk score)
CVSS v3.1 Base (Scope unchanged) = Roundup( min[(Impact + Exploitability), 10] )
Impact (ISS) = 1 − [(1 − C)(1 − I)(1 − A)]; Impact = 6.42 × ISS
Exploitability = 8.22 × AV × AC × PR × UI
AV: Network 0.85, Adjacent 0.62, Local 0.55, Physical 0.20
AC: Low 0.77, High 0.44; PR (Scope unchanged): None 0.85, Low 0.62, High 0.27; UI: None 0.85, Required 0.62
Base = 0 if Impact ≤ 0
ALE = SLE × ARO (SLE = single loss expectancy in ₹, ARO = annual rate of occurrence per year, ALE in ₹/year)
ROSI = (ALE_before − ALE_after − Cost of control) / Cost of control
Testing effort (person-days) ≈ Σ (assets × days per asset type) + reporting days

Example 1 — CVSS base score for an unauthenticated remote SQL injection with full data access (AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N).

Example 2 — the same flaw, but only reachable after login with a low-privilege account (PR:L → 0.62).

Example 3 — annualised loss and whether the test pays for itself. An e-commerce firm estimates that a successful injection-led data breach costs ₹1.8 crore (regulatory, notification, forensics, churn) and judges it likely once in 4 years.

Example 4 — risk matrix and ranking of four findings. Likelihood and impact on 1-5.

FindingLikelihoodImpactRiskBand
Unauthenticated SQLi on login page5525Critical
Default SNMP community string (internal)4312High
Missing HttpOnly flag on session cookie339Medium
Server version banner disclosure414Low

Example 5 — scan arithmetic and scope sizing. A /24 internal subnet is tested.

Vulnerability assessmentPenetration testRed team exercise
GoalList weaknessesProve exploitability and impactEmulate a real adversary, test detection
Breadth vs depthWide, shallowNarrow, deepObjective-driven
AutomationMostly automatedTool-assisted, manualHeavily manual, custom tooling
DurationHours to days1-3 weeks4-12 weeks
Defender awarenessKnownUsually knownUsually unknown
OutputScan report with CVSSExploitation narrative + remediationAttack path, detection gap, ATT&CK map

Where it is used

Interview questions

Common mistakes

Related topics

Web application security (OWASP Top 10) · Network security: firewalls, VPN and IDS · Security operations: SOC and SIEM · Digital forensics · IT governance, risk and compliance · Information security fundamentals

Open in the Knowledge reader →Find jobs →