mirror of
https://github.com/frankwxu/digital-forensics-lab.git
synced 2026-02-21 11:17:52 +00:00
add WEP40 crack
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Illegal_Possession_Images/Wireless_aircrack_WEP40_1.pptx
Normal file
BIN
Illegal_Possession_Images/Wireless_aircrack_WEP40_1.pptx
Normal file
Binary file not shown.
@@ -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()
|
||||
@@ -0,0 +1,72 @@
|
||||
# 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 generate_combinations(device):
|
||||
characters = string.ascii_lowercase
|
||||
combinations = torch.tensor([list(map(ord, chars)) for chars in itertools.product(
|
||||
characters, repeat=8)], dtype=torch.uint8, device=device)
|
||||
return combinations
|
||||
|
||||
|
||||
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")
|
||||
|
||||
|
||||
combinations = generate_combinations(device)
|
||||
num_combinations = combinations.shape[0]
|
||||
start_time = time.time()
|
||||
|
||||
valid_combinations = combinations[check_xor_sum(combinations)]
|
||||
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 %d combinations" %
|
||||
(end_time - start_time, num_combinations))
|
||||
BIN
Illegal_Possession_Images/lab_files/wlan_decrypt/file.xz
Normal file
BIN
Illegal_Possession_Images/lab_files/wlan_decrypt/file.xz
Normal file
Binary file not shown.
26
Illegal_Possession_Images/lab_files/wlan_decrypt/findseed.py
Normal file
26
Illegal_Possession_Images/lab_files/wlan_decrypt/findseed.py
Normal file
@@ -0,0 +1,26 @@
|
||||
# https://www.vnsecurity.net/ctf%20-%20clgt%20crew/
|
||||
# 2015/03/16/codegate-good-crypto.html
|
||||
|
||||
key=[0xa4,0x3d,0xf6,0xf3,0x74]
|
||||
a, c, m = 0x000343fd, 0x269ec3, 0xFFFFFF
|
||||
secret_key_bytes=5
|
||||
|
||||
for seed in range(1<<24):
|
||||
correct = True
|
||||
x = seed
|
||||
|
||||
for i in range(secret_key_bytes):
|
||||
x = (a * x + c) & m
|
||||
# shift 16 bits to right
|
||||
# the same as check the second most significant byte
|
||||
if (x>>16)!=key[i]:
|
||||
correct = False
|
||||
break
|
||||
|
||||
if correct:
|
||||
print("Found it: ", hex(seed))
|
||||
print("Verify: ")
|
||||
|
||||
for i in range(secret_key_bytes):
|
||||
seed = (a* seed + c) & m
|
||||
print(hex(seed>>16),hex(seed))
|
||||
Binary file not shown.
Reference in New Issue
Block a user