Last active
September 15, 2023 14:06
-
-
Save mtask/5bba6a10a508715ede06aa94afb5f2bb to your computer and use it in GitHub Desktop.
stuff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import itertools | |
RES = [] | |
def xor(var, key): | |
return bytes(a ^ b for a, b in zip(var, key)) | |
def xorbyte(b): | |
r = [] | |
for n in range(0, 256): | |
x = hex(n).replace("0x", "") | |
if len(x) < 2: | |
x = "0"+x | |
key = bytes.fromhex(x) | |
try: | |
res = xor(b, key).decode('utf-8') | |
if re.match('[ -~]', res): | |
r.append(res) | |
except UnicodeDecodeError: | |
pass | |
return r | |
with open("test.txt.enc", "rb") as f: | |
while (b := f.read(1)): | |
r = xorbyte(b) | |
if r: | |
RES.append(r) | |
for i in itertools.product(*RES): | |
print(''.join(i)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment