{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "nbsphinx": "hidden" }, "outputs": [], "source": [ "# Delete this cell to re-enable tracebacks\n", "import sys\n", "import traceback\n", "ipython = get_ipython()\n", "\n", "def hide_traceback(exc_tuple=None, filename=None, tb_offset=None,\n", " exception_only=False, running_compiled_code=False):\n", " etype, value, tb = sys.exc_info() \n", " value.__cause__ = None # suppress chained exceptions\n", " return ipython._showtraceback(etype, value, ipython.InteractiveTB.get_exception_only(etype, value))\n", "\n", "ipython.showtraceback = hide_traceback" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "nbsphinx": "hidden" }, "outputs": [], "source": [ "# JSON output syntax highlighting\n", "from __future__ import print_function\n", "from pygments import highlight\n", "from pygments.lexers import JsonLexer\n", "from pygments.formatters import HtmlFormatter\n", "from IPython.display import HTML\n", "\n", "original_print = print\n", "\n", "def json_print(inpt):\n", " string = str(inpt)\n", " if string[0] == '{':\n", " formatter = HtmlFormatter()\n", " return HTML('{}'.format(\n", " formatter.get_style_defs('.highlight'),\n", " highlight(string, JsonLexer(), formatter)))\n", " else:\n", " original_print(inpt)\n", "\n", "print = json_print" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Creating STIX Content" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Creating STIX Domain Objects\n", "\n", "To create a STIX object, provide keyword arguments to the type's constructor:" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
{\n",
" "type": "indicator",\n",
" "spec_version": "2.1",\n",
" "id": "indicator--a862ff86-68d9-42e5-8095-cd80c040e112",\n",
" "created": "2020-06-24T15:04:40.048932Z",\n",
" "modified": "2020-06-24T15:04:40.048932Z",\n",
" "name": "File hash for malware variant",\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "pattern_type": "stix",\n",
" "pattern_version": "2.1",\n",
" "valid_from": "2020-06-24T15:04:40.048932Z"\n",
"}\n",
"
{\n",
" "type": "malware",\n",
" "spec_version": "2.1",\n",
" "id": "malware--389c934c-258c-44fb-ae4b-14c6c12270f6",\n",
" "created": "2020-06-24T14:53:20.156644Z",\n",
" "modified": "2020-06-24T14:53:20.156644Z",\n",
" "name": "Poison Ivy",\n",
" "is_family": false\n",
"}\n",
"
{\n",
" "type": "relationship",\n",
" "spec_version": "2.1",\n",
" "id": "relationship--2f6a8785-e27b-487e-b870-b85a2121502d",\n",
" "created": "2020-06-24T15:05:18.250605Z",\n",
" "modified": "2020-06-24T15:05:18.250605Z",\n",
" "relationship_type": "indicates",\n",
" "source_ref": "indicator--a862ff86-68d9-42e5-8095-cd80c040e112",\n",
" "target_ref": "malware--389c934c-258c-44fb-ae4b-14c6c12270f6"\n",
"}\n",
"
{\n",
" "type": "relationship",\n",
" "spec_version": "2.1",\n",
" "id": "relationship--d43ec245-5496-44f4-8732-3131380435de",\n",
" "created": "2020-06-24T15:05:47.705352Z",\n",
" "modified": "2020-06-24T15:05:47.705352Z",\n",
" "relationship_type": "indicates",\n",
" "source_ref": "indicator--a862ff86-68d9-42e5-8095-cd80c040e112",\n",
" "target_ref": "malware--389c934c-258c-44fb-ae4b-14c6c12270f6"\n",
"}\n",
"
{\n",
" "type": "bundle",\n",
" "id": "bundle--177c6477-2dee-43d5-b4c9-8b7f3f5ec517",\n",
" "objects": [\n",
" {\n",
" "type": "indicator",\n",
" "spec_version": "2.1",\n",
" "id": "indicator--a862ff86-68d9-42e5-8095-cd80c040e112",\n",
" "created": "2020-06-24T15:04:40.048932Z",\n",
" "modified": "2020-06-24T15:04:40.048932Z",\n",
" "name": "File hash for malware variant",\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
" "pattern_type": "stix",\n",
" "pattern_version": "2.1",\n",
" "valid_from": "2020-06-24T15:04:40.048932Z"\n",
" },\n",
" {\n",
" "type": "malware",\n",
" "spec_version": "2.1",\n",
" "id": "malware--389c934c-258c-44fb-ae4b-14c6c12270f6",\n",
" "created": "2020-06-24T14:53:20.156644Z",\n",
" "modified": "2020-06-24T14:53:20.156644Z",\n",
" "name": "Poison Ivy",\n",
" "is_family": false\n",
" },\n",
" {\n",
" "type": "relationship",\n",
" "spec_version": "2.1",\n",
" "id": "relationship--2f6a8785-e27b-487e-b870-b85a2121502d",\n",
" "created": "2020-06-24T15:05:18.250605Z",\n",
" "modified": "2020-06-24T15:05:18.250605Z",\n",
" "relationship_type": "indicates",\n",
" "source_ref": "indicator--a862ff86-68d9-42e5-8095-cd80c040e112",\n",
" "target_ref": "malware--389c934c-258c-44fb-ae4b-14c6c12270f6"\n",
" }\n",
" ]\n",
"}\n",
"
{\n",
" "type": "ipv4-addr",\n",
" "id": "ipv4-addr--dc63603e-e634-5357-b239-d4b562bc5445",\n",
" "value": "177.60.40.7",\n",
" "resolves_to_refs": [\n",
" "mac-addr--43f380fd-37c6-476d-8643-60849bf9240e"\n",
" ],\n",
" "spec_version": "2.1"\n",
"}\n",
"
{\n",
" "type": "ipv4-addr",\n",
" "id": "ipv4-addr--dc63603e-e634-5357-b239-d4b562bc5445",\n",
" "value": "177.60.40.7",\n",
" "resolves_to_refs": [\n",
" "mac-addr--f72d7d00-86bd-5cd2-8c86-52f7a83bef62",\n",
" "mac-addr--875ad625-177b-5c2a-9101-d44b0ad55938"\n",
" ],\n",
" "spec_version": "2.1"\n",
"}\n",
"