ibibek commited on
Commit
720ee15
·
1 Parent(s): 81fdaa9

Upload 26 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ data/chroma.sqlite3 filter=lfs diff=lfs merge=lfs -text
37
+ docs/EngageHandbook-v1.0.pdf filter=lfs diff=lfs merge=lfs -text
Home.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ st.set_page_config(
4
+ page_title="Adversary Engagement Ontology",
5
+ page_icon='🕷',
6
+ layout='wide'
7
+ )
8
+ st.header("Adversary Engagement Ontology")
9
+
10
+ st.write("Adversary Engagement Ontology (AEO) is a candidate ontology to the Unified Cyber Ontology (UCO), a community effort for the ontological standardization of cyber domain concepts and objects under a unifying framework, and is part of the Cyber Domain Ontology (CDO). Community efforts and development has always been manual labor intensive in regards to ontology changes, ontology example generation for adopters, documentation generation. Large Language Models (LLMs) have been shown to be capable of automating many tasks or aiding in human expert decision-making. We demonstrate how foundational LLMs such as ChatGPT and GPT4 can assist in ontology example generation, ontology development, and overall be used in automation tooling for structured but tedious tasks. This space can be used to create an example of how to setup the AEO instance. It uses the power of OpenAI's ChatGPT. The generator currently uses strictly prewritten rules of AEO, discussion on an automation process is still early . he generator currently is bounded by prompt size limits.")
11
+
12
+ st.write("There are different pages in this space which you can use to generate examples, personas, honey tokens, and also create an auto engagement strategy")
__init__.py ADDED
File without changes
__pycache__/__init__.cpython-311.pyc ADDED
Binary file (191 Bytes). View file
 
__pycache__/__init__.cpython-39.pyc ADDED
Binary file (146 Bytes). View file
 
__pycache__/aeo_example_generator.cpython-311.pyc ADDED
Binary file (24.1 kB). View file
 
__pycache__/aeo_example_generator.cpython-39.pyc ADDED
Binary file (17.3 kB). View file
 
aeo_ex_generator/__init__.py ADDED
File without changes
aeo_ex_generator/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (191 Bytes). View file
 
aeo_ex_generator/__pycache__/__init__.cpython-39.pyc ADDED
Binary file (146 Bytes). View file
 
aeo_ex_generator/__pycache__/aeo_example_generator.cpython-311.pyc ADDED
Binary file (24.1 kB). View file
 
aeo_ex_generator/__pycache__/aeo_example_generator.cpython-39.pyc ADDED
Binary file (17.3 kB). View file
 
