Windows cross-compilation support for solve_piwi/solve_piwi_bs
This commit is contained in:
28
Makefile
28
Makefile
@ -41,3 +41,31 @@ get_crapto1:
|
||||
wget http://crapto1.netgarage.org/crapto1-v3.3.tar.xz
|
||||
mkdir crapto1-v3.3
|
||||
tar Jxvf crapto1-v3.3.tar.xz -C crapto1-v3.3
|
||||
|
||||
# Windows cross compilation
|
||||
MINGW32 = i686-w64-mingw32-gcc
|
||||
MINGW64 = x86_64-w64-mingw32-gcc
|
||||
# solve.c code cannot be compiled on windows without patching the includes
|
||||
|
||||
WIN32EXES = solve_piwi_bs32.exe solve_piwi32.exe libnfc_crypto1_crack32.exe
|
||||
win32: $(WIN32EXES)
|
||||
win32_clean:
|
||||
rm -f $(WIN32EXES)
|
||||
|
||||
WIN64EXES = solve_piwi_bs64.exe solve_piwi64.exe libnfc_crypto1_crack64.exe
|
||||
win64: $(WIN64EXES)
|
||||
win64_clean:
|
||||
rm -f $(WIN64EXES)
|
||||
|
||||
solve_piwi_bs32.exe:
|
||||
$(MINGW32) $(CFLAGS) solve_piwi_bs.c $(CRYPTO1_BS) $(CRAPTO1) ${CRAPTEV1} -static -m32 -o $@ -lpthread
|
||||
|
||||
solve_piwi_bs64.exe:
|
||||
$(MINGW64) $(CFLAGS) solve_piwi_bs.c $(CRYPTO1_BS) $(CRAPTO1) ${CRAPTEV1} -static -o $@ -lpthread
|
||||
|
||||
solve_piwi32.exe:
|
||||
$(MINGW32) $(CFLAGS) solve_piwi.c $(CRYPTO1_BS) $(CRAPTO1) ${CRAPTEV1} -static -m32 -o $@ -lpthread
|
||||
|
||||
solve_piwi64.exe:
|
||||
$(MINGW64) $(CFLAGS) solve_piwi.c $(CRYPTO1_BS) $(CRAPTO1) ${CRAPTEV1} -static -o $@ -lpthread
|
||||
|
||||
|
@ -23,16 +23,16 @@ uint64_t split(uint8_t p){
|
||||
uint32_t uid;
|
||||
uint64_t *readnonces(char* fname){
|
||||
int i;
|
||||
FILE *f = fopen(fname, "r");
|
||||
FILE *f = fopen(fname, "rb");
|
||||
uint64_t *nonces = malloc(sizeof (uint64_t) << 24);
|
||||
if(fread(&uid, 1, 4, f)){
|
||||
uid = rev32(uid);
|
||||
}
|
||||
fseek(f, 6, SEEK_SET);
|
||||
i = 0;
|
||||
while(!feof(f)){
|
||||
uint32_t nt_enc1, nt_enc2;
|
||||
uint8_t par_enc;
|
||||
while(!feof(f)){
|
||||
if(fread(&nt_enc1, 1, 4, f) && fread(&nt_enc2, 1, 4, f) && fread(&par_enc, 1, 1, f)){
|
||||
nonces[i ] = split(~(par_enc >> 4)) << 32 | nt_enc1;
|
||||
nonces[i+1] = split(~(par_enc & 0xff)) << 32 | nt_enc2;
|
||||
@ -45,7 +45,7 @@ uint64_t *readnonces(char* fname){
|
||||
}
|
||||
|
||||
uint32_t **space;
|
||||
size_t thread_count = 1;
|
||||
uint8_t thread_count = 1;
|
||||
uint64_t states_tested = 0;
|
||||
uint64_t total_states;
|
||||
|
||||
@ -85,7 +85,7 @@ int main(int argc, char* argv[]){
|
||||
space[j] = 0;
|
||||
}
|
||||
pthread_t threads[thread_count];
|
||||
printf("Starting %zu threads to test %"llu" states\n", thread_count, total_states);
|
||||
printf("Starting %u threads to test %"llu" states\n", thread_count, total_states);
|
||||
size_t i;
|
||||
states_tested = 0;
|
||||
for(i = 0; i < thread_count; i++){
|
||||
|
@ -24,7 +24,7 @@ uint64_t split(uint8_t p){
|
||||
uint32_t uid;
|
||||
uint64_t *readnonces(char* fname){
|
||||
int i;
|
||||
FILE *f = fopen(fname, "r");
|
||||
FILE *f = fopen(fname, "rb");
|
||||
uint64_t *nonces = malloc(sizeof (uint64_t) << 24);
|
||||
if(fread(&uid, 1, 4, f)){
|
||||
uid = rev32(uid);
|
||||
@ -46,7 +46,7 @@ uint64_t *readnonces(char* fname){
|
||||
}
|
||||
|
||||
uint32_t **space;
|
||||
size_t thread_count = 1;
|
||||
uint8_t thread_count = 1;
|
||||
|
||||
void* crack_states_thread(void* x){
|
||||
const size_t thread_id = (size_t)x;
|
||||
@ -76,7 +76,9 @@ int main(int argc, char* argv[]){
|
||||
|
||||
#ifndef __WIN32
|
||||
thread_count = sysconf(_SC_NPROCESSORS_CONF);
|
||||
#endif /* _WIN32 */
|
||||
#else
|
||||
thread_count = 1;
|
||||
#endif
|
||||
|
||||
// append some zeroes to the end of the space to make sure threads don't go off into the wild
|
||||
size_t j = 0;
|
||||
@ -112,7 +114,7 @@ int main(int argc, char* argv[]){
|
||||
total_states_tested = 0;
|
||||
keys_found = 0;
|
||||
|
||||
printf("Starting %zu threads to test %"llu" states\n", thread_count, total_states);
|
||||
printf("Starting %u threads to test %"llu" states\n", thread_count, total_states);
|
||||
for(i = 0; i < thread_count; i++){
|
||||
pthread_create(&threads[i], NULL, crack_states_thread, (void*) i);
|
||||
}
|
||||
|
Reference in New Issue
Block a user