security-gym 0.3.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- security_gym-0.3.1/.github/workflows/ci.yml +48 -0
- security_gym-0.3.1/.github/workflows/publish.yml +63 -0
- security_gym-0.3.1/.gitignore +28 -0
- security_gym-0.3.1/.zenodo.json +34 -0
- security_gym-0.3.1/CITATION.cff +28 -0
- security_gym-0.3.1/CLAUDE.md +76 -0
- security_gym-0.3.1/LICENSE +190 -0
- security_gym-0.3.1/PKG-INFO +442 -0
- security_gym-0.3.1/README.md +396 -0
- security_gym-0.3.1/ROADMAP.md +151 -0
- security_gym-0.3.1/TODO.md +91 -0
- security_gym-0.3.1/attacks/__init__.py +1 -0
- security_gym-0.3.1/attacks/__main__.py +180 -0
- security_gym-0.3.1/attacks/campaigns/recon_ssh_log4shell.yaml +118 -0
- security_gym-0.3.1/attacks/campaigns/ssh_brute_only.yaml +42 -0
- security_gym-0.3.1/attacks/collection/__init__.py +1 -0
- security_gym-0.3.1/attacks/collection/auditd.py +110 -0
- security_gym-0.3.1/attacks/collection/collector.py +198 -0
- security_gym-0.3.1/attacks/collection/ebpf_collector.py +321 -0
- security_gym-0.3.1/attacks/collection/import_logs.py +216 -0
- security_gym-0.3.1/attacks/collection/labeler.py +136 -0
- security_gym-0.3.1/attacks/config.py +318 -0
- security_gym-0.3.1/attacks/modules/__init__.py +5 -0
- security_gym-0.3.1/attacks/modules/base.py +143 -0
- security_gym-0.3.1/attacks/modules/credential_stuffing.py +152 -0
- security_gym-0.3.1/attacks/modules/log4shell.py +143 -0
- security_gym-0.3.1/attacks/modules/recon.py +91 -0
- security_gym-0.3.1/attacks/modules/ssh_brute_force.py +141 -0
- security_gym-0.3.1/attacks/modules/ssh_post_auth.py +212 -0
- security_gym-0.3.1/attacks/network/__init__.py +1 -0
- security_gym-0.3.1/attacks/network/ip_manager.py +174 -0
- security_gym-0.3.1/attacks/orchestrator.py +299 -0
- security_gym-0.3.1/attacks/tests/__init__.py +0 -0
- security_gym-0.3.1/attacks/tests/test_config.py +235 -0
- security_gym-0.3.1/attacks/tests/test_import_logs.py +301 -0
- security_gym-0.3.1/attacks/tests/test_ip_manager.py +160 -0
- security_gym-0.3.1/attacks/tests/test_labeler.py +189 -0
- security_gym-0.3.1/attacks/tests/test_modules.py +270 -0
- security_gym-0.3.1/campaigns/credential_stuffing_only.yaml +86 -0
- security_gym-0.3.1/campaigns/full_killchain.yaml +147 -0
- security_gym-0.3.1/campaigns/log4shell_only.yaml +61 -0
- security_gym-0.3.1/campaigns/post_auth_only.yaml +61 -0
- security_gym-0.3.1/campaigns/recon_only.yaml +48 -0
- security_gym-0.3.1/campaigns/recon_ssh_log4shell.yaml +138 -0
- security_gym-0.3.1/campaigns/ssh_brute_only.yaml +56 -0
- security_gym-0.3.1/configs/stream_30d_heavy.yaml +28 -0
- security_gym-0.3.1/configs/stream_365d_realistic.yaml +46 -0
- security_gym-0.3.1/configs/stream_7d_brute_only.yaml +24 -0
- security_gym-0.3.1/configs/stream_90d_mixed.yaml +32 -0
- security_gym-0.3.1/data/.gitkeep +0 -0
- security_gym-0.3.1/pyproject.toml +78 -0
- security_gym-0.3.1/scripts/collect_ebpf_baseline.py +134 -0
- security_gym-0.3.1/scripts/insert_ebpf_baseline.py +104 -0
- security_gym-0.3.1/scripts/run_all_campaigns.sh +73 -0
- security_gym-0.3.1/scripts/scrub_benign_db.py +123 -0
- security_gym-0.3.1/scripts/validate_labels.py +611 -0
- security_gym-0.3.1/server/BUILD.md +122 -0
- security_gym-0.3.1/server/docker-compose.yml +25 -0
- security_gym-0.3.1/server/ebpf_collector.py +412 -0
- security_gym-0.3.1/server/nginx.conf +20 -0
- security_gym-0.3.1/src/security_gym/__init__.py +49 -0
- security_gym-0.3.1/src/security_gym/adapters/__init__.py +5 -0
- security_gym-0.3.1/src/security_gym/adapters/scan_stream.py +274 -0
- security_gym-0.3.1/src/security_gym/data/__init__.py +5 -0
- security_gym-0.3.1/src/security_gym/data/composer.py +429 -0
- security_gym-0.3.1/src/security_gym/data/event_store.py +232 -0
- security_gym-0.3.1/src/security_gym/data/loader.py +1 -0
- security_gym-0.3.1/src/security_gym/data/schema.py +65 -0
- security_gym-0.3.1/src/security_gym/envs/__init__.py +9 -0
- security_gym-0.3.1/src/security_gym/envs/log_stream_env.py +479 -0
- security_gym-0.3.1/src/security_gym/envs/wrappers.py +209 -0
- security_gym-0.3.1/src/security_gym/features/__init__.py +10 -0
- security_gym-0.3.1/src/security_gym/features/extractors.py +80 -0
- security_gym-0.3.1/src/security_gym/features/hasher.py +70 -0
- security_gym-0.3.1/src/security_gym/features/session.py +224 -0
- security_gym-0.3.1/src/security_gym/parsers/__init__.py +12 -0
- security_gym-0.3.1/src/security_gym/parsers/_syslog_header.py +107 -0
- security_gym-0.3.1/src/security_gym/parsers/auth_log.py +124 -0
- security_gym-0.3.1/src/security_gym/parsers/base.py +44 -0
- security_gym-0.3.1/src/security_gym/parsers/ebpf.py +99 -0
- security_gym-0.3.1/src/security_gym/parsers/journal.py +112 -0
- security_gym-0.3.1/src/security_gym/parsers/registry.py +34 -0
- security_gym-0.3.1/src/security_gym/parsers/syslog.py +78 -0
- security_gym-0.3.1/src/security_gym/parsers/web_access.py +86 -0
- security_gym-0.3.1/src/security_gym/parsers/web_error.py +82 -0
- security_gym-0.3.1/src/security_gym/py.typed +0 -0
- security_gym-0.3.1/src/security_gym/scripts/__init__.py +0 -0
- security_gym-0.3.1/src/security_gym/scripts/download.py +158 -0
- security_gym-0.3.1/src/security_gym/targets/__init__.py +3 -0
- security_gym-0.3.1/src/security_gym/targets/builder.py +100 -0
- security_gym-0.3.1/tests/__init__.py +0 -0
- security_gym-0.3.1/tests/conftest.py +324 -0
- security_gym-0.3.1/tests/test_composer.py +486 -0
- security_gym-0.3.1/tests/test_ebpf_parser.py +112 -0
- security_gym-0.3.1/tests/test_env.py +369 -0
- security_gym-0.3.1/tests/test_event_store.py +79 -0
- security_gym-0.3.1/tests/test_features.py +94 -0
- security_gym-0.3.1/tests/test_journal_parser.py +97 -0
- security_gym-0.3.1/tests/test_parsers.py +173 -0
- security_gym-0.3.1/tests/test_scan_stream.py +295 -0
- security_gym-0.3.1/tests/test_session_features.py +176 -0
- security_gym-0.3.1/tests/test_syslog_parser.py +132 -0
- security_gym-0.3.1/tests/test_targets.py +64 -0
- security_gym-0.3.1/tests/test_web_access_parser.py +71 -0
- security_gym-0.3.1/tests/test_web_error_parser.py +66 -0
- security_gym-0.3.1/tests/test_wrappers.py +226 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
- uses: actions/setup-python@v5
|
|
15
|
+
with:
|
|
16
|
+
python-version: "3.11"
|
|
17
|
+
- name: Install dependencies
|
|
18
|
+
run: pip install -e ".[dev,attacks]"
|
|
19
|
+
- name: Run tests
|
|
20
|
+
run: pytest tests/ attacks/tests/ --tb=short
|
|
21
|
+
|
|
22
|
+
lint:
|
|
23
|
+
runs-on: ubuntu-latest
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@v4
|
|
26
|
+
- uses: actions/setup-python@v5
|
|
27
|
+
with:
|
|
28
|
+
python-version: "3.11"
|
|
29
|
+
- name: Install dependencies
|
|
30
|
+
run: pip install -e ".[dev]"
|
|
31
|
+
- name: Ruff check
|
|
32
|
+
run: ruff check src/ tests/ attacks/
|
|
33
|
+
|
|
34
|
+
security:
|
|
35
|
+
runs-on: ubuntu-latest
|
|
36
|
+
steps:
|
|
37
|
+
- uses: actions/checkout@v4
|
|
38
|
+
- uses: actions/setup-python@v5
|
|
39
|
+
with:
|
|
40
|
+
python-version: "3.11"
|
|
41
|
+
- name: Install dependencies
|
|
42
|
+
run: |
|
|
43
|
+
pip install -e ".[dev]"
|
|
44
|
+
pip install pip-audit bandit
|
|
45
|
+
- name: Audit dependencies
|
|
46
|
+
run: pip-audit --skip-editable
|
|
47
|
+
- name: Static security analysis
|
|
48
|
+
run: bandit -r src/ -c pyproject.toml
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
id-token: write
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- name: Set up Python 3.11
|
|
19
|
+
uses: actions/setup-python@v5
|
|
20
|
+
with:
|
|
21
|
+
python-version: "3.11"
|
|
22
|
+
|
|
23
|
+
- name: Install build dependencies
|
|
24
|
+
run: python -m pip install --upgrade pip build
|
|
25
|
+
|
|
26
|
+
- name: Build package
|
|
27
|
+
run: python -m build
|
|
28
|
+
|
|
29
|
+
- name: Upload dist artifacts
|
|
30
|
+
uses: actions/upload-artifact@v4
|
|
31
|
+
with:
|
|
32
|
+
name: dist
|
|
33
|
+
path: dist/
|
|
34
|
+
|
|
35
|
+
publish-testpypi:
|
|
36
|
+
runs-on: ubuntu-latest
|
|
37
|
+
needs: build
|
|
38
|
+
environment: testpypi
|
|
39
|
+
steps:
|
|
40
|
+
- name: Download dist artifacts
|
|
41
|
+
uses: actions/download-artifact@v4
|
|
42
|
+
with:
|
|
43
|
+
name: dist
|
|
44
|
+
path: dist/
|
|
45
|
+
|
|
46
|
+
- name: Publish to TestPyPI
|
|
47
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
48
|
+
with:
|
|
49
|
+
repository-url: https://test.pypi.org/legacy/
|
|
50
|
+
|
|
51
|
+
publish-pypi:
|
|
52
|
+
runs-on: ubuntu-latest
|
|
53
|
+
needs: publish-testpypi
|
|
54
|
+
environment: pypi
|
|
55
|
+
steps:
|
|
56
|
+
- name: Download dist artifacts
|
|
57
|
+
uses: actions/download-artifact@v4
|
|
58
|
+
with:
|
|
59
|
+
name: dist
|
|
60
|
+
path: dist/
|
|
61
|
+
|
|
62
|
+
- name: Publish to PyPI
|
|
63
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.py[cod]
|
|
3
|
+
*$py.class
|
|
4
|
+
*.egg-info/
|
|
5
|
+
dist/
|
|
6
|
+
build/
|
|
7
|
+
*.egg
|
|
8
|
+
.eggs/
|
|
9
|
+
*.so
|
|
10
|
+
.venv/
|
|
11
|
+
venv/
|
|
12
|
+
env/
|
|
13
|
+
.env
|
|
14
|
+
*.db
|
|
15
|
+
*.db-wal
|
|
16
|
+
*.db-shm
|
|
17
|
+
*.sqlite
|
|
18
|
+
*.sqlite3
|
|
19
|
+
data/*.db
|
|
20
|
+
data/*.sqlite
|
|
21
|
+
.pytest_cache/
|
|
22
|
+
.ruff_cache/
|
|
23
|
+
.mypy_cache/
|
|
24
|
+
htmlcov/
|
|
25
|
+
.coverage
|
|
26
|
+
*.log
|
|
27
|
+
real_logs/
|
|
28
|
+
.DS_Store
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"title": "Security Gym: Gymnasium Environments for Cybersecurity Threat Detection with Continual Learning",
|
|
3
|
+
"description": "Gymnasium-compatible environment that replays labeled Linux log streams for continual learning research. Scripted attacks mixed with real server traffic produce ground-truth-labeled data with multi-head prediction targets. Built for the Alberta Plan vision of long-lived agents that continually learn from non-stationary sensory streams.",
|
|
4
|
+
"upload_type": "software",
|
|
5
|
+
"access_right": "open",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"creators": [
|
|
8
|
+
{
|
|
9
|
+
"name": "Lawson, Keith",
|
|
10
|
+
"affiliation": ""
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"keywords": [
|
|
14
|
+
"gymnasium",
|
|
15
|
+
"cybersecurity",
|
|
16
|
+
"continual learning",
|
|
17
|
+
"reinforcement learning",
|
|
18
|
+
"intrusion detection",
|
|
19
|
+
"log analysis",
|
|
20
|
+
"Alberta Plan"
|
|
21
|
+
],
|
|
22
|
+
"related_identifiers": [
|
|
23
|
+
{
|
|
24
|
+
"identifier": "https://github.com/j-klawson/security-gym",
|
|
25
|
+
"relation": "isSupplementTo",
|
|
26
|
+
"scheme": "url"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"identifier": "https://arxiv.org/abs/2208.11173",
|
|
30
|
+
"relation": "references",
|
|
31
|
+
"scheme": "url"
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
title: "Security Gym"
|
|
3
|
+
message: "If you use this software, please cite it using the metadata from this file."
|
|
4
|
+
type: software
|
|
5
|
+
authors:
|
|
6
|
+
- family-names: Lawson
|
|
7
|
+
given-names: Keith
|
|
8
|
+
repository-code: "https://github.com/j-klawson/security-gym"
|
|
9
|
+
url: "https://github.com/j-klawson/security-gym"
|
|
10
|
+
license: Apache-2.0
|
|
11
|
+
version: "0.3.0"
|
|
12
|
+
date-released: "2026-03-01"
|
|
13
|
+
doi: "10.5281/zenodo.18810299"
|
|
14
|
+
keywords:
|
|
15
|
+
- gymnasium
|
|
16
|
+
- cybersecurity
|
|
17
|
+
- continual learning
|
|
18
|
+
- reinforcement learning
|
|
19
|
+
- intrusion detection
|
|
20
|
+
- log analysis
|
|
21
|
+
- Alberta Plan
|
|
22
|
+
abstract: >-
|
|
23
|
+
Gymnasium-compatible environment that replays labeled Linux log streams
|
|
24
|
+
for continual learning research. Scripted attacks mixed with real server
|
|
25
|
+
traffic produce ground-truth-labeled data — no episodes, no resets, just
|
|
26
|
+
a continuous stream of observations and multi-head prediction targets.
|
|
27
|
+
Built for the Alberta Plan vision of long-lived agents that continually
|
|
28
|
+
learn from non-stationary sensory streams.
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# security-gym
|
|
2
|
+
|
|
3
|
+
Gymnasium-compatible environment that replays labeled Linux log streams for continual learning research.
|
|
4
|
+
|
|
5
|
+
See `ROADMAP.md` for project phases and `TODO.md` for current action items.
|
|
6
|
+
|
|
7
|
+
## Architecture
|
|
8
|
+
|
|
9
|
+
- `src/security_gym/` — installable package (`pip install -e .`)
|
|
10
|
+
- `attacks/` — attack scripts for data generation (NOT pip-installed)
|
|
11
|
+
- `campaigns/` — YAML campaign configs for Isildur (ssh_brute_only, log4shell_only, recon_only, recon_ssh_log4shell, credential_stuffing_only, post_auth_only, full_killchain)
|
|
12
|
+
- `configs/` — YAML composition configs for StreamComposer (stream_7d_brute_only, stream_30d_heavy, stream_90d_mixed, stream_365d_realistic)
|
|
13
|
+
- `server/` — target VM provisioning docs, Docker Compose for vulnerable services, and eBPF collector daemon
|
|
14
|
+
- `data/` — runtime data directory (gitignored)
|
|
15
|
+
- `tests/` — pytest test suite
|
|
16
|
+
|
|
17
|
+
## Key Patterns
|
|
18
|
+
|
|
19
|
+
- **Parsers**: decorator-based registry (`@ParserRegistry.register('auth_log')`); six parsers: `auth_log`, `syslog`, `web_access`, `web_error`, `journal`, `ebpf`. Shared syslog header in `_syslog_header.py` with `parse_syslog_header()` supporting both BSD (`Feb 22 00:55:01`) and RFC 3339 (`2026-02-22T00:55:01.662021-05:00`) timestamp formats; RFC 3339 offsets are converted to UTC. Each parser stores `event_type` in `fields["event_type"]` for DB round-trip.
|
|
20
|
+
- **EventStore**: SQLite with WAL mode, ID-based cursor for resumable reads. Schema version 2. Valid sources: `auth_log`, `syslog`, `web_access`, `web_error`, `journal`, `ebpf_process`, `ebpf_network`, `ebpf_file`.
|
|
21
|
+
- **Environment (v1)**: `SecurityLogStream-v1` — agent sees raw text streams (like `tail -N` of log files and kernel event channels) and takes defensive actions that causally affect future observations.
|
|
22
|
+
- **Observation**: `Dict` of 6 `Text` channels (`auth_log`, `syslog`, `web_log`, `process_events`, `network_events`, `file_events`) + `Box(3)` system stats. Ring buffer per channel (configurable `tail_lines`, `max_chars`).
|
|
23
|
+
- **Action**: `Dict` of `Discrete(6)` (pass/alert/throttle/block_source/unblock/isolate) + `Box(1)` risk_score (0-10, GVF-like auxiliary prediction).
|
|
24
|
+
- **Reward**: asymmetric action costs (block benign = -1.0, block attacker = +1.0, pass benign = 0.0) + risk score MSE + ongoing consequence feedback from blocked/throttled events.
|
|
25
|
+
- **Defense state**: blocklist (100% drop), throttle list (90% drop), isolation mode (blocks all network events). Agent can escalate/de-escalate: throttle → block → unblock.
|
|
26
|
+
- **Continuous stream**: `terminated=False` always, `truncated=True` at end of data.
|
|
27
|
+
- **eBPF Collector**: `server/ebpf_collector.py` — BCC daemon attaching to kernel tracepoints (execve, connect, accept, openat, unlinkat). Deployed on Isildur (Debian 11, kernel 5.10, BCC 0.18). Output: timestamped text lines with enriched fields — process events include `ppid` + `parent_comm` (via `task->real_parent`), network events include `uid`. Self-PID filtering to avoid feedback loops. Orchestration wrapper: `attacks/collection/ebpf_collector.py` (paramiko Ed25519 SSH transport with keepalive).
|
|
28
|
+
- **Adapter**: `SecurityGymStream` reads EventStore directly, maintains ring buffers per channel (same as env), yields text observations + ground truth dicts. Supports `speed` (0=full, 1.0=realtime, 10.0=10x) and `loop` (never-ending wrap-around) parameters.
|
|
29
|
+
- **StreamComposer**: offline composition of benign + attack EventStore DBs into experiment streams (`data/composer.py`). Handles both log and eBPF events (all use same events table). YAML config specifies duration, seed, Poisson attack schedule (`campaigns_per_day`), and MITRE ATT&CK-weighted type distribution. Cycles benign events to fill duration, transplants attack sessions preserving intra-session timing. Deterministic given seed.
|
|
30
|
+
- **Registration**: belt+suspenders — `__init__.py` calls `register_envs()` on import AND `pyproject.toml` entry point for auto-discovery
|
|
31
|
+
- **Attack Modules**: decorator-based registry (`@AttackModuleRegistry.register('ssh_brute_force')`); five modules: `recon` (scapy SYN scan), `ssh_brute_force` (paramiko), `log4shell` (requests + JNDI injection), `credential_stuffing` (paramiko, unique cred pairs tried once each), `ssh_post_auth` (paramiko, post-auth command execution with 4 command profiles + optional payload download). Non-stationary `TimingProfile` with constant/accelerating/decelerating/custom profiles. Full kill chain campaign: recon → credential stuffing → post-auth execution.
|
|
32
|
+
- **Campaign Framework**: YAML-driven orchestrator — load config → start eBPF collector (if enabled) → execute phases → stop eBPF → SSH collect logs → label (time+IP matching) → bulk insert into EventStore. CLI: `python -m attacks run/validate/list-modules/compose`. eBPF collection configured via `collection.ebpf.enabled: true` in campaign YAML. eBPF events are routed through the same `CampaignLabeler` as log events (time+IP matching), so kernel events during attack windows are correctly labeled malicious.
|
|
33
|
+
- **Label Validation**: `scripts/validate_labels.py` — 9 checks (label consistency, raw line spot-checks, campaign boundaries, campaign type cross-val, target array NaN masking, attack type distribution, temporal order, no unlabeled events, session coherence). Supports `--check NAME` to run subset, `--spot-check N`, `--sample-size N`, `--verbose`. Exit 0 = all pass/skip, exit 1 = any FAIL. Distribution check is WARN-only (campaign weights control frequency, not event count — brute_force generates ~40x more events per campaign than discovery).
|
|
34
|
+
- **Deprecated (v0)**: Feature extractors (`features/extractors.py`, `features/hasher.py`, `features/session.py`), wrappers (`envs/wrappers.py`), and target builder (`targets/builder.py`) are retained for backwards compatibility but no longer used by the v1 environment. The agent now learns its own representations from raw text.
|
|
35
|
+
- **Data Versions**: v1 databases (`benign.db`, `campaigns.db`) contain log events only. v2 databases (`benign_v2.db`, `campaigns_v2.db`) add eBPF kernel events. Composition configs, campaign YAMLs, and config defaults all point at v2 databases. Benign eBPF baseline collected via `scripts/collect_ebpf_baseline.py`. v2 experiment streams composed: `exp_7d_brute.db` (26k events), `exp_30d_heavy.db` (510k), `exp01_90d.db` (475k), `exp_365d_realistic.db` (1.64M).
|
|
36
|
+
- **Known Data Quality**: campaigns.db has 87 temporal order violations (multi-server import boundary) and 6 mixed-label sessions (labeler edge cases). campaigns_v2.db has 20 temporal order violations and 3 mixed-label sessions. Composed experiment streams are clean — StreamComposer sorts by timestamp. benign.db shares the temporal order issue. Check 2 (raw line spot-checks) fails on eBPF events because the spot-checker can't pattern-match kernel event lines (file opens, accepts, exits) — these are correctly labeled by time+IP window matching.
|
|
37
|
+
- **CI**: GitHub Actions — test, lint (ruff), security (pip-audit + bandit) jobs on push/PR to main
|
|
38
|
+
|
|
39
|
+
## Commands
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install -e ".[dev]" # Install with dev deps
|
|
43
|
+
pip install -e ".[attacks]" # Install with attack deps
|
|
44
|
+
pytest tests/ # Run all tests
|
|
45
|
+
pytest attacks/tests/ # Run attack framework tests
|
|
46
|
+
pytest tests/test_env.py -v # Run env tests only
|
|
47
|
+
ruff check src/ tests/ attacks/ # Lint
|
|
48
|
+
python -m attacks validate campaigns/ssh_brute_only.yaml # Validate campaign
|
|
49
|
+
python -m attacks run campaigns/ssh_brute_only.yaml --dry-run # Preview campaign
|
|
50
|
+
python -m attacks import-logs real_logs/server1-var-log.tar --db data/benign.db --host server1 # Import benign logs
|
|
51
|
+
python -m attacks list-modules # Show available attack modules
|
|
52
|
+
python -m attacks compose configs/stream_90d_mixed.yaml # Compose experiment stream
|
|
53
|
+
python -m attacks compose configs/stream_90d_mixed.yaml --dry-run # Preview composition
|
|
54
|
+
python scripts/validate_labels.py data/campaigns_v2.db -v # Validate label accuracy
|
|
55
|
+
python scripts/validate_labels.py data/exp01_90d.db --spot-check 20 # Spot-check composed stream
|
|
56
|
+
python scripts/collect_ebpf_baseline.py --duration 3600 # Collect benign eBPF baseline
|
|
57
|
+
python scripts/insert_ebpf_baseline.py /tmp/ebpf_baseline.log # Insert manual eBPF baseline
|
|
58
|
+
sudo ./scripts/run_all_campaigns.sh # Run all 7 campaigns (needs sudo for IP aliasing)
|
|
59
|
+
python -m build # Build wheel
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Server Infrastructure (Isildur)
|
|
63
|
+
|
|
64
|
+
- **Host:** Debian 11.11 VM (192.168.2.201) on Frodo hypervisor, frozen (APT disabled, packages held)
|
|
65
|
+
- **Docker:** v20.10.5 with docker-compose v1.25 (requires `version: "3"` in compose files, use `docker-compose` not `docker compose`)
|
|
66
|
+
- **Services:** Log4Shell (CVE-2021-44228) on :8080 (`ghcr.io/christophetd/log4shell-vulnerable-app`), Nginx 1.21.0 reverse proxy on :80, SSH on :22
|
|
67
|
+
- **Users:** `researcher` (adm, systemd-journal groups) for log collection via SSH key `~/.ssh/isildur_research`, password auth enabled for attack modules; `keith` (sudo, docker groups) for administration
|
|
68
|
+
- **Log sources:** auth.log, syslog, nginx access/error logs, journalctl, Docker JSON logs
|
|
69
|
+
- **eBPF:** BCC 0.18 installed (manual .deb for kernel 5.10). Collector daemon at `server/ebpf_collector.py`. Sudoers rules grant researcher NOPASSWD for collector, pkill, python3.
|
|
70
|
+
- **Ground truth:** auditd rules track wget/curl/sh/bash execution with `research_exploit` key; researcher has NOPASSWD sudo for `ausearch`
|
|
71
|
+
- **Snapshots:** `ISILDUR_READY_V1` golden state on Frodo; `ISILDUR_READY_V2` after BCC install + eBPF sudoers (see `server/BUILD.md` section 5)
|
|
72
|
+
|
|
73
|
+
## Sibling Projects
|
|
74
|
+
|
|
75
|
+
- `chronos-sec` — Cowrie honeypot agent (source of parser/hasher/target patterns)
|
|
76
|
+
- `alberta-framework` — JAX learning framework (ScanStream protocol)
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding any notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2026 Keith Lawson (https://github.com/j-klawson)
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|