From b266fa6b7ea18c46f87152f054dde695cf4e2cdc Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Thu, 11 Aug 2022 15:42:35 -0700 Subject: [PATCH] hashcat: add meson Provides simpler and faster build recipes than the custom ones currently in use. Uses wraps(subprojects) from WrapDB instead of custom dependencies when the host does not provide them. Added a CI to test most platforms. Added wraps in case host system is missing dependencies. Supports cross compilation. Sample Windows cross build definition files added. Signed-off-by: Rosen Penev --- .github/workflows/meson.yml | 167 ++++++++++ BUILD_WSL.md | 5 +- BUILD_macOS.md | 3 - meson.build | 236 ++++++++++++++ meson_options.txt | 14 + mingw32-cross.txt | 16 + mingw64-cross.txt | 16 + modules | 1 + modules/.lock | 0 src/Makefile | 13 +- src/meson.build | 127 ++++++++ src/modules/meson.build | 543 ++++++++++++++++++++++++++++++++ subprojects/.gitignore | 2 + subprojects/minizip-ng.wrap | 13 + subprojects/opencl-headers.wrap | 13 + subprojects/xxhash.wrap | 13 + subprojects/zlib.wrap | 13 + tools/win-iconv-32.diff | 32 -- tools/win-iconv-64.diff | 32 -- ucrt64-cross.txt | 16 + 20 files changed, 1194 insertions(+), 81 deletions(-) create mode 100644 .github/workflows/meson.yml create mode 100644 meson.build create mode 100644 meson_options.txt create mode 100644 mingw32-cross.txt create mode 100644 mingw64-cross.txt create mode 120000 modules delete mode 100644 modules/.lock create mode 100644 src/meson.build create mode 100644 src/modules/meson.build create mode 100644 subprojects/.gitignore create mode 100644 subprojects/minizip-ng.wrap create mode 100644 subprojects/opencl-headers.wrap create mode 100644 subprojects/xxhash.wrap create mode 100644 subprojects/zlib.wrap delete mode 100644 tools/win-iconv-32.diff delete mode 100644 tools/win-iconv-64.diff create mode 100644 ucrt64-cross.txt diff --git a/.github/workflows/meson.yml b/.github/workflows/meson.yml new file mode 100644 index 000000000..128dec5f7 --- /dev/null +++ b/.github/workflows/meson.yml @@ -0,0 +1,167 @@ +name: On PRs - meson + +on: pull_request + +concurrency: + group: ${{github.workflow}}-${{github.head_ref}} + cancel-in-progress: true + +jobs: + Alpine: + runs-on: ubuntu-latest + strategy: + matrix: + platform: ['x86_64', 'x86', 'armhf', 'armv7', 'aarch64', 'ppc64le', 'riscv64'] + defaults: + run: + shell: alpine.sh {0} + steps: + - uses: actions/checkout@v4 + - uses: jirutka/setup-alpine@v1 + with: + branch: edge + arch: ${{matrix.platform}} + packages: > + build-base cmake meson pkgconf linux-headers opencl-dev minizip-dev xxhash-dev zlib-dev + - name: Compile and Test + run: | + meson setup "${{github.workspace}}/build" -Dwarning_level=3 + meson compile -C "${{github.workspace}}/build" --verbose + meson test -C "${{github.workspace}}/build" --verbose + Ubuntu: + runs-on: ubuntu-20.04 + strategy: + matrix: + cc: ['7', '13'] + steps: + - uses: actions/checkout@v4 + - uses: egor-tensin/setup-gcc@v1 + with: + version: ${{matrix.cc}} + - uses: BSFishy/meson-build@v1.0.3 + with: + action: build + directory: build + options: --verbose + meson-version: 0.57.0 + Ubuntu-clang: + runs-on: ubuntu-20.04 + strategy: + matrix: + cc: ['7', '18'] + env: + CC_LD: lld-${{matrix.cc}} + steps: + - uses: actions/checkout@v4 + - uses: egor-tensin/setup-clang@v1 + with: + version: ${{matrix.cc}} + - name: Install packages + run: | + sudo apt install -y lld-${{matrix.cc}} + - uses: BSFishy/meson-build@v1.0.3 + with: + action: build + directory: build + options: --verbose + meson-version: 0.57.0 + Cygwin: + runs-on: windows-latest + defaults: + run: + shell: msys2 {0} + steps: + - uses: actions/checkout@v4 + - uses: msys2/setup-msys2@v2 + with: + msystem: 'MSYS' + install: >- + gcc + libiconv-devel + meson + ninja + - name: Compile and Test + run: | + meson setup build + meson compile -C build --verbose + MSYS2: + runs-on: windows-latest + strategy: + matrix: + platform: ['MINGW64', 'UCRT64', 'CLANG64'] + defaults: + run: + shell: msys2 {0} + steps: + - uses: actions/checkout@v4 + - uses: msys2/setup-msys2@v2 + with: + msystem: ${{matrix.platform}} + pacboy: >- + cc:p + dlfcn:p + meson:p + minizip:p + ninja:p + opencl-headers:p + pkgconf:p + xxhash:p + - name: Compile and Test + run: | + meson setup "${{github.workspace}}/build" + meson compile -C "${{github.workspace}}/build" --verbose + MacOS: + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + - name: Install packages + run: | + python3 -m pip install meson ninja + - name: Compile and Test + run: | + meson setup "${{github.workspace}}/build" + meson compile -C "${{github.workspace}}/build" --verbose + DragonflyBSD: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: vmactions/dragonflybsd-vm@v1 + with: + prepare: | + pkg install -y meson ninja + run: | + meson setup "${{github.workspace}}/build" + meson compile -C "${{github.workspace}}/build" --verbose + FreeBSD: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: vmactions/freebsd-vm@v1 + with: + prepare: | + pkg install -y meson ninja + run: | + meson setup "${{github.workspace}}/build" + meson compile -C "${{github.workspace}}/build" --verbose + NetBSD: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: vmactions/netbsd-vm@v1 + with: + prepare: | + pkg_add meson + run: | + meson setup "${{github.workspace}}/build" + meson compile -C "${{github.workspace}}/build" --verbose + OpenBSD: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: vmactions/openbsd-vm@v1 + with: + prepare: | + pkg_add meson ninja + run: | + meson setup "${{github.workspace}}/build" + meson compile -C "${{github.workspace}}/build" --verbose diff --git a/BUILD_WSL.md b/BUILD_WSL.md index 115c3772b..75acdcb15 100644 --- a/BUILD_WSL.md +++ b/BUILD_WSL.md @@ -12,11 +12,8 @@ Enable WSL. Press the win + r key on your keyboard simultaneously and in the "Run" popup window type bash and make sure to install additional dependencies necessary for hashcat compilation ``` -sudo apt install gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 make git +sudo apt install gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 win-iconv-mingw-w64-dev make git git clone https://github.com/hashcat/hashcat -git clone https://github.com/win-iconv/win-iconv -cd win-iconv/ -patch < ../hashcat/tools/win-iconv-64.diff sudo make install cd ../ ``` diff --git a/BUILD_macOS.md b/BUILD_macOS.md index 67d09a6bf..bf9dd35e7 100644 --- a/BUILD_macOS.md +++ b/BUILD_macOS.md @@ -9,9 +9,6 @@ Make sure to have the HomeBrew upgraded. ``` brew install mingw-w64 git clone https://github.com/hashcat/hashcat -git clone https://github.com/win-iconv/win-iconv -cd win-iconv/ -patch < ../hashcat/tools/win-iconv-64.diff sudo make install cd ../ ``` diff --git a/meson.build b/meson.build new file mode 100644 index 000000000..13f8aa78c --- /dev/null +++ b/meson.build @@ -0,0 +1,236 @@ +project( + 'hashcat', + 'c', + 'cpp', + version: '6.3.1', + default_options: ['c_std=gnu11', 'cpp_std=c++11', 'warning_level=1'], + meson_version: '>=0.49.0', +) + +cc = meson.get_compiler('c') + +if cc.links('#include \nint main(){iconv_open("", "");}') + iconv_dep = dependency('', required: false) +else + iconv_dep = cc.find_library('iconv') +endif + +threads_dep = dependency('threads') + +deps = [ + iconv_dep, + threads_dep, + dependency('OpenCL-Headers'), + dependency('minizip'), + dependency('libxxhash'), + dependency('zlib'), +] + +if host_machine.system() != 'windows' + if meson.version().version_compare('>=0.62') + deps += dependency('dl') + else + deps += cc.find_library('dl') + endif +endif + +if host_machine.system() == 'windows' + deps += cc.find_library('psapi') + deps += cc.find_library('ws2_32') + if meson.is_cross_build() + deps += cc.find_library('ssp') + endif +elif host_machine.system() == 'darwin' + deps += dependency('appleframeworks', modules: ['CoreFoundation', 'Foundation', 'IOKit', 'Metal']) +else + deps += cc.find_library('m') +endif + +lzma = static_library( + 'lzma', + 'deps/LZMA-SDK/C/7zAlloc.c', + 'deps/LZMA-SDK/C/7zArcIn.c', + 'deps/LZMA-SDK/C/7zBuf.c', + 'deps/LZMA-SDK/C/7zBuf2.c', + 'deps/LZMA-SDK/C/7zCrc.c', + 'deps/LZMA-SDK/C/7zCrcOpt.c', + 'deps/LZMA-SDK/C/7zDec.c', + 'deps/LZMA-SDK/C/7zFile.c', + 'deps/LZMA-SDK/C/7zStream.c', + 'deps/LZMA-SDK/C/Aes.c', + 'deps/LZMA-SDK/C/AesOpt.c', + 'deps/LZMA-SDK/C/Alloc.c', + 'deps/LZMA-SDK/C/Bcj2.c', + 'deps/LZMA-SDK/C/Bcj2Enc.c', + 'deps/LZMA-SDK/C/Bra.c', + 'deps/LZMA-SDK/C/Bra86.c', + 'deps/LZMA-SDK/C/BraIA64.c', + 'deps/LZMA-SDK/C/CpuArch.c', + 'deps/LZMA-SDK/C/Delta.c', + 'deps/LZMA-SDK/C/DllSecur.c', + 'deps/LZMA-SDK/C/LzFind.c', + 'deps/LZMA-SDK/C/LzFindMt.c', + 'deps/LZMA-SDK/C/Lzma2Dec.c', + 'deps/LZMA-SDK/C/Lzma2DecMt.c', + 'deps/LZMA-SDK/C/Lzma2Enc.c', + 'deps/LZMA-SDK/C/Lzma86Dec.c', + 'deps/LZMA-SDK/C/Lzma86Enc.c', + 'deps/LZMA-SDK/C/LzmaDec.c', + 'deps/LZMA-SDK/C/LzmaEnc.c', + 'deps/LZMA-SDK/C/LzmaLib.c', + 'deps/LZMA-SDK/C/MtCoder.c', + 'deps/LZMA-SDK/C/MtDec.c', + 'deps/LZMA-SDK/C/Ppmd7.c', + 'deps/LZMA-SDK/C/Ppmd7Dec.c', + 'deps/LZMA-SDK/C/Ppmd7Enc.c', + 'deps/LZMA-SDK/C/Sha256.c', + 'deps/LZMA-SDK/C/Sha256Opt.c', + 'deps/LZMA-SDK/C/Sort.c', + 'deps/LZMA-SDK/C/Threads.c', + 'deps/LZMA-SDK/C/Xz.c', + 'deps/LZMA-SDK/C/XzCrc64.c', + 'deps/LZMA-SDK/C/XzCrc64Opt.c', + 'deps/LZMA-SDK/C/XzDec.c', + 'deps/LZMA-SDK/C/XzEnc.c', + 'deps/LZMA-SDK/C/XzIn.c', + dependencies: threads_dep, +) + +lzma_inc = include_directories('deps/LZMA-SDK/C') +lzma_dep = declare_dependency( + include_directories: lzma_inc, + link_with: lzma, +) + +deps += lzma_dep + +if get_option('unrar') and host_machine.system() != 'cygwin' + unrar = static_library( + 'unrar', + 'deps/unrar/archive.cpp', + 'deps/unrar/arcread.cpp', + 'deps/unrar/blake2s.cpp', + 'deps/unrar/cmddata.cpp', + 'deps/unrar/consio.cpp', + 'deps/unrar/crc.cpp', + 'deps/unrar/crypt.cpp', + 'deps/unrar/encname.cpp', + 'deps/unrar/errhnd.cpp', + 'deps/unrar/extinfo.cpp', + 'deps/unrar/extract.cpp', + 'deps/unrar/filcreat.cpp', + 'deps/unrar/file.cpp', + 'deps/unrar/filefn.cpp', + 'deps/unrar/filestr.cpp', + 'deps/unrar/find.cpp', + 'deps/unrar/getbits.cpp', + 'deps/unrar/global.cpp', + 'deps/unrar/hash.cpp', + 'deps/unrar/hc_decompress_rar.cpp', + 'deps/unrar/headers.cpp', + 'deps/unrar/isnt.cpp', + 'deps/unrar/list.cpp', + 'deps/unrar/match.cpp', + 'deps/unrar/options.cpp', + 'deps/unrar/pathfn.cpp', + 'deps/unrar/qopen.cpp', + 'deps/unrar/rarvm.cpp', + 'deps/unrar/rawread.cpp', + 'deps/unrar/rdwrfn.cpp', + 'deps/unrar/recvol.cpp', + 'deps/unrar/resource.cpp', + 'deps/unrar/rijndael.cpp', + 'deps/unrar/rs.cpp', + 'deps/unrar/rs16.cpp', + 'deps/unrar/scantree.cpp', + 'deps/unrar/secpassword.cpp', + 'deps/unrar/sha1.cpp', + 'deps/unrar/sha256.cpp', + 'deps/unrar/smallfn.cpp', + 'deps/unrar/strfn.cpp', + 'deps/unrar/strlist.cpp', + 'deps/unrar/system.cpp', + 'deps/unrar/threadpool.cpp', + 'deps/unrar/timefn.cpp', + 'deps/unrar/ui.cpp', + 'deps/unrar/unicode.cpp', + 'deps/unrar/unpack.cpp', + 'deps/unrar/volume.cpp', + ) + + unrar_inc = include_directories('deps/unrar') + unrar_dep = declare_dependency( + include_directories: unrar_inc, + link_with: unrar, + ) + + deps += unrar_dep + if host_machine.system() == 'windows' + deps += cc.find_library('powrprof') + deps += cc.find_library('wbemuuid') + endif +else + unrar_dep = dependency('', required: false) +endif + +incdirs = include_directories('include', 'OpenCL') + +subdir('src') +subdir('modules') + +install_data( + 'hashcat.hcstat2', + install_dir: get_option('libdir') / meson.project_name(), +) + +install_subdir( + 'OpenCL', + install_dir: get_option('libdir') / meson.project_name(), +) + +install_subdir( + 'tunings', + install_dir: get_option('libdir') / meson.project_name(), +) + +install_subdir( + 'charsets', + install_dir: get_option('datadir') / 'doc' / meson.project_name(), +) + +install_subdir( + 'docs', + install_dir: get_option('datadir') / 'doc' / meson.project_name(), +) + +install_subdir( + 'layouts', + install_dir: get_option('datadir') / 'doc' / meson.project_name(), +) + +install_subdir( + 'masks', + install_dir: get_option('datadir') / 'doc' / meson.project_name(), +) + +install_subdir( + 'rules', + install_dir: get_option('datadir') / 'doc' / meson.project_name(), +) + +install_data( + 'example0.sh', + 'example400.sh', + 'example500.sh', + 'example.dict', + install_dir: get_option('datadir') / 'doc' / meson.project_name(), +) + +executable( + 'hashcat', + 'src/main.c', + c_args: ['-DCOMPTIME=0', '-DVERSION_TAG="@0@"'.format(meson.project_version())], + dependencies: libhashcat_dep, + pie: true, + install: true, +) diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 000000000..a4890adc6 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,14 @@ +option('brain', type : 'boolean', + value : true, + description : 'Build libhashcat with support for its brain', +) + +option('cubin', type : 'boolean', + value : true, + description : 'Build libhashcat with cubin support', +) + +option('unrar', type : 'boolean', + value : true, + description : 'Build libhashcat with unrar support', +) diff --git a/mingw32-cross.txt b/mingw32-cross.txt new file mode 100644 index 000000000..17fe490fb --- /dev/null +++ b/mingw32-cross.txt @@ -0,0 +1,16 @@ +[binaries] +c = 'i686-w64-mingw32-gcc' +cpp = 'i686-w64-mingw32-g++' +ld = 'i686-w64-mingw32-ld' +ar = 'i686-w64-mingw32-ar' +dlltool = 'i686-w64-mingw32-dlltool' +strip = 'i686-w64-mingw32-strip' +pkgconfig = 'i686-w64-mingw32-pkg-config' +windres = 'i686-w64-mingw32-windres' +exe_wrapper = 'wine' + +[host_machine] +system = 'windows' +cpu_family = 'x86' +cpu = 'x86' +endian = 'little' diff --git a/mingw64-cross.txt b/mingw64-cross.txt new file mode 100644 index 000000000..c28c7ee97 --- /dev/null +++ b/mingw64-cross.txt @@ -0,0 +1,16 @@ +[binaries] +c = 'x86_64-w64-mingw32-gcc' +cpp = 'x86_64-w64-mingw32-g++' +ld = 'x86_64-w64-mingw32-ld' +ar = 'x86_64-w64-mingw32-ar' +dlltool = 'x86_64-w64-mingw32-dlltool' +strip = 'x86_64-w64-mingw32-strip' +pkgconfig = 'x86_64-w64-mingw32-pkg-config' +windres = 'x86_64-w64-mingw32-windres' +exe_wrapper = 'wine64' + +[host_machine] +system = 'windows' +cpu_family = 'x86_64' +cpu = 'x86_64' +endian = 'little' diff --git a/modules b/modules new file mode 120000 index 000000000..b36e7f391 --- /dev/null +++ b/modules @@ -0,0 +1 @@ +src/modules \ No newline at end of file diff --git a/modules/.lock b/modules/.lock deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/Makefile b/src/Makefile index a7eb7b985..12d4dd2b2 100644 --- a/src/Makefile +++ b/src/Makefile @@ -732,13 +732,6 @@ CXX_WIN := x86_64-w64-mingw32-g++ AR_LINUX := ar AR_WIN := x86_64-w64-mingw32-ar -## To compile win-iconv with mingw clone from here: https://github.com/win-iconv/win-iconv -## -## Then patch the makefile with the patches from tools/win-iconv-64.diff and run make install -## - -WIN_ICONV := /opt/win-iconv-64 - ## ## Compiler options ## @@ -748,7 +741,6 @@ CFLAGS_CROSS_LINUX += -fPIC CFLAGS_CROSS_LINUX += -DWITH_HWMON CFLAGS_CROSS_WIN := $(CFLAGS) CFLAGS_CROSS_WIN += -fPIC -CFLAGS_CROSS_WIN += -I$(WIN_ICONV)/include/ CFLAGS_CROSS_WIN += -DWITH_HWMON LFLAGS_CROSS_LINUX := $(LFLAGS) @@ -758,6 +750,7 @@ LFLAGS_CROSS_LINUX += -lm LFLAGS_CROSS_WIN := $(LFLAGS) LFLAGS_CROSS_WIN += -Wl,--dynamicbase LFLAGS_CROSS_WIN += -Wl,--nxcompat +LFLAGS_CROSS_WIN += -liconv LFLAGS_CROSS_WIN += -lpsapi LFLAGS_CROSS_WIN += -lws2_32 LFLAGS_CROSS_WIN += -lpowrprof @@ -874,10 +867,10 @@ obj/combined.WIN.a: $(WIN_OBJS) hashcat.bin: src/main.c obj/combined.LINUX.a $(CC_LINUX) $(CCFLAGS) $(CFLAGS_CROSS_LINUX) -o $@ $^ $(LFLAGS_CROSS_LINUX) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\" -hashcat.exe: src/main.c obj/combined.WIN.a $(WIN_ICONV)/lib/libiconv.a +hashcat.exe: src/main.c obj/combined.WIN.a $(CC_WIN) $(CCFLAGS) $(CFLAGS_CROSS_WIN) -o $@ $^ $(LFLAGS_CROSS_WIN) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -hashcat.dll: src/main.c obj/combined.WIN.a $(WIN_ICONV)/lib/libiconv.a +hashcat.dll: src/main.c obj/combined.WIN.a $(CC_WIN) $(CCFLAGS) $(CFLAGS_CROSS_WIN) -o $@ $^ $(LFLAGS_CROSS_WIN) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -shared endif diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 000000000..e80762fb6 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,127 @@ +libhashcat_srcs = files( + 'affinity.c', + 'autotune.c', + 'backend.c', + 'benchmark.c', + 'bitmap.c', + 'bitops.c', + 'combinator.c', + 'common.c', + 'convert.c', + 'cpt.c', + 'cpu_crc32.c', + 'debugfile.c', + 'dictstat.c', + 'dispatch.c', + 'dynloader.c', + 'emu_general.c', + 'emu_inc_bignum_operations.c', + 'emu_inc_cipher_aes.c', + 'emu_inc_cipher_camellia.c', + 'emu_inc_cipher_des.c', + 'emu_inc_cipher_kuznyechik.c', + 'emu_inc_cipher_serpent.c', + 'emu_inc_cipher_twofish.c', + 'emu_inc_common.c', + 'emu_inc_ecc_secp256k1.c', + 'emu_inc_hash_base58.c', + 'emu_inc_hash_md4.c', + 'emu_inc_hash_md5.c', + 'emu_inc_hash_ripemd160.c', + 'emu_inc_hash_sha1.c', + 'emu_inc_hash_sha224.c', + 'emu_inc_hash_sha256.c', + 'emu_inc_hash_sha384.c', + 'emu_inc_hash_sha512.c', + 'emu_inc_hash_streebog256.c', + 'emu_inc_hash_streebog512.c', + 'emu_inc_hash_whirlpool.c', + 'emu_inc_platform.c', + 'emu_inc_rp.c', + 'emu_inc_rp_optimized.c', + 'emu_inc_scalar.c', + 'emu_inc_simd.c', + 'event.c', + 'ext_ADL.c', + 'ext_OpenCL.c', + 'ext_cuda.c', + 'ext_hip.c', + 'ext_hiprtc.c', + 'ext_iokit.c', + 'ext_lzma.c', + 'ext_nvapi.c', + 'ext_nvml.c', + 'ext_nvrtc.c', + 'ext_sysfs_amdgpu.c', + 'ext_sysfs_cpu.c', + 'filehandling.c', + 'folder.c', + 'hashcat.c', + 'hashes.c', + 'hlfmt.c', + 'hwmon.c', + 'induct.c', + 'interface.c', + 'keyboard_layout.c', + 'locking.c', + 'logfile.c', + 'loopback.c', + 'memory.c', + 'monitor.c', + 'mpsp.c', + 'outfile.c', + 'outfile_check.c', + 'pidfile.c', + 'potfile.c', + 'restore.c', + 'rp.c', + 'rp_cpu.c', + 'selftest.c', + 'shared.c', + 'slow_candidates.c', + 'status.c', + 'stdout.c', + 'straight.c', + 'terminal.c', + 'thread.c', + 'timer.c', + 'tuningdb.c', + 'usage.c', + 'user_options.c', + 'wordlist.c', +) + +if host_machine.system() == 'darwin' + add_languages('objc') + libhashcat_srcs += files('ext_metal.m') +endif + +hashcat_args = [] +if get_option('brain') + hashcat_args += '-DWITH_BRAIN' + libhashcat_srcs += 'brain.c' +endif + +if get_option('cubin') + hashcat_args += '-DWITH_CUBIN' +endif + +if host_machine.system() in ['cygwin', 'darwin', 'linux', 'windows'] + hashcat_args += '-DWITH_HWMON' +endif + +libhashcat = library( + 'hashcat', + libhashcat_srcs, + c_args: hashcat_args, + include_directories: incdirs, + version: meson.project_version(), + dependencies: deps, + install: true, +) + +libhashcat_dep = declare_dependency( + dependencies: deps, + include_directories: incdirs, + link_with: libhashcat, +) diff --git a/src/modules/meson.build b/src/modules/meson.build new file mode 100644 index 000000000..18a4326c2 --- /dev/null +++ b/src/modules/meson.build @@ -0,0 +1,543 @@ +modules = [ + '00000', + '00010', + '00011', + '00012', + '00020', + '00021', + '00022', + '00023', + '00024', + '00030', + '00040', + '00050', + '00060', + '00070', + '00100', + '00101', + '00110', + '00111', + '00112', + '00120', + '00121', + '00122', + '00124', + '00125', + '00130', + '00131', + '00132', + '00133', + '00140', + '00141', + '00150', + '00160', + '00170', + '00200', + '00300', + '00400', + '00500', + '00501', + '00600', + '00610', + '00620', + '00900', + '01000', + '01100', + '01300', + '01400', + '01410', + '01411', + '01420', + '01421', + '01430', + '01440', + '01441', + '01450', + '01460', + '01470', + '01500', + '01600', + '01700', + '01710', + '01711', + '01720', + '01722', + '01730', + '01731', + '01740', + '01750', + '01760', + '01770', + '01800', + '02000', + '02100', + '02400', + '02410', + '02500', + '02501', + '02600', + '02611', + '02612', + '02630', + '02711', + '02811', + '03000', + '03100', + '03200', + '03500', + '03610', + '03710', + '03711', + '03730', + '03800', + '03910', + '04010', + '04110', + '04300', + '04400', + '04410', + '04420', + '04430', + '04500', + '04510', + '04520', + '04521', + '04522', + '04700', + '04710', + '04711', + '04800', + '04900', + '05000', + '05100', + '05200', + '05300', + '05400', + '05500', + '05600', + '05700', + '05800', + '06000', + '06050', + '06060', + '06100', + '06211', + '06212', + '06213', + '06221', + '06222', + '06223', + '06231', + '06232', + '06233', + '06241', + '06242', + '06243', + '06300', + '06400', + '06500', + '06600', + '06700', + '06800', + '06900', + '07000', + '07100', + '07200', + '07300', + '07350', + '07400', + '07401', + '07500', + '07700', + '07701', + '07800', + '07801', + '07900', + '08000', + '08100', + '08200', + '08300', + '08400', + '08500', + '08600', + '08700', + '08800', + '08900', + '09000', + '09100', + '09200', + '09300', + '09400', + '09500', + '09600', + '09700', + '09710', + '09720', + '09800', + '09810', + '09820', + '09900', + '10000', + '10100', + '10200', + '10300', + '10400', + '10410', + '10420', + '10500', + '10600', + '10700', + '10800', + '10810', + '10820', + '10830', + '10840', + '10870', + '10900', + '10901', + '11000', + '11100', + '11200', + '11300', + '11400', + '11500', + '11600', + '11700', + '11750', + '11760', + '11800', + '11850', + '11860', + '11900', + '12000', + '12001', + '12100', + '12200', + '12300', + '12400', + '12500', + '12600', + '12700', + '12800', + '12900', + '13000', + '13100', + '13200', + '13300', + '13400', + '13500', + '13600', + '13711', + '13712', + '13713', + '13721', + '13722', + '13723', + '13731', + '13732', + '13733', + '13741', + '13742', + '13743', + '13751', + '13752', + '13753', + '13761', + '13762', + '13763', + '13771', + '13772', + '13773', + '13781', + '13782', + '13783', + '13800', + '13900', + '14000', + '14100', + '14400', + '14500', + '14600', + '14700', + '14800', + '14900', + '15000', + '15100', + '15200', + '15300', + '15310', + '15400', + '15500', + '15600', + '15700', + '15900', + '15910', + '16000', + '16100', + '16200', + '16300', + '16400', + '16500', + '16600', + '16700', + '16800', + '16801', + '16900', + '17010', + '17020', + '17030', + '17040', + '17200', + '17210', + '17220', + '17225', + '17230', + '17300', + '17400', + '17500', + '17600', + '17700', + '17800', + '17900', + '18000', + '18100', + '18200', + '18300', + '18400', + '18500', + '18600', + '18700', + '18800', + '18900', + '19000', + '19100', + '19200', + '19300', + '19500', + '19600', + '19700', + '19800', + '19900', + '20011', + '20012', + '20013', + '20200', + '20300', + '20400', + '20500', + '20510', + '20600', + '20710', + '20711', + '20712', + '20720', + '20800', + '20900', + '21000', + '21100', + '21200', + '21300', + '21310', + '21400', + '21420', + '21500', + '21501', + '21600', + '21700', + '21800', + '22000', + '22001', + '22100', + '22200', + '22300', + '22301', + '22400', + '22500', + '22600', + '22700', + '22911', + '22921', + '22931', + '22941', + '22951', + '23001', + '23002', + '23003', + '23100', + '23200', + '23300', + '23400', + '23500', + '23600', + '23700', + '23900', + '24100', + '24200', + '24300', + '24410', + '24420', + '24500', + '24600', + '24700', + '24800', + '24900', + '25000', + '25100', + '25200', + '25300', + '25400', + '25500', + '25600', + '25700', + '25800', + '25900', + '26000', + '26100', + '26200', + '26300', + '26401', + '26402', + '26403', + '26500', + '26600', + '26610', + '26700', + '26800', + '26900', + '27000', + '27100', + '27200', + '27300', + '27400', + '27500', + '27600', + '27700', + '27800', + '27900', + '28000', + '28100', + '28200', + '28300', + '28400', + '28501', + '28502', + '28503', + '28504', + '28505', + '28506', + '28600', + '28700', + '28800', + '28900', + '29000', + '29100', + '29200', + '29311', + '29312', + '29313', + '29321', + '29322', + '29323', + '29331', + '29332', + '29333', + '29341', + '29342', + '29343', + '29411', + '29412', + '29413', + '29421', + '29422', + '29423', + '29431', + '29432', + '29433', + '29441', + '29442', + '29443', + '29451', + '29452', + '29453', + '29461', + '29462', + '29463', + '29471', + '29472', + '29473', + '29481', + '29482', + '29483', + '29511', + '29512', + '29513', + '29521', + '29522', + '29523', + '29531', + '29532', + '29533', + '29541', + '29542', + '29543', + '29600', + '29700', + '29800', + '29910', + '29920', + '29930', + '29940', + '30000', + '30120', + '30420', + '30500', + '30600', + '30700', + '30901', + '30902', + '30903', + '30904', + '30905', + '30906', + '31000', + '31100', + '31200', + '31300', + '31400', + '31700', + '31800', + '31900', + '32000', + '32010', + '32020', + '32030', + '32031', + '32040', + '32041', + '32050', + '32060', + '32070', + '32100', + '32200', + '32300', + '32410', + '32420', + '32500', + '99999', +] + +if unrar_dep.found() + modules += '23800' +endif + +foreach m : modules + shared_library( + 'module_@0@'.format(m), + 'module_@0@.c'.format(m), + c_args: '-DMODULE_INTERFACE_VERSION_CURRENT=700', + name_prefix: '', + dependencies: libhashcat_dep, + install: true, + install_dir: get_option('libdir') / 'hashcat' / 'modules', + ) +endforeach diff --git a/subprojects/.gitignore b/subprojects/.gitignore new file mode 100644 index 000000000..faa2502ea --- /dev/null +++ b/subprojects/.gitignore @@ -0,0 +1,2 @@ +/*/ +!packagefiles/ diff --git a/subprojects/minizip-ng.wrap b/subprojects/minizip-ng.wrap new file mode 100644 index 000000000..35c574bda --- /dev/null +++ b/subprojects/minizip-ng.wrap @@ -0,0 +1,13 @@ +[wrap-file] +directory = minizip-ng-4.0.4 +source_url = https://github.com/zlib-ng/minizip-ng/archive/refs/tags/4.0.4.tar.gz +source_filename = 4.0.4.tar.gz +source_hash = 955800fe39f9d830fcb84e60746952f6a48e41093ec7a233c63ad611b5fcfe9f +patch_filename = minizip-ng_4.0.4-1_patch.zip +patch_url = https://wrapdb.mesonbuild.com/v2/minizip-ng_4.0.4-1/get_patch +patch_hash = ea85589c3b658728c97690cd7acaf05c8391ec1b99b63f234b9468e4a308c498 +source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/minizip-ng_4.0.4-1/4.0.4.tar.gz +wrapdb_version = 4.0.4-1 + +[provide] +minizip = minizip_ng_dep diff --git a/subprojects/opencl-headers.wrap b/subprojects/opencl-headers.wrap new file mode 100644 index 000000000..15a8e309b --- /dev/null +++ b/subprojects/opencl-headers.wrap @@ -0,0 +1,13 @@ +[wrap-file] +directory = OpenCL-Headers-2023.04.17 +source_url = https://github.com/KhronosGroup/OpenCL-Headers/archive/refs/tags/v2023.04.17.tar.gz +source_filename = OpenCL-Headers-2023.04.17.tar.gz +source_hash = 0ce992f4167f958f68a37918dec6325be18f848dee29a4521c633aae3304915d +patch_filename = opencl-headers_2023.04.17-1_patch.zip +patch_url = https://wrapdb.mesonbuild.com/v2/opencl-headers_2023.04.17-1/get_patch +patch_hash = 7f948e8da8d5c654f05e7d9e8832669645d69e712fed836541f029e4f65712c6 +source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/opencl-headers_2023.04.17-1/OpenCL-Headers-2023.04.17.tar.gz +wrapdb_version = 2023.04.17-1 + +[provide] +OpenCL-Headers = opencl_headers_dep diff --git a/subprojects/xxhash.wrap b/subprojects/xxhash.wrap new file mode 100644 index 000000000..e4d612565 --- /dev/null +++ b/subprojects/xxhash.wrap @@ -0,0 +1,13 @@ +[wrap-file] +directory = xxHash-0.8.2 +source_url = https://github.com/Cyan4973/xxHash/archive/v0.8.2.tar.gz +source_filename = xxHash-0.8.2.tar.gz +source_hash = baee0c6afd4f03165de7a4e67988d16f0f2b257b51d0e3cb91909302a26a79c4 +patch_filename = xxhash_0.8.2-1_patch.zip +patch_url = https://wrapdb.mesonbuild.com/v2/xxhash_0.8.2-1/get_patch +patch_hash = e721ef7a4c4ee0ade8b8440f6f7cb9f935b68e825249d74cb1c2503c53e68d25 +source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/xxhash_0.8.2-1/xxHash-0.8.2.tar.gz +wrapdb_version = 0.8.2-1 + +[provide] +libxxhash = xxhash_dep diff --git a/subprojects/zlib.wrap b/subprojects/zlib.wrap new file mode 100644 index 000000000..aa14de177 --- /dev/null +++ b/subprojects/zlib.wrap @@ -0,0 +1,13 @@ +[wrap-file] +directory = zlib-1.3.1 +source_url = http://zlib.net/fossils/zlib-1.3.1.tar.gz +source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/zlib_1.3.1-1/zlib-1.3.1.tar.gz +source_filename = zlib-1.3.1.tar.gz +source_hash = 9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23 +patch_filename = zlib_1.3.1-1_patch.zip +patch_url = https://wrapdb.mesonbuild.com/v2/zlib_1.3.1-1/get_patch +patch_hash = e79b98eb24a75392009cec6f99ca5cdca9881ff20bfa174e8b8926d5c7a47095 +wrapdb_version = 1.3.1-1 + +[provide] +zlib = zlib_dep diff --git a/tools/win-iconv-32.diff b/tools/win-iconv-32.diff deleted file mode 100644 index 7dc17e3a6..000000000 --- a/tools/win-iconv-32.diff +++ /dev/null @@ -1,32 +0,0 @@ -diff --git a/Makefile b/Makefile -index 5937584..8777fad 100644 ---- a/Makefile -+++ b/Makefile -@@ -6,10 +6,10 @@ - # MKDIR_P, INSTALL, RM - # prefix, BINARY_PATH, INCLUDE_PATH, LIBRARY_PATH - --CC ?= gcc --AR ?= ar --RANLIB ?= ranlib --DLLTOOL ?= dlltool -+CC := i686-w64-mingw32-gcc -+AR := i686-w64-mingw32-ar -+RANLIB := i686-w64-mingw32-ranlib -+DLLTOOL := i686-w64-mingw32-dlltool - - MKDIR_P = mkdir -p - INSTALL = install -c -@@ -19,10 +19,10 @@ RM = rm -f - DEFAULT_LIBICONV_DLL ?= \"\" - - CFLAGS += -pedantic -Wall --CFLAGS += -DUSE_LIBICONV_DLL -+#CFLAGS += -DUSE_LIBICONV_DLL - CFLAGS += -DDEFAULT_LIBICONV_DLL=$(DEFAULT_LIBICONV_DLL) - --prefix ?= /usr/local -+prefix ?= /opt/win-iconv-32 - BINARY_PATH = $(prefix)/bin - INCLUDE_PATH = $(prefix)/include - LIBRARY_PATH = $(prefix)/lib diff --git a/tools/win-iconv-64.diff b/tools/win-iconv-64.diff deleted file mode 100644 index 2c658d8c1..000000000 --- a/tools/win-iconv-64.diff +++ /dev/null @@ -1,32 +0,0 @@ -diff --git a/Makefile b/Makefile -index 5937584..c4742a3 100644 ---- a/Makefile -+++ b/Makefile -@@ -6,10 +6,10 @@ - # MKDIR_P, INSTALL, RM - # prefix, BINARY_PATH, INCLUDE_PATH, LIBRARY_PATH - --CC ?= gcc --AR ?= ar --RANLIB ?= ranlib --DLLTOOL ?= dlltool -+CC := x86_64-w64-mingw32-gcc -+AR := x86_64-w64-mingw32-ar -+RANLIB := x86_64-w64-mingw32-ranlib -+DLLTOOL := x86_64-w64-mingw32-dlltool - - MKDIR_P = mkdir -p - INSTALL = install -c -@@ -19,10 +19,10 @@ RM = rm -f - DEFAULT_LIBICONV_DLL ?= \"\" - - CFLAGS += -pedantic -Wall --CFLAGS += -DUSE_LIBICONV_DLL -+#CFLAGS += -DUSE_LIBICONV_DLL - CFLAGS += -DDEFAULT_LIBICONV_DLL=$(DEFAULT_LIBICONV_DLL) - --prefix ?= /usr/local -+prefix ?= /opt/win-iconv-64 - BINARY_PATH = $(prefix)/bin - INCLUDE_PATH = $(prefix)/include - LIBRARY_PATH = $(prefix)/lib diff --git a/ucrt64-cross.txt b/ucrt64-cross.txt new file mode 100644 index 000000000..d2061b5b1 --- /dev/null +++ b/ucrt64-cross.txt @@ -0,0 +1,16 @@ +[binaries] +c = 'x86_64-w64-mingw32ucrt-gcc' +cpp = 'x86_64-w64-mingw32ucrt-g++' +ld = 'x86_64-w64-mingw32ucrt-ld' +ar = 'x86_64-w64-mingw32ucrt-ar' +dlltool = 'x86_64-w64-mingw32ucrt-dlltool' +strip = 'x86_64-w64-mingw32ucrt-strip' +pkgconfig = 'x86_64-w64-mingw32ucrt-pkg-config' +windres = 'x86_64-w64-mingw32ucrt-windres' +exe_wrapper = 'wine64' + +[host_machine] +system = 'windows' +cpu_family = 'x86_64' +cpu = 'x86_64' +endian = 'little'