aeo_ex_generator/aeo_example_generator.py ADDED
@@ -0,0 +1,456 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import openai
3
+ import json
4
+ import rdflib
5
+
6
+
7
+ class ExampleGenerator:
8
+ def __init__(self):
9
+ self.ontologies = {}
10
+ self.ontology_files = []
11
+ self.rules = {}
12
+ def add_ontology(self, onto):
13
+ if onto in self.ontology_files:
14
+ raise ValueError("Ontology file already exists.")
15
+ else:
16
+ onto_data = self.get_ontology_file(onto)
17
+ if onto_data:
18
+ self.ontology_files.append(onto)
19
+ self.ontologies[onto] = self.get_ontology_file(onto)
20
+ self.rules[onto] = self.generate_rules(onto)
21
+ else:
22
+ raise ValueError("Ontology file error.")
23
+ def get_ontology_file(self,filename):
24
+ text = ""
25
+ if os.path.isfile(filename):
26
+ with open(filename,'r') as f:
27
+ text = f.read()
28
+ f.close()
29
+ return text
30
+ else:
31
+ raise ValueError("Invalid filename.")
32
+ def ChatGPTTextSplitter(self,text):
33
+ """Splits text in smaller subblocks to feed to the LLM"""
34
+ prompt = f"""The total length of content that I want to send you is too large to send in only one piece.
35
+
36
+ For sending you that content, I will follow this rule:
37
+
38
+ [START PART 1/10]
39
+ this is the content of the part 1 out of 10 in total
40
+ [END PART 1/10]
41
+
42
+ Then you just answer: "Instructions Sent."
43
+
44
+ And when I tell you "ALL PARTS SENT", then you can continue processing the data and answering my requests.
45
+ """
46
+ if type(text) == str:
47
+ textsize = 12000
48
+ blocksize = int(len(text) / textsize)
49
+ if blocksize > 0:
50
+ yield prompt
51
+
52
+ for b in range(1,blocksize+1):
53
+ if b < blocksize+1:
54
+ prompt = f"""Do not answer yet. This is just another part of the text I want to send you. Just receive and acknowledge as "Part {b}/{blocksize} received" and wait for the next part.
55
+ [START PART {b}/{blocksize}]
56
+ {text[(b-1)*textsize:b*textsize]}
57
+ [END PART {b}/{blocksize}]
58
+ Remember not answering yet. Just acknowledge you received this part with the message "Part {b}/{blocksize} received" and wait for the next part.
59
+ """
60
+ yield prompt
61
+ else:
62
+ prompt = f"""
63
+ [START PART {b}/{blocksize}]
64
+ {text[(b-1)*textsize:b*textsize]}
65
+ [END PART {b}/{blocksize}]
66
+ ALL PARTS SENT. Now you can continue processing the request.
67
+ """
68
+ yield prompt
69
+ else:
70
+ yield text
71
+ elif type(text) == list:
72
+ yield prompt
73
+
74
+ for n,block in enumerate(text):
75
+ if n+1 < len(text):
76
+ prompt = f"""Do not answer yet. This is just another part of the text I want to send you. Just receive and acknowledge as "Part {n+1}/{len(text)} received" and wait for the next part.
77
+ [START PART {n+1}/{len(text)}]
78
+ {text[n]}
79
+ [END PART {n+1}/{len(text)}]
80
+ Remember not answering yet. Just acknowledge you received this part with the message "Part {n+1}/{len(text)} received" and wait for the next part.
81
+ """
82
+ yield prompt
83
+ else:
84
+ prompt = f"""
85
+ [START PART {n+1}/{len(text)}]
86
+ {text[n]}
87
+ [END PART {n+1}/{len(text)}]
88
+ ALL PARTS SENT. Now you can continue processing the request.
89
+ """
90
+ yield prompt
91
+
92
+ def send_ontology(self):
93
+ ontology = ""
94
+ if len(self.ontologies) > 0:
95
+ for k,v in self.ontologies.items():
96
+ ontology+=v+"\n"
97
+ print("Sending Ontology in Parts")
98
+ for i in self.ChatGPTTextSplitter(ontology):
99
+ print(self.llm_api(i))
100
+ else:
101
+ raise ValueError("No loaded ontology to send.")
102
+ def llm_api(self,prompt,model="gpt-3.5-turbo"):
103
+ messages = [{
104
+ "role":"user",
105
+ "content":prompt
106
+ }]
107
+ res = openai.ChatCompletion.create(model=model,messages=messages,temperature=0)
108
+ return res.choices[0].message['content']
109
+
110
+ def generate_rules(self,onto=None):
111
+ engagement_actions = ['engagement:Access',
112
+ 'engagement:Alert',
113
+ 'engagement:Beacon',
114
+ 'engagement:Deploy',
115
+ 'engagement:Obfuscate',
116
+ 'engagement:Respond'
117
+ ]
118
+ engagement_objects = [
119
+ 'engagement:Honeypot',
120
+ 'engagement:Honeytoken',
121
+ 'engagement:Breadcrumb',
122
+ 'engagement:BreadcrumbTrail',
123
+ 'engagement:LureObject',
124
+ 'engagement:HoneyObject',
125
+ 'engagement:Decoy',
126
+ 'engagement:DataSource'
127
+ ]
128
+ engagement_objectives = [
129
+ 'objective:CommandAndControl',
130
+ 'objective:CredentialAccess',
131
+ 'objective:DevelopResource',
132
+ 'objective:Discover',
133
+ 'objective:EscalatePrivilege',
134
+ 'objective:Evade',
135
+ 'objective:Execute',
136
+ 'objective:Exfilitrate',
137
+ 'objective:GainInitialAccess',
138
+ 'objective:Impact',
139
+ 'objective:MoveLaterally',
140
+ 'objective:Persist',
141
+ 'objective:Reconnaissance',
142
+ 'objective:Affect',
143
+ 'objective:Collect',
144
+ 'objective:Detect',
145
+ 'objective:Direct',
146
+ 'objective:Disrupt',
147
+ 'objective:Elicit',
148
+ 'objective:Expose',
149
+ 'objective:Motivate',
150
+ 'objective:Plan',
151
+ 'objective:Prepare',
152
+ 'objective:Prevent',
153
+ 'objective:Reassure',
154
+ 'objective:Analyze',
155
+ 'objective:Deny',
156
+ 'objective:ElicitBehavior',
157
+ 'objective:Lure',
158
+ 'objective:TimeSink',
159
+ 'objective:Track',
160
+ 'objective:Trap'
161
+ ]
162
+ prefix_ns = {"engagement": "https://ontology.adversaryengagement.org/ae/engagement#",
163
+ "objective":"https://ontology.adversaryengagement.org/ae/objective#",
164
+ "role":"https://ontology.adversaryengagement.org/ae/role#",
165
+ "identity":"https://ontology.adversaryengagement.org/ae/identity#",
166
+ "uco-core prefix":"https://ontology.unifiedcyberontology.org/uco/core#",
167
+ "uco-types":"https://ontology.unifiedcyberontology.org/uco/types#",
168
+ "uco-role":"https://ontology.unifiedcyberontology.org/uco/role#"
169
+ }
170
+ ns_str =""
171
+ for k,v in prefix_ns.items():
172
+ ns_str+=f"If namespace {k} prefix is used then {v}\n"
173
+ lookup = {"1":{"0":['Each'],
174
+ "1":['connects to']
175
+ }
176
+ }
177
+ v = """Remember make a json-ld format example that only uses classes and properties terms from Adversary Engagement Ontology, Unified Cyber Ontology."""
178
+
179
+ structure = {'engagement:Narrative':{'engagement:hasStoryline':{"1":'engagement:Storyline'}
180
+ },
181
+ 'engagement:Storyline':{'engagement:hasEvent':{"1":'uco-types:Thread'}
182
+ },
183
+ 'uco-types:Thread':{'co:element':'contains all engagement:PlannedEvents',
184
+ 'co:item':{"0":'uco-types:ThreadItem one each for each engagement:PlannedEvent'},
185
+ 'co:size':"",
186
+ 'uco-types:threadOriginItem':"is the uco-types:ThreadItem for the first engagement:PlannedEvent",
187
+ 'uco-types:threadTerminalItem':"is the uco-types:ThreadItem for the last engagement:PlannedEvent"
188
+ },
189
+ 'co:size':{'@type':'is xsd:nonNegativeInteger',
190
+ '@value':"which is the number of uco-types:ThreadItem"
191
+ },
192
+ 'uco-types:ThreadItem':{'co:itemContent':'is the engagement:PlannedEvent',
193
+ 'optional uco-types:threadNextItem':"is the next uco-types:ThreadItem for the next engagement:PlannedEvent if there is one",
194
+ 'optional uco-types:threadPreviousItem':'is the previous uco-types:ThreadItem for the previous'
195
+ },
196
+ 'engagement:PlannedEvent':{'engagement:eventContext':"connects to one of the following engagement actions:"+"\n\t\t"+"\n\t\t".join(engagement_actions)
197
+ },
198
+ 'engagement action':{'uco-core:performer':"",'uco-core:object': 'connects to one of the following engagement deception objects'+"\n\t\t"+"\n\t\t".join(engagement_objects)
199
+ },
200
+ 'engagement deception object':{'engagement:hasCharacterization':{'1':'uco-core:UcoObject'},
201
+ 'objective:hasObjective':'with @type objective:Objective and @id with one of the following instances:'+"\n\t\t"+"\n\t\t".join(engagement_objectives),
202
+ 'uco-core:name':'is the objective'
203
+ },
204
+ 'person':{'@type':'is uco-identity:Person',
205
+ 'uco-core:hasFacet':{"1":{'connects to uco-identity:SimpleNameFacet':{'uco-identity:familyName':"",'uco-identity:givenName':""}
206
+ }
207
+ }
208
+ },
209
+ 'uco-core:Role':{'@id':"is the role",'uco-core:name': 'is the role'
210
+ },
211
+ 'uco-core:Role there is a uco-core:Relationship':{'uco-core:kindofRelationship':'is "has_Role"',
212
+ 'uco-core:source':{"1":"the person who has the role"},
213
+ "uco-core:target":{"1":"uco-core:Role"}
214
+ },
215
+ 'engagement:BreadcrumbTrail':{'engagement:hasBreadcrumb':{"1":{'uco-types:Thread':{'co:element':"contains all engagement:Breadcrumb that belong to this engagement:BreadcrumbTrail","co:size":"","co:item":"contains all uco-types:ThreadItem one each for each engagement:Breadcrumb","uco-types:threadOriginItem":"is the uco-types:ThreadItem for the first engagement:Breadcrumb belonging to this engagement:BreadcrumbTrail","uco-types:threadTerminalItem":"is the uco-types:ThreadItem for the last engagement:Breadcrumb belonging to this engagement:BreadcrumbTrail"}}
216
+ }},
217
+ 'engagement:Breadcrumb':{'engagement:hasCharacterization':{"1":{'which connects to a uco-core:UcoObject which':{'uco-core:description':'which describes the object characterizing the breadcrumb'}},'uco-core:name': 'is the role'
218
+ }},
219
+ "class":{'@type': 'which is the class',
220
+ '@id': 'which is a unique identifier'},
221
+ "ns":ns_str
222
+
223
+ }
224
+
225
+ def get_list(struct,limiter="\n\t",skippre=False):
226
+ all_stat = []
227
+ for k,v in struct.items():
228
+ if k == "ns":
229
+ all_stat.append(v)
230
+ elif type(v)==dict:
231
+ look = "1"
232
+ if len(v) > 1:
233
+ plural = "has properties:"
234
+ else:
235
+ plural = "has property:"
236
+ if type(v)==dict:
237
+ statement = [" ".join([lookup[look]["0"][0],k,plural])]
238
+ if skippre:
239
+ statement = [" ".join([k,plural])]
240
+ for vk, vv in v.items():
241
+ statement.append(limiter)
242
+ statement.append(vk)
243
+ if type(vv)==dict:
244
+ for i in list(lookup.keys()):
245
+ if i in vv:
246
+ val = v[vk][i]
247
+ if type(val)==dict:
248
+ statement.append( get_list(val,limiter+"\t",skippre=True) )
249
+ else:
250
+ if not skippre:
251
+ statement.append(lookup[look]["1"][0])
252
+ statement.append(v[vk][i])
253
+ elif type(vv)==str:
254
+ statement.append(v[vk])
255
+ val = " ".join(statement)
256
+ all_stat.append(val)
257
+ return "\n".join(all_stat)
258
+
259
+ v = get_list(structure)
260
+ return v
261
+ def generate_rule(self,onto=None):
262
+ """Raw rule string of AEO."""
263
+ v = """Remember make a json-ld format example that only uses classes and properties terms from Adversary Engagement Ontology, Unified Cyber Ontology.
264
+
265
+ Each engagement:Narrative has property:
266
+ engagement:hasStoryline connects to an engagement:Storyline
267
+ Each engagement:Storyline has property:
268
+ engagement:hasEvent connects to a uco-types:Thread
269
+ Each uco-types:Thread has properties:
270
+ co:element contains all engagement:PlannedEvents
271
+ co:item contains all uco-types:ThreadItem one each for each engagement:PlannedEvent.
272
+ co:size
273
+ uco-types:threadOriginItem is the uco-types:ThreadItem for the first engagement:PlannedEvent
274
+ uco-types:threadTerminalItem is the uco-types:ThreadItem for the last engagement:PlannedEvent
275
+ Each co:size has properties:
276
+ @type as xsd:nonNegativeInteger
277
+ @value which is the number of uco-types:ThreadItem
278
+ Each uco-types:ThreadItem has property:
279
+ co:itemContent is the engagement:PlannedEvent
280
+ optional uco-types:threadNextItem is the next uco-types:ThreadItem for the next engagement:PlannedEvent if there is one,
281
+ optional uco-types:threadPreviousItem is the previous uco-types:ThreadItem for the previous engagement:PlannedEvent if there is one
282
+ Each engagement:PlannedEvent has property:
283
+ engagement:eventContext connects to one of the following engagement actions:
284
+ engagement:Access
285
+ engagement:Alert
286
+ engagement:Beacon
287
+ engagement:Deploy
288
+ engagement:Obfuscate
289
+ engagement:Respond
290
+ Each engagement action has properties:
291
+ uco-core:performer
292
+ uco-core:object which is the object which the action is applied to
293
+ Each engagement action has property:
294
+ uco-core:object connects to one of the following engagement deception objects:
295
+ engagement:Honeypot
296
+ engagement:Honeytoken
297
+ engagement:Breadcrumb
298
+ engagement:BreadcrumbTrail
299
+ engagement:LureObject
300
+ engagement:HoneyObject
301
+ engagement:Decoy
302
+ engagement:DataSource
303
+ Each engagement deception object has properties:
304
+ engagement:hasCharacterization connects to a uco-core:UcoObject
305
+ objective:hasObjective with @type objective:Objective and @id with one of the following instances:
306
+ objective:CommandAndControl
307
+ objective:CredentialAccess
308
+ objective:DevelopResource
309
+ objective:Discover
310
+ objective:EscalatePrivilege
311
+ objective:Evade
312
+ objective:Execute
313
+ objective:Exfilitrate
314
+ objective:GainInitialAccess
315
+ objective:Impact
316
+ objective:MoveLaterally
317
+ objective:Persist
318
+ objective:Reconnaissance
319
+ objective:Affect
320
+ objective:Collect
321
+ objective:Detect
322
+ objective:Direct
323
+ objective:Disrupt
324
+ objective:Elicit
325
+ objective:Expose
326
+ objective:Motivate
327
+ objective:Plan
328
+ objective:Prepare
329
+ objective:Prevent
330
+ objective:Reassure
331
+ objective:Analyze
332
+ objective:Deny
333
+ objective:ElicitBehavior
334
+ objective:Lure
335
+ objective:TimeSink
336
+ objective:Track
337
+ objective:Trap
338
+ uco-core:name is the objective
339
+ All people have property:
340
+ @type is uco-identity:Person
341
+ uco-core:hasFacet that connects to one of the following:
342
+ uco-identity:SimpleNameFacet which has the property:
343
+ uco-identity:familyName
344
+ uco-identity:givenName
345
+ Each uco-core:Role has properties:
346
+ @id is the role
347
+ uco-core:name is the role
348
+ Each uco-core:Role there is a uco-core:Relationship with properties:
349
+ uco-core:kindofRelationship is "has_Role"
350
+ uco-core:source connects to the person who has the role
351
+ uco-core:target connects to uco-core:Role
352
+ Each engagement:BreadcrumbTrail has property:
353
+ engagement:hasBreadcrumb connects to uco-types:Thread
354
+ This uco-types:Thread has property:
355
+ co:element contains all engagement:Breadcrumb that belong to this engagement:BreadcrumbTrail
356
+ co:item contains all uco-types:ThreadItem one each for each engagement:Breadcrumb
357
+ co:size
358
+ uco-types:threadOriginItem is the uco-types:ThreadItem for the first engagement:Breadcrumb belonging to this engagement:BreadcrumbTrail
359
+ uco-types:threadTerminalItem is the uco-types:ThreadItem for the last engagement:Breadcrumb belonging to this engagement:BreadcrumbTrail
360
+ Each engagement:Breadcrumb has the properties:
361
+ engagement:hasCharacterization which connects to a uco-core:UcoObject with the property:
362
+ uco-core:description which describes the object characterizing the breadcrumb
363
+ All classes must include property:
364
+ @type is the class
365
+ @id is a unique identifier
366
+
367
+ If namespace engagement prefix is used then https://ontology.adversaryengagement.org/ae/engagement#
368
+ If namespace objective prefix is used then https://ontology.adversaryengagement.org/ae/objective#
369
+ If namespace role prefix is used then https://ontology.adversaryengagement.org/ae/role#
370
+ If namespace identity prefix is used then https://ontology.adversaryengagement.org/ae/identity#
371
+ If namespace uco-core prefix is used then https://ontology.unifiedcyberontology.org/uco/core#
372
+ If namespace uco-types prefix is used then https://ontology.unifiedcyberontology.org/uco/types#
373
+ If namespace uco-role prefix is used then https://ontology.unifiedcyberontology.org/uco/role#
374
+ """
375
+ return v
376
+
377
+ def generate_continue(self):
378
+ v = """
379
+ continue
380
+ """
381
+ return v
382
+
383
+ def raw_prompt(self,description):
384
+
385
+ def run(val):
386
+ prompt = f"""Give me a full json-ld format example for the following scenario:
387
+ {description}
388
+
389
+ {"".join(val)}
390
+ """
391
+ for i in self.ChatGPTTextSplitter(prompt):
392
+ res = self.llm_api(i)
393
+ return res
394
+ # return json.loads(res)
395
+ res_val = run(self.generate_rules())
396
+ try:
397
+ val = json.loads(res_val)
398
+ return val
399
+ except:
400
+ #the response was cut off, prompt for the continuation.
401
+ data = []
402
+ data.append(res_val)
403
+ while True:
404
+ res = self.llm_api(self.generate_continue())
405
+ data.append(res)
406
+ try:
407
+ full = "".join(data)
408
+ return json.loads(full)
409
+ except:
410
+ pass
411
+
412
+ return None
413
+
414
+ def check_for_nested(self,jsonObject):
415
+ try:
416
+ for k,v in jsonObject.items():
417
+ if type(v) == dict:
418
+ return True
419
+ except:
420
+ pass
421
+ return False
422
+
423
+ def recursive_typelist(self,obj,ls):
424
+ if type(obj)!=dict:
425
+ return ls
426
+ obj_type = obj['@type'].split(":")[0]
427
+ if obj_type not in ls:
428
+ ls.append(obj_type)
429
+ for k,v in obj.items():
430
+ if self.check_for_nested(v):
431
+ return_ls = self.recursive_typelist(v,ls)
432
+ for re in return_ls:
433
+ if re not in ls:
434
+ ls.append(re)
435
+ return ls
436
+
437
+
438
+ def prompt(self,description):
439
+ res = self.raw_prompt(description)
440
+
441
+ #include only relevent namespaces
442
+ type_list = []
443
+ try:
444
+ for k in res['@graph']:
445
+ ns = k['@type'].split(":")[0]
446
+ if ns not in type_list:
447
+ type_list.append(ns)
448
+ type_list = self.recursive_typelist(k,type_list)
449
+ new_prefixes = {}
450
+ for k,v in res['@context'].items():
451
+ if k in type_list:
452
+ new_prefixes[k] = v
453
+ res['@context'] = new_prefixes
454
+ except:
455
+ return res
456
+ return res
aeo_example_generator.py ADDED
@@ -0,0 +1,456 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import openai
3
+ import json
4
+ import rdflib
5
+
6
+
7
+ class ExampleGenerator:
8
+ def __init__(self):
9
+ self.ontologies = {}
10
+ self.ontology_files = []
11
+ self.rules = {}
12
+ def add_ontology(self, onto):
13
+ if onto in self.ontology_files:
14
+ raise ValueError("Ontology file already exists.")
15
+ else:
16
+ onto_data = self.get_ontology_file(onto)
17
+ if onto_data:
18
+ self.ontology_files.append(onto)
19
+ self.ontologies[onto] = self.get_ontology_file(onto)
20
+ self.rules[onto] = self.generate_rules(onto)
21
+ else:
22
+ raise ValueError("Ontology file error.")
23
+ def get_ontology_file(self,filename):
24
+ text = ""
25
+ if os.path.isfile(filename):
26
+ with open(filename,'r') as f:
27
+ text = f.read()
28
+ f.close()
29
+ return text
30
+ else:
31
+ raise ValueError("Invalid filename.")
32
+ def ChatGPTTextSplitter(self,text):
33
+ """Splits text in smaller subblocks to feed to the LLM"""
34
+ prompt = f"""The total length of content that I want to send you is too large to send in only one piece.
35
+
36
+ For sending you that content, I will follow this rule:
37
+
38
+ [START PART 1/10]
39
+ this is the content of the part 1 out of 10 in total
40
+ [END PART 1/10]
41
+
42
+ Then you just answer: "Instructions Sent."
43
+
44
+ And when I tell you "ALL PARTS SENT", then you can continue processing the data and answering my requests.
45
+ """
46
+ if type(text) == str:
47
+ textsize = 12000
48
+ blocksize = int(len(text) / textsize)
49
+ if blocksize > 0:
50
+ yield prompt
51
+
52
+ for b in range(1,blocksize+1):
53
+ if b < blocksize+1:
54
+ prompt = f"""Do not answer yet. This is just another part of the text I want to send you. Just receive and acknowledge as "Part {b}/{blocksize} received" and wait for the next part.
55
+ [START PART {b}/{blocksize}]
56
+ {text[(b-1)*textsize:b*textsize]}
57
+ [END PART {b}/{blocksize}]
58
+ Remember not answering yet. Just acknowledge you received this part with the message "Part {b}/{blocksize} received" and wait for the next part.
59
+ """
60
+ yield prompt
61
+ else:
62
+ prompt = f"""
63
+ [START PART {b}/{blocksize}]
64
+ {text[(b-1)*textsize:b*textsize]}
65
+ [END PART {b}/{blocksize}]
66
+ ALL PARTS SENT. Now you can continue processing the request.
67
+ """
68
+ yield prompt
69
+ else:
70
+ yield text
71
+ elif type(text) == list:
72
+ yield prompt
73
+
74
+ for n,block in enumerate(text):
75
+ if n+1 < len(text):
76
+ prompt = f"""Do not answer yet. This is just another part of the text I want to send you. Just receive and acknowledge as "Part {n+1}/{len(text)} received" and wait for the next part.
77
+ [START PART {n+1}/{len(text)}]
78
+ {text[n]}
79
+ [END PART {n+1}/{len(text)}]
80
+ Remember not answering yet. Just acknowledge you received this part with the message "Part {n+1}/{len(text)} received" and wait for the next part.
81
+ """
82
+ yield prompt
83
+ else:
84
+ prompt = f"""
85
+ [START PART {n+1}/{len(text)}]
86
+ {text[n]}
87
+ [END PART {n+1}/{len(text)}]
88
+ ALL PARTS SENT. Now you can continue processing the request.
89
+ """
90
+ yield prompt
91
+
92
+ def send_ontology(self):
93
+ ontology = ""
94
+ if len(self.ontologies) > 0:
95
+ for k,v in self.ontologies.items():
96
+ ontology+=v+"\n"
97
+ print("Sending Ontology in Parts")
98
+ for i in self.ChatGPTTextSplitter(ontology):
99
+ print(self.llm_api(i))
100
+ else:
101
+ raise ValueError("No loaded ontology to send.")
102
+ def llm_api(self,prompt,model="gpt-3.5-turbo"):
103
+ messages = [{
104
+ "role":"user",
105
+ "content":prompt
106
+ }]
107
+ res = openai.ChatCompletion.create(model=model,messages=messages,temperature=0)
108
+ return res.choices[0].message['content']
109
+
110
+ def generate_rules(self,onto=None):
111
+ engagement_actions = ['engagement:Access',
112
+ 'engagement:Alert',
113
+ 'engagement:Beacon',
114
+ 'engagement:Deploy',
115
+ 'engagement:Obfuscate',
116
+ 'engagement:Respond'
117
+ ]
118
+ engagement_objects = [
119
+ 'engagement:Honeypot',
120
+ 'engagement:Honeytoken',
121
+ 'engagement:Breadcrumb',
122
+ 'engagement:BreadcrumbTrail',
123
+ 'engagement:LureObject',
124
+ 'engagement:HoneyObject',
125
+ 'engagement:Decoy',
126
+ 'engagement:DataSource'
127
+ ]
128
+ engagement_objectives = [
129
+ 'objective:CommandAndControl',
130
+ 'objective:CredentialAccess',
131
+ 'objective:DevelopResource',
132
+ 'objective:Discover',
133
+ 'objective:EscalatePrivilege',
134
+ 'objective:Evade',
135
+ 'objective:Execute',
136
+ 'objective:Exfilitrate',
137
+ 'objective:GainInitialAccess',
138
+ 'objective:Impact',
139
+ 'objective:MoveLaterally',
140
+ 'objective:Persist',
141
+ 'objective:Reconnaissance',
142
+ 'objective:Affect',
143
+ 'objective:Collect',
144
+ 'objective:Detect',
145
+ 'objective:Direct',
146
+ 'objective:Disrupt',
147
+ 'objective:Elicit',
148
+ 'objective:Expose',
149
+ 'objective:Motivate',
150
+ 'objective:Plan',
151
+ 'objective:Prepare',
152
+ 'objective:Prevent',
153
+ 'objective:Reassure',
154
+ 'objective:Analyze',
155
+ 'objective:Deny',
156
+ 'objective:ElicitBehavior',
157
+ 'objective:Lure',
158
+ 'objective:TimeSink',
159
+ 'objective:Track',
160
+ 'objective:Trap'
161
+ ]
162
+ prefix_ns = {"engagement": "https://ontology.adversaryengagement.org/ae/engagement#",
163
+ "objective":"https://ontology.adversaryengagement.org/ae/objective#",
164
+ "role":"https://ontology.adversaryengagement.org/ae/role#",
165
+ "identity":"https://ontology.adversaryengagement.org/ae/identity#",
166
+ "uco-core prefix":"https://ontology.unifiedcyberontology.org/uco/core#",
167
+ "uco-types":"https://ontology.unifiedcyberontology.org/uco/types#",
168
+ "uco-role":"https://ontology.unifiedcyberontology.org/uco/role#"
169
+ }
170
+ ns_str =""
171
+ for k,v in prefix_ns.items():
172
+ ns_str+=f"If namespace {k} prefix is used then {v}\n"
173
+ lookup = {"1":{"0":['Each'],
174
+ "1":['connects to']
175
+ }
176
+ }
177
+ v = """Remember make a json-ld format example that only uses classes and properties terms from Adversary Engagement Ontology, Unified Cyber Ontology."""
178
+
179
+ structure = {'engagement:Narrative':{'engagement:hasStoryline':{"1":'engagement:Storyline'}
180
+ },
181
+ 'engagement:Storyline':{'engagement:hasEvent':{"1":'uco-types:Thread'}
182
+ },
183
+ 'uco-types:Thread':{'co:element':'contains all engagement:PlannedEvents',
184
+ 'co:item':{"0":'uco-types:ThreadItem one each for each engagement:PlannedEvent'},
185
+ 'co:size':"",
186
+ 'uco-types:threadOriginItem':"is the uco-types:ThreadItem for the first engagement:PlannedEvent",
187
+ 'uco-types:threadTerminalItem':"is the uco-types:ThreadItem for the last engagement:PlannedEvent"
188
+ },
189
+ 'co:size':{'@type':'is xsd:nonNegativeInteger',
190
+ '@value':"which is the number of uco-types:ThreadItem"
191
+ },
192
+ 'uco-types:ThreadItem':{'co:itemContent':'is the engagement:PlannedEvent',
193
+ 'optional uco-types:threadNextItem':"is the next uco-types:ThreadItem for the next engagement:PlannedEvent if there is one",
194
+ 'optional uco-types:threadPreviousItem':'is the previous uco-types:ThreadItem for the previous'
195
+ },
196
+ 'engagement:PlannedEvent':{'engagement:eventContext':"connects to one of the following engagement actions:"+"\n\t\t"+"\n\t\t".join(engagement_actions)
197
+ },
198
+ 'engagement action':{'uco-core:performer':"",'uco-core:object': 'connects to one of the following engagement deception objects'+"\n\t\t"+"\n\t\t".join(engagement_objects)
199
+ },
200
+ 'engagement deception object':{'engagement:hasCharacterization':{'1':'uco-core:UcoObject'},
201
+ 'objective:hasObjective':'with @type objective:Objective and @id with one of the following instances:'+"\n\t\t"+"\n\t\t".join(engagement_objectives),
202
+ 'uco-core:name':'is the objective'
203
+ },
204
+ 'person':{'@type':'is uco-identity:Person',
205
+ 'uco-core:hasFacet':{"1":{'connects to uco-identity:SimpleNameFacet':{'uco-identity:familyName':"",'uco-identity:givenName':""}
206
+ }
207
+ }
208
+ },
209
+ 'uco-core:Role':{'@id':"is the role",'uco-core:name': 'is the role'
210
+ },
211
+ 'uco-core:Role there is a uco-core:Relationship':{'uco-core:kindofRelationship':'is "has_Role"',
212
+ 'uco-core:source':{"1":"the person who has the role"},
213
+ "uco-core:target":{"1":"uco-core:Role"}
214
+ },
215
+ 'engagement:BreadcrumbTrail':{'engagement:hasBreadcrumb':{"1":{'uco-types:Thread':{'co:element':"contains all engagement:Breadcrumb that belong to this engagement:BreadcrumbTrail","co:size":"","co:item":"contains all uco-types:ThreadItem one each for each engagement:Breadcrumb","uco-types:threadOriginItem":"is the uco-types:ThreadItem for the first engagement:Breadcrumb belonging to this engagement:BreadcrumbTrail","uco-types:threadTerminalItem":"is the uco-types:ThreadItem for the last engagement:Breadcrumb belonging to this engagement:BreadcrumbTrail"}}
216
+ }},
217
+ 'engagement:Breadcrumb':{'engagement:hasCharacterization':{"1":{'which connects to a uco-core:UcoObject which':{'uco-core:description':'which describes the object characterizing the breadcrumb'}},'uco-core:name': 'is the role'
218
+ }},
219
+ "class":{'@type': 'which is the class',
220
+ '@id': 'which is a unique identifier'},
221
+ "ns":ns_str
222
+
223
+ }
224
+
225
+ def get_list(struct,limiter="\n\t",skippre=False):
226
+ all_stat = []
227
+ for k,v in struct.items():
228
+ if k == "ns":
229
+ all_stat.append(v)
230
+ elif type(v)==dict:
231
+ look = "1"
232
+ if len(v) > 1:
233
+ plural = "has properties:"
234
+ else:
235
+ plural = "has property:"
236
+ if type(v)==dict:
237
+ statement = [" ".join([lookup[look]["0"][0],k,plural])]
238
+ if skippre:
239
+ statement = [" ".join([k,plural])]
240
+ for vk, vv in v.items():
241
+ statement.append(limiter)
242
+ statement.append(vk)
243
+ if type(vv)==dict:
244
+ for i in list(lookup.keys()):
245
+ if i in vv:
246
+ val = v[vk][i]
247
+ if type(val)==dict:
248
+ statement.append( get_list(val,limiter+"\t",skippre=True) )
249
+ else:
250
+ if not skippre:
251
+ statement.append(lookup[look]["1"][0])
252
+ statement.append(v[vk][i])
253
+ elif type(vv)==str:
254
+ statement.append(v[vk])
255
+ val = " ".join(statement)
256
+ all_stat.append(val)
257
+ return "\n".join(all_stat)
258
+
259
+ v = get_list(structure)
260
+ return v
261
+ def generate_rule(self,onto=None):
262
+ """Raw rule string of AEO."""
263
+ v = """Remember make a json-ld format example that only uses classes and properties terms from Adversary Engagement Ontology, Unified Cyber Ontology.
264
+
265
+ Each engagement:Narrative has property:
266
+ engagement:hasStoryline connects to an engagement:Storyline
267
+ Each engagement:Storyline has property:
268
+ engagement:hasEvent connects to a uco-types:Thread
269
+ Each uco-types:Thread has properties:
270
+ co:element contains all engagement:PlannedEvents
271
+ co:item contains all uco-types:ThreadItem one each for each engagement:PlannedEvent.
272
+ co:size
273
+ uco-types:threadOriginItem is the uco-types:ThreadItem for the first engagement:PlannedEvent
274
+ uco-types:threadTerminalItem is the uco-types:ThreadItem for the last engagement:PlannedEvent
275
+ Each co:size has properties:
276
+ @type as xsd:nonNegativeInteger
277
+ @value which is the number of uco-types:ThreadItem
278
+ Each uco-types:ThreadItem has property:
279
+ co:itemContent is the engagement:PlannedEvent
280
+ optional uco-types:threadNextItem is the next uco-types:ThreadItem for the next engagement:PlannedEvent if there is one,
281
+ optional uco-types:threadPreviousItem is the previous uco-types:ThreadItem for the previous engagement:PlannedEvent if there is one
282
+ Each engagement:PlannedEvent has property:
283
+ engagement:eventContext connects to one of the following engagement actions:
284
+ engagement:Access
285
+ engagement:Alert
286
+ engagement:Beacon
287
+ engagement:Deploy
288
+ engagement:Obfuscate
289
+ engagement:Respond
290
+ Each engagement action has properties:
291
+ uco-core:performer
292
+ uco-core:object which is the object which the action is applied to
293
+ Each engagement action has property:
294
+ uco-core:object connects to one of the following engagement deception objects:
295
+ engagement:Honeypot
296
+ engagement:Honeytoken
297
+ engagement:Breadcrumb
298
+ engagement:BreadcrumbTrail
299
+ engagement:LureObject
300
+ engagement:HoneyObject
301
+ engagement:Decoy
302
+ engagement:DataSource
303
+ Each engagement deception object has properties:
304
+ engagement:hasCharacterization connects to a uco-core:UcoObject
305
+ objective:hasObjective with @type objective:Objective and @id with one of the following instances:
306
+ objective:CommandAndControl
307
+ objective:CredentialAccess
308
+ objective:DevelopResource
309
+ objective:Discover
310
+ objective:EscalatePrivilege
311
+ objective:Evade
312
+ objective:Execute
313
+ objective:Exfilitrate
314
+ objective:GainInitialAccess
315
+ objective:Impact
316
+ objective:MoveLaterally
317
+ objective:Persist
318
+ objective:Reconnaissance
319
+ objective:Affect
320
+ objective:Collect
321
+ objective:Detect
322
+ objective:Direct
323
+ objective:Disrupt
324
+ objective:Elicit
325
+ objective:Expose
326
+ objective:Motivate
327
+ objective:Plan
328
+ objective:Prepare
329
+ objective:Prevent
330
+ objective:Reassure
331
+ objective:Analyze
332
+ objective:Deny
333
+ objective:ElicitBehavior
334
+ objective:Lure
335
+ objective:TimeSink
336
+ objective:Track
337
+ objective:Trap
338
+ uco-core:name is the objective
339
+ All people have property:
340
+ @type is uco-identity:Person
341
+ uco-core:hasFacet that connects to one of the following:
342
+ uco-identity:SimpleNameFacet which has the property:
343
+ uco-identity:familyName
344
+ uco-identity:givenName
345
+ Each uco-core:Role has properties:
346
+ @id is the role
347
+ uco-core:name is the role
348
+ Each uco-core:Role there is a uco-core:Relationship with properties:
349
+ uco-core:kindofRelationship is "has_Role"
350
+ uco-core:source connects to the person who has the role
351
+ uco-core:target connects to uco-core:Role
352
+ Each engagement:BreadcrumbTrail has property:
353
+ engagement:hasBreadcrumb connects to uco-types:Thread
354
+ This uco-types:Thread has property:
355
+ co:element contains all engagement:Breadcrumb that belong to this engagement:BreadcrumbTrail
356
+ co:item contains all uco-types:ThreadItem one each for each engagement:Breadcrumb
357
+ co:size
358
+ uco-types:threadOriginItem is the uco-types:ThreadItem for the first engagement:Breadcrumb belonging to this engagement:BreadcrumbTrail
359
+ uco-types:threadTerminalItem is the uco-types:ThreadItem for the last engagement:Breadcrumb belonging to this engagement:BreadcrumbTrail
360
+ Each engagement:Breadcrumb has the properties:
361
+ engagement:hasCharacterization which connects to a uco-core:UcoObject with the property:
362
+ uco-core:description which describes the object characterizing the breadcrumb
363
+ All classes must include property:
364
+ @type is the class
365
+ @id is a unique identifier
366
+
367
+ If namespace engagement prefix is used then https://ontology.adversaryengagement.org/ae/engagement#
368
+ If namespace objective prefix is used then https://ontology.adversaryengagement.org/ae/objective#
369
+ If namespace role prefix is used then https://ontology.adversaryengagement.org/ae/role#
370
+ If namespace identity prefix is used then https://ontology.adversaryengagement.org/ae/identity#
371
+ If namespace uco-core prefix is used then https://ontology.unifiedcyberontology.org/uco/core#
372
+ If namespace uco-types prefix is used then https://ontology.unifiedcyberontology.org/uco/types#
373
+ If namespace uco-role prefix is used then https://ontology.unifiedcyberontology.org/uco/role#
374
+ """
375
+ return v
376
+
377
+ def generate_continue(self):
378
+ v = """
379
+ continue
380
+ """
381
+ return v
382
+
383
+ def raw_prompt(self,description):
384
+
385
+ def run(val):
386
+ prompt = f"""Give me a full json-ld format example for the following scenario:
387
+ {description}
388
+
389
+ {"".join(val)}
390
+ """
391
+ for i in self.ChatGPTTextSplitter(prompt):
392
+ res = self.llm_api(i)
393
+ return res
394
+ # return json.loads(res)
395
+ res_val = run(self.generate_rules())
396
+ try:
397
+ val = json.loads(res_val)
398
+ return val
399
+ except:
400
+ #the response was cut off, prompt for the continuation.
401
+ data = []
402
+ data.append(res_val)
403
+ while True:
404
+ res = self.llm_api(self.generate_continue())
405
+ data.append(res)
406
+ try:
407
+ full = "".join(data)
408
+ return json.loads(full)
409
+ except:
410
+ pass
411
+
412
+ return None
413
+
414
+ def check_for_nested(self,jsonObject):
415
+ try:
416
+ for k,v in jsonObject.items():
417
+ if type(v) == dict:
418
+ return True
419
+ except:
420
+ pass
421
+ return False
422
+
423
+ def recursive_typelist(self,obj,ls):
424
+ if type(obj)!=dict:
425
+ return ls
426
+ obj_type = obj['@type'].split(":")[0]
427
+ if obj_type not in ls:
428
+ ls.append(obj_type)
429
+ for k,v in obj.items():
430
+ if self.check_for_nested(v):
431
+ return_ls = self.recursive_typelist(v,ls)
432
+ for re in return_ls:
433
+ if re not in ls:
434
+ ls.append(re)
435
+ return ls
436
+
437
+
438
+ def prompt(self,description):
439
+ res = self.raw_prompt(description)
440
+
441
+ #include only relevent namespaces
442
+ type_list = []
443
+ try:
444
+ for k in res['@graph']:
445
+ ns = k['@type'].split(":")[0]
446
+ if ns not in type_list:
447
+ type_list.append(ns)
448
+ type_list = self.recursive_typelist(k,type_list)
449
+ new_prefixes = {}
450
+ for k,v in res['@context'].items():
451
+ if k in type_list:
452
+ new_prefixes[k] = v
453
+ res['@context'] = new_prefixes
454
+ except:
455
+ return res
456
+ return res
data/chroma.sqlite3 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:81687fffb098ff3950a4143bb89be8c7d051bc24c4ba95a667ad3901ec6d66b5
3
+ size 2187264
data/d1a96671-aee8-491c-a591-df54be606f81/data_level0.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f18abd8c514282db82706e52b0a33ed659cd534e925a6f149deb7af9ce34bd8e
3
+ size 6284000
data/d1a96671-aee8-491c-a591-df54be606f81/header.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:effaa959ce2b30070fdafc2fe82096fc46e4ee7561b75920dd3ce43d09679b21
3
+ size 100
data/d1a96671-aee8-491c-a591-df54be606f81/length.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f51030a50f6bee470c5fc6702c6e43fe48a4bb732a4ed0cd0752b6a994ef47d7
3
+ size 4000
data/d1a96671-aee8-491c-a591-df54be606f81/link_lists.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
3
+ size 0
docs/EngageHandbook-v1.0.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b48dfb9833d4b8152effe2bc39abcf73ad72ca02e1a72636e09c3d1d05b6857b
3
+ size 1886870
docs/SmallBusinessExample.md ADDED
@@ -0,0 +1,1089 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Small Business Example
2
+
3
+
4
+ ```python
5
+ # This software was produced for the U.S. Government under contract FA8702-23-C-0001,
6
+ # and is subject to the Rights in Data-General Clause 52.227-14, Alt. IV (DEC 2007)
7
+ # ©2023 The MITRE Corporation. Published under the Linux Foundation’s Cyber Domain Ontology project’s Apache 2 license.
8
+ # Released under MITRE PRS 18-4297.
9
+ ```
10
+
11
+ After checking out the specific class instantiation tutorial examples such as `Honeypot`, `FluidDeception` and `Breadcrumb`, we believe enumerating through an application example can help our audience understand how AEO can represent and support a deception operation.
12
+
13
+ # Premise
14
+
15
+ - You are part of a small business called <b> MineralRUs Inc.</b>, which is a small, yet critical mining company in New Hampshire specializing in rare earth elements.
16
+ - Your main clients are from particular sectors of technology and defense industries, and are considered to be critical infrastructure. Therefore, your business and its operation is essential to the integrity of supply chains enabling those critical infrastructure.
17
+ - MineralRUs Inc. maintains paper-based record of their key intellectual property and operational procedures, which are stored in a physical safe. This fact is known by only a select few in the company.
18
+ - Your business has a small, unorganized computer network with only generic security infrastructure, and the company does not have the resources to employ an in-house information security team. Instead, a very small team is tasked with maintaining Operational Technology (OT) systems on the network.
19
+
20
+ Your company has recently received an advisory from federal authorities, warning businesses in your industry about the rapidly growing threat of cyber espionage by state-sponsored Advanced Persistent Threats (APTs). In response, your company decides to engage an external cybersecurity provider to assist with timely incident response and prevention. The external provider recommends the employment of active adversary engagement plans, and asks you to develop a high-level deception and denial strategy.
21
+
22
+ ## Preplanning & Indentifying Assets
23
+
24
+ To get started with the planning of this adversary engagement operation, we begin with an existing tool, namely the <b> Fact&Fiction/(D&D) matrix </b>. The original matrix uses Deception & Denial (D&D) technique types as the row header (for more details, see [Heckman, K. E., et al. (2015), Denial and deception in cyber defense.](https://www.researchgate.net/publication/275270540_Denial_and_Deception_in_Cyber_Defense)
25
+
26
+ The <b> row header </b> outlines two types of methods that concurrently facilitate adversary engagement: <b>misleading-type methods used to reveal specific information to an adversary and ambiguity-type methods for concealing or denying information from an adversary </b>. The ambiguity-type methods for denial can be used to safe-guard assets through confusion and obfuscation, thus impeding an adversary's efforts to obtain a clear view of relevant resources and access paths. On the other hand, the misleading-type methods aim to induce a desired (mis)perception of the cyber ecosystem through the controlled revelation of real or fabricated information to an adversary.
27
+
28
+
29
+ The <b> column header </b> refers to the <b> value of information </b> an adversary gains from some revealed event. In this specific method, fact is used to describe the asset information and fiction specifically implies the intended (mis)perception of such information.
30
+
31
+
32
+ [remove?] Generally speaking, we do not specify actual values, but comparative concepts such as high-value, low-value or no-value in relationship with the deception operation and the expectation of value an adversary justifies for expending resources for. Extension to numerical values can be done, but is not within the scope of this example.
33
+
34
+ || Deception Operation Mislead-type Methods (Revealing) | Denial Operation Ambiguity-type Methods (Concealing) |
35
+ |---| --- | --- |
36
+ |Fact | Network in New Hampshire, business runs a mine in New Hampshire | Business relationships with a specific strategic partner, types of minerals mined given to the strategic partner, process of mineral mining that is essential to the strategic partner, amounts of mined minerals for the strategic partner, company safe location, passcodes, locations of IP keys|
37
+ |Fiction | low-value IP is stored on the network, contained within falsified, obfuscated files | Most important IP is located in <i> this </i> specific encrypted volume |
38
+
39
+ 1. The fiction under the Deception Operation column refers to presenting to an adversary that there is low-value intellectual property on the network such as referencing perhaps other types of non-confidential mineral mining processes and outdated contracts with public partners.
40
+
41
+ 2. The fact under Deception Operation refers to bits of factual but so called friendly information that can help bring realism to the deception operation and allow adversaries to validate some mutual information to minimize inconsistencies in the perception.
42
+
43
+ 3. The fiction under the Denial Operation refers to giving the adversary the perception that it is in the defender's interest for the network to conceal the location of the IP.
44
+
45
+ 4. The fact under the Denial Operation refers to the information or assets the strategic partner would like to conceal such as their business relationships and exact details about the mining process and contracted amounts of minerals provided by MineralRUs.
46
+
47
+ By enumerating the assets of the business such as the intellectual property located in the safe and business operation details, we directly identify what information we would like to deny an adversary. Building on this analysis, we then decide on the appropriate adversary engagement tools and techniques for our deception and denial needs.
48
+
49
+ At this point, we would like to raise a reminder that the AE ontology specializes in the characterization of deception and denial operations, but asset evaluation and risk profiling are outside the scope of this work. Such concepts and processes fall within the purview of the soon-to-come UCO Risk and Cyber Threat Intelligence (CTI) subontologies.
50
+
51
+
52
+
53
+ ## From the Narrative to a Graph
54
+
55
+ The Adversary Engagement Ontology provides the structure needed to transform your abstract deception operation plan into graph representation. The degree of how detailed your `Narrative` depends on how extensively refined do you want your preoperation planning to be.
56
+
57
+
58
+ ### The Mapping Process
59
+
60
+ - 1. Start with a basic more or less static structure. Outline the sequence of planned events for the deception operation. Then comes the following iterative process:
61
+ - 2.a Select deception techniques and objects according to the intended fiction (cf. Fact&Fiction matrix)
62
+ - 2.b Evaluate the refinements: Does it deliver your desired fiction in the most feasible, effective and efficient manner?
63
+ - 2.c If not, repeat 2.a and 2.b until satisfied.
64
+
65
+ ### Diagram representation
66
+
67
+ ![SmallBusinessNarrativeExample.drawio.png](SmallBusinessNarrativeExample.drawio.png)
68
+
69
+ In this diagram, the `Narrative` has very little `PlannedEvent(s)` within the `Storyline`. That's okay! Not all deception operations need to consider adversaries with straightforward access to the contents and artifacts of a network. Deception operations typically use just a subset of all the deception tools and tricks, particularly since the employment of each additional component comes with additional cost in terms of resources, risk, and operational integrity. In our example scenario of a small business, extremely complex forms of deception are deemed infeasible within their scope of available resources and risk models.
70
+
71
+ - The class [`engagement:Honeypot`](https://aeontology.sail-lab.org/docs/class-engagementhoneypot.html) in this use case is used with the specific objective `objective:Direct` to lure an adversary away from the real assets of the network to this fictitious staged location.
72
+
73
+ - Staged files are instantiated under the general [`engagement:LureObject`](https://aeontology.sail-lab.org/docs/class-engagementlureobject.html) class, though these can be fully real, partially real or completely facticious files. Furthermore, these `LureObject(s)` are associated with the objective `objective:Exfiltrate` which implies that these files are intended to be taken by an adversary off the network. (More complex representations may include instances associated with attack patterns for an adversary with the same objective.)
74
+
75
+ - The method which we plan to be notified whether these files were removed from the network is through a canary token, however one can have other `DataSource(s)` such as a network monitor.
76
+
77
+ ## Building the JSON-LD:
78
+
79
+ 1. As with all `Narrative(s)`, we start with instantiating an [`engagement:Narrative`](https://aeontology.sail-lab.org/docs/class-engagementnarrative.html) class which is often referred to as a deception campaign and is the collection of all storylines . We also specify a large-scale operational objective to the Narrative object. This instance of an [`engagement:Narrative`](https://aeontology.sail-lab.org/docs/class-engagementnarrative.html) only has one instance of a [`engagement:Storyline`](https://aeontology.sail-lab.org/docs/class-engagementstoryline.html) attached since we have only developed one plan so far. However, we can model this with multiple `Storyline(s)` if we wanted to separate each falsified file as its own `Storyline`.
80
+ 2. An objective can be attached to describe large-scale operational objectives. Explicit objectives are considered individual, so please remember that!
81
+
82
+
83
+ ```python
84
+ {
85
+ "@id": "kb:narrative1",
86
+ "@type": "engagement:Narrative",
87
+ "engagement:hasStoryline": [
88
+ {
89
+ "@id": "kb:storyline1",
90
+ "@type": "engagement:Storyline",
91
+ "uco-core:name": "ProtectTheFilesNarrative"
92
+ }
93
+ ],
94
+ "objective:hasObjective": [
95
+ {
96
+ "@id": "kb:objective1",
97
+ "@type": "objective:Objective",
98
+ "uco-core:name": "ProtectTheFiles"
99
+ }
100
+ ],
101
+ "uco-core:description": "Grand objective is to lure adversaries or insiders on the network away from details of the mining operations, location and passcode of the safe containing intellectual property."
102
+ }
103
+ ```
104
+
105
+
106
+
107
+
108
+ {'@id': 'kb:narrative1',
109
+ '@type': 'engagement:Narrative',
110
+ 'engagement:hasStoryline': [{'@id': 'kb:storyline1',
111
+ '@type': 'engagement:Storyline',
112
+ 'uco-core:name': 'ProtectTheFilesNarrative'}],
113
+ 'objective:hasObjective': [{'@id': 'kb:objective1',
114
+ '@type': 'objective:Objective',
115
+ 'uco-core:name': 'ProtectTheFiles'}],
116
+ 'uco-core:description': 'Grand objective is to lure adversaries or insiders on the network away from details of the mining operations, location and passcode of the safe containing intellectual property.'}
117
+
118
+
119
+
120
+ 3. Next, to populate the sequence of `PlannedEvent(s)`for a our instance of [`engagement:Storyline`](https://aeontology.sail-lab.org/docs/class-engagementstoryline.html), we add an event, let's call it `kb:Event1`.
121
+ 4. Each instance of [`PlannedEvent`](https://aeontology.sail-lab.org/docs/class-engagementplannedevent.html) is designed to have an action class e.g. `engagement:Deploy` by the [`engagement:eventContext`](https://aeontology.sail-lab.org/docs/prop-engagementeventcontext.html) property. By design, action concepts like `Deploy` can support properties such as `performers`, `object`, `environment` etc because of its parent class `uco-action:Action`.
122
+ 5. In this explicit case, the `object` that is `Deploy`(ed) is an instance of a [`engagement:Honeypot`](https://aeontology.sail-lab.org/docs/class-engagementhoneypot.html) with the specific objective of `objective:Direct`, implying the honeypot is used to direct adversaries to or away from other assets on the network.
123
+
124
+
125
+ ```python
126
+ {
127
+ "@id": "kb:Event1",
128
+ "@type": "engagement:PlannedEvent",
129
+ "engagement:eventContext": [
130
+ {
131
+ "@id": "kb:deploy1",
132
+ "@type": "engagement:Deploy",
133
+ "uco-action:object": [
134
+ {
135
+ "@id": "kb:honeypot1",
136
+ "@type": "engagement:Honeypot",
137
+ "uco-core:description": "Fake production server to contain the fabricated files.",
138
+ "objective:hasObjective": [
139
+ {
140
+ "@id": "objective:Direct"
141
+ }
142
+ ]
143
+
144
+ }]
145
+ }]
146
+ }
147
+ ```
148
+
149
+
150
+
151
+
152
+ {'@id': 'kb:Event1',
153
+ '@type': 'engagement:PlannedEvent',
154
+ 'engagement:eventContext': [{'@id': 'kb:deploy1',
155
+ '@type': 'engagement:Deploy',
156
+ 'uco-action:object': [{'@id': 'kb:honeypot1',
157
+ '@type': 'engagement:Honeypot',
158
+ 'uco-core:description': 'Fake production server to contain the fabricated files.',
159
+ 'objective:hasObjective': [{'@id': 'objective:Direct'}]}]}]}
160
+
161
+
162
+
163
+ 6. Besides an instance of a [`engagement:Honeypot`](https://aeontology.sail-lab.org/docs/class-engagementhoneypot.html) and the CanaryTokenAlert `dataSource`, two deception objects namely the obfuscated, falsified files were deployed during the first `PlannedEvent`. Both files `kb:obffile1` and `kb:obffile2` are an instances of a [`engagement:LureObject`](https://aeontology.sail-lab.org/docs/class-engagementlureobject.html) with the explicit objective `objective:Exfiltrate` of being exfilitrated from the network by adversaries. The first file being false information on the mining procedures used by the business and the second file refers to false passcodes in case the adversary happens to be an insider.
164
+
165
+
166
+ ```python
167
+ {
168
+ "@id": "kb:obffile1",
169
+ "@type": "engagement:LureObject",
170
+ "uco-core:name": "mining-procedure.pdf",
171
+ "uco-core:description": "Fake file of mining procedures.",
172
+ "objective:hasObjective": [
173
+ {
174
+ "@id": "objective:Exfilitrate"
175
+ }
176
+ ]
177
+ },
178
+ {
179
+ "@id": "kb:obffile2",
180
+ "@type": "engagement:LureObject",
181
+ "uco-core:name": "backup-safe-passcode.pdf",
182
+ "uco-core:description": "Fake file of safe passcode and physical location of the safe.",
183
+ "objective:hasObjective": [
184
+ {
185
+ "@id": "objective:Exfiltrate"
186
+ }
187
+ ]
188
+ }
189
+ ```
190
+
191
+
192
+
193
+
194
+ {'@id': 'kb:obffile2',
195
+ '@type': 'engagement:LureObject',
196
+ 'uco-core:name': 'backup-safe-passcode.pdf',
197
+ 'uco-core:description': 'Fake file of safe passcode and physical location of the safe.',
198
+ 'objective:hasObjective': [{'@id': 'objective:Exfiltrate'}]}
199
+
200
+
201
+
202
+ 7. We also know who is going to `Deploy` the deception objects so we should also include that through the `performer` property.
203
+ 8. We also attach an objective the `Deploy` action.
204
+
205
+
206
+ ```python
207
+ {"uco-action:performer": [
208
+ {
209
+ "@id": "kb:person1",
210
+ "@type": "uco-identity:Person",
211
+ "uco-core:hasFacet": [
212
+ {
213
+ "@id": "kb:RichardRocky",
214
+ "@type": "identity:SimpleNameFacet",
215
+ "uco-identity:familyName": "Richard",
216
+ "uco-identity:givenName": "Rocky"
217
+ }
218
+ ]
219
+ }
220
+ ],
221
+ "objective:hasObjective": [
222
+ {
223
+ "@id": "objective:Deploy"
224
+ }
225
+ ]
226
+ }
227
+ ```
228
+
229
+
230
+
231
+
232
+ {'uco-action:performer': [{'@id': 'kb:person1',
233
+ '@type': 'uco-identity:Person',
234
+ 'uco-core:hasFacet': [{'@id': 'kb:RichardRocky',
235
+ '@type': 'identity:SimpleNameFacet',
236
+ 'uco-identity:familyName': 'Richard',
237
+ 'uco-identity:givenName': 'Rocky'}]}],
238
+ 'objective:hasObjective': [{'@id': 'objective:Deploy'}]}
239
+
240
+
241
+
242
+ 9. The first instance of [`PlannedEvent`](https://aeontology.sail-lab.org/docs/class-engagementplannedevent.html) describes the deployment of the deception objects onto the network. Now we continue to what we expect to happen in the next `PlannedEvent` called `kb:Event2`. We left the property [`eventContext`](https://aeontology.sail-lab.org/docs/prop-engagementeventcontext.html) with `...` because this needs to be expanded, but we will get to that in the next step.
243
+
244
+
245
+ ```python
246
+ {
247
+ "@id": "kb:Event2",
248
+ "@type": "engagement:PlannedEvent",
249
+ "engagement:eventContext": [...],
250
+ "uco-core:name": "adv-exfiltrates-Obfuscated-files"
251
+ }
252
+
253
+ ```
254
+
255
+ 10. The first thing we expect is an action that is partially-observable, but not entirely. In this case, we do not actually know if a file is exfiltrated until we are alerted by our `dataSource` that it recieved a signal from the obfuscated file through the canarytoken. We include an instance of `Alert` to represent the relationship between the CanaryTokenAlert system and the obfuscated files which we are able to deduce.
256
+
257
+
258
+ ```python
259
+ {
260
+ "@id": "kb:alert0",
261
+ "@type": "engagement:Alert",
262
+ "uco-action:performer": [
263
+ {
264
+ "@id": "kb:obffile1"
265
+ },
266
+ {
267
+ "@id": "kb:obffile2"
268
+ },
269
+ {
270
+ "@id": "kb:file1",
271
+ "@type": "uco-observable:File",
272
+ "uco-core:name": "backup-safe-passcode.pdf",
273
+ "uco-core:hasFacet": [
274
+ {
275
+ "@id": "kb:filefacet1",
276
+ "@type": "uco-observable:FileFacet",
277
+ "observable:filename": "backup-safe-passcode.pdf"
278
+ }
279
+ ]
280
+ },
281
+ {
282
+ "@id": "kb:file2",
283
+ "@type": "uco-observable:File",
284
+ "uco-core:name": "mining-procedure.pdf",
285
+ "uco-core:hasFacet": [
286
+ {
287
+ "@id": "kb:filefacet1",
288
+ "@type": "uco-observable:FileFacet",
289
+ "observable:filename": "mining-procedure.pdf"
290
+ }
291
+ ]
292
+ }
293
+ ],
294
+ "uco-action:object": [
295
+ {
296
+ "@id": "kb:DataSource1",
297
+ "@type": "engagement:DataSource",
298
+ "uco-core:name": "CanaryTokenAlert"
299
+ }
300
+ ]
301
+ }
302
+ ```
303
+
304
+ 11. The second thing we expect is to be alerted by some data source. Then, the action class we will use to describe this is an instance of [`Alert`](https://aeontology.sail-lab.org/docs/class-engagementalert.html). The `performer` for this instance of [`Alert`](https://aeontology.sail-lab.org/docs/class-engagementalert.html) is not going to be a person or identity, but rather an [`engagement:DataSource`](https://aeontology.sail-lab.org/docs/class-engagementdatasource.html) we call CanaryTokenAlert.
305
+ 12. The `object` property of `Alert` would be an identity such as a person such as our deployer, Richard Rocky.
306
+ 13. The attached objective to this action is `objective:Detect` because the usage of an alert is to inform a defender or identity of an event.
307
+
308
+
309
+ ```python
310
+ {
311
+ "@id": "kb:alert1",
312
+ "@type": "engagement:Alert",
313
+ "engagement:alertContext": [...],
314
+ "uco-action:object": [
315
+ {
316
+ "@id": "kb:person1"
317
+ }
318
+ ],
319
+ "uco-action:performer": [
320
+ {
321
+ "@id": "kb:DataSource1",
322
+ "@type": "engagement:DataSource",
323
+ "uco-core:name": "CanaryTokenAlert"
324
+ }
325
+ ]
326
+ }
327
+
328
+ ```
329
+
330
+ 14. We now expand the property `alertContext` to describe what this explicit alert implies about an occurence. By design, we expect to see another action such as `Access` since the alert informed us that one of the falsified files were accessed.
331
+ 15. Unified Cyber Ontology (UCO) explicitly has a class called `uco-observable:File` which we use to instantiate the UCO object itself with an attached facet `uco-observable:FileFacet`. We reference the `kb:obffile1` instance with the property `object`.
332
+
333
+ `kb:obffile1`
334
+
335
+
336
+ ```python
337
+ {
338
+ "engagement:alertContext": [
339
+ {
340
+ "@id": "kb:access1",
341
+ "@type": "engagement:Access",
342
+ "uco-action:object": [
343
+ {
344
+ "@id": "kb:obffile1",
345
+ },
346
+ {
347
+ "@id": "kb:file1",
348
+ "@type": "uco-observable:File",
349
+ "uco-core:name": "backup-safe-passcode.pdf",
350
+ "uco-core:hasFacet": [
351
+ {
352
+ "@id": "kb:filefacet1",
353
+ "@type": "uco-observable:FileFacet",
354
+ "observable:filename": "backup-safe-passcode.pdf"
355
+ }
356
+ ]
357
+ }
358
+ ],
359
+ "uco-action:performer": [...]
360
+ }
361
+ ]
362
+ }
363
+ ```
364
+
365
+ 16. We then repeat the process for `kb:obffile2`. Additionally, we expect the `performer` of the `Access` action to be a specific person, namely Mary Moroe. This is because she is the only other person that is aware of the physical safe and has a privilege user account that would have user account access to view this file.
366
+
367
+ `kb:obffile2`
368
+
369
+
370
+ ```python
371
+ {
372
+ "engagement:alertContext": [
373
+ {
374
+ "@id": "kb:access1",
375
+ "@type": "engagement:Access",
376
+ "uco-action:object": [
377
+ {
378
+ "@id": "kb:obffile2"
379
+ },
380
+ {
381
+ "@id": "kb:file2",
382
+ "@type": "uco-observable:File",
383
+ "uco-core:name": "mining-procedure.pdf",
384
+ "uco-core:hasFacet": [
385
+ {
386
+ "@id": "kb:filefacet1",
387
+ "@type": "uco-observable:FileFacet",
388
+ "observable:filename": "mining-procedure.pdf"
389
+ }
390
+ ]
391
+ }
392
+ ],
393
+ "uco-action:performer": [
394
+ {
395
+ "@id": "kb:person2",
396
+ "@type": "uco-identity:Person",
397
+ "uco-core:hasFacet": [
398
+ {
399
+ "@id": "kb:MaryMoroe",
400
+ "@type": "identity:SimpleNameFacet",
401
+ "uco-identity:familyName": "Mary",
402
+ "uco-identity:givenName": "Moroe"
403
+ }
404
+ ]
405
+ }
406
+ ]
407
+ }
408
+ ]
409
+ }
410
+ ```
411
+
412
+ 17. Now that the [`PlannedEvent`](https://aeontology.sail-lab.org/docs/class-engagementplannedevent.html) is complete, we now need to ensure that the `PlannedEvent(s)` can be used as a sequence of events tied to the [`engagement:Storyline`](https://aeontology.sail-lab.org/docs/class-engagementstoryline.html). To do this, UCO has a specific class called `uco-types:Thread` which has the structure for supporting the concepts of sequential relationships.
413
+
414
+ 18. Our explicit instance of [`engagement:Storyline`](https://aeontology.sail-lab.org/docs/class-engagementstoryline.html) uses a property called `hasEvent` to instantiate an instance of `uco-types:Thread`. The important properties of `uco-types:Thread` for our use case are: `co:element`, `co:item`, `co:size`, `uco-types:threadOriginItem`, `uco-types:threadTerminalItem`. We outline the necessary properties and will expand them separately.
415
+
416
+
417
+ ```python
418
+ {
419
+ "@id": "kb:storyline1",
420
+ "@type": "engagement:Storyline",
421
+ "engagement:hasEvent": [
422
+ {
423
+ "@id": "kb:eventthread1",
424
+ "@type": "uco-types:Thread",
425
+ "co:element": [...],
426
+ "co:item": [...],
427
+ "co:size": {...},
428
+ "uco-types:threadOriginItem": [...],
429
+ "uco-types:threadTerminalItem": [...]
430
+ }
431
+ ]
432
+ }
433
+ ```
434
+
435
+
436
+
437
+
438
+ {'@id': 'kb:storyline1',
439
+ '@type': 'engagement:Storyline',
440
+ 'engagement:hasEvent': [Ellipsis]}
441
+
442
+
443
+
444
+ `co:element` refers to the elements of the `Thread` so in our case, they reference our instantiated `PlannedEvent(s)`: `kb:Event1` and `kb:Event2`
445
+
446
+
447
+ ```python
448
+ {"co:element": [
449
+ {
450
+ "@id": "kb:Event1"
451
+ },
452
+ {
453
+ "@id": "kb:Event2"
454
+ }
455
+ ] }
456
+ ```
457
+
458
+
459
+
460
+
461
+ {'co:element': [{'@id': 'kb:Event1'}, {'@id': 'kb:Event2'}]}
462
+
463
+
464
+
465
+ `co:item` refers to the event as a thread item itself.
466
+
467
+
468
+ ```python
469
+ {
470
+
471
+ "co:item": [
472
+ {
473
+ "@id": "kb:event-thread-item1"
474
+ },
475
+ {
476
+ "@id": "kb:event-thread-item2"
477
+ }
478
+ ]}
479
+ ```
480
+
481
+
482
+
483
+
484
+ {'co:item': [{'@id': 'kb:event-thread-item1'},
485
+ {'@id': 'kb:event-thread-item2'}]}
486
+
487
+
488
+
489
+ `co:size` refers to the number of thread items in the thread.
490
+
491
+
492
+ ```python
493
+ { "co:size": {
494
+ "@type": "xsd:nonNegativeInteger",
495
+ "@value": "2"
496
+ }}
497
+ ```
498
+
499
+
500
+
501
+
502
+ {'co:size': {'@type': 'xsd:nonNegativeInteger', '@value': '2'}}
503
+
504
+
505
+
506
+ `uco-types:threadOriginItem` refers to the first thread item or source thread item.
507
+
508
+
509
+ ```python
510
+ { "uco-types:threadOriginItem": [
511
+ {
512
+ "@id": "kb:event-thread-item1"
513
+ }
514
+ ]}
515
+ ```
516
+
517
+
518
+
519
+
520
+ {'uco-types:threadOriginItem': [{'@id': 'kb:event-thread-item1'}]}
521
+
522
+
523
+
524
+ `uco-types:threadTerminalItem` refers to the last thread item which terminates the sequence of thread items.
525
+
526
+
527
+ ```python
528
+ {
529
+ "uco-types:threadTerminalItem": [
530
+ {
531
+ "@id": "kb:event-thread-item2"
532
+ }
533
+ ]
534
+ }
535
+ ```
536
+
537
+
538
+
539
+
540
+ {'uco-types:threadTerminalItem': [{'@id': 'kb:event-thread-item2'}]}
541
+
542
+
543
+
544
+ 19. Finally, in the home stretch, we need to use `uco-types:ThreadItem` to create the chain of threads using the `uco-types:threadNextItem` property and `uco-types:threadPreviousItem` property. `kb:Event1` only uses the `threadNextItem` and `kb:Event2` only uses the `threadPreviousItem`.
545
+
546
+ `kb:Event1`
547
+
548
+
549
+ ```python
550
+ {
551
+ "@id": "kb:event-thread-item1",
552
+ "@type": "uco-types:ThreadItem",
553
+ "co:itemContent": {
554
+ "@id": "kb:Event1"
555
+ },
556
+ "uco-types:threadNextItem": [
557
+ {
558
+ "@id": "kb:event-thread-item2"
559
+ }
560
+ ]
561
+ }
562
+ ```
563
+
564
+
565
+
566
+
567
+ {'@id': 'kb:event-thread-item1',
568
+ '@type': 'uco-types:ThreadItem',
569
+ 'co:itemContent': {'@id': 'kb:Event1'},
570
+ 'uco-types:threadNextItem': [{'@id': 'kb:event-thread-item2'}]}
571
+
572
+
573
+
574
+ `kb:Event2`
575
+
576
+
577
+ ```python
578
+ {
579
+ "@id": "kb:event-thread-item2",
580
+ "@type": "uco-types:ThreadItem",
581
+ "co:itemContent": {
582
+ "@id": "kb:Event2"
583
+ },
584
+ "uco-types:threadPreviousItem": [
585
+ {
586
+ "@id": "kb:event-thread-item1"
587
+ }
588
+ ]
589
+ }
590
+
591
+ ```
592
+
593
+
594
+
595
+
596
+ {'@id': 'kb:event-thread-item2',
597
+ '@type': 'uco-types:ThreadItem',
598
+ 'co:itemContent': {'@id': 'kb:Event2'},
599
+ 'uco-types:threadPreviousItem': [{'@id': 'kb:event-thread-item1'}]}
600
+
601
+
602
+
603
+ And voila! Your adversary engagement plan is now fully represented in a standardized knowledge graph using the AE ontology.
604
+
605
+ # Querying a Graph
606
+
607
+ Now that we have a fully functional example which we can insert into a graph database, let's test some queries. We'll work with logistics for the narrative which can help in the development of more variance and variety of deception techniques used within the `Narrative`
608
+
609
+
610
+ ```python
611
+ import rdflib
612
+ g = rdflib.Graph()
613
+ narrative_example = "SmallBusinessExample.jsonld"
614
+ g.parse(narrative_example)
615
+ ```
616
+
617
+
618
+
619
+
620
+ <Graph identifier=N3f6735a044f846e19ecfecb90e0d2179 (<class 'rdflib.graph.Graph'>)>
621
+
622
+
623
+
624
+ ## [Q] How many deception objects were instantiated with the objective `engagement:Exfiltrate`?
625
+
626
+ It may be useful to know how many deception objects were deployed with the objective to be exfiltrated. For our example, it is relatively easy to deploy more obfuscated files on a network than scale up the number of highly functional honeypots on a network, therefore perhaps in a revision of the deception plan, more falsified files are placed on the network for more visibility.
627
+
628
+
629
+ ```python
630
+ query = """
631
+ PREFIX co: <http://purl.org/co/>
632
+ PREFIX kb: <http://example.org/kb/>
633
+ PREFIX engagement: <https://ontology.adversaryengagement.org/ae/engagement/>
634
+ PREFIX objective: <https://ontology.adversaryengagement.org/ae/objective/>
635
+
636
+
637
+ SELECT (COUNT(DISTINCT ?s) as ?count)
638
+
639
+ WHERE {
640
+ ?s objective:hasObjective ?o .
641
+ ?s ?p objective:Exfiltrate .
642
+ }
643
+ """
644
+ for row in g.query(query):
645
+ print(row)
646
+ ```
647
+
648
+ (rdflib.term.Literal('2', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#integer')),)
649
+
650
+
651
+ ## [Q] What are the distinct objectives used during planned events that deployed objects?
652
+
653
+ It may also be useful to know whether or not our deception operation uses a wide variety of techniques based on their objective. If we know specific characteristics of an adversary such as their attack pattern preferences, we may wish to diversify our plan or simulate a network environment that caters to their preferences for false sense of security.
654
+
655
+
656
+ ```python
657
+ query = """
658
+ PREFIX co: <http://purl.org/co/>
659
+ PREFIX kb: <http://example.org/kb/>
660
+ PREFIX engagement: <https://ontology.adversaryengagement.org/ae/engagement/>
661
+ PREFIX objective: <https://ontology.adversaryengagement.org/ae/objective/>
662
+
663
+
664
+ SELECT DISTINCT ?obj
665
+
666
+ WHERE {
667
+ ?allevents engagement:eventContext ?action .
668
+ ?action ?p engagement:Deploy .
669
+ ?event ?y ?action .
670
+ ?event engagement:eventContext ?action .
671
+ ?action ?has ?object .
672
+ ?object objective:hasObjective ?obj .
673
+ }
674
+ """
675
+ for row in g.query(query):
676
+ print(row)
677
+ ```
678
+
679
+ (rdflib.term.URIRef('https://ontology.adversaryengagement.org/ae/objective/Direct'),)
680
+ (rdflib.term.URIRef('https://ontology.adversaryengagement.org/ae/objective/Exfilitrate'),)
681
+
682
+
683
+ ### Full JSON-LD Format
684
+
685
+
686
+ ```python
687
+ {
688
+ "@context": {
689
+ "co": "http://purl.org/co/",
690
+ "engagement": "https://ontology.adversaryengagement.org/ae/engagement/",
691
+ "objective": "https://ontology.adversaryengagement.org/ae/objective/",
692
+ "role": "https://ontology.adversaryengagement.org/ae/role/",
693
+ "kb": "http://example.org/kb/",
694
+ "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
695
+ "uco-action": "https://ontology.unifiedcyberontology.org/uco/action/",
696
+ "uco-core": "https://ontology.unifiedcyberontology.org/uco/core/",
697
+ "uco-identity": "https://ontology.unifiedcyberontology.org/uco/identity/",
698
+ "uco-observable": "https://ontology.unifiedcyberontology.org/uco/observable/",
699
+ "uco-types": "https://ontology.unifiedcyberontology.org/uco/types/",
700
+ "xsd": "http://www.w3.org/2001/XMLSchema#"
701
+ },
702
+ "@graph": [
703
+ {
704
+ "@id": "kb:narrative1",
705
+ "@type": "engagement:Narrative",
706
+ "engagement:hasStoryline": [
707
+ {
708
+ "@id": "kb:storyline1",
709
+ "@type": "engagement:Storyline",
710
+ "uco-core:name": "ProtectTheFilesNarrative"
711
+ }
712
+ ],
713
+ "objective:hasObjective": [
714
+ {
715
+ "@id": "kb:objective1",
716
+ "@type": "objective:Objective",
717
+ "uco-core:name": "ProtectTheFiles"
718
+ }
719
+ ],
720
+ "uco-core:description": "Grand objective is to lure adversaries or insiders on the network away from details of the mining operations, location and passcode of the safe containing intellectual property."
721
+ },
722
+ {
723
+ "@id": "kb:Event1",
724
+ "@type": "engagement:PlannedEvent",
725
+ "engagement:eventContext": [
726
+ {
727
+ "@id": "kb:deploy1",
728
+ "@type": "engagement:Deploy",
729
+ "uco-action:object": [
730
+ {
731
+ "@id": "kb:honeypot1",
732
+ "@type": "engagement:Honeypot",
733
+ "uco-core:description": "Fake production server to contain the fabricated files.",
734
+ "objective:hasObjective": [
735
+ {
736
+ "@id": "objective:Direct"
737
+ }
738
+ ]
739
+
740
+ },
741
+ {
742
+ "@id": "kb:obffile1",
743
+ "@type": "engagement:LureObject",
744
+ "uco-core:name": "mining-procedure.pdf",
745
+ "uco-core:description": "ADO file of mining procedures.",
746
+ "objective:hasObjective": [
747
+ {
748
+ "@id": "objective:Exfiltrate"
749
+ }
750
+ ]
751
+ },
752
+ {
753
+ "@id": "kb:obffile2",
754
+ "@type": "engagement:LureObject",
755
+ "uco-core:name": "backup-safe-passcode.pdf",
756
+ "uco-core:description": "ADO file of safe passcode and physical location of the safe.",
757
+ "objective:hasObjective": [
758
+ {
759
+ "@id": "objective:Exfiltrate"
760
+ }
761
+ ]
762
+ }
763
+ ],
764
+ "uco-action:performer": [
765
+ {
766
+ "@id": "kb:person1",
767
+ "@type": "uco-identity:Person",
768
+ "uco-core:hasFacet": [
769
+ {
770
+ "@id": "kb:RichardRocky",
771
+ "@type": "identity:SimpleNameFacet",
772
+ "uco-identity:familyName": "Richard",
773
+ "uco-identity:givenName": "Rocky"
774
+ }
775
+ ]
776
+ }
777
+ ]
778
+ }
779
+ ],
780
+ "objective:hasObjective": [
781
+ {
782
+ "@id": "objective:Deploy"
783
+ }
784
+ ],
785
+ "uco-core:name": "def-deploy-deception-objects"
786
+ },
787
+ {
788
+ "@id": "kb:Event2",
789
+ "@type": "engagement:PlannedEvent",
790
+ "engagement:eventContext": [
791
+ {
792
+ "@id": "kb:alert0",
793
+ "@type": "engagement:Alert",
794
+ "uco-action:performer": [
795
+ {
796
+ "@id": "kb:obffile1"
797
+ },
798
+ {
799
+ "@id": "kb:obffile2"
800
+ },
801
+ {
802
+ "@id": "kb:file1",
803
+ "@type": "uco-observable:File",
804
+ "uco-core:name": "backup-safe-passcode.pdf",
805
+ "uco-core:hasFacet": [
806
+ {
807
+ "@id": "kb:filefacet1",
808
+ "@type": "uco-observable:FileFacet",
809
+ "observable:filename": "backup-safe-passcode.pdf"
810
+ }
811
+ ]
812
+ },
813
+ {
814
+ "@id": "kb:file2",
815
+ "@type": "uco-observable:File",
816
+ "uco-core:name": "mining-procedure.pdf",
817
+ "uco-core:hasFacet": [
818
+ {
819
+ "@id": "kb:filefacet1",
820
+ "@type": "uco-observable:FileFacet",
821
+ "observable:filename": "mining-procedure.pdf"
822
+ }
823
+ ]
824
+ }
825
+ ],
826
+ "uco-action:object": [
827
+ {
828
+ "@id": "kb:DataSource1",
829
+ "@type": "engagement:DataSource",
830
+ "uco-core:name": "CanaryTokenAlert"
831
+ }
832
+ ]
833
+ },
834
+
835
+
836
+ {
837
+ "@id": "kb:alert1",
838
+ "@type": "engagement:Alert",
839
+ "engagement:alertContext": [
840
+ {
841
+ "@id": "kb:access1",
842
+ "@type": "engagement:Access",
843
+ "uco-action:object": [
844
+ {
845
+ "@id": "kb:obffile1"
846
+ },
847
+ {
848
+ "@id": "kb:obffile2"
849
+ },
850
+ {
851
+ "@id": "kb:file1",
852
+ "@type": "uco-observable:File",
853
+ "uco-core:name": "backup-safe-passcode.pdf",
854
+ "uco-core:hasFacet": [
855
+ {
856
+ "@id": "kb:filefacet1",
857
+ "@type": "uco-observable:FileFacet",
858
+ "observable:filename": "backup-safe-passcode.pdf"
859
+ }
860
+ ]
861
+ },
862
+ {
863
+ "@id": "kb:file2",
864
+ "@type": "uco-observable:File",
865
+ "uco-core:name": "mining-procedure.pdf",
866
+ "uco-core:hasFacet": [
867
+ {
868
+ "@id": "kb:filefacet1",
869
+ "@type": "uco-observable:FileFacet",
870
+ "observable:filename": "mining-procedure.pdf"
871
+ }
872
+ ]
873
+ }
874
+ ],
875
+ "uco-action:performer": [
876
+ {
877
+ "@id": "kb:person2",
878
+ "@type": "uco-identity:Person",
879
+ "uco-core:hasFacet": [
880
+ {
881
+ "@id": "kb:MaryMoroe",
882
+ "@type": "identity:SimpleNameFacet",
883
+ "uco-identity:familyName": "Mary",
884
+ "uco-identity:givenName": "Moroe"
885
+ }
886
+ ]
887
+ }
888
+ ]
889
+ }
890
+ ],
891
+ "uco-action:object": [
892
+ {
893
+ "@id": "kb:person1"
894
+ }
895
+ ],
896
+ "uco-action:performer": [
897
+ {
898
+ "@id": "kb:DataSource1",
899
+ "@type": "engagement:DataSource",
900
+ "uco-core:name": "CanaryTokenAlert"
901
+ }
902
+ ]
903
+ }
904
+ ],
905
+ "objective:hasObjective": [
906
+ {
907
+ "@id": "objective:Detect"
908
+ }
909
+ ],
910
+ "uco-core:name": "adv-exfiltrates-Obfuscated-files"
911
+ },
912
+
913
+ {
914
+ "@id": "kb:storyline1",
915
+ "@type": "engagement:Storyline",
916
+ "engagement:hasEvent": [
917
+ {
918
+ "@id": "kb:eventthread1",
919
+ "@type": "uco-types:Thread",
920
+ "co:element": [
921
+ {
922
+ "@id": "kb:Event1"
923
+ },
924
+ {
925
+ "@id": "kb:Event2"
926
+ }
927
+ ],
928
+ "co:item": [
929
+ {
930
+ "@id": "kb:event-thread-item1"
931
+ },
932
+ {
933
+ "@id": "kb:event-thread-item2"
934
+ }
935
+ ],
936
+ "co:size": {
937
+ "@type": "xsd:nonNegativeInteger",
938
+ "@value": "2"
939
+ },
940
+ "uco-types:threadOriginItem": [
941
+ {
942
+ "@id": "kb:event-thread-item1"
943
+ }
944
+ ],
945
+ "uco-types:threadTerminalItem": [
946
+ {
947
+ "@id": "kb:event-thread-item2"
948
+ }
949
+ ]
950
+ }
951
+ ]
952
+ },
953
+ {
954
+ "@id": "kb:event-thread-item1",
955
+ "@type": "uco-types:ThreadItem",
956
+ "co:itemContent": {
957
+ "@id": "kb:Event1"
958
+ },
959
+ "uco-types:threadNextItem": [
960
+ {
961
+ "@id": "kb:event-thread-item2"
962
+ }
963
+ ]
964
+ },
965
+ {
966
+ "@id": "kb:event-thread-item2",
967
+ "@type": "uco-types:ThreadItem",
968
+ "co:itemContent": {
969
+ "@id": "kb:Event2"
970
+ },
971
+ "uco-types:threadPreviousItem": [
972
+ {
973
+ "@id": "kb:event-thread-item1"
974
+ }
975
+ ]
976
+ }
977
+ ]
978
+ }
979
+
980
+ ```
981
+
982
+
983
+
984
+
985
+ {'@context': {'co': 'http://purl.org/co/',
986
+ 'engagement': 'https://ontology.adversaryengagement.org/ae/engagement/',
987
+ 'objective': 'https://ontology.adversaryengagement.org/ae/objective/',
988
+ 'role': 'https://ontology.adversaryengagement.org/ae/role/',
989
+ 'kb': 'http://example.org/kb/',
990
+ 'rdfs': 'http://www.w3.org/2000/01/rdf-schema#',
991
+ 'uco-action': 'https://ontology.unifiedcyberontology.org/uco/action/',
992
+ 'uco-core': 'https://ontology.unifiedcyberontology.org/uco/core/',
993
+ 'uco-identity': 'https://ontology.unifiedcyberontology.org/uco/identity/',
994
+ 'uco-observable': 'https://ontology.unifiedcyberontology.org/uco/observable/',
995
+ 'uco-types': 'https://ontology.unifiedcyberontology.org/uco/types/',
996
+ 'xsd': 'http://www.w3.org/2001/XMLSchema#'},
997
+ '@graph': [{'@id': 'kb:narrative1',
998
+ '@type': 'engagement:Narrative',
999
+ 'engagement:hasStoryline': [{'@id': 'kb:storyline1',
1000
+ '@type': 'engagement:Storyline',
1001
+ 'uco-core:name': 'ProtectTheFilesNarrative'}],
1002
+ 'objective:hasObjective': [{'@id': 'kb:objective1',
1003
+ '@type': 'objective:Objective',
1004
+ 'uco-core:name': 'ProtectTheFiles'}],
1005
+ 'uco-core:description': 'Grand objective is to lure adversaries or insiders on the network away from details of the mining operations, location and passcode of the safe containing intellectual property.'},
1006
+ {'@id': 'kb:Event1',
1007
+ '@type': 'engagement:PlannedEvent',
1008
+ 'engagement:eventContext': [{'@id': 'kb:deploy1',
1009
+ '@type': 'engagement:Deploy',
1010
+ 'uco-action:object': [{'@id': 'kb:honeypot1',
1011
+ '@type': 'engagement:Honeypot',
1012
+ 'uco-core:description': 'Fake production server to contain the fabricated files.',
1013
+ 'objective:hasObjective': [{'@id': 'objective:Direct'}]},
1014
+ {'@id': 'kb:obffile1',
1015
+ '@type': 'engagement:LureObject',
1016
+ 'uco-core:name': 'mining-procedure.pdf',
1017
+ 'uco-core:description': 'ADO file of mining procedures.',
1018
+ 'objective:hasObjective': [{'@id': 'objective:exfiltrate'}]},
1019
+ {'@id': 'kb:obffile2',
1020
+ '@type': 'engagement:LureObject',
1021
+ 'uco-core:name': 'backup-safe-passcode.pdf',
1022
+ 'uco-core:description': 'ADO file of safe passcode and physical location of the safe.',
1023
+ 'objective:hasObjective': [{'@id': 'objective:exfiltrate'}]}],
1024
+ 'uco-action:performer': [{'@id': 'kb:person1',
1025
+ '@type': 'uco-identity:Person',
1026
+ 'uco-core:hasFacet': [{'@id': 'kb:RichardRocky',
1027
+ '@type': 'identity:SimpleNameFacet',
1028
+ 'uco-identity:familyName': 'Richard',
1029
+ 'uco-identity:givenName': 'Rocky'}]}]}],
1030
+ 'objective:hasObjective': [{'@id': 'objective:Deploy'}],
1031
+ 'uco-core:name': 'def-deploy-deception-objects'},
1032
+ {'@id': 'kb:Event2',
1033
+ '@type': 'engagement:PlannedEvent',
1034
+ 'engagement:eventContext': [{'@id': 'kb:alert1',
1035
+ '@type': 'engagement:Alert',
1036
+ 'engagement:alertContext': [{'@id': 'kb:access1',
1037
+ '@type': 'engagement:Access',
1038
+ 'uco-action:object': [{'@id': 'kb:obffile1'},
1039
+ {'@id': 'kb:obffile2'},
1040
+ {'@id': 'kb:file1',
1041
+ '@type': 'uco-observable:File',
1042
+ 'uco-core:name': 'backup-safe-passcode.pdf',
1043
+ 'uco-core:hasFacet': [{'@id': 'kb:filefacet1',
1044
+ '@type': 'uco-observable:FileFacet',
1045
+ 'observable:filename': 'backup-safe-passcode.pdf'}]},
1046
+ {'@id': 'kb:file2',
1047
+ '@type': 'uco-observable:File',
1048
+ 'uco-core:name': 'mining-procedure.pdf',
1049
+ 'uco-core:hasFacet': [{'@id': 'kb:filefacet1',
1050
+ '@type': 'uco-observable:FileFacet',
1051
+ 'observable:filename': 'mining-procedure.pdf'}]}],
1052
+ 'uco-action:performer': [{'@id': 'kb:person2',
1053
+ '@type': 'uco-identity:Person',
1054
+ 'uco-core:hasFacet': [{'@id': 'kb:MaryMoroe',
1055
+ '@type': 'identity:SimpleNameFacet',
1056
+ 'uco-identity:familyName': 'Mary',
1057
+ 'uco-identity:givenName': 'Moroe'}]}]}],
1058
+ 'uco-action:object': [{'@id': 'kb:person1'}],
1059
+ 'uco-action:performer': [{'@id': 'kb:DataSource1',
1060
+ '@type': 'engagement:DataSource',
1061
+ 'uco-core:name': 'CanaryTokenAlert'}]}],
1062
+ 'objective:hasObjective': [{'@id': 'objective:Detect'}],
1063
+ 'uco-core:name': 'adv-exfiltrates-Obfuscated-files'},
1064
+ {'@id': 'kb:storyline1',
1065
+ '@type': 'engagement:Storyline',
1066
+ 'engagement:hasEvent': [{'@id': 'kb:eventthread1',
1067
+ '@type': 'uco-types:Thread',
1068
+ 'co:element': [{'@id': 'kb:Event1'}, {'@id': 'kb:Event2'}],
1069
+ 'co:item': [{'@id': 'kb:event-thread-item1'},
1070
+ {'@id': 'kb:event-thread-item2'}],
1071
+ 'co:size': {'@type': 'xsd:nonNegativeInteger', '@value': '2'},
1072
+ 'uco-types:threadOriginItem': [{'@id': 'kb:event-thread-item1'}],
1073
+ 'uco-types:threadTerminalItem': [{'@id': 'kb:event-thread-item2'}]}]},
1074
+ {'@id': 'kb:event-thread-item1',
1075
+ '@type': 'uco-types:ThreadItem',
1076
+ 'co:itemContent': {'@id': 'kb:Event1'},
1077
+ 'uco-types:threadNextItem': [{'@id': 'kb:event-thread-item2'}]},
1078
+ {'@id': 'kb:event-thread-item2',
1079
+ '@type': 'uco-types:ThreadItem',
1080
+ 'co:itemContent': {'@id': 'kb:Event2'},
1081
+ 'uco-types:threadPreviousItem': [{'@id': 'kb:event-thread-item1'}]}]}
1082
+
1083
+
1084
+
1085
+ Note: Objectives are considered individual and, as such, will not be found under any classes in the documentation. For more details on the AE Ontology Documentation, please [click here](https://aeontology.sail-lab.org/docs/index.html). The UCO Documentation can be accessed from this [link.](https://unifiedcyberontology.org/releases/0.7.0/docs/index.html)
1086
+
1087
+
1088
+ The aforementioned examples are based on the latest release of AE Ontology version 0.1.8. It should be noted that the AE Ontology will continue to incorporate additive improvements, which may involve the inclusion of new classes and the removal of old concepts, potentially affecting the existing examples. We recommend checking the [latest release](https://aeontology.sail-lab.org/release/) news on [AE ontology website](https://aeontology.sail-lab.org/) to ensure you have access to the most up-to-date information. Additionally, supplementary examples can be found in the GitHub [`examples`](https://github.com/UNHSAILLab/Adversary-Engagement-Ontology/tree/main/examples) directory. Lastly, if you have any inquiries, please do not hesitate to contact us through this [contact form](https://aeontology.sail-lab.org/contact/).
1089
+
docs/aeo_example_generator.py ADDED
@@ -0,0 +1,300 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import openai
3
+ import json
4
+ import rdflib
5
+
6
+
7
+ class ExampleGenerator:
8
+ def __init__(self):
9
+ self.ontologies = {}
10
+ self.ontology_files = []
11
+ self.rules = {}
12
+ def add_ontology(self, onto):
13
+ if onto in self.ontology_files:
14
+ raise ValueError("Ontology file already exists.")
15
+ else:
16
+ onto_data = self.get_ontology_file(onto)
17
+ if onto_data:
18
+ self.ontology_files.append(onto)
19
+ self.ontologies[onto] = self.get_ontology_file(onto)
20
+ self.rules[onto] = self.generate_rules(onto)
21
+ else:
22
+ raise ValueError("Ontology file error.")
23
+ def get_ontology_file(self,filename):
24
+ text = ""
25
+ if os.path.isfile(filename):
26
+ with open(filename,'r') as f:
27
+ text = f.read()
28
+ f.close()
29
+ return text
30
+ else:
31
+ raise ValueError("Invalid filename.")
32
+ def ChatGPTTextSplitter(self,text):
33
+ """Splits text in smaller subblocks to feed to the LLM"""
34
+ prompt = f"""The total length of content that I want to send you is too large to send in only one piece.
35
+
36
+ For sending you that content, I will follow this rule:
37
+
38
+ [START PART 1/10]
39
+ this is the content of the part 1 out of 10 in total
40
+ [END PART 1/10]
41
+
42
+ Then you just answer: "Instructions Sent."
43
+
44
+ And when I tell you "ALL PARTS SENT", then you can continue processing the data and answering my requests.
45
+ """
46
+ if type(text) == str:
47
+ textsize = 12000
48
+ blocksize = int(len(text) / textsize)
49
+ if blocksize > 0:
50
+ yield prompt
51
+
52
+ for b in range(1,blocksize+1):
53
+ if b < blocksize+1:
54
+ prompt = f"""Do not answer yet. This is just another part of the text I want to send you. Just receive and acknowledge as "Part {b}/{blocksize} received" and wait for the next part.
55
+ [START PART {b}/{blocksize}]
56
+ {text[(b-1)*textsize:b*textsize]}
57
+ [END PART {b}/{blocksize}]
58
+ Remember not answering yet. Just acknowledge you received this part with the message "Part {b}/{blocksize} received" and wait for the next part.
59
+ """
60
+ yield prompt
61
+ else:
62
+ prompt = f"""
63
+ [START PART {b}/{blocksize}]
64
+ {text[(b-1)*textsize:b*textsize]}
65
+ [END PART {b}/{blocksize}]
66
+ ALL PARTS SENT. Now you can continue processing the request.
67
+ """
68
+ yield prompt
69
+ else:
70
+ yield text
71
+ elif type(text) == list:
72
+ yield prompt
73
+
74
+ for n,block in enumerate(text):
75
+ if n+1 < len(text):
76
+ prompt = f"""Do not answer yet. This is just another part of the text I want to send you. Just receive and acknowledge as "Part {n+1}/{len(text)} received" and wait for the next part.
77
+ [START PART {n+1}/{len(text)}]
78
+ {text[n]}
79
+ [END PART {n+1}/{len(text)}]
80
+ Remember not answering yet. Just acknowledge you received this part with the message "Part {n+1}/{len(text)} received" and wait for the next part.
81
+ """
82
+ yield prompt
83
+ else:
84
+ prompt = f"""
85
+ [START PART {n+1}/{len(text)}]
86
+ {text[n]}
87
+ [END PART {n+1}/{len(text)}]
88
+ ALL PARTS SENT. Now you can continue processing the request.
89
+ """
90
+ yield prompt
91
+
92
+ def send_ontology(self):
93
+ ontology = ""
94
+ if len(self.ontologies) > 0:
95
+ for k,v in self.ontologies.items():
96
+ ontology+=v+"\n"
97
+ print("Sending Ontology in Parts")
98
+ for i in self.ChatGPTTextSplitter(ontology):
99
+ print(self.llm_api(i))
100
+ else:
101
+ raise ValueError("No loaded ontology to send.")
102
+ def llm_api(self,prompt,model="gpt-3.5-turbo"):
103
+ messages = [{
104
+ "role":"user",
105
+ "content":prompt
106
+ }]
107
+ res = openai.ChatCompletion.create(model=model,messages=messages,temperature=0)
108
+ return res.choices[0].message['content']
109
+
110
+ def generate_rule(self,onto=None):
111
+ """Raw rule string of AEO."""
112
+ v = """Remember make a json-ld format example that only uses classes and properties terms from Adversary Engagement Ontology, Unified Cyber Ontology.
113
+
114
+ Each engagement:Narrative has property:
115
+ engagement:hasStoryline connects to an engagement:Storyline
116
+ Each engagement:Storyline has property:
117
+ engagement:hasEvent connects to a uco-types:Thread
118
+ Each uco-types:Thread has properties:
119
+ co:element contains all engagement:PlannedEvents
120
+ co:item contains all uco-types:ThreadItem one each for each engagement:PlannedEvent.
121
+ co:size
122
+ uco-types:threadOriginItem is the uco-types:ThreadItem for the first engagement:PlannedEvent
123
+ uco-types:threadTerminalItem is the uco-types:ThreadItem for the last engagement:PlannedEvent
124
+ Each co:size has properties:
125
+ @type as xsd:nonNegativeInteger
126
+ @value which is the number of uco-types:ThreadItem
127
+ Each uco-types:ThreadItem has property:
128
+ co:itemContent is the engagement:PlannedEvent
129
+ optional uco-types:threadNextItem is the next uco-types:ThreadItem for the next engagement:PlannedEvent if there is one,
130
+ optional uco-types:threadPreviousItem is the previous uco-types:ThreadItem for the previous engagement:PlannedEvent if there is one
131
+ Each engagement:PlannedEvent has property:
132
+ engagement:eventContext connects to one engagement action has property @type one of the following:
133
+ engagement:Access
134
+ engagement:Alert
135
+ engagement:Beacon
136
+ engagement:Deploy
137
+ engagement:Obfuscate
138
+ engagement:Respond
139
+ Each engagement action has properties:
140
+ @type is the action
141
+ uco-core:performer
142
+ uco-core:object connects to one of the following engagement deception object denoted as "EDO" objects:
143
+ engagement:Honeypot
144
+ engagement:Honeytoken
145
+ engagement:Breadcrumb
146
+ engagement:BreadcrumbTrail
147
+ engagement:LureObject
148
+ engagement:HoneyObject
149
+ engagement:Decoy
150
+ engagement:DataSource
151
+ Each "EDO" object has properties:
152
+ engagement:hasCharacterization connects to a uco-core:UcoObject
153
+ objective:hasObjective with @type objective:Objective and @id with one of the following instances:
154
+ objective:CommandAndControl
155
+ objective:CredentialAccess
156
+ objective:DevelopResource
157
+ objective:Discover
158
+ objective:EscalatePrivilege
159
+ objective:Evade
160
+ objective:Execute
161
+ objective:Exfilitrate
162
+ objective:GainInitialAccess
163
+ objective:Impact
164
+ objective:MoveLaterally
165
+ objective:Persist
166
+ objective:Reconnaissance
167
+ objective:Affect
168
+ objective:Collect
169
+ objective:Detect
170
+ objective:Direct
171
+ objective:Disrupt
172
+ objective:Elicit
173
+ objective:Expose
174
+ objective:Motivate
175
+ objective:Plan
176
+ objective:Prepare
177
+ objective:Prevent
178
+ objective:Reassure
179
+ objective:Analyze
180
+ objective:Deny
181
+ objective:ElicitBehavior
182
+ objective:Lure
183
+ objective:TimeSink
184
+ objective:Track
185
+ objective:Trap
186
+ uco-core:name is the objective
187
+ All people have property:
188
+ @type is uco-identity:Person
189
+ uco-core:hasFacet that connects to one of the following:
190
+ uco-identity:SimpleNameFacet which has the property:
191
+ uco-identity:familyName
192
+ uco-identity:givenName
193
+ Each uco-core:Role has properties:
194
+ @id is the role
195
+ uco-core:name is the role
196
+ Each uco-core:Role there is a uco-core:Relationship with properties:
197
+ uco-core:kindofRelationship is "has_Role"
198
+ uco-core:source connects to the person who has the role
199
+ uco-core:target connects to uco-core:Role
200
+ Each engagement:BreadcrumbTrail has property:
201
+ engagement:hasBreadcrumb connects to uco-types:Thread
202
+ This uco-types:Thread has property:
203
+ co:element contains all engagement:Breadcrumb that belong to this engagement:BreadcrumbTrail
204
+ co:item contains all uco-types:ThreadItem one each for each engagement:Breadcrumb
205
+ co:size
206
+ uco-types:threadOriginItem is the uco-types:ThreadItem for the first engagement:Breadcrumb belonging to this engagement:BreadcrumbTrail
207
+ uco-types:threadTerminalItem is the uco-types:ThreadItem for the last engagement:Breadcrumb belonging to this engagement:BreadcrumbTrail
208
+ Each engagement:Breadcrumb has the properties:
209
+ engagement:hasCharacterization which connects to a uco-core:UcoObject with the property:
210
+ uco-core:description which describes the object characterizing the breadcrumb
211
+ All classes must include property:
212
+ @type is the class
213
+ @id is a unique identifier
214
+
215
+ If namespace "engagement" prefix is used then https://ontology.adversaryengagement.org/ae/engagement#
216
+ If namespace "objective" prefix is used then https://ontology.adversaryengagement.org/ae/objective#
217
+ If namespace "role" prefix is used then https://ontology.adversaryengagement.org/ae/role#
218
+ If namespace "identity" prefix is used then https://ontology.adversaryengagement.org/ae/identity#
219
+ If namespace "uco-core" prefix is used then https://ontology.unifiedcyberontology.org/uco/core#
220
+ If namespace "uco-types" prefix is used then https://ontology.unifiedcyberontology.org/uco/types#
221
+ If namespace "uco-role" prefix is used then https://ontology.unifiedcyberontology.org/uco/role#
222
+ """
223
+ return v
224
+
225
+ def generate_continue(self):
226
+ v = """
227
+ continue
228
+ """
229
+ return v
230
+
231
+ def raw_prompt(self,description):
232
+
233
+ def run(val):
234
+ prompt = f"""Give me a full json-ld format example for the following scenario:
235
+ {description}
236
+
237
+ {"".join(val)}
238
+ """
239
+ for i in self.ChatGPTTextSplitter(prompt):
240
+ res = self.llm_api(i)
241
+ return res
242
+ # return json.loads(res)
243
+ res_val = run(self.generate_rule())
244
+ #res_val = run(self.generate_rules())
245
+ try:
246
+ val = json.loads(res_val)
247
+ return val
248
+ except:
249
+ #the response was cut off, prompt for the continuation.
250
+ data = []
251
+ data.append(res_val)
252
+ while True:
253
+ res = self.llm_api(self.generate_continue())
254
+ data.append(res)
255
+ try:
256
+ full = "".join(data)
257
+ return json.loads(full)
258
+ except:
259
+ pass
260
+
261
+ return None
262
+
263
+ def get_ns(self,string):
264
+ return string.split(":")[0]
265
+
266
+
267
+ def prompt(self,description):
268
+ res = self.raw_prompt(description)
269
+
270
+ #include only relevent namespaces
271
+ prefixes = []
272
+
273
+ def is_nested(LIST):
274
+ if type(LIST) == list:
275
+ for JSON in LIST:
276
+ for key in JSON.keys():
277
+ if type(JSON[key]) == dict:
278
+ is_nested(JSON[key])
279
+ if '@type' in JSON.keys():
280
+ prefixes.append(self.get_ns(JSON['@type']))
281
+ else:
282
+ JSON = LIST
283
+ for key in JSON.keys():
284
+ if type(JSON[key]) == dict:
285
+ is_nested(JSON[key])
286
+ if '@type' in JSON.keys():
287
+ prefixes.append(self.get_ns(JSON['@type']))
288
+
289
+
290
+ is_nested(res['@graph'])
291
+ prefixes = set(prefixes)
292
+
293
+ new_prefixes = {}
294
+ for prefix in prefixes:
295
+ if prefix in res['@context']:
296
+ new_prefixes[prefix] = res['@context'][prefix]
297
+
298
+ res['@context'] = new_prefixes
299
+
300
+ return res
pages/1_AEO_Example_Generator.py ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import openai
3
+
4
+
5
+
6
+
7
+ st.title('AEO Example Generator')
8
+
9
+ about = ''' Adversary Engagement Ontology (AEO) is a candidate ontology to the Unified Cyber Ontology (UCO), a community effort for the ontological standardization of cyber domain concepts and objects under a unifying framework, and is part of the Cyber Domain Ontology (CDO). Community efforts and development has always been manual labor intensive in regards to ontology changes, ontology example generation for adopters, documentation generation. Large Language Models (LLMs) have been shown to be capable of automating many tasks or aiding in human expert decision-making. We demonstrate how foundational LLMs such as ChatGPT and GPT4 can assist in ontology example generation, ontology development, and overall be used in automation tooling for structured but tedious tasks.
10
+ This space can be used to create an example of how to setup the AEO instance. It uses the power of OpenAI's ChatGPT.
11
+ The generator currently uses strictly prewritten rules of AEO, discussion on an automation process is still early .
12
+ he generator currently is bounded by prompt size limits.
13
+
14
+ There are some known work arounds but none are functionally implemented yet.
15
+
16
+ Official GitHub: https://github.com/UNHSAILLab/Adversary-Engagement-Ontology
17
+ '''
18
+ st.markdown(about)
19
+
20
+ openai_key = st.text_input("Enter your OpenAI key", type="password")
21
+ openai.api_key = openai_key
22
+
23
+
24
+
25
+
26
+ from aeo_ex_generator.aeo_example_generator import ExampleGenerator
27
+ ex = ExampleGenerator()
28
+
29
+
30
+
31
+ # Prompt Examples
32
+ st.subheader("Prompts Examples")
33
+ with st.expander("Example-1"):
34
+ st.write("""
35
+ Use one engagement:Narrative
36
+ Use one engagement:Storyline
37
+ Use the following people:
38
+ Bob Smith is a defender role
39
+ Mary Jane is an adversary role
40
+ Use three planned events:
41
+ Planned Event one - Bob Smith deploys a honeyobject enviroment and a honeytoken file containing fake user credentials called "user-creds.dmp". The objective is to direct and elicit. He also deploys a honeypot with the objective to detect and trap.
42
+ Planned Event two - The honeypot beacons to the dataTarget called CanaryTokenAlert, the performer is the honeypot, the object is the CanaryTokenAlert.
43
+ Planned Event three - CanaryTokenAlert dataSource alerts Bob Smith that the second honeypot was accessed. The performer is the CanaryTokenAlert, the object is Bob Smith
44
+ """)
45
+ with st.expander("Example-2"):
46
+ st.write("""
47
+ Use one engagement:Narrative
48
+ Use one engagement:Storyline
49
+ Use the following people:
50
+ John White is a defender role
51
+ Use three planned events:
52
+ Planned Event one - John White deploys a breadcrumbtrail consisting of four breadcrumbs. The objective is to direct. He also deploys a honeypot with the objective to trap.
53
+ Planned Event two - The honeypot beacons to the dataTarget called CommandControlCenter, the performer is the honeypot, the object is the CommandControlCenter.
54
+ Planned Event three - CommandControlCenter dataSource alerts John White that the honeypot was accessed. The performer is the CommandControlCenter, the object is John White
55
+ """)
56
+
57
+
58
+ st.subheader("Write a prompt to generate the example.")
59
+ user_input = st.text_area("Enter your description here ", "", height=200)
60
+
61
+ # call your function
62
+ # result = foo(user_input)
63
+ if user_input:
64
+ e = ex.prompt(user_input)
65
+ result = [i for i in e['@graph']]
66
+ # display result
67
+ st.subheader('Prefix namespaces mentioned in the example:')
68
+ st.text_area("", e['@context'], height=200)
69
+ #st.json(e['@context'])
70
+ st.subheader('Full example:')
71
+ try:
72
+ st.json(result)
73
+ except:
74
+ st.text_area("", result, height=400)
75
+
76
+
pages/2_Generate_Personas.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import sys
3
+ #from dotenv import load_dotenv
4
+ from langchain.document_loaders import PyPDFLoader
5
+ from langchain.document_loaders import UnstructuredMarkdownLoader
6
+ from langchain.document_loaders import TextLoader
7
+ from langchain.embeddings import OpenAIEmbeddings
8
+ from langchain.vectorstores import Chroma
9
+ from langchain.chat_models import ChatOpenAI
10
+ from langchain.chains import ConversationalRetrievalChain
11
+ from langchain.text_splitter import CharacterTextSplitter
12
+ from langchain.agents.agent_toolkits import create_retriever_tool
13
+ from langchain.agents.agent_toolkits import create_conversational_retrieval_agent
14
+ from langchain.chat_models import ChatOpenAI
15
+
16
+ import streamlit as st
17
+
18
+ st.subheader("In this example you can generate fake personas")
19
+
20
+ OpenAI_Key = st.text_input(" Please enter your OpenAI key here to continue")
21
+ # only continue if the key is given
22
+ if OpenAI_Key:
23
+ os.environ['OPENAI_API_KEY'] = OpenAI_Key
24
+ vectordb = Chroma(persist_directory="./data", embedding_function=OpenAIEmbeddings())
25
+
26
+ retriever = vectordb.as_retriever()
27
+
28
+ tool = create_retriever_tool(
29
+ retriever,
30
+ "search_AEO",
31
+ "Searches and returns documents regarding adversary engagement."
32
+ )
33
+ tools = [tool]
34
+
35
+
36
+ llm = ChatOpenAI(model_name="gpt-4", temperature = 0)
37
+ agent_executor = create_conversational_retrieval_agent(llm, tools, verbose=True)
38
+
39
+ st.subheader("In this example you can generate the fake personas")
40
+ user_input = st.text_area("Enter your description here ", "", height=200)
41
+
42
+ if user_input:
43
+ st.subheader("Generated Personas")
44
+ prompt_1 = "### Instruction: Based on the Mitre Engagement Matrix please creae a fake personas with below description. ### Description" + user_input
45
+ result = agent_executor({"input":prompt_1 })
46
+
47
+ st.write(result['output'])
pages/3_Generate_Honey_Tokens.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import sys
3
+ #from dotenv import load_dotenv
4
+ from langchain.document_loaders import PyPDFLoader
5
+ from langchain.document_loaders import UnstructuredMarkdownLoader
6
+ from langchain.document_loaders import TextLoader
7
+ from langchain.embeddings import OpenAIEmbeddings
8
+ from langchain.vectorstores import Chroma
9
+ from langchain.chat_models import ChatOpenAI
10
+ from langchain.chains import ConversationalRetrievalChain
11
+ from langchain.text_splitter import CharacterTextSplitter
12
+ from langchain.agents.agent_toolkits import create_retriever_tool
13
+ from langchain.agents.agent_toolkits import create_conversational_retrieval_agent
14
+ from langchain.chat_models import ChatOpenAI
15
+
16
+ import streamlit as st
17
+
18
+ st.subheader("In this example you can generate honey tokens")
19
+
20
+ OpenAI_Key = st.text_input(" Please enter your OpenAI key here to continue")
21
+ # only continue if the key is given
22
+ if OpenAI_Key:
23
+ os.environ['OPENAI_API_KEY'] = OpenAI_Key
24
+ vectordb = Chroma(persist_directory="./data", embedding_function=OpenAIEmbeddings())
25
+
26
+ retriever = vectordb.as_retriever()
27
+
28
+ tool = create_retriever_tool(
29
+ retriever,
30
+ "search_AEO",
31
+ "Searches and returns documents regarding adversary engagement."
32
+ )
33
+ tools = [tool]
34
+
35
+
36
+ llm = ChatOpenAI(model_name="gpt-4", temperature = 0)
37
+ agent_executor = create_conversational_retrieval_agent(llm, tools, verbose=True)
38
+
39
+ st.subheader("In this example you can generate the fake personas")
40
+ user_input = st.text_area("Enter your description here ", "", height=200)
41
+
42
+ if user_input:
43
+ st.subheader("Generated Honeytokens")
44
+ prompt_1 = "### Instruction: Based on the Mitre Engagement Matrix please creae a fake personas with below description. ### Description" + user_input
45
+ result = agent_executor({"input":prompt_1 })
46
+
47
+ st.write(result['output'])
pages/4_AutoEngage.py ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import sys
3
+ #from dotenv import load_dotenv
4
+ from langchain.document_loaders import PyPDFLoader
5
+ from langchain.document_loaders import UnstructuredMarkdownLoader
6
+ from langchain.document_loaders import TextLoader
7
+ from langchain.embeddings import OpenAIEmbeddings
8
+ from langchain.vectorstores import Chroma
9
+ from langchain.chat_models import ChatOpenAI
10
+ from langchain.chains import ConversationalRetrievalChain
11
+ from langchain.text_splitter import CharacterTextSplitter
12
+ from langchain.agents.agent_toolkits import create_retriever_tool
13
+ from langchain.agents.agent_toolkits import create_conversational_retrieval_agent
14
+ from langchain.chat_models import ChatOpenAI
15
+
16
+ import streamlit as st
17
+
18
+ st.write("""In this space you need to provide the description of the engagement
19
+ and it will automatically generate the deception strategy and itemized
20
+ action along with the JSON-LD description.""")
21
+
22
+
23
+ OpenAI_Key = st.text_input(" Please enter your OpenAI key here to continue")
24
+ # only continue if the key is given
25
+ if OpenAI_Key:
26
+ os.environ['OPENAI_API_KEY'] = OpenAI_Key
27
+ vectordb = Chroma(persist_directory="./data", embedding_function=OpenAIEmbeddings())
28
+
29
+ retriever = vectordb.as_retriever()
30
+
31
+ tool = create_retriever_tool(
32
+ retriever,
33
+ "search_AEO",
34
+ "Searches and returns documents regarding adversary engagement."
35
+ )
36
+ tools = [tool]
37
+
38
+
39
+ llm = ChatOpenAI(model_name="gpt-4", temperature = 0)
40
+ agent_executor = create_conversational_retrieval_agent(llm, tools, verbose=True)
41
+ # result = agent_executor({"input": "What is the point of the engagement matrix?"})
42
+
43
+ # Creating High Level Deception and denial strategy
44
+ example= """ You are part of a small business called MineralRUs Inc., which is a small, yet critical mining company in New Hampshire specializing in rare earth elements.
45
+ Your main clients are from particular sectors of technology and defense industries, and are considered to be critical infrastructure. Therefore, your business and its operation is essential to the integrity of supply chains enabling those critical infrastructure.
46
+ MineralRUs Inc. maintains paper-based record of their key intellectual property and operational procedures, which are stored in a physical safe. This fact is known by only a select few in the company.
47
+ Your business has a small, unorganized computer network with only generic security infrastructure, and the company does not have the resources to employ an in-house information security team. Instead, a very small team is tasked with maintaining Operational Technology (OT) systems on the network.
48
+ Your company has recently received an advisory from federal authorities, warning businesses in your industry about the rapidly growing threat of cyber espionage by state-sponsored Advanced Persistent Threats (APTs). In response, your company decides to engage an external cybersecurity provider to assist with timely incident response and prevention. The external provider recommends the employment of active adversary engagement plans, and asks you to develop a high-level deception and denial strategy.
49
+ """
50
+ user_input = st.text_area("Enter your engagement strategy: ", example, height=400)
51
+ prompt_1 = user_input + "### Instruction: You are an expert in Mitre's Attack Framework. Please create a high-level deception and denial strategy for the given scenario."
52
+
53
+ st.subheader('High Level Deception and Denial Strategy ')
54
+ result = agent_executor({"input":prompt_1 })
55
+
56
+ st.write(result['output'])
57
+
58
+ if result:
59
+ st.subheader('Itemized Action Plan')
60
+ prompt_2 = """### Instruction: I am giving you the high level deception and denial strategy.
61
+ Please create a specific itemized action plan for the below strategy. ### Scenario""" + result['output']
62
+ result_2 = agent_executor({"input":prompt_2 })
63
+
64
+ st.write(result_2['output'])
65
+
66
+ if result_2:
67
+ st.subheader('JSON-LD Description')
68
+ prompt_3 = """### Instruction: Please use AEO ontology to map the plan given below to the JSON-LD description. ### Plan: """ + result_2['output']
69
+ result_3 = agent_executor({'input': prompt_3})
70
+
71
+ st.write(result_3['output'])
72
+
73
+
74
+
75
+
76
+
77
+
requirements.txt ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ rdflib==7.0.0
2
+ openai==0.27.6
3
+ tiktoken
4
+ chromadb
5
+ langchain
6
+ pypdf
7
+ streamlit
8
+ unstructured
9
+ marker
10
+ rdflib