1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-12-22 14:48:12 +00:00

Prepare reordering or files to help integration into linux distributions as discussed in https://github.com/hashcat/oclHashcat/issues/20

TODOS:
- Let oclHashcat actually use the new paths
- Find a better way for native compilation
- Replace /bin/cp with /usr/bin/install where it has to copy files recursive
This commit is contained in:
Jens Steube 2015-12-13 12:21:36 +01:00
parent 79166ee291
commit 1537390fae
6 changed files with 109 additions and 6 deletions

View File

@ -33,6 +33,7 @@
#include <pthread.h>
#include <semaphore.h>
#include <dlfcn.h>
#include <pwd.h>
#ifdef LINUX
#include <termio.h>

View File

@ -1936,6 +1936,8 @@ void dump_hex (const char *s, size_t size);
void truecrypt_crc32 (char *file, unsigned char keytab[64]);
char *get_install_dir (const char *progname);
char *get_profile_dir (const char *homedir);
char *get_session_dir (const char *profile_dir, const char *session);
uint get_vliw_by_compute_capability (const uint major, const uint minor);
uint get_vliw_by_device_name (const char *device_name);

View File

@ -1134,7 +1134,10 @@ typedef struct
char *session;
char separator;
char *hashfile;
char *homedir;
char *install_dir;
char *profile_dir;
char *session_dir;
char *outfile;
uint outfile_format;
uint outfile_autohex;

View File

