@ -2364,7 +2364,6 @@ static void run_kernel (const uint kern_run, hc_device_param_t *device_param, co
case KERN_RUN_2 : kernel = device_param - > kernel2 ; break ;
case KERN_RUN_23 : kernel = device_param - > kernel23 ; break ;
case KERN_RUN_3 : kernel = device_param - > kernel3 ; break ;
case KERN_RUN_WEAK : kernel = device_param - > kernel_weak ; break ;
}
hc_clSetKernelArg ( kernel , 21 , sizeof ( cl_uint ) , device_param - > kernel_params [ 21 ] ) ;
@ -4540,17 +4539,11 @@ static void weak_hash_check (hc_device_param_t *device_param, const uint salt_po
device_param - > kernel_params_buf32 [ 30 ] = 0 ;
device_param - > kernel_params_buf32 [ 31 ] = 1 ;
char * dictfile_old = data . dictfile ;
char * dictfile2_old = data . dictfile2 ;
char * mask_old = data . mask ;
int attack_mode_old = data . attack_mode ;
char * dictfile_old = data . dictfile ;
const char * weak_hash_check = " weak-hash-check " ;
data . dictfile = ( char * ) weak_hash_check ;
data . dictfile2 = ( char * ) weak_hash_check ;
data . mask = ( char * ) weak_hash_check ;
data . attack_mode = ATTACK_MODE_STRAIGHT ;
data . dictfile = ( char * ) weak_hash_check ;
/**
* run the kernel
@ -4558,7 +4551,7 @@ static void weak_hash_check (hc_device_param_t *device_param, const uint salt_po
if ( data . attack_exec = = ATTACK_EXEC_INSIDE_KERNEL )
{
run_kernel ( KERN_RUN_ WEAK , device_param , 1 ) ;
run_kernel ( KERN_RUN_ 1 , device_param , 1 ) ;
}
else
{
@ -4600,10 +4593,7 @@ static void weak_hash_check (hc_device_param_t *device_param, const uint salt_po
device_param - > kernel_params_buf32 [ 30 ] = 0 ;
device_param - > kernel_params_buf32 [ 31 ] = 0 ;
data . dictfile = dictfile_old ;
data . dictfile2 = dictfile2_old ;
data . mask = mask_old ;
data . attack_mode = attack_mode_old ;
data . dictfile = dictfile_old ;
}
// hlfmt hashcat
@ -6097,6 +6087,18 @@ int main (int argc, char **argv)
}
}
if ( attack_mode ! = ATTACK_MODE_STRAIGHT )
{
if ( weak_hash_threshold ! = WEAK_HASH_THRESHOLD )
{
log_error ( " ERROR: setting --weak-hash-threshold allowed only in straight-attack mode " ) ;
return ( - 1 ) ;
}
weak_hash_threshold = 0 ;
}
/**
* induction directory
*/
@ -13309,149 +13311,6 @@ int main (int argc, char **argv)
sprintf ( build_opts , " -I%s/ -DVENDOR_ID=%d -DCUDA_ARCH=%d " , shared_dir , device_param - > vendor_id , ( device_param - > sm_major * 100 ) + device_param - > sm_minor ) ;
/**
* a0 kernel , required for some fast hashes to make weak_hash_check work
*/
const uint add_flag = OPTS_TYPE_PT_ADD01
| OPTS_TYPE_PT_ADD02
| OPTS_TYPE_PT_ADD80
| OPTS_TYPE_PT_ADDBITS14
| OPTS_TYPE_PT_ADDBITS15
| OPTS_TYPE_ST_ADD01
| OPTS_TYPE_ST_ADD02
| OPTS_TYPE_ST_ADD80
| OPTS_TYPE_ST_ADDBITS14
| OPTS_TYPE_ST_ADDBITS15
| OPTS_TYPE_PT_BITSLICE ;
if ( ( weak_hash_threshold ) & & ( attack_exec = = ATTACK_EXEC_INSIDE_KERNEL ) & & ( opts_type & add_flag ) )
{
/**
* kernel source filename
*/
char source_file [ 256 ] ;
memset ( source_file , 0 , sizeof ( source_file ) ) ;
generate_source_kernel_filename ( attack_exec , ATTACK_KERN_STRAIGHT , kern_type , shared_dir , source_file ) ;
struct stat sst ;
if ( stat ( source_file , & sst ) = = - 1 )
{
log_error ( " ERROR: %s: %s " , source_file , strerror ( errno ) ) ;
return - 1 ;
}
/**
* kernel cached filename
*/
char cached_file [ 256 ] ;
memset ( cached_file , 0 , sizeof ( cached_file ) ) ;
generate_cached_kernel_filename ( attack_exec , ATTACK_KERN_STRAIGHT , kern_type , profile_dir , device_name_chksum , cached_file ) ;
int cached = 1 ;
struct stat cst ;
if ( stat ( cached_file , & cst ) = = - 1 )
{
cached = 0 ;
}
/**
* kernel compile or load
*/
size_t * kernel_lengths = ( size_t * ) mymalloc ( sizeof ( size_t ) ) ;
const unsigned char * * kernel_sources = ( const unsigned char * * ) mymalloc ( sizeof ( unsigned char * ) ) ;
if ( force_jit_compilation = = 0 )
{
if ( cached = = 0 )
{
if ( quiet = = 0 ) log_info ( " Device #%u: Kernel %s not found in cache! Building may take a while... " , device_id + 1 , cached_file ) ;
load_kernel ( source_file , 1 , kernel_lengths , kernel_sources ) ;
device_param - > program_weak = hc_clCreateProgramWithSource ( device_param - > context , 1 , ( const char * * ) kernel_sources , NULL ) ;
hc_clBuildProgram ( device_param - > program_weak , 1 , & device_param - > device , build_opts , NULL , NULL ) ;
size_t binary_size ;
clGetProgramInfo ( device_param - > program_weak , CL_PROGRAM_BINARY_SIZES , sizeof ( size_t ) , & binary_size , NULL ) ;
unsigned char * binary = ( unsigned char * ) mymalloc ( binary_size ) ;
clGetProgramInfo ( device_param - > program_weak , CL_PROGRAM_BINARIES , sizeof ( binary ) , & binary , NULL ) ;
writeProgramBin ( cached_file , binary , binary_size ) ;
local_free ( binary ) ;
}
else
{
if ( quiet = = 0 ) log_info ( " Device #%u: Kernel %s (%ld bytes) " , device_id + 1 , cached_file , cst . st_size ) ;
load_kernel ( cached_file , 1 , kernel_lengths , kernel_sources ) ;
device_param - > program_weak = hc_clCreateProgramWithBinary ( device_param - > context , 1 , & device_param - > device , kernel_lengths , ( const unsigned char * * ) kernel_sources , NULL ) ;
hc_clBuildProgram ( device_param - > program_weak , 1 , & device_param - > device , build_opts , NULL , NULL ) ;
}
}
else
{
if ( quiet = = 0 ) log_info ( " Device #%u: Kernel %s (%ld bytes) " , device_id + 1 , source_file , sst . st_size ) ;
load_kernel ( source_file , 1 , kernel_lengths , kernel_sources ) ;
device_param - > program_weak = hc_clCreateProgramWithSource ( device_param - > context , 1 , ( const char * * ) kernel_sources , NULL ) ;
if ( force_jit_compilation = = 1500 )
{
sprintf ( build_opts , " %s -DDESCRYPT_SALT=%d " , build_opts , data . salts_buf [ 0 ] . salt_buf [ 0 ] ) ;
}
else if ( force_jit_compilation = = 8900 )
{
sprintf ( build_opts , " %s -DSCRYPT_N=%d -DSCRYPT_R=%d -DSCRYPT_P=%d -DSCRYPT_TMTO=%d " , build_opts , data . salts_buf [ 0 ] . scrypt_N , data . salts_buf [ 0 ] . scrypt_r , data . salts_buf [ 0 ] . scrypt_p , 1 < < data . salts_buf [ 0 ] . scrypt_tmto ) ;
}
hc_clBuildProgram ( device_param - > program_weak , 1 , & device_param - > device , build_opts , NULL , NULL ) ;
}
local_free ( kernel_lengths ) ;
local_free ( kernel_sources [ 0 ] ) ;
local_free ( kernel_sources ) ;
// this is mostly for debug
size_t ret_val_size = 0 ;
clGetProgramBuildInfo ( device_param - > program_weak , device_param - > device , CL_PROGRAM_BUILD_LOG , 0 , NULL , & ret_val_size ) ;
if ( ret_val_size > 2 )
{
char * build_log = ( char * ) mymalloc ( ret_val_size + 1 ) ;
memset ( build_log , 0 , ret_val_size + 1 ) ;
clGetProgramBuildInfo ( device_param - > program_weak , device_param - > device , CL_PROGRAM_BUILD_LOG , ret_val_size , build_log , NULL ) ;
puts ( build_log ) ;
myfree ( build_log ) ;
}
}
/**
* main kernel
*/
@ -13810,7 +13669,6 @@ int main (int argc, char **argv)
device_param - > d_pws_buf = hc_clCreateBuffer ( device_param - > context , CL_MEM_READ_ONLY , size_pws , NULL ) ;
device_param - > d_pws_amp_buf = hc_clCreateBuffer ( device_param - > context , CL_MEM_READ_ONLY , size_pws , NULL ) ;
device_param - > d_rules_c = hc_clCreateBuffer ( device_param - > context , CL_MEM_READ_ONLY , size_rules_c , NULL ) ; // we need this for weak-hash-check even if the user has choosen for ex: -a 3
device_param - > d_tmps = hc_clCreateBuffer ( device_param - > context , CL_MEM_READ_WRITE , size_tmps , NULL ) ;
device_param - > d_hooks = hc_clCreateBuffer ( device_param - > context , CL_MEM_READ_WRITE , size_hooks , NULL ) ;
device_param - > d_bitmap_s1_a = hc_clCreateBuffer ( device_param - > context , CL_MEM_READ_ONLY , bitmap_size , NULL ) ;
@ -13842,7 +13700,6 @@ int main (int argc, char **argv)
run_kernel_bzero ( device_param , device_param - > d_pws_buf , size_pws ) ;
run_kernel_bzero ( device_param , device_param - > d_pws_amp_buf , size_pws ) ;
run_kernel_bzero ( device_param , device_param - > d_rules_c , size_rules_c ) ;
run_kernel_bzero ( device_param , device_param - > d_tmps , size_tmps ) ;
run_kernel_bzero ( device_param , device_param - > d_hooks , size_hooks ) ;
run_kernel_bzero ( device_param , device_param - > d_plain_bufs , size_plains ) ;
@ -13854,9 +13711,12 @@ int main (int argc, char **argv)
if ( attack_kern = = ATTACK_KERN_STRAIGHT )
{
device_param - > d_rules = hc_clCreateBuffer ( device_param - > context , CL_MEM_READ_ONLY , size_rules , NULL ) ;
device_param - > d_rules = hc_clCreateBuffer ( device_param - > context , CL_MEM_READ_ONLY , size_rules , NULL ) ;
device_param - > d_rules_c = hc_clCreateBuffer ( device_param - > context , CL_MEM_READ_ONLY , size_rules_c , NULL ) ;
hc_clEnqueueWriteBuffer ( device_param - > command_queue , device_param - > d_rules , CL_TRUE , 0 , size_rules , kernel_rules_buf , 0 , NULL , NULL ) ;
run_kernel_bzero ( device_param , device_param - > d_rules_c , size_rules_c ) ;
}
else if ( attack_kern = = ATTACK_KERN_COMBI )
{
@ -14088,40 +13948,6 @@ int main (int argc, char **argv)
device_param - > kernel3 = hc_clCreateKernel ( device_param - > program , kernel_name ) ;
}
if ( weak_hash_threshold )
{
if ( opts_type & add_flag )
{
if ( opti_type & OPTI_TYPE_SINGLE_HASH )
{
snprintf ( kernel_name , sizeof ( kernel_name ) - 1 , " m%05d_s%02d " , kern_type , 4 ) ;
device_param - > kernel_weak = hc_clCreateKernel ( device_param - > program_weak , kernel_name ) ;
}
else
{
snprintf ( kernel_name , sizeof ( kernel_name ) - 1 , " m%05d_m%02d " , kern_type , 4 ) ;
device_param - > kernel_weak = hc_clCreateKernel ( device_param - > program_weak , kernel_name ) ;
}
}
else
{
if ( opti_type & OPTI_TYPE_SINGLE_HASH )
{
snprintf ( kernel_name , sizeof ( kernel_name ) - 1 , " m%05d_s%02d " , kern_type , 4 ) ;
device_param - > kernel_weak = hc_clCreateKernel ( device_param - > program , kernel_name ) ;
}
else
{
snprintf ( kernel_name , sizeof ( kernel_name ) - 1 , " m%05d_m%02d " , kern_type , 4 ) ;
device_param - > kernel_weak = hc_clCreateKernel ( device_param - > program , kernel_name ) ;
}
}
}
if ( data . attack_mode = = ATTACK_MODE_BF )
{
if ( opts_type & OPTS_TYPE_PT_BITSLICE )
@ -14173,11 +13999,6 @@ int main (int argc, char **argv)
if ( opts_type & OPTS_TYPE_HOOK12 ) hc_clSetKernelArg ( device_param - > kernel12 , i , sizeof ( cl_mem ) , device_param - > kernel_params [ i ] ) ;
if ( opts_type & OPTS_TYPE_HOOK23 ) hc_clSetKernelArg ( device_param - > kernel23 , i , sizeof ( cl_mem ) , device_param - > kernel_params [ i ] ) ;
if ( weak_hash_threshold )
{
hc_clSetKernelArg ( device_param - > kernel_weak , i , sizeof ( cl_mem ) , device_param - > kernel_params [ i ] ) ;
}
}
for ( uint i = 21 ; i < = 31 ; i + + )
@ -14188,11 +14009,6 @@ int main (int argc, char **argv)
if ( opts_type & OPTS_TYPE_HOOK12 ) hc_clSetKernelArg ( device_param - > kernel12 , i , sizeof ( cl_uint ) , device_param - > kernel_params [ i ] ) ;
if ( opts_type & OPTS_TYPE_HOOK23 ) hc_clSetKernelArg ( device_param - > kernel23 , i , sizeof ( cl_uint ) , device_param - > kernel_params [ i ] ) ;
if ( weak_hash_threshold )
{
hc_clSetKernelArg ( device_param - > kernel_weak , i , sizeof ( cl_uint ) , device_param - > kernel_params [ i ] ) ;
}
}
if ( attack_mode = = ATTACK_MODE_BF )
@ -16494,12 +16310,10 @@ int main (int argc, char **argv)
if ( device_param - > kernel_tb ) hc_clReleaseKernel ( device_param - > kernel_tb ) ;
if ( device_param - > kernel_tm ) hc_clReleaseKernel ( device_param - > kernel_tm ) ;
if ( device_param - > kernel_amp ) hc_clReleaseKernel ( device_param - > kernel_amp ) ;
if ( device_param - > kernel_weak ) hc_clReleaseKernel ( device_param - > kernel_weak ) ;
if ( device_param - > program ) hc_clReleaseProgram ( device_param - > program ) ;
if ( device_param - > program_mp ) hc_clReleaseProgram ( device_param - > program_mp ) ;
if ( device_param - > program_amp ) hc_clReleaseProgram ( device_param - > program_amp ) ;
if ( device_param - > program_weak ) hc_clReleaseProgram ( device_param - > program_weak ) ;
if ( device_param - > command_queue ) hc_clReleaseCommandQueue ( device_param - > command_queue ) ;
if ( device_param - > context ) hc_clReleaseContext ( device_param - > context ) ;