Skip to content

Commit 0c7d1f9

Browse files
optimized, woo
optimization on mod in interm1000 loop. also cleaned up some loose memory. not sure if anything else can be done.
1 parent 1431579 commit 0c7d1f9

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

crack.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void print_char_reg(char* to_print, unsigned len) {
3939
bool check_pass(char* psswd) { // NOTE: Will only check correctly 6 char passwords
4040
char salt[9] = "hfT7jp2q";
4141
char hash[23] = "v8XH/MrpaYdagdMgM4yKc."; //THIS IS THE REAL HASH
42-
// char hash[23] = "Kx3u7/FpY8TZv0y2tgyGC1";
42+
//char hash[23] = "O53e58A82lSBz1tJeJRfY/";
4343
char magic[4] = "$1$";
4444
// compute alternate sum
4545
char input[21];
@@ -143,7 +143,7 @@ int main(int argc, char** argv) { // TODO:
143143

144144
double duration;
145145
time_t start;
146-
146+
147147
start = clock();
148148
thread t1(check_block, begin_1, end_1, 0);
149149
// thread t2(check_block, begin_2, end_2, 0);
@@ -180,7 +180,7 @@ void compute_primitive_md5(char* input, unsigned in_len, char* digest) {
180180
MD5_Init(context);
181181
MD5_Update(context, (unsigned char*)(input), in_len);
182182
MD5_Final((unsigned char*)(digest), context);
183-
// delete context;
183+
delete context;
184184
// MD5((unsigned char*)(input), in_len, (unsigned char*)(digest)); //compute the md5 (which is also the altsum)
185185
return;
186186
}
@@ -248,11 +248,12 @@ void interm_1000(char* psswd, unsigned p_len, char* salt, unsigned s_len, char*
248248
memcpy(working_final + working_final_len, psswd, p_len);
249249
working_final_len += p_len;
250250
}
251-
if (i % 3 != 0) { // if not divisible by 3, salt
251+
if ((i >= 3 ? i % 3 : i) != 0) { // if not divisible by 3, salt
252252
memcpy(working_final + working_final_len, salt, s_len);
253253
working_final_len += s_len;
254254
}
255-
if (i % 7 != 0) { // if not divisible by 7, password
255+
//if (i % 7 != 0) { // if not divisible by 7, password
256+
if((i >= 7 ? i % 7 : i) != 0) { // FASSSSSTTTTTT
256257
memcpy(working_final + working_final_len, psswd, p_len);
257258
working_final_len += p_len;
258259
}
@@ -297,11 +298,13 @@ void rearrange(char * finalsum, unsigned sum_len, char* partitioned_stuff) {
297298
partitioned_stuff[i+1] = gimme_char(((new_order[0] & 0xc0) >> 6) | ((new_order[1] & 0xf) << 2));
298299
partitioned_stuff[i+2] = gimme_char(((new_order[1] & 0xf0) >> 4) | ((new_order[2] & 0x3) << 4));
299300
partitioned_stuff[i+3] = gimme_char((new_order[2] & 0xfc) >> 2);
300-
new_order = new_order + 3;
301+
new_order += 3;
301302
}
302303
partitioned_stuff[21] = gimme_char((new_order[0] & 0xc0) >> 6);
303304
partitioned_stuff[20] = gimme_char((new_order[0] & 0x3f));
304305
partitioned_stuff[22] = '\0';
306+
new_order -= 15;
307+
delete [] new_order;
305308
return;
306309
}
307310

makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
crack : crack.cpp
2-
g++ -std=c++11 crack.cpp -o crack -pthread -lssl -lcrypto -L/usr/local/opt/openssl/lib -I/usr/local/opt/openssl/include
2+
g++ -std=c++11 crack.cpp -o crack -Ofast -pthread -lssl -lcrypto -L/usr/local/opt/openssl/lib -I/usr/local/opt/openssl/include
33

44
fedora : crack.cpp
5-
g++ -std=c++11 crack.cpp -o crack -lcrypto -pthread
5+
g++ -std=c++11 crack.cpp -o crack -Ofast -lcrypto -pthread
66

77
clean :
88
rm crack

0 commit comments

Comments
 (0)