mirror of
https://github.com/hashcat/hashcat.git
synced 2025-07-01 20:32:38 +00:00
Add build Dockerfiles for binary compilation.
Compiles both Linux and Windows binaries. Used to produce official releases for hashcat.net. Includes Dockerfiles for Ubuntu 20.04 or Arch-based environments. Supports optional user custom patches via docker/patches/.
This commit is contained in:
parent
e811e8e1ae
commit
b28fa54dc6
4
BUILD.md
4
BUILD.md
@ -61,6 +61,10 @@ Otherwise:
|
|||||||
- Cached kernels go to: $HOME/.cache/hashcat
|
- Cached kernels go to: $HOME/.cache/hashcat
|
||||||
- Potfiles go to: $HOME/.local/share/hashcat/
|
- Potfiles go to: $HOME/.local/share/hashcat/
|
||||||
|
|
||||||
|
### Building hashcat binaries using Docker ###
|
||||||
|
|
||||||
|
Refer to [BUILD_Docker.md](BUILD_Docker.md)
|
||||||
|
|
||||||
### Building hashcat for Windows (using macOS) ###
|
### Building hashcat for Windows (using macOS) ###
|
||||||
|
|
||||||
Refer to [BUILD_macOS.md](BUILD_macOS.md)
|
Refer to [BUILD_macOS.md](BUILD_macOS.md)
|
||||||
|
40
BUILD_Docker.md
Normal file
40
BUILD_Docker.md
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
# Compiling hashcat binaries with Docker
|
||||||
|
|
||||||
|
To build both Linux and Windows binaries in a clean and reproducible environment a dockerfile is available.
|
||||||
|
It is not considered to be used as a runtime OS.
|
||||||
|
|
||||||
|
### Building ###
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker build -f docker/BinaryPackage.ubuntu20 -t hashcat-binaries .
|
||||||
|
```
|
||||||
|
|
||||||
|
This will create a Docker image with all required toolchains and dependencies.
|
||||||
|
|
||||||
|
Optionally you can place custom *.patch or *.diff files into `patches/` folder. They will be applied before compiling.
|
||||||
|
|
||||||
|
### Output ###
|
||||||
|
|
||||||
|
The resulting output package will be located in: `/root/xy/hashcat-<version>.7z`.
|
||||||
|
|
||||||
|
You can copy it to your host with this command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run --rm \
|
||||||
|
-e HOST_UID=$(id -u) \
|
||||||
|
-e HOST_GID=$(id -g) \
|
||||||
|
-v $(pwd):/out \
|
||||||
|
hashcat-binaries \
|
||||||
|
bash -c "cp /root/xy/hashcat-*.7z /out && chown \$HOST_UID:\$HOST_GID /out/hashcat-*.7z"
|
||||||
|
```
|
||||||
|
|
||||||
|
The package will be available on your host machine in the `out` directory.
|
||||||
|
|
||||||
|
### Debug ###
|
||||||
|
|
||||||
|
In case you want to play around in the docker, run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run --rm -it hashcat-binaries /bin/bash
|
||||||
|
```
|
||||||
|
|
66
docker/BinaryPackage.arch
Normal file
66
docker/BinaryPackage.arch
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
FROM archlinux:latest
|
||||||
|
|
||||||
|
# Set environment
|
||||||
|
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \
|
||||||
|
locale-gen && \
|
||||||
|
echo "LANG=en_US.UTF-8" > /etc/locale.conf && \
|
||||||
|
ln -sf /usr/share/zoneinfo/UTC /etc/localtime
|
||||||
|
ENV LANG=en_US.UTF-8
|
||||||
|
ENV LC_ALL=en_US.UTF-8
|
||||||
|
|
||||||
|
# Install all necessary packages
|
||||||
|
RUN pacman -Sy --noconfirm \
|
||||||
|
base-devel \
|
||||||
|
git \
|
||||||
|
cmake \
|
||||||
|
unzip \
|
||||||
|
wget \
|
||||||
|
zstd \
|
||||||
|
python \
|
||||||
|
mingw-w64-gcc \
|
||||||
|
mingw-w64-crt \
|
||||||
|
mingw-w64-headers \
|
||||||
|
mingw-w64-binutils \
|
||||||
|
mingw-w64-winpthreads \
|
||||||
|
p7zip \
|
||||||
|
dos2unix \
|
||||||
|
&& pacman -Scc --noconfirm
|
||||||
|
|
||||||
|
# Set source working directory
|
||||||
|
WORKDIR /root
|
||||||
|
|
||||||
|
# Clone hashcat and win-iconv repositories
|
||||||
|
RUN git clone https://github.com/win-iconv/win-iconv.git
|
||||||
|
|
||||||
|
# Build win-iconv for Windows target
|
||||||
|
WORKDIR /root/win-iconv
|
||||||
|
RUN cmake \
|
||||||
|
-D WIN_ICONV_BUILD_EXECUTABLE=OFF \
|
||||||
|
-D CMAKE_INSTALL_PREFIX=/opt/win-iconv-64 \
|
||||||
|
-D CMAKE_C_COMPILER=$(which x86_64-w64-mingw32-gcc) \
|
||||||
|
-D CMAKE_CXX_COMPILER=$(which x86_64-w64-mingw32-g++) \
|
||||||
|
. && \
|
||||||
|
make -j$(nproc) && make install
|
||||||
|
|
||||||
|
# Download and extract MSYS2 Python headers (still 3.12)
|
||||||
|
RUN mkdir /opt/cpython-mingw
|
||||||
|
WORKDIR /opt/cpython-mingw
|
||||||
|
RUN wget https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-python-3.12.10-1-any.pkg.tar.zst && \
|
||||||
|
zstd -d mingw-w64-x86_64-python-3.12.10-1-any.pkg.tar.zst && \
|
||||||
|
tar -xf mingw-w64-x86_64-python-3.12.10-1-any.pkg.tar
|
||||||
|
|
||||||
|
## Custom patches
|
||||||
|
WORKDIR /root
|
||||||
|
COPY docker/patches/ /root/patches/
|
||||||
|
|
||||||
|
## hashcat
|
||||||
|
WORKDIR /root
|
||||||
|
RUN git clone https://github.com/hashcat/hashcat.git
|
||||||
|
|
||||||
|
## Compile
|
||||||
|
WORKDIR /root/hashcat
|
||||||
|
RUN bash -c 'shopt -s nullglob; for p in /root/patches/*.patch /root/patches/*.diff; do pwd && git apply "$p"; done'
|
||||||
|
RUN make -s binaries
|
||||||
|
RUN tools/package_bin.sh
|
||||||
|
|
||||||
|
CMD ["/bin/bash"]
|
104
docker/BinaryPackage.ubuntu20
Normal file
104
docker/BinaryPackage.ubuntu20
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
FROM ubuntu:20.04
|
||||||
|
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
|
## Change to bash
|
||||||
|
|
||||||
|
RUN echo "dash dash/sh boolean false" | debconf-set-selections && dpkg-reconfigure dash
|
||||||
|
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y --no-install-recommends \
|
||||||
|
ca-certificates \
|
||||||
|
build-essential \
|
||||||
|
git \
|
||||||
|
wget \
|
||||||
|
pkg-config \
|
||||||
|
make \
|
||||||
|
gcc-mingw-w64-x86-64 \
|
||||||
|
g++-mingw-w64-x86-64 \
|
||||||
|
dos2unix \
|
||||||
|
libssl-dev \
|
||||||
|
zlib1g-dev \
|
||||||
|
libncurses5-dev \
|
||||||
|
libncursesw5-dev \
|
||||||
|
libreadline-dev \
|
||||||
|
libsqlite3-dev \
|
||||||
|
libgdbm-dev \
|
||||||
|
libdb5.3-dev \
|
||||||
|
libbz2-dev \
|
||||||
|
libexpat1-dev \
|
||||||
|
liblzma-dev tk-dev \
|
||||||
|
unzip \
|
||||||
|
zstd \
|
||||||
|
tar
|
||||||
|
|
||||||
|
WORKDIR /root
|
||||||
|
|
||||||
|
## Ubuntu 20.04 cmake version is incompatible to recent win-iconv so we use our own
|
||||||
|
RUN wget https://github.com/Kitware/CMake/releases/download/v3.25.3/cmake-3.25.3-linux-x86_64.sh && \
|
||||||
|
chmod +x cmake-3.25.3-linux-x86_64.sh && \
|
||||||
|
./cmake-3.25.3-linux-x86_64.sh --skip-license --prefix=/usr/local
|
||||||
|
|
||||||
|
## Also 7z on ubuntu 20.04 is very outdated
|
||||||
|
WORKDIR /root
|
||||||
|
RUN git clone --branch 24.09 https://github.com/ip7z/7zip.git
|
||||||
|
WORKDIR /root/7zip/CPP/7zip/Bundles/Alone2
|
||||||
|
RUN make -f makefile.gcc -j
|
||||||
|
RUN cp /root/7zip/CPP/7zip/Bundles/Alone2/_o/7zz /usr/local/bin/7z
|
||||||
|
|
||||||
|
## Iconv for windows
|
||||||
|
WORKDIR /root
|
||||||
|
RUN git clone --branch v0.0.10 https://github.com/win-iconv/win-iconv.git
|
||||||
|
|
||||||
|
WORKDIR /root/win-iconv
|
||||||
|
RUN cmake \
|
||||||
|
-D WIN_ICONV_BUILD_EXECUTABLE=OFF \
|
||||||
|
-D CMAKE_INSTALL_PREFIX=/opt/win-iconv-64 \
|
||||||
|
-D CMAKE_C_COMPILER=$(which x86_64-w64-mingw32-gcc) \
|
||||||
|
-D CMAKE_CXX_COMPILER=$(which x86_64-w64-mingw32-g++) \
|
||||||
|
. && \
|
||||||
|
make install
|
||||||
|
|
||||||
|
## Ubuntu 20.04 python version 3.10 is too old, it lacks support for non-GIL mode
|
||||||
|
|
||||||
|
WORKDIR /root
|
||||||
|
|
||||||
|
ENV PYTHON_VERSION=3.13.3
|
||||||
|
|
||||||
|
RUN wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz && \
|
||||||
|
tar xzf Python-${PYTHON_VERSION}.tgz
|
||||||
|
|
||||||
|
WORKDIR /root/Python-${PYTHON_VERSION}
|
||||||
|
|
||||||
|
RUN ./configure --prefix=/opt/linux-python && \
|
||||||
|
make -j && make install
|
||||||
|
|
||||||
|
ENV PATH="/opt/linux-python/bin:$PATH"
|
||||||
|
|
||||||
|
## For Windows we also need python
|
||||||
|
|
||||||
|
WORKDIR /root
|
||||||
|
|
||||||
|
RUN mkdir /opt/cpython-mingw
|
||||||
|
WORKDIR /opt/cpython-mingw
|
||||||
|
RUN wget https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-python-3.12.10-1-any.pkg.tar.zst
|
||||||
|
RUN unzstd mingw-w64-x86_64-python-3.12.10-1-any.pkg.tar.zst
|
||||||
|
RUN tar -xf mingw-w64-x86_64-python-3.12.10-1-any.pkg.tar
|
||||||
|
|
||||||
|
## Custom patches
|
||||||
|
|
||||||
|
WORKDIR /root
|
||||||
|
|
||||||
|
COPY docker/patches/ /root/patches/
|
||||||
|
|
||||||
|
RUN git clone https://github.com/hashcat/hashcat.git
|
||||||
|
|
||||||
|
WORKDIR /root/hashcat
|
||||||
|
|
||||||
|
RUN bash -c 'shopt -s nullglob; for p in /root/patches/*.patch /root/patches/*.diff; do pwd && git apply "$p"; done'
|
||||||
|
|
||||||
|
RUN make -s binaries
|
||||||
|
|
||||||
|
RUN tools/package_bin.sh
|
||||||
|
|
||||||
|
RUN ["/bin/bash"]
|
0
docker/patches/.gitkeep
Normal file
0
docker/patches/.gitkeep
Normal file
Loading…
Reference in New Issue
Block a user