Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
```console
PUT /windows-security-logs
{
"mappings": {
"properties": {
"@timestamp": {"type": "date"},
"event": {
"properties": {
"code": {"type": "keyword"}, # Event codes like 4624 (successful logon) and 4625 (failed logon) are stored as keywords for exact matching.
"action": {"type": "keyword"}
}
},
"user": {
"properties": {
"name": {"type": "keyword"},
"domain": {"type": "keyword"}
}
},
"host": {
"properties": {
"name": {"type": "keyword"},
"ip": {"type": "ip"}
}
},
"source": {
"properties": {
"ip": {"type": "ip"}
}
},
"logon": {
"properties": {
"type": {"type": "keyword"}
}
}
}
}
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
```bash
curl -X PUT "$ELASTICSEARCH_URL/windows-security-logs" \
-H "Authorization: ApiKey $ELASTIC_API_KEY" \
-H "Content-Type: application/json" \
-d '{"mappings":{"properties":{"@timestamp":{"type":"date"},"event":{"properties":{"code":{"type":"keyword"},"action":{"type":"keyword"}}},"user":{"properties":{"name":{"type":"keyword"},"domain":{"type":"keyword"}}},"host":{"properties":{"name":{"type":"keyword"},"ip":{"type":"ip"}}},"source":{"properties":{"ip":{"type":"ip"}}},"logon":{"properties":{"type":{"type":"keyword"}}}}}}'
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
```js
const { Client } = require("@elastic/elasticsearch");

const client = new Client({
nodes: [process.env["ELASTICSEARCH_URL"]],
auth: {
apiKey: process.env["ELASTIC_API_KEY"],
},
});

async function run() {
const response = await client.indices.create({
index: "windows-security-logs",
mappings: {
properties: {
"@timestamp": {
type: "date",
},
event: {
properties: {
code: {
type: "keyword",
},
action: {
type: "keyword",
},
},
},
user: {
properties: {
name: {
type: "keyword",
},
domain: {
type: "keyword",
},
},
},
host: {
properties: {
name: {
type: "keyword",
},
ip: {
type: "ip",
},
},
},
source: {
properties: {
ip: {
type: "ip",
},
},
},
logon: {
properties: {
type: {
type: "keyword",
},
},
},
},
},
});
console.log(response);
}

run();
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
```php
<?php

require(__DIR__ . "/vendor/autoload.php");

use Elastic\Elasticsearch\ClientBuilder;

$client = ClientBuilder::create()
->setHosts([getenv("ELASTICSEARCH_URL")])
->setApiKey(getenv("ELASTIC_API_KEY"))
->build();

$resp = $client->indices()->create([
"index" => "windows-security-logs",
"body" => [
"mappings" => [
"properties" => [
"@timestamp" => [
"type" => "date",
],
"event" => [
"properties" => [
"code" => [
"type" => "keyword",
],
"action" => [
"type" => "keyword",
],
],
],
"user" => [
"properties" => [
"name" => [
"type" => "keyword",
],
"domain" => [
"type" => "keyword",
],
],
],
"host" => [
"properties" => [
"name" => [
"type" => "keyword",
],
"ip" => [
"type" => "ip",
],
],
],
"source" => [
"properties" => [
"ip" => [
"type" => "ip",
],
],
],
"logon" => [
"properties" => [
"type" => [
"type" => "keyword",
],
],
],
],
],
],
]);
echo $resp->asString();

```
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
```python
import os
from elasticsearch import Elasticsearch

client = Elasticsearch(
hosts=[os.getenv("ELASTICSEARCH_URL")],
api_key=os.getenv("ELASTIC_API_KEY"),
)

resp = client.indices.create(
index="windows-security-logs",
mappings={
"properties": {
"@timestamp": {
"type": "date"
},
"event": {
"properties": {
"code": {
"type": "keyword"
},
"action": {
"type": "keyword"
}
}
},
"user": {
"properties": {
"name": {
"type": "keyword"
},
"domain": {
"type": "keyword"
}
}
},
"host": {
"properties": {
"name": {
"type": "keyword"
},
"ip": {
"type": "ip"
}
}
},
"source": {
"properties": {
"ip": {
"type": "ip"
}
}
},
"logon": {
"properties": {
"type": {
"type": "keyword"
}
}
}
}
},
)
print(resp)

