|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "id": "f9a8c4ddbec98d57", |
| 6 | + "metadata": { |
| 7 | + "collapsed": false |
| 8 | + }, |
| 9 | + "source": [ |
| 10 | + "# Generate and visualize STIX bundle using Flexible Intel Feed or Ransomware Feed\n", |
| 11 | + "This notebook contains an example of generating STIX report bundles using Flexible Intel Feed or Ransomware Feed and visualize them with [STIX Viewer](https://oasis-open.github.io/cti-stix-visualization/)" |
| 12 | + ] |
| 13 | + }, |
| 14 | + { |
| 15 | + "cell_type": "markdown", |
| 16 | + "id": "7f72de57", |
| 17 | + "metadata": {}, |
| 18 | + "source": [ |
| 19 | + "A script connects to ReversingLabs TAXII 2.1 feed (via the [ReversingLabs SDK](https://github.com/reversinglabs/reversinglabs-sdk-py3)), pulls down all STIX objects added after a given timestamp, and writes them to a JSON file (matched_stix.json).\n", |
| 20 | + "\n", |
| 21 | + "Create JSON (ticloud_credentials.json) or pass your credentials directly using the script below. Obtain the credentials for data.reversinglabs.com access by contacting [email protected]\n", |
| 22 | + "\n", |
| 23 | + "Examples of the available API roots:\n", |
| 24 | + " \"ransomware-api-root\",\n", |
| 25 | + " \"ransomware-lite\",\n", |
| 26 | + " \"flexible-intel-feeds\"" |
| 27 | + ] |
| 28 | + }, |
| 29 | + { |
| 30 | + "cell_type": "code", |
| 31 | + "execution_count": null, |
| 32 | + "id": "d9fbf3de", |
| 33 | + "metadata": {}, |
| 34 | + "outputs": [], |
| 35 | + "source": [ |
| 36 | + "import json\n", |
| 37 | + "from ReversingLabs.SDK.ticloud import TAXIIRansomwareFeed\n", |
| 38 | + "\n", |
| 39 | + "CREDS = json.load(open(\"ticloud_credentials.json\"))\n", |
| 40 | + "USER = CREDS[\"username\"]\n", |
| 41 | + "PASS = CREDS[\"password\"]\n", |
| 42 | + "\n", |
| 43 | + "feed = TAXIIRansomwareFeed(\n", |
| 44 | + " host=\"https://data.reversinglabs.com\",\n", |
| 45 | + " username=USER,\n", |
| 46 | + " password=PASS\n", |
| 47 | + ")\n", |
| 48 | + "\n", |
| 49 | + "time_string = \"2025-06-11T00:00:00Z\"\n", |
| 50 | + "\n", |
| 51 | + "objs = feed.get_objects_aggregated(\n", |
| 52 | + " api_root=\"<api_root>\", \n", |
| 53 | + " collection_id=\"<collection_id>\",\n", |
| 54 | + " result_limit=500,\n", |
| 55 | + " added_after=time_string\n", |
| 56 | + ")\n", |
| 57 | + "\n", |
| 58 | + "print(f\"Found {len(objs)} matching STIX objects\")\n", |
| 59 | + "\n", |
| 60 | + "with open(\"matched_stix.json\", \"w\") as fp:\n", |
| 61 | + " json.dump(objs, fp, indent=2)\n" |
| 62 | + ] |
| 63 | + }, |
| 64 | + { |
| 65 | + "cell_type": "markdown", |
| 66 | + "id": "8486a457", |
| 67 | + "metadata": {}, |
| 68 | + "source": [ |
| 69 | + "Jupyter notebook embeds the OASIS CTI STIX Visualizer in an iFrame. The JSON bundle is automatically produced with previous script and presented in the separate iFrame.\n", |
| 70 | + "\n", |
| 71 | + "Select the JSON content and paste in the cti-stix-visualization dialog box to get an interactive graph, table view and timeline information about the STIX objects." |
| 72 | + ] |
| 73 | + }, |
| 74 | + { |
| 75 | + "cell_type": "code", |
| 76 | + "execution_count": null, |
| 77 | + "id": "9e74918e", |
| 78 | + "metadata": {}, |
| 79 | + "outputs": [], |
| 80 | + "source": [ |
| 81 | + "# Visualize STIX Bundle\n", |
| 82 | + "# Cut & paste your JSON file contents below, or load from a file\n", |
| 83 | + "import json\n", |
| 84 | + "from IPython.display import display, IFrame\n", |
| 85 | + "import ipywidgets as widgets\n", |
| 86 | + "\n", |
| 87 | + "with open(\"matched_stix.json\") as f:\n", |
| 88 | + " bundle = json.load(f)\n", |
| 89 | + "\n", |
| 90 | + "ta = widgets.Textarea(\n", |
| 91 | + " value=json.dumps(bundle, indent=2),\n", |
| 92 | + " layout=widgets.Layout(width=\"1200px\", height=\"300px\")\n", |
| 93 | + ")\n", |
| 94 | + "display(ta)\n", |
| 95 | + "\n", |
| 96 | + "display(IFrame(\n", |
| 97 | + " src=\"https://oasis-open.github.io/cti-stix-visualization/\",\n", |
| 98 | + " width=1200, height=1000\n", |
| 99 | + "))" |
| 100 | + ] |
| 101 | + } |
| 102 | + ], |
| 103 | + "metadata": { |
| 104 | + "kernelspec": { |
| 105 | + "display_name": "Python 3", |
| 106 | + "language": "python", |
| 107 | + "name": "python3" |
| 108 | + }, |
| 109 | + "language_info": { |
| 110 | + "codemirror_mode": { |
| 111 | + "name": "ipython", |
| 112 | + "version": 3 |
| 113 | + }, |
| 114 | + "file_extension": ".py", |
| 115 | + "mimetype": "text/x-python", |
| 116 | + "name": "python", |
| 117 | + "nbconvert_exporter": "python", |
| 118 | + "pygments_lexer": "ipython3", |
| 119 | + "version": "3.13.0" |
| 120 | + } |
| 121 | + }, |
| 122 | + "nbformat": 4, |
| 123 | + "nbformat_minor": 5 |
| 124 | +} |
0 commit comments