1#!/usr/bin/env python
2
3# Copyright (c) 2017, The MITRE Corporation. All rights reserved.
4# See LICENSE.txt for complete terms.
5
6"""Creates the CybOX content for CybOX_Artifact_Instance.xml
7"""
8
9import os
10
11from cybox.core import Observable, Observables
12from cybox.objects.artifact_object import Artifact, Base64Encoding
13
14
15def main():
16    test_file = os.path.join(os.path.dirname(__file__), "test.pcap")
17
18    with open(test_file, "rb") as f:
19        data = f.read()
20
21    a = Artifact(data, Artifact.TYPE_NETWORK)
22    a.packaging.append(Base64Encoding())
23
24    o = Observable(a)
25
26    o.description = ("This Observable specifies an instance of an Artifact "
27                     "object, specifically some network traffic that was "
28                     "captured in a PCAP file and then base64 encoded for "
29                     "transport.")
30
31    print(Observables(o).to_xml(encoding=None))
32
33
34if __name__ == "__main__":
35    main()
36