Demo for Hydra and Hashcat
- Setup
postgresandsshservice for Hydra.
To run this project, you will need to add the following environment variables to
your .env file:
-
DB configs:
POSTGRES_USER: Postgres user.POSTGRES_PASSWORD: Postgres password.
E.g:
# .env
POSTGRES_USER=postgres
POSTGRES_PASSWORD=***
You can also check out the file .env.example to see all required environment
variables.
-
Docker installed locally:
#!/usr/bin/env bash # Uninstall old versions sudo apt-get remove docker docker-engine docker.io containerd runc # Set up the repository # Update the apt package index and install packages to allow apt to use a # repository over HTTPS sudo apt-get update sudo apt-get install \ ca-certificates \ curl \ gnupg \ lsb-release # Add Docker’s official GPG key sudo mkdir -m 0755 -p /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg # Use the following command to set up the repository echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null # Install Docker Engine # Update the apt package index sudo apt-get update # Install Docker Engine, containerd, and Docker Compose. sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin # Post installation steps # Add your user to the docker group sudo usermod -aG docker $USER
-
nvidiadrivers: Required for thehashcatcontainer.sudo ubuntu-drivers autoinstall
-
cuda toolkitdriver: Required for thehashcatcontainer.wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-ubuntu2204.pin sudo mv cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600 wget https://developer.download.nvidia.com/compute/cuda/12.1.0/local_installers/cuda-repo-ubuntu2204-12-1-local_12.1.0-530.30.02-1_amd64.deb sudo dpkg -i cuda-repo-ubuntu2204-12-1-local_12.1.0-530.30.02-1_amd64.deb sudo cp /var/cuda-repo-ubuntu2204-12-1-local/cuda-*-keyring.gpg /usr/share/keyrings/ sudo apt-get update sudo apt-get -y install cudaYou should see the output when running
nvidia-smi:Thu Mar 23 00:08:35 2023 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 525.89.02 Driver Version: 525.89.02 CUDA Version: 12.0 | |-------------------------------+----------------------+----------------------+ | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | | | | MIG M. | |===============================+======================+======================| | 0 NVIDIA GeForce ... Off | 00000000:01:00.0 On | N/A | | 39% 37C P8 2W / 46W | 395MiB / 4096MiB | 0% Default | | | | N/A | +-------------------------------+----------------------+----------------------+ +-----------------------------------------------------------------------------+ | Processes: | | GPU GI CI PID Type Process name GPU Memory | | ID ID Usage | |=============================================================================| | 0 N/A N/A 1104 G /usr/lib/xorg/Xorg 133MiB | | 0 N/A N/A 1423 G /usr/bin/gnome-shell 83MiB | | 0 N/A N/A 3237 G ...755303089409397513,131072 83MiB | | 0 N/A N/A 3811 G /usr/bin/wezterm-gui 2MiB | | 0 N/A N/A 4245 G ...RendererForSitePerProcess 83MiB | +-----------------------------------------------------------------------------+
-
nvidia-container-toolkit: Required for thehashcatcontainer to access the GPU hardware. If you install thehashcattool to your host machine, you can skip this step.distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \ && curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \ && curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | \ sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \ sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list sudo apt-get update sudo apt-get install -y nvidia-container-toolkit
Note: For Ubuntu 22.10, just replace
$(. /etc/os-release;echo $ID$VERSION_ID)withubuntu22.04, which is the latest supported version.Restart the docker daemon:
sudo systemctl restart docker
At this point, a working setup can be tested by running a base CUDA container:
sudo docker run --rm --runtime=nvidia --gpus all nvidia/cuda:11.6.2-base-ubuntu20.04 nvidia-smi
This should result in a console output shown below:
+-----------------------------------------------------------------------------+ | NVIDIA-SMI 450.51.06 Driver Version: 450.51.06 CUDA Version: 11.0 | |-------------------------------+----------------------+----------------------+ | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | | | | MIG M. | |===============================+======================+======================| | 0 Tesla T4 On | 00000000:00:1E.0 Off | 0 | | N/A 34C P8 9W / 70W | 0MiB / 15109MiB | 0% Default | | | | N/A | +-------------------------------+----------------------+----------------------+ +-----------------------------------------------------------------------------+ | Processes: | | GPU GI CI PID Type Process name GPU Memory | | ID ID Usage | |=============================================================================| | No running processes found | +-----------------------------------------------------------------------------+
Clone the project:
git clone https://github.com/DuckyMomo20012/pw-crack-demo.gitGo to the project directory:
cd pw-crack-demRun the project using docker-compose:
docker compose up -dFinally, you can stop the project by running:
docker compose down -vThe config files for hydra container is mounted from configs/hydra/ to
/var/configs/ directory:
-
pg: The config files to crack sample PostgreSQL database.-
pwlist.txt: Thelogin:passwordlist to crack the database. The default postgres password is defined in.envfile, usingPOSTGRES_PASSWORDvariable. -
servers.txt: The server list to crack the database. The default server is with the hostpostgres(which is the container name) and port5432.Note: Since the
hydraandpostgrescontainers are in the same network, so they can communicate with each other using the container name for simplicity, instead of using the IP address. -
run.sh: The script to runhydrato crack the database.
-
The container is also configured to use the ssh service, so you can test to
crack the password of your local machine.
We haven't setup any config files for hashcat container yet. You can use
examples provided by hashcat to test the container, which in the hashcat
directory.
- Setup
hashcatcontainer to crack WPA/WPA2 password.
Contributions are always welcome!
Please read the Code of Conduct.
-
How can I setup more services for
hydrato crack?- You can install the required library for the service you want to crack in
the
docker/hydra/Dockerfilefile and rebuild the image.
- You can install the required library for the service you want to crack in
the
Distributed under MIT license. See LICENSE for more information.
Duong Vinh - @duckymomo20012 - tienvinh.duong4@gmail.com
Project Link: https://github.com/DuckyMomo20012/pw-crack-demo.
Here are useful resources and libraries that we have used in our projects:
- Awesome Readme Template: A detailed template to bootstrap your README file quickly.