-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlast.py
237 lines (185 loc) · 7.17 KB
/
last.py
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# # import hashlib
# # import base64
# # import binascii
# # def custom_reduce(funcs, inputs, initial):
# # result = initial
# # for func, inp in zip(funcs, inputs):
# # result = func(result, inp)
# # return result
# # def custom_transformations(input_str):
# # c1 = "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm"
# # c2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
# # n1 = [5, 6, 7, 8, 9, 0, 1, 2, 3, 4]
# # n2 = "0123456789"
# # transformations = [
# # # Various string transformations
# # lambda s: s.split(c)[0],
# # lambda s: ''.join([c1[c2.index(ch)] if ch in c2 else ch for ch in s]),
# # lambda s: s[0:4],
# # lambda s: s.encode('utf-8').hex(),
# # lambda s: s.replace('-', ''),
# # ]
# # for transform in transformations:
# # input_str = transform(input_str)
# # return input_str
# # def check_credentials(username, password):
# # # Actual decryption logic from the challenge
# # challenges = [
# # [lambda x: x.split(), len],
# # [lambda x: [(-1 if ch in ['n','q','z','v','a'] else ch) for ch in x], lambda x: x],
# # [lambda x: x[0:4], len],
# # [lambda x: x.encode('utf-8'), ord],
# # ]
# # # Perform custom reduce operations
# # for challenge in challenges:
# # try:
# # result = custom_reduce(challenge[0], challenge[1:], password)
# # if not result:
# # return False
# # except:
# # return False
# # # SHA-256 verification
# # password_hash = hashlib.sha256(password.encode()).digest()
# # expected_hash = bytes([9,87,39,96,151,202,140,186,120,235,167,229,47,231,6,212,77,205,58,14,248,104,169,79,116,140,236,98,126,26,100,120])
# # return password_hash == expected_hash
# # def main():
# # # Decode username and password using custom transformations
# # username = custom_transformations("Aurion Flux")
# # password = custom_transformations("1")
# # if check_credentials(username, password):
# # print("Credentials Verified!")
# # # Add flag retrieval logic here
# # else:
# # print("Access Denied")
# # if __name__ == "__main__":
# # main()
# import hashlib
# import itertools
# import string
# def generate_passwords():
# # Base characters for generating passwords
# chars = string.ascii_letters + string.digits + '!@#$%^&*()_+'
# # Generate sequential and pattern-based passwords
# password_patterns = [
# # Specific pattern passwords
# "ncrnt{CellM@nagerAccess%d}",
# "SpacePrison%d!",
# "Access%dControl!",
# "Prison2024%d!",
# # More complex patterns
# "Warden%d2024!",
# "Guard%dAccess!",
# "Security%dCode!",
# ]
# # Sequential number ranges to try
# number_ranges = [
# range(0, 100),
# range(2020, 2025),
# range(1, 10),
# range(100, 1000)
# ]
# for pattern in password_patterns:
# for num_range in number_ranges:
# for num in num_range:
# yield pattern % num
# def decrypt_credentials():
# # Prisoner names from the HTML
# usernames = [
# # Full names
# "Aurion Flux",
# "Zyra Talon",
# "Kryon Vale",
# "Vex Drakon",
# "Nyx Solaris",
# "Lazari Void",
# "Kael Xypher",
# "Cypher Lux",
# "Dax Zenith",
# "Lyra Quasar",
# # First names
# "Aurion", "Zyra", "Kryon", "Vex", "Nyx",
# "Lazari", "Kael", "Cypher", "Dax", "Lyra",
# # Last names
# "Flux", "Talon", "Vale", "Drakon", "Solaris",
# "Void", "Xypher", "Lux", "Zenith", "Quasar",
# # Variations
# "Warden", "Guard", "Admin", "SpacePrison"
# ]
# # Expected SHA-256 hash
# expected_hash = bytes([9,87,39,96,151,202,140,186,120,235,167,229,47,231,6,212,77,205,58,14,248,104,169,79,116,140,236,98,126,26,100,120])
# # Iterate through usernames and passwords
# for username in usernames:
# for password in generate_passwords():
# try:
# # Compute SHA-256 hash of the password
# password_hash = hashlib.sha256(password.encode()).digest()
# # Check if hash matches
# if password_hash == expected_hash:
# print("Credentials Found:")
# print(f"Username: {username}")
# print(f"Password: {password}")
# return username, password
# except Exception as e:
# # Skip any encoding errors
# continue
# print("No valid credentials found.")
# return None
# def main():
# decrypt_credentials()
# if __name__ == "__main__":
# main()
import hashlib
import itertools
def custom_transform(username, access_code):
c1 = "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm"
c2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
n1 = [5, 6, 7, 8, 9, 0, 1, 2, 3, 4]
n2 = "0123456789"
# Combine username and access code for transformation
combined = username + access_code
# Perform transformations similar to original JS code
def transform_step(s):
# Character substitution
s = ''.join([c1[c2.index(ch)] if ch in c2 else ch for ch in s])
# Slice and modify
s = s[:4]
# Additional transformations
s = s.encode('utf-8').hex()
s = s.replace('-', '')
return s
return transform_step(combined)
def decrypt_credentials():
# Full prisoner names from the HTML
usernames = [
"Aurion Flux", "Zyra Talon", "Kryon Vale", "Vex Drakon",
"Nyx Solaris", "Lazari Void", "Kael Xypher", "Cypher Lux",
"Dax Zenith", "Lyra Quasar"
]
# Expected SHA-256 hash
expected_hash = bytes([9,87,39,96,151,202,140,186,120,235,167,229,47,231,6,212,77,205,58,14,248,104,169,79,116,140,236,98,126,26,100,120])
# Try access codes from 1 to 1000
for access_code in range(1, 1001):
for username in usernames:
try:
# Convert access code to string
access_code_str = str(access_code)
# Apply transformations
transformed = custom_transform(username, access_code_str)
# Compute SHA-256 hash of the transformed string
password_hash = hashlib.sha256(transformed.encode()).digest()
# Check if hash matches
if password_hash == expected_hash:
print("Credentials Found:")
print(f"Username: {username}")
print(f"Access Code: {access_code_str}")
print(f"Transformed: {transformed}")
return username, access_code_str
except Exception as e:
# Skip any errors
continue
print("No valid credentials found.")
return None
def main():
decrypt_credentials()
if __name__ == "__main__":
main()