-
-
Save xct/a5b56b03e8b7a97eb8ec2a5bc67ffa38 to your computer and use it in GitHub Desktop.
Decrypt vulnerable vimcrypt files
This file contains 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
# 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