MCPcopy Create free account
hub / github.com/STIXProject/python-stix / main

Function main

examples/indicator-hash.py:19–52  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17
18
19def main():
20 # Create a CyboX File Object
21 f = File()
22
23 # This automatically detects that it's an MD5 hash based on the length
24 f.add_hash("4EC0027BEF4D7E1786A04D021FA8A67F")
25
26 # Create an Indicator with the File Hash Object created above.
27 indicator = Indicator()
28 indicator.title = "File Hash Example"
29 indicator.description = (
30 "An indicator containing a File observable with an associated hash"
31 )
32 indicator.set_producer_identity("The MITRE Corporation")
33 indicator.set_produced_time(utils.dates.now())
34
35 # Add The File Object to the Indicator. This will promote the CybOX Object
36 # to a CybOX Observable internally.
37 indicator.add_object(f)
38
39 # Create a STIX Package
40 stix_package = STIXPackage()
41
42 # Create the STIX Header and add a description.
43 stix_header = STIXHeader()
44 stix_header.description = "File Hash Indicator Example"
45 stix_package.stix_header = stix_header
46
47 # Add our Indicator object. The add() method will inspect the input and
48 # append it to the `stix_package.indicators` collection.
49 stix_package.add(indicator)
50
51 # Print the XML!
52 print(stix_package.to_xml())
53
54
55if __name__ == '__main__':

Callers 1

indicator-hash.pyFile · 0.70

Calls 8

set_producer_identityMethod · 0.95
set_produced_timeMethod · 0.95
add_objectMethod · 0.95
addMethod · 0.95
IndicatorClass · 0.90
STIXPackageClass · 0.90
STIXHeaderClass · 0.90
to_xmlMethod · 0.45

Tested by

no test coverage detected