std::vector<std::vector<long> > attack_DES(int PAIRS){ char ip[65], ipi[65], pt1[2], pt2[2], ct1[2], ct2[2]; char l3a_t[33], l3b_t[33], r3a_t[33], r3b_t[33], C_t[33], l3_xor[49]; char l0a_t[33], l0b_t[33], inverted[33], temp[8], E_t[49], E_t_xor[49]; int i; int E[9], C[9], E_xor[9]; int temp_e, temp_c; int *l0a = &pairs[PAIRS][0][0][0]; int *l0b = &pairs[PAIRS][1][0][0]; int *r0a = &pairs[PAIRS][0][0][1]; int *r0b = &pairs[PAIRS][1][0][1]; int *l3a = &pairs[PAIRS][0][1][0]; int *l3b = &pairs[PAIRS][1][1][0]; int *r3a = &pairs[PAIRS][0][1][1]; int *r3b = &pairs[PAIRS][1][1][1]; unpack_32(l3a, l3a_t); unpack_32(l3b, l3b_t); unpack_32(r3a, r3a_t); unpack_32(r3b, r3b_t); unpack_32(l0a, l0a_t); unpack_32(l0b, l0b_t); //First we traverse down f to find E* and E1 //Diff for L3/R2 for (i = 1; i <= 32; i++){ l3_xor[i] = l3a_t[i] ^ l3b_t[i]; } //Expand Left for (i = 1; i <= 48; i++){ E_t_xor[i] = l3_xor[exp1[i]]; E_t[i] = l3a_t[exp1[i]]; } //Now we will traverse up f to find C //Diff for R3 and L0 for (i = 1; i <= 32; i++){ r3a_t[i] ^= r3b_t[i]; l0a_t[i] ^= l0b_t[i]; } //Difference of differences of L0 and R3 for (i = 1; i <= 32; i++){ inverted[i] = l0a_t[i] ^ r3a_t[i]; } //Reverse P using inverted array to find C for (i = 1; i <= 32; i++) C_t[i] = inverted[pinverse[i]]; //Put E, E_xor and C possibilities into array as ints int k = 0; for (i = 0; i < 48; i+=6){ for(int j = 1; j <= 6; j++){ temp[j] = E_t_xor[i+j]; } pack_6(&temp_e, temp); E_xor[k] = temp_e; k++; } k = 0; for (i = 0; i < 48; i+=6){ for(int j = 1; j <= 6; j++){ temp[j] = E_t[i+j]; } pack_6(&temp_e, temp); E[k] = temp_e; k++; } k = 0; for (i = 0; i < 32; i+=4){ for(int j = 1; j <= 4; j++){ temp[j] = C_t[i+j]; } pack_4(&temp_c, temp); C[k] = temp_c; k++; } //Build vector to store B values std::vector<std::vector<long> > B; std::vector<std::vector<long> > J; for (int i = 0; i < 8; i++){ std::vector<long> v = INTables[i][E_xor[i]][C[i]]; std::vector<long> placeholder; B.push_back(v); } int temp_array; //Cycle through B vector and xor values with E for Js for (int i = 0; i < 8; ++i){ std::vector<long> bs = B[i]; std::vector<long> placeholder2; J.push_back(placeholder2); for(int j = 0; j < bs.size(); ++j){ temp_array = bs[j] ^ E[i]; J[i].push_back(temp_array); } } return J; //std::vector<long> kposs = key_possibilities(J); //reverse_key_schedule(kposs); }
int _rfs_open(struct rfs_instance *instance, const char *path, int flags, uint64_t *desc) { if (instance->sendrecv.socket == -1) { return -ECONNABORTED; } unsigned path_len = strlen(path) + 1; uint16_t fi_flags = rfs_file_flags(flags); unsigned overall_size = sizeof(fi_flags) + path_len; struct rfs_command cmd = { cmd_open, overall_size }; char *buffer = malloc(cmd.data_len); pack(path, path_len, pack_16(&fi_flags, buffer )); send_token_t token = { 0 }; if (do_send(&instance->sendrecv, queue_data(buffer, overall_size, queue_cmd(&cmd, &token))) < 0) { free(buffer); return -ECONNABORTED; } free(buffer); struct rfs_answer ans = { 0 }; if (rfs_receive_answer(&instance->sendrecv, &ans) == -1) { return -ECONNABORTED; } if (ans.command != cmd_open) { return cleanup_badmsg(instance, &ans); } if (ans.ret == -1) { if (ans.ret_errno == -ENOENT) { delete_from_cache(&instance->attr_cache, path); } return -ans.ret_errno; } uint32_t stat_failed = 0; uint32_t user_len = 0; uint32_t group_len = 0; #define ans_buffer_size sizeof(*desc) \ + sizeof(stat_failed) + STAT_BLOCK_SIZE + sizeof(user_len) + sizeof(group_len) \ + (MAX_SUPPORTED_NAME_LEN + 1) + (MAX_SUPPORTED_NAME_LEN + 1) char ans_buffer[ans_buffer_size] = { 0 }; if (ans.data_len > sizeof(ans_buffer)) { return cleanup_badmsg(instance, &ans); } #undef ans_buffer_size if (rfs_receive_data(&instance->sendrecv, ans_buffer, ans.data_len) == -1) { return -ECONNABORTED; } struct stat stbuf = { 0 }; const char *user = unpack_32(&group_len, unpack_32(&user_len, unpack_stat(&stbuf, unpack_32(&stat_failed, unpack_64(desc, ans_buffer ))))); const char *group = user + user_len; DEBUG("handle: %llu\n", (long long unsigned)(*desc)); stbuf.st_uid = resolve_username(instance, user); stbuf.st_gid = resolve_groupname(instance, group, user); if (ans.ret_errno == 0) { if (stat_failed == 0) { cache_file(&instance->attr_cache, path, &stbuf); } resume_add_file_to_open_list(&instance->resume.open_files, path, flags, *desc); } else { delete_from_cache(&instance->attr_cache, path); } return ans.ret == -1 ? -ans.ret_errno : ans.ret; }