-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathoffice_rtf.py
181 lines (155 loc) · 6.3 KB
/
office_rtf.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# Copyright (C) 2018 Kevin Ross
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from lib.cuckoo.common.abstracts import Signature
class RTFEmbeddedContent(Signature):
name = "rtf_embedded_content"
description = "The RTF file contains embedded content"
severity = 1
confidence = 100
categories = ["office", "static"]
authors = ["Kevin Ross"]
minimum = "1.3"
evented = True
ttps = ["T1137"] # MITRE v6,7,8
def run(self):
ret = False
if "static" in self.results and "office_rtf" in self.results["static"]:
for key in self.results["static"]["office_rtf"]:
for block in self.results["static"]["office_rtf"][key]:
if "type_embed" in block:
index = block["index"]
classname = block["class_name"]
size = block["size"]
self.data.append(
{
"embedded content": "Object %s index %s contains embedded object %s with size %s bytes"
% (key, index, classname, size)
}
)
ret = True
return ret
class RTFExploitStatic(Signature):
name = "rtf_exploit_static"
description = "The RTF file contains an object with potential exploit code"
severity = 3
confidence = 100
categories = ["exploit", "office", "static"]
authors = ["Kevin Ross"]
minimum = "1.3"
evented = True
ttps = ["T1137", "T1203"] # MITRE v6,7,8
mbcs = ["OB0009", "E1203"]
def run(self):
ret = False
if "static" in self.results and "office_rtf" in self.results["static"]:
for key in self.results["static"]["office_rtf"]:
for block in self.results["static"]["office_rtf"][key]:
if "CVE" in block:
index = block["index"]
cve = block["CVE"]
if cve:
self.data.append({"cve": "Object %s index %s contains %s" % (key, index, cve)})
ret = True
return ret
class RTFEmbeddedOfficeFile(Signature):
name = "rtf_embedded_office_file"
description = (
"The RTF file contains an embedded Office file potentially to display as a decoy document during malicious activities"
)
severity = 2
confidence = 100
categories = ["office", "static"]
authors = ["Kevin Ross"]
minimum = "1.3"
evented = True
ttps = ["T1137"] # MITRE v6,7,8
mbcs = ["OC0001", "C0016", "C0016.001"] # micro-behaviour
def run(self):
ret = False
if "static" in self.results and "office_rtf" in self.results["static"]:
for key in self.results["static"]["office_rtf"]:
for block in self.results["static"]["office_rtf"][key]:
if "class_name" in block:
if "Word.Document." in block["class_name"]:
index = block["index"]
self.data.append(
{"office file": "Object %s index %s contains an embedded office document" % (key, index)}
)
ret = True
return ret
class RTFASLRBypass(Signature):
name = "rtf_aslr_bypass"
description = "The RTF file contains a potential ASLR bypass"
severity = 3
confidence = 50
categories = ["office", "static", "exploit"]
authors = ["Kevin Ross"]
minimum = "1.3"
evented = True
ttps = ["T1137", "T1203"] # MITRE v6,7,8
mbcs = ["OB0009", "E1203"]
def run(self):
aslrbypass = [
"otkloadr.wrassembly.1",
"otkloadr.wrloader.1",
]
ret = False
if "static" in self.results and "office_rtf" in self.results["static"]:
for key in self.results["static"]["office_rtf"]:
for block in self.results["static"]["office_rtf"][key]:
if "class_name" in block:
for bypass in aslrbypass:
classname = block["class_name"]
index = block["index"]
if bypass in classname.lower():
self.data.append(
{"aslr bypass": "Object %s index %s contains possible ASLR bypass %s" % (key, index, classname)}
)
ret = True
return ret
class RTFAnomalyCharacterSet(Signature):
name = "rtf_anomaly_characterset"
description = "The RTF file has an unknown character set"
severity = 2
confidence = 100
categories = ["office", "static"]
authors = ["Kevin Ross"]
minimum = "1.3"
evented = True
ttps = ["T1137"] # MITRE v6,7,8
def run(self):
ret = False
if "file" in self.results.get("target", {}):
filetype = self.results["target"]["file"].get("type", "")
if "Rich Text Format" in filetype and "unknown character set" in filetype:
ret = True
return ret
class RTFAnomalyVersion(Signature):
name = "rtf_anomaly_version"
description = "The RTF file has an unknown version"
severity = 2
confidence = 100
categories = ["office", "static"]
authors = ["Kevin Ross"]
minimum = "1.3"
evented = True
ttps = ["T1137"] # MITRE v6,7,8
def run(self):
ret = False
if "file" in self.results.get("target", {}):
filetype = self.results["target"]["file"].get("type", "")
if "Rich Text Format" in filetype and "unknown version" in filetype:
ret = True
return ret