diff --git a/Illegal_Possession_Images/lab_files/wlan_decrypt/crackWEP40_GPU_Improved_v1.py b/Illegal_Possession_Images/lab_files/wlan_decrypt/crackWEP40_GPU_Improved_v1.py new file mode 100644 index 0000000..1922ef9 --- /dev/null +++ b/Illegal_Possession_Images/lab_files/wlan_decrypt/crackWEP40_GPU_Improved_v1.py @@ -0,0 +1,76 @@ +# Generated By ChatGPT DGL +# Write Python code that generates all possible combinations of 8 characters, +# with each character consisting of either a lowercase or uppercase English letter and +# also has a function to check the XOR sum of the 0th, 3rd, 6th characters, +# the XOR sum of the 1st, 4th, 7th characters, +# and the XOR sum of the 2nd and 5th characters. +# Also add function to check sha1 hash of the combination startwith 0xff7b948953ac +# Use Pytorch framework to use GPU +# Generated By ChatGPT DGL +# Write Python code that generates all possible combinations of 8 characters, +# with each character consisting of either a lowercase or uppercase English letter and +# also has a function to check the XOR sum of the 0th, 3rd, 6th characters, +# the XOR sum of the 1st, 4th, 7th characters, +# and the XOR sum of the 2nd and 5th characters. +# Also add function to check sha1 hash of the combination startwith 0xff7b948953ac +# Use Pytorch framework to use GPU + +import torch +import string +import hashlib +import time +import itertools + + +def generate_combinations_test(device): + ascii_codes = [ord(char) for char in "cgwpkexz"] + return torch.tensor([ascii_codes], dtype=torch.uint8, device=device) + + +def check_xor_sum(combination): + xor_sum_0_3_6 = combination[:, 0].int( + ) ^ combination[:, 3].int() ^ combination[:, 6].int() + xor_sum_1_4_7 = combination[:, 1].int( + ) ^ combination[:, 4].int() ^ combination[:, 7].int() + xor_sum_2_5 = combination[:, 2].int() ^ combination[:, 5].int() + return (xor_sum_0_3_6 == 0x6b) & (xor_sum_1_4_7 == 0x76) & (xor_sum_2_5 == 0x12) + +def add_xy_and_check_sha1(valid_combinations, device): + letters = 'abcdefghijklmnopqrstuvwxyz' + xy_combinations = torch.tensor( + [[ord(x), ord(y)] for x in letters for y in letters], dtype=torch.uint8, device=device) + + final_results = [] + for combination in valid_combinations: + for xy in xy_combinations: + new_combination = torch.cat((combination[:3], xy[0].unsqueeze( + 0), combination[3:6], xy[1].unsqueeze(0), combination[6:]), dim=0) + sha1_hash = hashlib.sha1( + new_combination.cpu().numpy().tobytes()).hexdigest() + if sha1_hash.startswith('ff7b948953ac'): + final_results.append(new_combination) + return final_results + +if torch.cuda.is_available(): + device = torch.device("cuda") +else: + device = torch.device("cpu") + +start_time = time.time() +characters = string.ascii_lowercase +valid_combinations=[] +for e in torch.tensor([list(map(ord, chars)) for chars in itertools.product( + characters, repeat=8)], dtype=torch.uint8, device=device): + if check_xor_sum(e): + valid_combinations.append(e) + print(e) + +valid_combinations = add_xy_and_check_sha1(valid_combinations, device) +if len(valid_combinations) > 0: + print(valid_combinations[0].char().cpu().numpy().tolist()) +else: + print("No valid combinations found") + +end_time = time.time() +print("Processing took %.2f seconds for " % + (end_time - start_time)) \ No newline at end of file diff --git a/Illegal_Possession_Images/lab_files/wlan_decrypt/crackWEP40_noGPU.py b/Illegal_Possession_Images/lab_files/wlan_decrypt/crackWEP40_noGPU.py new file mode 100644 index 0000000..b097699 --- /dev/null +++ b/Illegal_Possession_Images/lab_files/wlan_decrypt/crackWEP40_noGPU.py @@ -0,0 +1,59 @@ +# Write Python code that generates all possible combinations of 8 characters, +# with each character is a lowercase English letter and also has a function, check_xor_sum, +# to check the XOR sum of the 0th, 3rd, 6th characters is 0x6b, the XOR sum of the 1st, 4th, 7th characters is 0x76, +# and the XOR sum of the 2nd and 5th characters is 0x12. If check_xor_sum returns true, +# remember these valid combinations. Then write a function to generate all combinations of two lower case characters, +# call x and y, insert x after 3rd position and insert y after 6th position of valid combinations. +# The resultant new combination is 10 characters long strings. +# Also add function to check sha1 hash of the 10-character strings starts with ff7b948953ac. Print final results. + +import hashlib +import itertools + +def check_xor_sum(string): + if ord(string[0]) ^ ord(string[3]) ^ ord(string[6]) == 0x6b and \ + ord(string[1]) ^ ord(string[4]) ^ ord(string[7]) == 0x76 and \ + ord(string[2]) ^ ord(string[5]) == 0x12: + return True + return False + +def generate_8_char_combinations(): + characters = 'abcdefghijklmnopqrstuvwxyz' + combinations = itertools.product(characters, repeat=8) + valid_combinations = [] + for combination in combinations: + string = "".join(combination) + if check_xor_sum(string): + valid_combinations.append(string) + # valid_combinations = ["cgwpkexz"] + return valid_combinations + +def insert_letters(valid_combinations): + characters = 'abcdefghijklmnopqrstuvwxyz' + new_combinations = [] + for x in characters: + for y in characters: + for valid_combination in valid_combinations: + new_combination = valid_combination[:3] + x + \ + valid_combination[3:6] + y + valid_combination[6:] + new_combinations.append(new_combination) + return new_combinations + +def check_sha1_hash(new_combinations): + final_results = [] + for new_combination in new_combinations: + sha1_hash = hashlib.sha1(new_combination.encode('utf-8')).hexdigest() + if sha1_hash.startswith("ff7b948953ac"): + final_results.append(new_combination) + return final_results + +def main(): + valid_combinations = generate_8_char_combinations() + new_combinations = insert_letters(valid_combinations) + final_results = check_sha1_hash(new_combinations) + print("Final results:") + for result in final_results: + print(result) + +if __name__ == '__main__': + main() diff --git a/Illegal_Possession_Images/lab_files/wlan_decrypt/crackWEP40_noGPU_Improved_v1.py b/Illegal_Possession_Images/lab_files/wlan_decrypt/crackWEP40_noGPU_Improved_v1.py new file mode 100644 index 0000000..9d8e04a --- /dev/null +++ b/Illegal_Possession_Images/lab_files/wlan_decrypt/crackWEP40_noGPU_Improved_v1.py @@ -0,0 +1,55 @@ +import itertools +import string +import hashlib + + +def generate_combinations(): + characters = string.ascii_lowercase + combinations = itertools.product(characters, repeat=8) + # For testing only + # combinations = ["aaaaaaaa", "cgwpkexz", "cgwpkexa", "cgwpkexa", "cgwpkexa", "cgwpkexa"] + return combinations + + +def check_xor_sum(combination): + if ord(combination[0]) ^ ord( + combination[3]) ^ ord(combination[6]) != 0x6b : + return False + if ord(combination[1]) ^ ord( + combination[4]) ^ ord(combination[7]) != 0x76: + return False + if ord(combination[2]) ^ ord(combination[5]) != 0x12: + return False + return True + + +def insert_letters(valid_combination): + new_combinations = [] + characters = 'abcdefghijklmnopqrstuvwxyz' + for x in characters: + for y in characters: + new_combination = tuple(list(valid_combination[:3]) + [x] + + list(valid_combination[3:6]) + [y] + + list(valid_combination[6:])) + new_combinations.append(new_combination) + return new_combinations + +def check_sha1_hash(combination): + combination_str = ''.join(combination) + sha1_hash = hashlib.sha1(combination_str.encode('utf-8')) + return sha1_hash.hexdigest().startswith('ff7b948953ac') + + +cracked= False +for combination in generate_combinations(): + # print("process: ", ''.join(combination)) + if check_xor_sum(combination): + print("Match xor sum: ", ''.join(combination)) + for comb_x_y in insert_letters(combination): + if check_sha1_hash(comb_x_y): + cracked = True + print("Cracked: ", ''.join(comb_x_y)) + break + if cracked: + break +