|
1 | | -# Cyber threat intelligence |
| 1 | +# Cyber Threat Intelligence Platform Example |
2 | 2 |
|
3 | | -## Introduction |
| 3 | +This example demonstrates how to use TypeDB as the database in a cyber threat intelligence context. The schema is based on |
| 4 | +STIX2.1 and models threat actors, campaigns, and their relationships. |
4 | 5 |
|
5 | | -In this demo, you'll learn how to use TypeDB as the database in a cyber threat intelligence context. We'll cover |
6 | | -some basic operations like listing identities and their subtypes with the help of type-inference. |
| 6 | +## Setup |
7 | 7 |
|
8 | | -## Required knowledge |
| 8 | +Ensure you have a running TypeDB 3.0 server. |
9 | 9 |
|
10 | | -This demo assumes knowledge of: |
| 10 | +The easiest way to load this example is using TypeDB Console. If you're using version 3.5.0, you can load the schema and data files in one line: |
11 | 11 |
|
12 | | -- TypeDB's transaction system. |
13 | | -- All basic TypeQL syntax elements. |
14 | | -- TypeDB Studio's interface. |
| 12 | +Non-interactive mode: |
| 13 | +``` |
| 14 | +typedb console --username=<username> --address=<address> --command="database create-init cyber-threat-intelligence <path to schema.tql> <path to data.tql>" |
| 15 | +``` |
15 | 16 |
|
16 | | -For more information, please see our [documentation](https://docs.typedb.com/docs/general/introduction). |
| 17 | +The `database create-init` can also be run interactively if you're already in Console! |
17 | 18 |
|
18 | | -General knowledge of STIX2.1 would be a plus. |
| 19 | +This example dataset is also released under the releases page so you **can load from URL**: |
| 20 | +``` |
| 21 | +typedb console --username=<username> --address=<address> --command="database create-init cyber-threat-intelligence http://github.com/typedb/typedb-examples/releases/latest/download/cyber-threat-intelligence-schema.tql http://github.com/typedb/typedb-examples/releases/latest/download/cyber-threat-intelligence-data.tql" |
| 22 | +``` |
19 | 23 |
|
20 | | -## Getting started |
| 24 | +### Manual setup |
21 | 25 |
|
22 | | -Start your TypeDB server and open TypeDB Studio. Make sure you are using a `schema` transaction and run the following |
23 | | -TypeQL file: |
| 26 | +If you wanted to load the dataset step-by-step or using an older version of TypeDB Console, you can do the following: |
24 | 27 |
|
25 | | -```define-schema.tql``` |
| 28 | +1. In TypeDB Console, create a database - we'll use `cyber-threat-intelligence` in this setup |
| 29 | +2. Open a `schema` transaction |
| 30 | +3. Load the `schema.tql` - the easiest is to use `source <path to schema.tql>` |
| 31 | +4. Commit the schema and verify no errors appear |
| 32 | +5. Open a `write` transaction |
| 33 | +6. Load the `data.tql` - the easiest is to use `source <path to data.tql>` |
| 34 | +7. Commit the data |
26 | 35 |
|
27 | | -Then switch to a `write` transaction and run the following: |
28 | 36 |
|
29 | | -```insert-data.tql``` |
| 37 | +## Example queries |
30 | 38 |
|
31 | | -Remember to click on the green tick after running each of these scripts to commit the changes to the database. |
| 39 | +Once the dataset is loaded, you can play with some of these queries! |
32 | 40 |
|
33 | | -## Running the examples |
| 41 | +1. Find the campaigns that use the attack pattern designated "T1078" and the threat actor that the campaign is attributed to. |
| 42 | +```typeql |
| 43 | +match |
| 44 | + $attack-pattern isa attack-pattern, has name like "T1078"; |
| 45 | + uses($attack-pattern, $campaign); |
| 46 | + attributed-to($threat-actor, $campaign); |
| 47 | +fetch { |
| 48 | + "threat actor" : $threat-actor.name, |
| 49 | + "campaign name": $campaign.name |
| 50 | +}; |
| 51 | +``` |
34 | 52 |
|
35 | | -To get started, try running the examples. They are intended to be run once each and in order, so be aware that running |
36 | | -them more than once or out of order might generate validation errors on commit. If anything goes wrong, you can run the |
37 | | -`insert-data.tql` script again to reset everything. You'll want to switch between `read` and `write` transactions |
38 | | -depending on the queries in the example, and remember to commit after writes. |
| 53 | +This returns |
| 54 | +```json |
| 55 | +{ |
| 56 | + "campaign name": "Salt Typhoon Campaign (2020‑2025)", |
| 57 | + "threat actor": "Salt Typhoon" |
| 58 | +} |
| 59 | +``` |
| 60 | + |
| 61 | +2. Find the indicators that are associated with the "Salt Typhoon" campaign, sorted by confidence. |
| 62 | +```typeql |
| 63 | +match |
| 64 | + $campaign isa campaign, has name like "Salt Typhoon"; |
| 65 | + indicates($indicator, $campaign); |
| 66 | + $indicator has confidence $confidence; |
| 67 | +sort $confidence; |
| 68 | +fetch { |
| 69 | + "indicator": $indicator.name, |
| 70 | + "description": $indicator.description |
| 71 | +}; |
| 72 | +``` |
| 73 | +```json |
| 74 | +{ |
| 75 | + "indicator": "Salt Typhoon Domain – gesturefavo.com", |
| 76 | + "description": "Domain registered under OrderBox name‑servers with privacy protection." |
| 77 | +} |
| 78 | +{ |
| 79 | + "indicator": "Salt Typhoon Domain – example.com", |
| 80 | + "description": "Generic domain example used by the campaign." |
| 81 | +} |
| 82 | +{ |
| 83 | + "description": "IP cluster hosting multiple campaign domains.", |
| 84 | + "indicator": "Salt Typhoon IP – 162.251.82.125" |
| 85 | +} |
| 86 | +{ |
| 87 | + "indicator": "Salt Typhoon IP – 162.251.82.252", |
| 88 | + "description": "IP cluster hosting multiple campaign domains." |
| 89 | +} |
| 90 | +{ |
| 91 | + "description": "IP cluster hosting multiple campaign domains.", |
| 92 | + "indicator": "Salt Typhoon IP – 162.251.82.253" |
| 93 | +} |
| 94 | +``` |
| 95 | + |
| 96 | +## Schema Overview |
| 97 | + |
| 98 | +### Core Entities |
| 99 | +- **Attack Pattern**: Represents a specific technique or method used in an attack. |
| 100 | +- **Campaign**: Represents a series of related attacks. |
| 101 | +- **Course of Action**: Represents a recommended course of action to mitigate a threat. |
| 102 | +- **Identity**: Represents an individual, organization, or group. |
| 103 | +- **Indicator**: Represents a pattern or artifact that can be used to detect a threat. |
| 104 | +- **Threat Actor**: Represents an individual or group that poses a threat. |
| 105 | + |
| 106 | +### Key Relations |
| 107 | +- `attributed-to`: Attributes a threat to an actor (e.g. a `campaign` is attributed to some `threat-actor`). |
| 108 | +- `targets`: Links a threat with its target (e.g. a `campaign` targets some `identity`). |
| 109 | +- `uses`: Links a threat with a tool it uses (e.g. a `campaign` uses some `attack-pattern`). |
| 110 | +- `indicates`: Describes that the Indicator can detect evidence of the target threat (e.g. an Attack Pattern). |
| 111 | + |
| 112 | +## Sample Data |
| 113 | + |
| 114 | +The sample data includes a sample campaign along with its associated attack patterns, a threat actor, and activity indicators. |
0 commit comments