```
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
```ruby
require "elasticsearch"

client = Elasticsearch::Client.new(
host: ENV["ELASTICSEARCH_URL"],
api_key: ENV["ELASTIC_API_KEY"]
)

response = client.indices.create(
index: "windows-security-logs",
body: {
"mappings": {
"properties": {
"@timestamp": {
"type": "date"
},
"event": {
"properties": {
"code": {
"type": "keyword"
},
"action": {
"type": "keyword"
}
}
},
"user": {
"properties": {
"name": {
"type": "keyword"
},
"domain": {
"type": "keyword"
}
}
},
"host": {
"properties": {
"name": {
"type": "keyword"
},
"ip": {
"type": "ip"
}
}
},
"source": {
"properties": {
"ip": {
"type": "ip"
}
}
},
"logon": {
"properties": {
"type": {
"type": "keyword"
}
}
}
}
}
}
)
print(resp)

```
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
```console
POST /_bulk?refresh=wait_for
{"index":{"_index":"asset-inventory"}}
{"host.name":"WS-001","asset.criticality":"medium","asset.owner":"IT","asset.department":"finance"}
{"index":{"_index":"asset-inventory"}}
{"host.name":"SRV-001","asset.criticality":"high","asset.owner":"IT","asset.department":"operations"}
{"index":{"_index":"asset-inventory"}}
{"host.name":"DB-001","asset.criticality":"critical","asset.owner":"DBA","asset.department":"finance"}
{"index":{"_index":"asset-inventory"}}
{"host.name":"DC-001","asset.criticality":"critical","asset.owner":"IT","asset.department":"infrastructure"}
{"index":{"_index":"user-context"}}
{"user.name":"jsmith","user.role":"analyst","user.department":"finance","user.privileged":false}
{"index":{"_index":"user-context"}}
{"user.name":"admin","user.role":"administrator","user.department":"IT","user.privileged":true}
{"index":{"_index":"threat-intel"}}
{"indicator.value":"185.220.101.45","indicator.type":"ip","threat.name":"APT-29","threat.severity":"high"}
{"index":{"_index":"threat-intel"}}
{"indicator.value":"powershell.exe","indicator.type":"process","threat.name":"Living off the Land","threat.severity":"medium"}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
```bash
curl -X POST "$ELASTICSEARCH_URL/_bulk?refresh=wait_for" \
-H "Authorization: ApiKey $ELASTIC_API_KEY" \
-H "Content-Type: application/x-ndjson" \
-d $'{"index":{"_index":"asset-inventory"}}\n{"host.name":"WS-001","asset.criticality":"medium","asset.owner":"IT","asset.department":"finance"}\n{"index":{"_index":"asset-inventory"}}\n{"host.name":"SRV-001","asset.criticality":"high","asset.owner":"IT","asset.department":"operations"}\n{"index":{"_index":"asset-inventory"}}\n{"host.name":"DB-001","asset.criticality":"critical","asset.owner":"DBA","asset.department":"finance"}\n{"index":{"_index":"asset-inventory"}}\n{"host.name":"DC-001","asset.criticality":"critical","asset.owner":"IT","asset.department":"infrastructure"}\n{"index":{"_index":"user-context"}}\n{"user.name":"jsmith","user.role":"analyst","user.department":"finance","user.privileged":false}\n{"index":{"_index":"user-context"}}\n{"user.name":"admin","user.role":"administrator","user.department":"IT","user.privileged":true}\n{"index":{"_index":"threat-intel"}}\n{"indicator.value":"185.220.101.45","indicator.type":"ip","threat.name":"APT-29","threat.severity":"high"}\n{"index":{"_index":"threat-intel"}}\n{"indicator.value":"powershell.exe","indicator.type":"process","threat.name":"Living off the Land","threat.severity":"medium"}\n'
```
Loading
Loading