-
Notifications
You must be signed in to change notification settings - Fork 20
/
INFO_Macho_Scripting_Execution.yar
282 lines (256 loc) · 8.94 KB
/
INFO_Macho_Scripting_Execution.yar
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
rule INFO_Macho_Hunting_Osascript
{
meta:
author = "Greg Lesnewich"
description = "checking Macho files for potential scripting interfaces like osascript"
reference = "https://speakerdeck.com/heirhabarov/hunting-for-macos-attack-techniques-part-1-initial-access-execution-credential-access-persistence?slide=31"
date = "2024-01-10"
version = "1.0"
DaysofYARA = "11/100"
strings:
$ = "osascript" nocase ascii wide
$ = "osacompile" nocase ascii wide
$ = ".scpt" nocase ascii wide
condition:
(
uint32(0) == 0xfeedface or // Mach-O MH_MAGIC
uint32(0) == 0xcefaedfe or // Mach-O MH_CIGAM
uint32(0) == 0xfeedfacf or // Mach-O MH_MAGIC_64
uint32(0) == 0xcffaedfe or // Mach-O MH_CIGAM_64
uint32(0) == 0xcafebabe or // Mach-O FAT_MAGIC
uint32(0) == 0xbebafeca // Mach-O FAT_CIGAM
) and any of them
}
rule INFO_Macho_Hunting_AppleScript_URL
{
meta:
author = "Greg Lesnewich"
description = "checking Macho files for potential scripting interfaces like AppleScript"
reference = "https://speakerdeck.com/heirhabarov/hunting-for-macos-attack-techniques-part-1-initial-access-execution-credential-access-persistence?slide=31"
date = "2024-01-10"
version = "1.0"
DaysofYARA = "11/100"
strings:
$ = "applescript://" nocase ascii wide
condition:
(
uint32(0) == 0xfeedface or // Mach-O MH_MAGIC
uint32(0) == 0xcefaedfe or // Mach-O MH_CIGAM
uint32(0) == 0xfeedfacf or // Mach-O MH_MAGIC_64
uint32(0) == 0xcffaedfe or // Mach-O MH_CIGAM_64
uint32(0) == 0xcafebabe or // Mach-O FAT_MAGIC
uint32(0) == 0xbebafeca // Mach-O FAT_CIGAM
) and any of them
}
rule INFO_Macho_Hunting_Python
{
meta:
author = "Greg Lesnewich"
description = "checking Macho files for additional execution strings like python"
reference = "https://speakerdeck.com/heirhabarov/hunting-for-macos-attack-techniques-part-1-initial-access-execution-credential-access-persistence?slide=31"
date = "2024-01-10"
version = "1.0"
DaysofYARA = "11/100"
strings:
$str = "python" nocase ascii wide
condition:
(
uint32(0) == 0xfeedface or // Mach-O MH_MAGIC
uint32(0) == 0xcefaedfe or // Mach-O MH_CIGAM
uint32(0) == 0xfeedfacf or // Mach-O MH_MAGIC_64
uint32(0) == 0xcffaedfe or // Mach-O MH_CIGAM_64
uint32(0) == 0xcafebabe or // Mach-O FAT_MAGIC
uint32(0) == 0xbebafeca // Mach-O FAT_CIGAM
) and all of them
}
rule INFO_Macho_Hunting_Ruby
{
meta:
author = "Greg Lesnewich"
description = "checking Macho files for additional execution strings like Ruby"
date = "2024-01-10"
version = "1.0"
DaysofYARA = "11/100"
reference = "https://speakerdeck.com/heirhabarov/hunting-for-macos-attack-techniques-part-1-initial-access-execution-credential-access-persistence?slide=31"
strings:
$str = "Ruby" nocase ascii wide
condition:
(
uint32(0) == 0xfeedface or // Mach-O MH_MAGIC
uint32(0) == 0xcefaedfe or // Mach-O MH_CIGAM
uint32(0) == 0xfeedfacf or // Mach-O MH_MAGIC_64
uint32(0) == 0xcffaedfe or // Mach-O MH_CIGAM_64
uint32(0) == 0xcafebabe or // Mach-O FAT_MAGIC
uint32(0) == 0xbebafeca // Mach-O FAT_CIGAM
) and all of them
}
rule INFO_Macho_Hunting_Perl
{
meta:
author = "Greg Lesnewich"
description = "checking Macho files for additional execution strings like perl"
date = "2024-01-10"
version = "1.0"
DaysofYARA = "11/100"
reference = "https://speakerdeck.com/heirhabarov/hunting-for-macos-attack-techniques-part-1-initial-access-execution-credential-access-persistence?slide=31"
strings:
$str = "perl" nocase ascii wide
condition:
(
uint32(0) == 0xfeedface or // Mach-O MH_MAGIC
uint32(0) == 0xcefaedfe or // Mach-O MH_CIGAM
uint32(0) == 0xfeedfacf or // Mach-O MH_MAGIC_64
uint32(0) == 0xcffaedfe or // Mach-O MH_CIGAM_64
uint32(0) == 0xcafebabe or // Mach-O FAT_MAGIC
uint32(0) == 0xbebafeca // Mach-O FAT_CIGAM
) and all of them
}
rule INFO_Macho_Execution_BinBash
{
meta:
author = "Greg Lesnewich"
date = "2023-02-01"
version = "1.0"
DaysofYARA = "11/100"
description = "checking Macho files for additional execution strings like bash shell"
reference = "https://speakerdeck.com/heirhabarov/hunting-for-macos-attack-techniques-part-1-initial-access-execution-credential-access-persistence?slide=31"
strings:
$ = "bin/bash" ascii wide
condition:
(
uint32(0) == 0xfeedface or // Mach-O MH_MAGIC
uint32(0) == 0xcefaedfe or // Mach-O MH_CIGAM
uint32(0) == 0xfeedfacf or // Mach-O MH_MAGIC_64
uint32(0) == 0xcffaedfe or // Mach-O MH_CIGAM_64
uint32(0) == 0xcafebabe or // Mach-O FAT_MAGIC
uint32(0) == 0xbebafeca // Mach-O FAT_CIGAM
)
and all of them
}
rule INFO_Macho_Execution_Bin_sh
{
meta:
author = "Greg Lesnewich"
date = "2023-02-01"
version = "1.0"
DaysofYARA = "11/100"
description = "checking Macho files for additional execution strings like sh shell"
reference = "https://speakerdeck.com/heirhabarov/hunting-for-macos-attack-techniques-part-1-initial-access-execution-credential-access-persistence?slide=31"
strings:
$ = "bin/sh" ascii wide
condition:
(
uint32(0) == 0xfeedface or // Mach-O MH_MAGIC
uint32(0) == 0xcefaedfe or // Mach-O MH_CIGAM
uint32(0) == 0xfeedfacf or // Mach-O MH_MAGIC_64
uint32(0) == 0xcffaedfe or // Mach-O MH_CIGAM_64
uint32(0) == 0xcafebabe or // Mach-O FAT_MAGIC
uint32(0) == 0xbebafeca // Mach-O FAT_CIGAM
) and all of them
}
rule INFO_Macho_Execution_BinZsh
{
meta:
author = "Greg Lesnewich"
date = "2023-02-01"
version = "1.0"
DaysofYARA = "11/100"
description = "checking Macho files for additional execution strings like zsh shell"
reference = "https://speakerdeck.com/heirhabarov/hunting-for-macos-attack-techniques-part-1-initial-access-execution-credential-access-persistence?slide=31"
strings:
$ = "bin/zsh" ascii wide
condition:
(
uint32(0) == 0xfeedface or // Mach-O MH_MAGIC
uint32(0) == 0xcefaedfe or // Mach-O MH_CIGAM
uint32(0) == 0xfeedfacf or // Mach-O MH_MAGIC_64
uint32(0) == 0xcffaedfe or // Mach-O MH_CIGAM_64
uint32(0) == 0xcafebabe or // Mach-O FAT_MAGIC
uint32(0) == 0xbebafeca // Mach-O FAT_CIGAM
) and all of them
}
rule INFO_Macho_Execution_Bin_tcsh
{
meta:
author = "Greg Lesnewich"
date = "2023-02-01"
version = "1.0"
DaysofYARA = "11/100"
description = "checking Macho files for additional execution strings like tcsh shell"
reference = "https://speakerdeck.com/heirhabarov/hunting-for-macos-attack-techniques-part-1-initial-access-execution-credential-access-persistence?slide=31"
strings:
$ = "bin/tcsh" ascii wide
condition:
(
uint32(0) == 0xfeedface or // Mach-O MH_MAGIC
uint32(0) == 0xcefaedfe or // Mach-O MH_CIGAM
uint32(0) == 0xfeedfacf or // Mach-O MH_MAGIC_64
uint32(0) == 0xcffaedfe or // Mach-O MH_CIGAM_64
uint32(0) == 0xcafebabe or // Mach-O FAT_MAGIC
uint32(0) == 0xbebafeca // Mach-O FAT_CIGAM
) and all of them
}
rule INFO_Macho_Execution_BinKsh
{
meta:
author = "Greg Lesnewich"
date = "2023-02-01"
version = "1.0"
DaysofYARA = "11/100"
description = "checking Macho files for additional execution strings like ksh shell"
reference = "https://speakerdeck.com/heirhabarov/hunting-for-macos-attack-techniques-part-1-initial-access-execution-credential-access-persistence?slide=31"
strings:
$ = "bin/ksh" ascii wide
condition:
(
uint32(0) == 0xfeedface or // Mach-O MH_MAGIC
uint32(0) == 0xcefaedfe or // Mach-O MH_CIGAM
uint32(0) == 0xfeedfacf or // Mach-O MH_MAGIC_64
uint32(0) == 0xcffaedfe or // Mach-O MH_CIGAM_64
uint32(0) == 0xcafebabe or // Mach-O FAT_MAGIC
uint32(0) == 0xbebafeca // Mach-O FAT_CIGAM
) and all of them
}
rule INFO_Macho_Execution_Bincsh
{
meta:
author = "Greg Lesnewich"
date = "2023-02-01"
version = "1.0"
DaysofYARA = "11/100"
description = "checking Macho files for additional execution strings like csh shell"
reference = "https://speakerdeck.com/heirhabarov/hunting-for-macos-attack-techniques-part-1-initial-access-execution-credential-access-persistence?slide=31"
strings:
$ = "bin/csh" ascii wide
condition:
(
uint32(0) == 0xfeedface or // Mach-O MH_MAGIC
uint32(0) == 0xcefaedfe or // Mach-O MH_CIGAM
uint32(0) == 0xfeedfacf or // Mach-O MH_MAGIC_64
uint32(0) == 0xcffaedfe or // Mach-O MH_CIGAM_64
uint32(0) == 0xcafebabe or // Mach-O FAT_MAGIC
uint32(0) == 0xbebafeca // Mach-O FAT_CIGAM
) and all of them
}
rule INFO_Macho_Execution_tclsh
{
meta:
author = "Greg Lesnewich"
date = "2023-02-01"
version = "1.0"
DaysofYARA = "11/100"
description = "checking Macho files for additional execution strings like tclsh shell"
reference = "https://speakerdeck.com/heirhabarov/hunting-for-macos-attack-techniques-part-1-initial-access-execution-credential-access-persistence?slide=31"
strings:
$ = "usr/bin/tclsh" ascii wide
$ = "bin/tclsh" ascii wide
condition:
(
uint32(0) == 0xfeedface or // Mach-O MH_MAGIC
uint32(0) == 0xcefaedfe or // Mach-O MH_CIGAM
uint32(0) == 0xfeedfacf or // Mach-O MH_MAGIC_64
uint32(0) == 0xcffaedfe or // Mach-O MH_CIGAM_64
uint32(0) == 0xcafebabe or // Mach-O FAT_MAGIC
uint32(0) == 0xbebafeca // Mach-O FAT_CIGAM
) and all of them
}