forked from CompassSecurity/BloodHoundQueries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustomqueries.json
345 lines (345 loc) · 14.2 KB
/
customqueries.json
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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
{
"queries": [
{
"name": "All Shortest Paths to Domain (including Computers)",
"queryList": [
{
"final": false,
"title": "Select a Domain...",
"query": "MATCH (d:Domain) RETURN d.name ORDER BY d.name ASC"
},
{
"final": true,
"query": "MATCH p = allShortestPaths((uc)-[r:{}*1..]->(d:Domain {name: $result})) WHERE (uc:User OR uc:Computer) RETURN p",
"endNode": "{}"
}
]
},
{
"name": "All Shortest Paths to no LAPS",
"queryList": [
{
"final": true,
"query": "MATCH p = allShortestPaths((uc)-[r:{}*1..]->(c:Computer)) WHERE (uc:User OR uc:Computer) AND NOT uc = c AND c.haslaps = false RETURN p"
}
]
},
{
"name": "All Shortest Paths from Kerberoastable Users to Computers",
"queryList": [
{
"final": true,
"query": "MATCH p = allShortestPaths((u:User)-[r:{}*1..]->(c:Computer)) WHERE u.hasspn = true RETURN p"
}
]
},
{
"name": "All Shortest Paths from Kerberoastable Users to High Value Targets",
"queryList": [
{
"final": true,
"query": "MATCH p = allShortestPaths((u:User)-[r:{}*1..]->(h)) WHERE u.hasspn = true AND h.highvalue = true RETURN p"
}
]
},
{
"name": "All Shortest Paths from Owned Principals (including everything)",
"queryList": [
{
"final": true,
"query": "MATCH p = allShortestPaths((u:User)-[r:{}*1..]->(a)) WHERE u.owned = true AND u <> a RETURN p"
}
]
},
{
"name": "All Shortest Paths from Owned Principals to Domain",
"queryList": [
{
"final": false,
"title": "Select a Domain...",
"query": "MATCH (d:Domain) RETURN d.name ORDER BY d.name ASC"
},
{
"final": true,
"query": "MATCH p = allShortestPaths((o)-[r:{}*1..]->(d:Domain)) WHERE o.owned = true AND d.name = $result RETURN p",
"endNode": "{}"
}
]
},
{
"name": "All Shortest Paths from Owned Principals to High Value Targets",
"queryList": [
{
"final": true,
"query": "MATCH p = allShortestPaths((o)-[r:{}*1..]->(h)) WHERE o.owned = true AND h.highvalue = true RETURN p"
}
]
},
{
"name": "All Shortest Paths from Owned Principals to no LAPS",
"queryList": [
{
"final": true,
"query": "MATCH p = allShortestPaths((o)-[r:{}*1..]->(c:Computer)) WHERE NOT o = c AND o.owned = true AND c.haslaps = false RETURN p"
}
]
},
{
"name": "All Shortest Paths from no Signing to Domain",
"queryList": [
{
"final": false,
"title": "Select a Domain...",
"query": "MATCH (d:Domain) RETURN d.name ORDER BY d.name ASC"
},
{
"final": true,
"query": "MATCH p = allShortestPaths((c:Computer)-[r:{}*1..]->(d:Domain)) WHERE c.hassigning = false AND d.name = $result RETURN p",
"endNode": "{}"
}
]
},
{
"name": "All Shortest Paths from no Signing to High Value Targets",
"queryList": [
{
"final": true,
"query": "MATCH p = allShortestPaths((c:Computer)-[r:{}*1..]->(h)) WHERE NOT c = h AND c.hassigning = false AND h.highvalue = true RETURN p"
}
]
},
{
"name": "All Shortest Paths from Domain Users and Domain Computers (including everything)",
"queryList": [
{
"final": true,
"query": "MATCH p = allShortestPaths((g:Group)-[r:{}*1..]->(a)) WHERE (g.objectid =~ $domain_users_id OR g.objectid =~ $domain_computers_id) AND g <> a RETURN p",
"props": {
"domain_users_id": "S-1-5-.*-513",
"domain_computers_id": "S-1-5-.*-515"
}
}
]
},
{
"name": "All Unconstrained Delegation Principals (excluding Domain Controllers and Administrators)",
"queryList": [
{
"final": true,
"query": "MATCH (dca)-[r:MemberOf*0..]->(g:Group) WHERE g.objectid =~ $domain_controllers_id OR g.objectid =~ $administrators_id WITH COLLECT(dca) AS exclude MATCH p = (d:Domain)-[r:Contains*1..]->(uc) WHERE (uc:User OR uc:Computer) AND uc.unconstraineddelegation = true AND NOT uc IN exclude RETURN p",
"props": {
"domain_controllers_id": "S-1-5-.*-516",
"administrators_id": ".*-S-1-5-32-544"
}
}
]
},
{
"name": "All Constrained Delegations",
"queryList": [
{
"final": true,
"query": "MATCH p = (a)-[:AllowedToDelegate]->(c:Computer) RETURN p"
}
]
},
{
"name": "All Computers Allowed to Delegate for Another Computer",
"queryList": [
{
"final": true,
"query": "MATCH p = (c1:Computer)-[:AllowedToDelegate]->(c2:Computer) RETURN p"
}
]
},
{
"name": "All ACLs to Computers (excluding High Value Targets)",
"queryList": [
{
"final": true,
"query": "MATCH p = (ucg)-[r]->(c:Computer) WHERE (ucg:User OR ucg:Computer OR ucg:Group) AND ucg.highvalue = false AND r.isacl = true RETURN p"
}
]
},
{
"name": "All Computers in Domain Admins",
"queryList": [
{
"final": false,
"title": "Select a Domain Admins group...",
"query": "MATCH (g:Group) WHERE g.objectid =~ $domain_admins_id RETURN g.name ORDER BY g.name ASC",
"props": {
"domain_admins_id": "S-1-5-.*-512"
}
},
{
"final": true,
"query": "MATCH p = (c:Computer)-[r:MemberOf|HasSIDHistory*1..]->(g:Group) WHERE g.name = $result RETURN p",
"endNode": "{}"
}
]
},
{
"name": "All Computers Local Admin to Another Computer",
"queryList": [
{
"final": true,
"query": "MATCH p = (c1:Computer)-[r1:AdminTo]->(c2:Computer) RETURN p UNION ALL MATCH p = (c3:Computer)-[r2:MemberOf|HasSIDHistory*1..]->(g:Group)-[r3:AdminTo]->(c4:Computer) RETURN p"
}
]
},
{
"name": "All Computers without LAPS",
"queryList": [
{
"final": true,
"query": "MATCH p = (d:Domain)-[r:Contains*1..]->(c:Computer) WHERE c.haslaps = false RETURN p"
}
]
},
{
"name": "All High Value Targets",
"queryList": [
{
"final": true,
"query": "MATCH p = (d:Domain)-[r:Contains*1..]->(h) WHERE h.highvalue = true RETURN p"
}
]
},
{
"name": "All Owned Principals",
"queryList": [
{
"final": true,
"query": "MATCH p = (d:Domain)-[r:Contains*1..]->(o) WHERE o.owned = true RETURN p"
}
]
},
{
"name": "LAPS Passwords Readable by Owned Principals",
"queryList": [
{
"final": true,
"query": "MATCH p = (n {owned: true})-[r1:MemberOf*1..]->(g:Group)-[r2:GenericAll]->(t:Computer {haslaps:true}) RETURN p"
}
]
},
{
"name": "Group Delegated Outbound Object Control of Owned Principals",
"queryList": [
{
"final": true,
"query": "MATCH p = (n {owned: true})-[r1:MemberOf*1..]->(g:Group)-[r2 {isacl: true}]->(t) RETURN p"
}
]
},
{
"name": "Find Dangerous Rights for Groups under Domain Users",
"queryList": [
{
"final": true,
"query": "MATCH p=(m:Group)-[r1:MemberOf*1..]->(g:Group)-[:Owns|WriteDacl|GenericAll|WriteOwner|ExecuteDCOM|GenericWrite|AllowedToDelegate|ForceChangePassword]->(n:Computer) WHERE m.objectid ENDS WITH '-513' RETURN p"
}
]
},
{
"name": "All Users with Password in AD",
"queryList": [
{
"final": true,
"query": "MATCH p = (d:Domain)-[r:Contains*1..]->(u:User) WHERE u.userpassword IS NOT NULL RETURN p"
}
]
},
{
"name": "All Users with \"Pass\" in AD Description",
"queryList": [
{
"final": true,
"query": "MATCH p = (d:Domain)-[r:Contains*1..]->(u:User) WHERE u.description =~ '(?i).*pass.*' RETURN p"
}
]
},
{
"name": "All Users with Password not Required",
"queryList": [
{
"final": true,
"query": "MATCH p = (d:Domain)-[r:Contains*1..]->(u:User) WHERE u.passwordnotreqd = true RETURN p"
}
]
},
{
"name": "All Users with with Same Name in Different Domains",
"queryList": [
{
"final": true,
"query": "MATCH (u1:User),(u2:User) WHERE split(u1.name,'@')[0] = split(u2.name,'@')[0] AND u1.domain <> u2.domain AND tointeger(split(u1.objectid,'-')[7]) >= 1000 RETURN u1"
}
]
},
{
"name": "Set DCSync Principals as High Value Targets",
"queryList": [
{
"final": true,
"query": "MATCH (s)-[r:MemberOf|GetChanges*1..]->(d:Domain) WITH s, d MATCH (s)-[r:MemberOf|GetChangesAll*1..]->(d) WITH s, d MATCH p = (s)-[r:MemberOf|GetChanges|GetChangesAll*1..]->(d) AND a.highvalue = false SET s.highvalue = true, s.highvaluereason = 'DCSync Principal' RETURN p"
}
]
},
{
"name": "Set Unconstrained Delegation Principals as High Value Targets",
"queryList": [
{
"final": true,
"query": "MATCH p = (d:Domain)-[r:Contains*1..]->(uc) WHERE (uc:User OR uc:Computer) AND uc.unconstraineddelegation = true AND a.highvalue = false SET uc.highvalue = true, uc.highvaluereason = 'Unconstrained Delegation Principal' RETURN p"
}
]
},
{
"name": "Set Local Admin or Reset Password Principals as High Value Targets",
"queryList": [
{
"final": true,
"query": "MATCH (a)-[r:AdminTo|ForceChangePassword]->(b) AND a.highvalue = false SET a.highvalue = true, a.highvaluereason = 'Local Admin or Reset Password Principal' RETURN a"
}
]
},
{
"name": "Set Principals with Privileges on Computers as High Value Targets",
"queryList": [
{
"final": true,
"query": "MATCH (a)-[r:AllowedToDelegate|ExecuteDCOM|ForceChangePassword|GenericAll|GenericWrite|Owns|WriteDacl|WriteOwner]->(n:Computer) AND a.highvalue = false SET a.highvalue = true, a.highvaluereason = 'Principal with Privileges on Computers' RETURN a"
}
]
},
{
"name": "Set Principals with Privileges on Cert Publishers as High Value Targets",
"queryList": [
{
"final": true,
"query": "MATCH (a)-[r:GenericAll|GenericWrite|MemberOf|Owns|WriteDacl|WriteOwner]->(g:Group) WHERE g.objectid =~ 'S-1-5-21-.*-517' AND a.highvalue = false SET a.highvalue = true, a.highvaluereason = 'Principal with Privileges on the Cert Publisher group' RETURN a"
}
]
},
{
"name": "Set Members of High Value Targets Groups as High Value Targets",
"queryList": [
{
"final": true,
"query": "MATCH (a)-[r:MemberOf*1..]->(g:Group) WHERE a.highvalue = false AND g.highvalue = true SET a.highvalue = true, a.highvaluereason = 'Member of High Value Target Group' RETURN a"
}
]
},
{
"name": "Remove Inactive Users and Computers from High Value Targets",
"queryList": [
{
"final": true,
"query": "MATCH (uc) WHERE uc.highvalue = true AND ((uc:User AND uc.enabled = false) OR (uc:Computer AND ((uc.enabled = false) OR (uc.lastlogon > 0 AND uc.lastlogon < (TIMESTAMP() / 1000 - 15552000)) OR (uc.lastlogontimestamp > 0 AND uc.lastlogontimestamp < (TIMESTAMP() / 1000 - 15552000))))) SET uc.highvalue = false, uc.nothighvaluereason = 'Inactive' RETURN uc"
}
]
}
]
}