Skip to content

Instantly share code, notes, and snippets.

@xct

xct/vimcrypt.py Secret

Created Apr 28, 2019
Embed
What would you like to do?
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