()
| 17 | |
| 18 | |
| 19 | def 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 | |
| 55 | if __name__ == '__main__': |
no test coverage detected