Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #/bin/python
- import os
- import binascii
- from Crypto.Cipher import DES
- key = "A858DE45"
- decypt = False
- # https://pythonhosted.org/pycrypto/Crypto.Cipher.DES3-module.html
- # MODE_EBC == Electronic Code Book == 1
- cipher = DES.new(key, 1)
- for fileStr in os.listdir("./posts"):
- f = open("./posts/"+fileStr)
- if fileStr == "allPosts":
- continue
- lines = f.readlines()
- content = lines[-2]
- content = content[:-2]
- decoded = ''
- i = 0
- # Decoding the text...
- if decypt:
- msg = cipher.encrypt(content.replace(" ", ""))
- content = msg.decode(encoding='UTF-8', errors='ignore')
- # Getting the ASCII out of hex
- while i < len(content):
- if content[i] == ' ':
- i += 1
- continue
- try:
- if int(content[i:i+2], 16) < 128:
- decoded += chr(int(content[i:i+2], 16))
- else:
- print("ERROR, not a ascii text file")
- break
- except(ValueError):
- print(fileStr)
- break
- i += 2
- if i == len(content):
- # it got all the way through...
- print(decoded)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement