Recently, I watched a video about writing a code to decode the title and contents of the file from decimal numbers into strings. However, it is written in python2 so I decided to rewrite the code in python3. Unfortunately, I am having trouble in decoding the contents of the picture.
This is the original code in python2:
#!/usr/bin/env python
import os
directory = '1262404985085867488371'
def decrypt(number):
return hex(int(number))[2:].replace("L","").decode("hex")
os.chdir(directory)
for i in os.listdir('.'):
try:
print(decrypt(i))
c = open(i).read()
open(decrypt(i),'w').write(decrypt(c))
#o.write(decrypt(c))
except:
print("FAILED WITH",i)
And this is the code written in python3:
#!/usr/bin/env python3
import os
directory = '1262404985085867488371'
def decrypt(number):
hex_num = hex(int(number))[2:].replace("L","")
return bytes.fromhex(hex_num).decode("ascii")
os.chdir(directory)
for i in os.listdir('.'):
try:
print(decrypt(i))
c = open(i).read()
open(decrypt(i),'w').write(decrypt(c))
#o.write(decrypt(c))
except:
print("FAILED WITH",i)
Can anyone help me to have a look how can I solve this problem? This is the problem about:
My computer got infected with ransomware and now none of my documents are accessible anymore! If you help me out, I'll reward you a flag! https://static.tjctf.org/7459b0c272ba30c9fea94391c7d7051d78e1732c871c3a6f27070fcb34f9e734_encrypted.tar.gz
Basically, I have tried by changing the ascii into utf-8 and open the file with the mode in "wb" or "rb" but neither of them works...