@ -21,7 +21,19 @@ MAKEFLAGS += -j 1
endif
##
## Library Paths
## Installation paths (Linux only)
##
INSTALL_FOLDER ?= /opt/test/usr/bin
SHARED_FOLDER ?= /opt/test/usr/share/oclHashcat
DOCUMENT_FOLDER ?= /opt/test/usr/share/doc/oclHashcat
#INSTALL_FOLDER ?= /usr/bin
#SHARED_FOLDER ?= /usr/share/oclHashcat
#DOCUMENT_FOLDER ?= /usr/share/doc/oclHashcat
##
## Library paths
##
OCL := deps/amd-app-sdk
@ -62,6 +74,9 @@ CLCOMPILE := $(CLCOMPILE_PATH)/clcompile.bin
BIN := .
INSTALL := install
CP := cp
##
## Misc stuff
##
@ -175,6 +190,35 @@ nv_all: $(foreach KERNEL,$(KERNELS_MODE_ALL),$(foreach DEVICE,$(NV_DEVIC
$(foreach DEVICE,$(NV_DEVICES_ALL),$(foreach BITNESS,$(NV_BITNESS_ALL),$(NV_OUT)/amp_a1_v1.$(DEVICE).$(BITNESS).cubin)) $(foreach DEVICE,$(NV_DEVICES_ALL),$(foreach BITNESS,$(NV_BITNESS_ALL),$(NV_OUT)/amp_a1_v2.$(DEVICE).$(BITNESS).cubin)) $(foreach DEVICE,$(NV_DEVICES_ALL),$(foreach BITNESS,$(NV_BITNESS_ALL),$(NV_OUT)/amp_a1_v4.$(DEVICE).$(BITNESS).cubin)) \
$(foreach DEVICE,$(NV_DEVICES_ALL),$(foreach BITNESS,$(NV_BITNESS_ALL),$(NV_OUT)/amp_a3_v1.$(DEVICE).$(BITNESS).cubin)) $(foreach DEVICE,$(NV_DEVICES_ALL),$(foreach BITNESS,$(NV_BITNESS_ALL),$(NV_OUT)/amp_a3_v2.$(DEVICE).$(BITNESS).cubin)) $(foreach DEVICE,$(NV_DEVICES_ALL),$(foreach BITNESS,$(NV_BITNESS_ALL),$(NV_OUT)/amp_a3_v4.$(DEVICE).$(BITNESS).cubin))
##
## Targets: Linux install
## We need some better native compilation logic here, fixing it to 64 bit for now and AMD kernels
## How to make /usr/bin/install doing recursive??
##
install: linux64 amd_all
$(INSTALL) -m 755 -d $(DOCUMENT_FOLDER)
$(CP) -a docs/* $(DOCUMENT_FOLDER)/
$(INSTALL) -m 755 -d $(DOCUMENT_FOLDER)/extra
$(CP) -a extra/* $(DOCUMENT_FOLDER)/extra/
$(INSTALL) -m 755 -d $(SHARED_FOLDER)
$(INSTALL) -m 755 -d $(SHARED_FOLDER)/charsets
$(CP) -a charsets/* $(SHARED_FOLDER)/charsets/
$(INSTALL) -m 755 -d $(SHARED_FOLDER)/kernels
$(CP) -a kernels/* $(SHARED_FOLDER)/kernels/
$(INSTALL) -m 755 -d $(SHARED_FOLDER)/masks
$(CP) -a masks/* $(SHARED_FOLDER)/masks/
$(INSTALL) -m 755 -d $(SHARED_FOLDER)/rules
$(CP) -a rules/* $(SHARED_FOLDER)/rules/
$(INSTALL) -m 755 -T hashcat.hcstat $(SHARED_FOLDER)/hashcat.hcstat
$(INSTALL) -m 755 -s -T oclHashcat64.bin $(INSTALL_FOLDER)/oclHashcat
uninstall:
$(RM) -f $(INSTALL_FOLDER)/oclHashcat
$(RM) -rf $(SHARED_FOLDER)
$(RM) -rf $(DOCUMENT_FOLDER)
##
## Targets: AMD Kernel (oclHashcat)
##
@ -382,10 +426,10 @@ obj/%.cudaHashcat.WIN.64.o: src/%.c
$(CC_WIN_64) $(CFLAGS) $(CFLAGS_WIN) $(CFLAGS_64) $(CFLAGS_CUDA_WIN) -c -o $@ $<
oclHashcat32.bin: src/oclHashcat.c obj/ext_OpenCL.oclHashcat.LINUX.32.o obj/ext_ADL.oclHashcat.LINUX.32.o obj/shared.oclHashcat.LINUX.32.o obj/rp_gpu_on_cpu.oclHashcat.LINUX.32.o
$(CC_LINUX_32) $(CFLAGS) $(CFLAGS_LINUX) $(CFLAGS_32) $(CFLAGS_OCL_LINUX) -o $@ -DCOMPTIME=$(NOW) $^ -L$(OCLLIBPATH32) $(LFLAGS_OCL_LINUX)
$(CC_LINUX_32) $(CFLAGS) $(CFLAGS_LINUX) $(CFLAGS_32) $(CFLAGS_OCL_LINUX) -o $@ -DCOMPTIME=$(NOW) $^ -L$(OCLLIBPATH32) $(LFLAGS_OCL_LINUX) -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\"
oclHashcat64.bin: src/oclHashcat.c obj/ext_OpenCL.oclHashcat.LINUX.64.o obj/ext_ADL.oclHashcat.LINUX.64.o obj/shared.oclHashcat.LINUX.64.o obj/rp_gpu_on_cpu.oclHashcat.LINUX.64.o
$(CC_LINUX_64) $(CFLAGS) $(CFLAGS_LINUX) $(CFLAGS_64) $(CFLAGS_OCL_LINUX) -o $@ -DCOMPTIME=$(NOW) $^ -L$(OCLLIBPATH64) $(LFLAGS_OCL_LINUX)
$(CC_LINUX_64) $(CFLAGS) $(CFLAGS_LINUX) $(CFLAGS_64) $(CFLAGS_OCL_LINUX) -o $@ -DCOMPTIME=$(NOW) $^ -L$(OCLLIBPATH64) $(LFLAGS_OCL_LINUX) -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\"
oclHashcat32.exe: src/oclHashcat.c obj/ext_OpenCL.oclHashcat.WIN.32.o obj/ext_ADL.oclHashcat.WIN.32.o obj/shared.oclHashcat.WIN.32.o obj/rp_gpu_on_cpu.oclHashcat.WIN.32.o lib/libOpenCL.a /usr/i686-w64-mingw32/lib/CRT_glob.o
$(CC_WIN_32) $(CFLAGS) $(CFLAGS_WIN) $(CFLAGS_32) $(CFLAGS_OCL_WIN) -o $@ -DCOMPTIME=$(NOW) $^ -L$(OCLLIBPATH32) $(LFLAGS_OCL_WIN) -static-libgcc
@ -394,10 +438,10 @@ oclHashcat64.exe: src/oclHashcat.c obj/ext_OpenCL.oclHashcat.WIN.64.o obj/ext
$(CC_WIN_64) $(CFLAGS) $(CFLAGS_WIN) $(CFLAGS_64) $(CFLAGS_OCL_WIN) -o $@ -DCOMPTIME=$(NOW) $^ -L$(OCLLIBPATH64) $(LFLAGS_OCL_WIN) -static-libgcc
cudaHashcat32.bin: src/oclHashcat.c obj/ext_cuda.cudaHashcat.LINUX.32.o obj/ext_nvml.cudaHashcat.LINUX.32.o obj/shared.cudaHashcat.LINUX.32.o obj/rp_gpu_on_cpu.cudaHashcat.LINUX.32.o
$(CC_LINUX_32) $(CFLAGS) $(CFLAGS_LINUX) $(CFLAGS_32) $(CFLAGS_CUDA_LINUX) -o $@ -DCOMPTIME=$(NOW) $^ -L$(CUDALIBPATH32) $(LFLAGS_CUDA_LINUX) -L$(NVMLLIBPATH32)
$(CC_LINUX_32) $(CFLAGS) $(CFLAGS_LINUX) $(CFLAGS_32) $(CFLAGS_CUDA_LINUX) -o $@ -DCOMPTIME=$(NOW) $^ -L$(CUDALIBPATH32) $(LFLAGS_CUDA_LINUX) -L$(NVMLLIBPATH32) -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\"
cudaHashcat64.bin: src/oclHashcat.c obj/ext_cuda.cudaHashcat.LINUX.64.o obj/ext_nvml.cudaHashcat.LINUX.64.o obj/shared.cudaHashcat.LINUX.64.o obj/rp_gpu_on_cpu.cudaHashcat.LINUX.64.o
$(CC_LINUX_64) $(CFLAGS) $(CFLAGS_LINUX) $(CFLAGS_64) $(CFLAGS_CUDA_LINUX) -o $@ -DCOMPTIME=$(NOW) $^ -L$(CUDALIBPATH64) $(LFLAGS_CUDA_LINUX) -L$(NVMLLIBPATH64)
$(CC_LINUX_64) $(CFLAGS) $(CFLAGS_LINUX) $(CFLAGS_64) $(CFLAGS_CUDA_LINUX) -o $@ -DCOMPTIME=$(NOW) $^ -L$(CUDALIBPATH64) $(LFLAGS_CUDA_LINUX) -L$(NVMLLIBPATH64) -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\"
cudaHashcat32.exe: src/oclHashcat.c obj/ext_cuda.cudaHashcat.WIN.32.o obj/ext_nvapi.cudaHashcat.WIN.32.o obj/shared.cudaHashcat.WIN.32.o obj/rp_gpu_on_cpu.cudaHashcat.WIN.32.o lib/libcuda.a /usr/i686-w64-mingw32/lib/CRT_glob.o
$(CC_WIN_32) $(CFLAGS) $(CFLAGS_WIN) $(CFLAGS_32) $(CFLAGS_CUDA_WIN) -o $@ -DCOMPTIME=$(NOW) $^ -L$(CUDALIBPATH32) $(LFLAGS_CUDA_WIN) -static-libgcc $(NVAPI)/x86/nvapi.lib

View File

@ -7016,12 +7016,45 @@ int main (int argc, char **argv)
data.scrypt_tmto = scrypt_tmto;
/**
* install_dir
* folders, as discussed on https://github.com/hashcat/oclHashcat/issues/20
*/
#ifdef LINUX
char *resolved_path = realpath (myargv[0], NULL);
char *install_dir = get_install_dir (resolved_path);
char *profile_dir = NULL;
char *session_dir = NULL;
if (strcmp (install_dir, INSTALL_FOLDER) == 0)
{
struct passwd *pw = getpwuid (getuid ());
const char *homedir = pw->pw_dir;
profile_dir = get_profile_dir (homedir);
session_dir = get_session_dir (profile_dir, session);
}
else
{
profile_dir = install_dir;
session_dir = install_dir;
}
myfree (resolved_path);
#else
char *install_dir = get_install_dir (myargv[0]);
char *profile_dir = install_dir;
char *session_dir = install_dir;
#endif
data.install_dir = install_dir;
data.profile_dir = profile_dir;
data.session_dir = session_dir;
/**
* cpu affinity

View File

@ -4093,6 +4093,26 @@ char *get_install_dir (const char *progname)
return (install_dir);
}
char *get_profile_dir (const char *homedir)
{
#define DOT_HASHCAT ".hashcat"
char *profile_dir = (char *) mymalloc (strlen (homedir) + 1 + strlen (DOT_HASHCAT) + 1);
sprintf (profile_dir, "%s/%s", homedir, DOT_HASHCAT);
return profile_dir;
}
char *get_session_dir (const char *profile_dir, const char *session)
{
char *session_dir = (char *) mymalloc (strlen (profile_dir) + 1 + strlen (session) + 1);
sprintf (session_dir, "%s/%s", profile_dir, session);
return session_dir;
}
void truecrypt_crc32 (char *file, unsigned char keytab[64])
{
uint crc = ~0;