Skip to content

Instantly share code, notes, and snippets.

@xct

xct/vimcrypt.py Secret

Created April 28, 2019 10:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xct/a5b56b03e8b7a97eb8ec2a5bc67ffa38 to your computer and use it in GitHub Desktop.
Save xct/a5b56b03e8b7a97eb8ec2a5bc67ffa38 to your computer and use it in GitHub Desktop.
Decrypt vulnerable vimcrypt files
# Author nastirth
import sys
import itertools
blocks = []
def xor(s, key):
key = key * (len(s) / len(key) + 1)
return ''.join(chr(ord(x) ^ ord(y)) for (x,y) in itertools.izip(s, key))
with open(sys.argv[1], 'rb') as file:
header = file.read(12)
salt = file.read(8)
iv = file.read(8)
blocks.append(file.read(8))
blocks.append(file.read(8))
blocks.append(file.read(8))
blocks.append(file.read(8))
plain = bytes('rijndael')
key = xor(blocks[0], plain)
plain = plain + xor(blocks[1], key)
plain = plain + xor(blocks[2], key)
plain = plain + xor(blocks[3], key)
print plain
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment