-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgen_result.py
More file actions
executable file
·39 lines (32 loc) · 949 Bytes
/
Copy pathgen_result.py
File metadata and controls
executable file
·39 lines (32 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/python3
import hashlib
def main():
# Generate stub
file = open("self_md5", "rb").read()
data = bytes()
for i in range(32):
for j in range(4):
data += open(f"digits/number{i}/bit{j}_0", "rb").read()
file = replace(file, data)
# Calculate the hash of stub
md5 = hashlib.md5()
md5.update(file)
digest = md5.hexdigest()
# Generate the real file
data = bytes()
for i in range(32):
md5_digit = int(digest[i], base=16)
for j in range(4):
bit = md5_digit % 2
md5_digit //= 2
data += open(f"digits/number{i}/bit{j}_{bit}", "rb").read()
file = replace(file, data)
# Write the file
open("result", "wb").write(file)
def replace(array1, array2):
array1 = list(array1)
for i in range(len(array2)):
array1[8256 + i] = array2[i]
return bytes(array1)
if __name__ == "__main__":
main()