mirror of
https://github.com/trustedsec/hate_crack.git
synced 2026-06-30 10:07:04 -07:00
Expand Docker E2E tests with hashcat crack
This commit is contained in:
@@ -2,6 +2,18 @@ FROM python:3.13-slim
|
||||
|
||||
WORKDIR /workspace
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
ca-certificates \
|
||||
curl \
|
||||
gzip \
|
||||
hashcat \
|
||||
ocl-icd-libopencl1 \
|
||||
pocl-opencl-icd \
|
||||
p7zip-full \
|
||||
transmission-cli \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN python -m pip install -q uv
|
||||
|
||||
COPY . /workspace
|
||||
|
||||
@@ -16,6 +16,12 @@ cd hashcat/
|
||||
make
|
||||
make install
|
||||
```
|
||||
|
||||
### External Dependencies
|
||||
These are required for certain download/extraction flows:
|
||||
|
||||
- `7z`/`7za` (p7zip) — used to extract `.7z` archives.
|
||||
- `transmission-cli` — used to download Weakpass torrents.
|
||||
### Download hate_crack
|
||||
```git clone --recurse-submodules https://github.com/trustedsec/hate_crack.git```
|
||||
* Customize binary and wordlist paths in "config.json"
|
||||
|
||||
@@ -6,14 +6,16 @@ from pathlib import Path
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
os.environ.get("HATE_CRACK_RUN_DOCKER_TESTS") != "1",
|
||||
reason="Set HATE_CRACK_RUN_DOCKER_TESTS=1 to run Docker-based tests.",
|
||||
)
|
||||
def test_docker_script_install_and_run():
|
||||
def _require_docker():
|
||||
if os.environ.get("HATE_CRACK_RUN_DOCKER_TESTS") != "1":
|
||||
pytest.skip("Set HATE_CRACK_RUN_DOCKER_TESTS=1 to run Docker-based tests.")
|
||||
if shutil.which("docker") is None:
|
||||
pytest.skip("docker not available")
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def docker_image():
|
||||
_require_docker()
|
||||
repo_root = Path(__file__).resolve().parents[1]
|
||||
image_tag = "hate-crack-e2e"
|
||||
|
||||
@@ -31,18 +33,46 @@ def test_docker_script_install_and_run():
|
||||
"Docker build failed. "
|
||||
f"stdout={build.stdout} stderr={build.stderr}"
|
||||
)
|
||||
return image_tag
|
||||
|
||||
|
||||
def _run_container(image_tag, command, timeout=180):
|
||||
try:
|
||||
run = subprocess.run(
|
||||
["docker", "run", "--rm", image_tag],
|
||||
["docker", "run", "--rm", image_tag, "bash", "-lc", command],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=120,
|
||||
timeout=timeout,
|
||||
)
|
||||
except subprocess.TimeoutExpired as exc:
|
||||
pytest.fail(f"Docker run timed out after {exc.timeout}s")
|
||||
return run
|
||||
|
||||
|
||||
def test_docker_script_install_and_run(docker_image):
|
||||
run = _run_container(
|
||||
docker_image,
|
||||
"/root/.local/bin/hate_crack --help >/tmp/hc_help.txt && ./hate_crack.py --help >/tmp/hc_script_help.txt",
|
||||
timeout=120,
|
||||
)
|
||||
assert run.returncode == 0, (
|
||||
"Docker script install/run failed. "
|
||||
f"stdout={run.stdout} stderr={run.stderr}"
|
||||
)
|
||||
|
||||
|
||||
def test_docker_hashcat_cracks_simple_password(docker_image):
|
||||
command = (
|
||||
"set -euo pipefail; "
|
||||
"curl -fsSL -o /tmp/rockyou.txt.gz https://weakpass.com/download/90/rockyou.txt.gz; "
|
||||
"gzip -d /tmp/rockyou.txt.gz; "
|
||||
"head -n 5000 /tmp/rockyou.txt > /tmp/rockyou.small.txt; "
|
||||
"echo 5f4dcc3b5aa765d61d8327deb882cf99 > /tmp/hash.txt; "
|
||||
"hashcat -m 0 -a 0 --potfile-disable -o /tmp/out.txt /tmp/hash.txt /tmp/rockyou.small.txt --quiet; "
|
||||
"grep -q ':password' /tmp/out.txt"
|
||||
)
|
||||
run = _run_container(docker_image, command, timeout=180)
|
||||
assert run.returncode == 0, (
|
||||
"Docker hashcat crack failed. "
|
||||
f"stdout={run.stdout} stderr={run.stderr}"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user