trapster 1.2.0__tar.gz → 1.2.2__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.
Files changed (58) hide show
  1. {trapster-1.2.0/trapster.egg-info → trapster-1.2.2}/PKG-INFO +165 -10
  2. {trapster-1.2.0 → trapster-1.2.2}/README.md +163 -8
  3. {trapster-1.2.0 → trapster-1.2.2}/requirements.txt +1 -1
  4. trapster-1.2.2/trapster/__init__.py +1 -0
  5. {trapster-1.2.0 → trapster-1.2.2}/trapster/data/trapster.conf +49 -37
  6. {trapster-1.2.0 → trapster-1.2.2}/trapster/libs/dns.py +21 -6
  7. trapster-1.2.2/trapster/logger/__init__.py +28 -0
  8. trapster-1.2.2/trapster/logger/api.py +12 -0
  9. trapster-1.2.2/trapster/logger/base.py +50 -0
  10. trapster-1.2.2/trapster/logger/ecs.py +32 -0
  11. trapster-1.2.2/trapster/logger/factory.py +71 -0
  12. trapster-1.2.2/trapster/logger/file.py +19 -0
  13. trapster-1.2.2/trapster/logger/formatters.py +202 -0
  14. trapster-1.2.2/trapster/logger/json.py +12 -0
  15. trapster-1.2.2/trapster/logger/output.py +110 -0
  16. trapster-1.2.2/trapster/logger/redis.py +12 -0
  17. {trapster-1.2.0 → trapster-1.2.2}/trapster/modules/base.py +18 -1
  18. {trapster-1.2.0 → trapster-1.2.2}/trapster/modules/dns.py +16 -10
  19. {trapster-1.2.0 → trapster-1.2.2}/trapster/modules/ftp.py +4 -7
  20. trapster-1.2.2/trapster/modules/http.py +842 -0
  21. {trapster-1.2.0 → trapster-1.2.2}/trapster/modules/https.py +35 -44
  22. {trapster-1.2.0 → trapster-1.2.2}/trapster/modules/ldap.py +85 -16
  23. {trapster-1.2.0 → trapster-1.2.2}/trapster/modules/ldaps.py +4 -0
  24. {trapster-1.2.0 → trapster-1.2.2}/trapster/modules/mssql.py +5 -4
  25. {trapster-1.2.0 → trapster-1.2.2}/trapster/modules/mysql.py +5 -4
  26. {trapster-1.2.0 → trapster-1.2.2}/trapster/modules/postgres.py +1 -0
  27. {trapster-1.2.0 → trapster-1.2.2}/trapster/modules/rdp.py +31 -13
  28. {trapster-1.2.0 → trapster-1.2.2}/trapster/modules/rsync.py +5 -4
  29. {trapster-1.2.0 → trapster-1.2.2}/trapster/modules/snmp.py +14 -3
  30. {trapster-1.2.0 → trapster-1.2.2}/trapster/modules/socks5.py +1 -0
  31. {trapster-1.2.0 → trapster-1.2.2}/trapster/modules/ssh.py +8 -6
  32. {trapster-1.2.0 → trapster-1.2.2}/trapster/modules/telnet.py +3 -0
  33. {trapster-1.2.0 → trapster-1.2.2}/trapster/modules/vnc.py +4 -3
  34. {trapster-1.2.0 → trapster-1.2.2}/trapster/trapster.py +8 -1
  35. {trapster-1.2.0 → trapster-1.2.2/trapster.egg-info}/PKG-INFO +165 -10
  36. {trapster-1.2.0 → trapster-1.2.2}/trapster.egg-info/SOURCES.txt +10 -1
  37. {trapster-1.2.0 → trapster-1.2.2}/trapster.egg-info/requires.txt +1 -1
  38. trapster-1.2.0/trapster/__init__.py +0 -1
  39. trapster-1.2.0/trapster/logger.py +0 -168
  40. trapster-1.2.0/trapster/modules/http.py +0 -501
  41. {trapster-1.2.0 → trapster-1.2.2}/LICENSE +0 -0
  42. {trapster-1.2.0 → trapster-1.2.2}/MANIFEST.in +0 -0
  43. {trapster-1.2.0 → trapster-1.2.2}/setup.cfg +0 -0
  44. {trapster-1.2.0 → trapster-1.2.2}/setup.py +0 -0
  45. {trapster-1.2.0 → trapster-1.2.2}/tests/test_ftp_server.py +0 -0
  46. {trapster-1.2.0 → trapster-1.2.2}/tests/test_ssh_server.py +0 -0
  47. {trapster-1.2.0 → trapster-1.2.2}/trapster/ai/__init__.py +0 -0
  48. {trapster-1.2.0 → trapster-1.2.2}/trapster/ai/base.py +0 -0
  49. {trapster-1.2.0 → trapster-1.2.2}/trapster/ai/http.py +0 -0
  50. {trapster-1.2.0 → trapster-1.2.2}/trapster/ai/ssh.py +0 -0
  51. {trapster-1.2.0 → trapster-1.2.2}/trapster/libs/__init__.py +0 -0
  52. {trapster-1.2.0 → trapster-1.2.2}/trapster/libs/ldapasn1.py +0 -0
  53. {trapster-1.2.0 → trapster-1.2.2}/trapster/libs/ntlm.py +0 -0
  54. {trapster-1.2.0 → trapster-1.2.2}/trapster/modules/__init__.py +0 -0
  55. {trapster-1.2.0 → trapster-1.2.2}/trapster/modules/resources/VNC_ascii.hcchr +0 -0
  56. {trapster-1.2.0 → trapster-1.2.2}/trapster.egg-info/dependency_links.txt +0 -0
  57. {trapster-1.2.0 → trapster-1.2.2}/trapster.egg-info/entry_points.txt +0 -0
  58. {trapster-1.2.0 → trapster-1.2.2}/trapster.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: trapster
3
- Version: 1.2.0
3
+ Version: 1.2.2
4
4
  Summary: Trapster Daemon
5
5
  Home-page: https://trapster.cloud/
6
6
  Author: 0xBallpoint
@@ -31,7 +31,7 @@ Requires-Dist: scapy>=2.5.0
31
31
  Requires-Dist: jinja2>=3.1.4
32
32
  Requires-Dist: PyYAML>=6.0.2
33
33
  Requires-Dist: fastapi>=0.115.9
34
- Requires-Dist: uvicorn>=0.34.0
34
+ Requires-Dist: hypercorn>=0.17.0
35
35
  Provides-Extra: ai
36
36
  Requires-Dist: openai<1.99.0; extra == "ai"
37
37
  Requires-Dist: openai-agents>=0.2.5; extra == "ai"
@@ -84,6 +84,7 @@ Visit the [Trapster website](https://trapster.cloud) to learn more about our com
84
84
  | HTTP/HTTPS (80/443) | Copy website, features custom YAML configuration templating engine |
85
85
  | SNMP (161) | Log SNMP queries |
86
86
  | LDAP (389) | Capture LDAP login attempts and queries |
87
+ | LDAPS (636) | Capture LDAP login attempts and queries over TLS |
87
88
  | Rsync (873) | Capture RSYNC login attempts |
88
89
  | MSSQL (1433) | Capture MSSQL login attempts |
89
90
  | MySQL (3306) | Capture MySQL login attempts |
@@ -109,16 +110,149 @@ AI_BASE_URL=https://api.openai.com/v1/
109
110
  AI_API_KEY=<YOUR_OPENAI_API_KEY>
110
111
  ```
111
112
 
113
+ ## Configuration wizard
114
+
115
+ You can start from the example **`trapster/data/trapster.conf`**, or run the helper script to create **`./trapster.generated.conf`** interactively.
116
+
117
+ ```bash
118
+ bash scripts/trapster-wizard.sh
119
+ ```
120
+
121
+ From a checkout, with a venv:
122
+
123
+ ```bash
124
+ python3 -m venv venv
125
+ source venv/bin/activate
126
+ pip install -r requirements.txt
127
+ bash scripts/trapster-wizard.sh
128
+ python main.py -c ./trapster.generated.conf
129
+ ```
130
+
131
+ Or install the package in editable mode (`pip install -e .`) and run `trapster -c ./trapster.generated.conf`.
132
+
133
+ The example configuration listens on well-known ports; binding them usually requires elevated privileges. Run as **root**, or use **`sudo -E`** (keeps your environment, e.g. an activated venv) when starting Trapster with Python.
134
+
112
135
  ## Logs
113
136
 
114
- ### Format
115
- Each module can generate up to 4 types of logs: `connection`, `data`, `login`, and `query`.
116
- * `connection`: Indicates that a connection has been made to the module.
117
- * `data`: Represents raw data that has been sent, logged in HEX format. This data is unprocessed.
118
- * `login`: Captures login attempts to the module. The data field is in JSON format and contains processed information.
119
- * `query`: Logs data that has been processed and does not correspond to an authentication attempt. The data field is in JSON format and contains processed information.
137
+ Trapster now separates:
138
+
139
+ - **format**: how events are structured (`default` or `ecs`)
140
+ - **output**: where events are sent (`terminal`, `file`, `api`, `redis`)
120
141
 
121
- You can then filter log type you don't need.
142
+ This lets you combine them freely, for example:
143
+ - default JSON -> terminal
144
+ - default JSON -> API
145
+ - ECS -> API
146
+
147
+ ### Event types
148
+ Each module can generate up to 4 event actions: `connection`, `data`, `login`, and `query`.
149
+ - `connection`: a connection has been made to the module
150
+ - `data`: raw payload received (hex-encoded in the `data` field)
151
+ - `login`: authentication attempt
152
+ - `query`: processed protocol request which is not an authentication attempt
153
+
154
+ ### Formats
155
+
156
+ #### `default`
157
+ The original Trapster event structure:
158
+ ```json
159
+ {
160
+ "device": "trapster-1",
161
+ "logtype": "ftp.login",
162
+ "dst_ip": "10.0.0.10",
163
+ "dst_port": 21,
164
+ "src_ip": "10.0.0.50",
165
+ "src_port": 49152,
166
+ "timestamp": "2026-05-08 10:00:00.123456",
167
+ "data": "68656c6c6f",
168
+ "extra": {
169
+ "username": "admin",
170
+ "password": "admin"
171
+ }
172
+ }
173
+ ```
174
+
175
+ #### `ecs`
176
+ Elastic Common Schema format, with protocol details under `trapster.<protocol>.*`:
177
+ ```json
178
+ {
179
+ "@timestamp": "2026-05-08T10:00:00.123456Z",
180
+ "ecs": { "version": "8.11.0" },
181
+ "event": {
182
+ "category": ["authentication", "network"],
183
+ "type": ["start", "info"],
184
+ "action": "login",
185
+ "outcome": "failure",
186
+ "dataset": "trapster.ftp"
187
+ },
188
+ "network": {
189
+ "transport": "tcp",
190
+ "protocol": "ftp",
191
+ "application": "ftp",
192
+ "type": "ipv4"
193
+ },
194
+ "trapster": {
195
+ "raw": "68656c6c6f",
196
+ "login": {
197
+ "username": "admin",
198
+ "password": "admin"
199
+ },
200
+ "ftp": {}
201
+ }
202
+ }
203
+ ```
204
+
205
+ ### Configuration examples
206
+
207
+ #### 1) Default JSON -> terminal
208
+ ```json
209
+ "logger": {
210
+ "output": "terminal",
211
+ "format": "default",
212
+ "kwargs": {}
213
+ }
214
+ ```
215
+
216
+ #### 2) ECS -> API
217
+ ```json
218
+ "logger": {
219
+ "output": "api",
220
+ "format": "ecs",
221
+ "kwargs": {
222
+ "url": "https://example.local/ingest",
223
+ "headers": {
224
+ "Authorization": "Bearer <token>"
225
+ }
226
+ }
227
+ }
228
+ ```
229
+
230
+ #### 3) Default JSON -> file
231
+ ```json
232
+ "logger": {
233
+ "output": "file",
234
+ "format": "default",
235
+ "kwargs": {
236
+ "logfile": "/var/log/trapster-community.log",
237
+ "mode": "a"
238
+ }
239
+ }
240
+ ```
241
+
242
+ ### Retrocompatibility
243
+ Existing logger configuration still works (`name` + `kwargs`):
244
+ ```json
245
+ "logger": {
246
+ "name": "JsonLogger",
247
+ "kwargs": {}
248
+ }
249
+ ```
250
+
251
+ And also:
252
+ - `FileLogger`
253
+ - `ApiLogger`
254
+ - `RedisLogger`
255
+ - `EcsLogger`
122
256
 
123
257
  ## HTTP Engine
124
258
 
@@ -126,7 +260,17 @@ You can then filter log type you don't need.
126
260
  The HTTP module can emulate any website. It works with YAML configuration files to match requests using regular expressions, and can generate responses using either a template or an AI model.
127
261
 
128
262
  The configuration are stored in [trapster/data/http](trapster/data/http), each folder represent a website.
129
- An example of the functionnalities can be found at [trapster/data/http/demo_api/config.yaml](trapster/data/http/demo_api/config.yaml)
263
+
264
+ `demo_api` ([trapster/data/http/demo_api](trapster/data/http/demo_api)) is a reference skin: every entry in its `config.yaml`
265
+ and template exists specifically to demonstrate one capability of the HTTP engine, so it's the
266
+ place to look when writing your own. It shows, among others:
267
+
268
+ - **`http_version: "2"`**: advertise HTTP/2 over ALPN (only takes effect when the skin is served over HTTPS).
269
+ - **Custom reason phrases**: override the HTTP/1.1 status line's reason (`reason:`), either a fixed string or a per-request Jinja expression.
270
+ - **ETags & conditional GET**: `etag()` generates IIS-style or hashed ETags from a per-deployment seed; a matching `If-None-Match` on a later request gets an automatic `304`.
271
+ - **Deploy-time `vars`**: values resolved once at startup from a random per-deployment seed, so they're identical across every request but unique per deployment.
272
+ - **Per-request templating**: `.j2` files re-render on every request (`request.form`, `request.query_string`, `uuid()`, `quote` filter, etc.), while inline `content`/`headers` are frozen at startup unless they reference `request`.
273
+ - **Static file serving, regex path/query matching, `default`/`errors`/`unknown_method` fallbacks.**
130
274
 
131
275
  **Structure:**
132
276
  - config.yaml: contains the configuration for the website.
@@ -184,6 +328,15 @@ If someone tries to login, you will get a log like this one:
184
328
 
185
329
  ## AI support
186
330
 
331
+ > **Disclaimer:** AI-generated responses are not a substitute for intrusion detection. A
332
+ > motivated attacker can fingerprint them (latency, inconsistent state across requests, subtle
333
+ > phrasing) with a handful of probes, so this feature should not be relied on in a defensive or
334
+ > production deployment. It's intended for external CTI research, observing attacker tooling and
335
+ > behavior against a permissive AI-driven backend, not as a hardened detection control.
336
+
337
+ <details>
338
+ <summary>Show AI support details</summary>
339
+
187
340
  To use AI, install the dependencies:
188
341
  ```bash
189
342
  pip install trapster[ai]
@@ -241,6 +394,8 @@ For example, this image show a request to capture SQLi attempts. Only the SQLi a
241
394
 
242
395
  A full example is available in `trapster/data/demo_ai`
243
396
 
397
+ </details>
398
+
244
399
  ## Contributing
245
400
 
246
401
  Contributions are welcome! Please follow these steps:
@@ -33,6 +33,7 @@ Visit the [Trapster website](https://trapster.cloud) to learn more about our com
33
33
  | HTTP/HTTPS (80/443) | Copy website, features custom YAML configuration templating engine |
34
34
  | SNMP (161) | Log SNMP queries |
35
35
  | LDAP (389) | Capture LDAP login attempts and queries |
36
+ | LDAPS (636) | Capture LDAP login attempts and queries over TLS |
36
37
  | Rsync (873) | Capture RSYNC login attempts |
37
38
  | MSSQL (1433) | Capture MSSQL login attempts |
38
39
  | MySQL (3306) | Capture MySQL login attempts |
@@ -58,16 +59,149 @@ AI_BASE_URL=https://api.openai.com/v1/
58
59
  AI_API_KEY=<YOUR_OPENAI_API_KEY>
59
60
  ```
60
61
 
62
+ ## Configuration wizard
63
+
64
+ You can start from the example **`trapster/data/trapster.conf`**, or run the helper script to create **`./trapster.generated.conf`** interactively.
65
+
66
+ ```bash
67
+ bash scripts/trapster-wizard.sh
68
+ ```
69
+
70
+ From a checkout, with a venv:
71
+
72
+ ```bash
73
+ python3 -m venv venv
74
+ source venv/bin/activate
75
+ pip install -r requirements.txt
76
+ bash scripts/trapster-wizard.sh
77
+ python main.py -c ./trapster.generated.conf
78
+ ```
79
+
80
+ Or install the package in editable mode (`pip install -e .`) and run `trapster -c ./trapster.generated.conf`.
81
+
82
+ The example configuration listens on well-known ports; binding them usually requires elevated privileges. Run as **root**, or use **`sudo -E`** (keeps your environment, e.g. an activated venv) when starting Trapster with Python.
83
+
61
84
  ## Logs
62
85
 
63
- ### Format
64
- Each module can generate up to 4 types of logs: `connection`, `data`, `login`, and `query`.
65
- * `connection`: Indicates that a connection has been made to the module.
66
- * `data`: Represents raw data that has been sent, logged in HEX format. This data is unprocessed.
67
- * `login`: Captures login attempts to the module. The data field is in JSON format and contains processed information.
68
- * `query`: Logs data that has been processed and does not correspond to an authentication attempt. The data field is in JSON format and contains processed information.
86
+ Trapster now separates:
87
+
88
+ - **format**: how events are structured (`default` or `ecs`)
89
+ - **output**: where events are sent (`terminal`, `file`, `api`, `redis`)
69
90
 
70
- You can then filter log type you don't need.
91
+ This lets you combine them freely, for example:
92
+ - default JSON -> terminal
93
+ - default JSON -> API
94
+ - ECS -> API
95
+
96
+ ### Event types
97
+ Each module can generate up to 4 event actions: `connection`, `data`, `login`, and `query`.
98
+ - `connection`: a connection has been made to the module
99
+ - `data`: raw payload received (hex-encoded in the `data` field)
100
+ - `login`: authentication attempt
101
+ - `query`: processed protocol request which is not an authentication attempt
102
+
103
+ ### Formats
104
+
105
+ #### `default`
106
+ The original Trapster event structure:
107
+ ```json
108
+ {
109
+ "device": "trapster-1",
110
+ "logtype": "ftp.login",
111
+ "dst_ip": "10.0.0.10",
112
+ "dst_port": 21,
113
+ "src_ip": "10.0.0.50",
114
+ "src_port": 49152,
115
+ "timestamp": "2026-05-08 10:00:00.123456",
116
+ "data": "68656c6c6f",
117
+ "extra": {
118
+ "username": "admin",
119
+ "password": "admin"
120
+ }
121
+ }
122
+ ```
123
+
124
+ #### `ecs`
125
+ Elastic Common Schema format, with protocol details under `trapster.<protocol>.*`:
126
+ ```json
127
+ {
128
+ "@timestamp": "2026-05-08T10:00:00.123456Z",
129
+ "ecs": { "version": "8.11.0" },
130
+ "event": {
131
+ "category": ["authentication", "network"],
132
+ "type": ["start", "info"],
133
+ "action": "login",
134
+ "outcome": "failure",
135
+ "dataset": "trapster.ftp"
136
+ },
137
+ "network": {
138
+ "transport": "tcp",
139
+ "protocol": "ftp",
140
+ "application": "ftp",
141
+ "type": "ipv4"
142
+ },
143
+ "trapster": {
144
+ "raw": "68656c6c6f",
145
+ "login": {
146
+ "username": "admin",
147
+ "password": "admin"
148
+ },
149
+ "ftp": {}
150
+ }
151
+ }
152
+ ```
153
+
154
+ ### Configuration examples
155
+
156
+ #### 1) Default JSON -> terminal
157
+ ```json
158
+ "logger": {
159
+ "output": "terminal",
160
+ "format": "default",
161
+ "kwargs": {}
162
+ }
163
+ ```
164
+
165
+ #### 2) ECS -> API
166
+ ```json
167
+ "logger": {
168
+ "output": "api",
169
+ "format": "ecs",
170
+ "kwargs": {
171
+ "url": "https://example.local/ingest",
172
+ "headers": {
173
+ "Authorization": "Bearer <token>"
174
+ }
175
+ }
176
+ }
177
+ ```
178
+
179
+ #### 3) Default JSON -> file
180
+ ```json
181
+ "logger": {
182
+ "output": "file",
183
+ "format": "default",
184
+ "kwargs": {
185
+ "logfile": "/var/log/trapster-community.log",
186
+ "mode": "a"
187
+ }
188
+ }
189
+ ```
190
+
191
+ ### Retrocompatibility
192
+ Existing logger configuration still works (`name` + `kwargs`):
193
+ ```json
194
+ "logger": {
195
+ "name": "JsonLogger",
196
+ "kwargs": {}
197
+ }
198
+ ```
199
+
200
+ And also:
201
+ - `FileLogger`
202
+ - `ApiLogger`
203
+ - `RedisLogger`
204
+ - `EcsLogger`
71
205
 
72
206
  ## HTTP Engine
73
207
 
@@ -75,7 +209,17 @@ You can then filter log type you don't need.
75
209
  The HTTP module can emulate any website. It works with YAML configuration files to match requests using regular expressions, and can generate responses using either a template or an AI model.
76
210
 
77
211
  The configuration are stored in [trapster/data/http](trapster/data/http), each folder represent a website.
78
- An example of the functionnalities can be found at [trapster/data/http/demo_api/config.yaml](trapster/data/http/demo_api/config.yaml)
212
+
213
+ `demo_api` ([trapster/data/http/demo_api](trapster/data/http/demo_api)) is a reference skin: every entry in its `config.yaml`
214
+ and template exists specifically to demonstrate one capability of the HTTP engine, so it's the
215
+ place to look when writing your own. It shows, among others:
216
+
217
+ - **`http_version: "2"`**: advertise HTTP/2 over ALPN (only takes effect when the skin is served over HTTPS).
218
+ - **Custom reason phrases**: override the HTTP/1.1 status line's reason (`reason:`), either a fixed string or a per-request Jinja expression.
219
+ - **ETags & conditional GET**: `etag()` generates IIS-style or hashed ETags from a per-deployment seed; a matching `If-None-Match` on a later request gets an automatic `304`.
220
+ - **Deploy-time `vars`**: values resolved once at startup from a random per-deployment seed, so they're identical across every request but unique per deployment.
221
+ - **Per-request templating**: `.j2` files re-render on every request (`request.form`, `request.query_string`, `uuid()`, `quote` filter, etc.), while inline `content`/`headers` are frozen at startup unless they reference `request`.
222
+ - **Static file serving, regex path/query matching, `default`/`errors`/`unknown_method` fallbacks.**
79
223
 
80
224
  **Structure:**
81
225
  - config.yaml: contains the configuration for the website.
@@ -133,6 +277,15 @@ If someone tries to login, you will get a log like this one:
133
277
 
134
278
  ## AI support
135
279
 
280
+ > **Disclaimer:** AI-generated responses are not a substitute for intrusion detection. A
281
+ > motivated attacker can fingerprint them (latency, inconsistent state across requests, subtle
282
+ > phrasing) with a handful of probes, so this feature should not be relied on in a defensive or
283
+ > production deployment. It's intended for external CTI research, observing attacker tooling and
284
+ > behavior against a permissive AI-driven backend, not as a hardened detection control.
285
+
286
+ <details>
287
+ <summary>Show AI support details</summary>
288
+
136
289
  To use AI, install the dependencies:
137
290
  ```bash
138
291
  pip install trapster[ai]
@@ -190,6 +343,8 @@ For example, this image show a request to capture SQLi attempts. Only the SQLi a
190
343
 
191
344
  A full example is available in `trapster/data/demo_ai`
192
345
 
346
+ </details>
347
+
193
348
  ## Contributing
194
349
 
195
350
  Contributions are welcome! Please follow these steps:
@@ -8,4 +8,4 @@ scapy>=2.5.0
8
8
  jinja2>=3.1.4
9
9
  PyYAML>=6.0.2
10
10
  fastapi>=0.115.9
11
- uvicorn>=0.34.0
11
+ hypercorn>=0.17.0
@@ -0,0 +1 @@
1
+ __version__="1.2.2"
@@ -1,14 +1,16 @@
1
1
  {
2
2
  "id": "trapster-1",
3
3
  "description": "example configuration file",
4
- "whitelist_ips": ["127.0.0.1"],
4
+ "whitelist_ips": [
5
+ "127.0.0.1"
6
+ ],
5
7
  "interface": "",
6
8
  "hostname": "DC01",
7
9
  "domain": "corp.local",
8
10
  "services": {
9
11
  "ftp": [
10
12
  {
11
- "port": 2121,
13
+ "port": 21,
12
14
  "username": null,
13
15
  "password": null,
14
16
  "banner": "Microsoft FTP Service"
@@ -16,7 +18,7 @@
16
18
  ],
17
19
  "http": [
18
20
  {
19
- "port": 8080,
21
+ "port": 80,
20
22
  "basic_auth": false,
21
23
  "username": "admin",
22
24
  "password": "admin",
@@ -25,44 +27,35 @@
25
27
  ],
26
28
  "https": [
27
29
  {
28
- "port": 8443,
29
- "skin": "fortigate",
30
- "country_name": "",
31
- "state_or_province_name": "",
32
- "locality_name": "",
33
- "organization_name": "Fortinet Ltd.",
34
- "common_name": "FortiGate",
35
- "key" : "trapster/data/ssl/https/key.pem",
36
- "certificate" : "trapster/data/ssl/https/certificate.pem"
30
+ "port": 443,
31
+ "basic_auth": false,
32
+ "username": "admin",
33
+ "password": "admin",
34
+ "skin": "demo_api",
35
+ "common_name": "server.internal"
37
36
  }
38
37
  ],
39
38
  "ssh": [
40
39
  {
41
- "port": 2222,
42
- "version": "SSH-2.0-OpenSSH_8.1p1 Debian-1",
43
- "banner": null,
40
+ "port": 22,
41
+ "version": "SSH-2.0-OpenSSH_9.2p1 Debian-2+deb12u7",
42
+ "banner": "",
44
43
  "users": {
45
44
  }
46
45
  }
47
46
  ],
48
47
  "dns": [
49
48
  {
50
- "port": 5353,
51
- "target_dns": "127.0.0.1"
49
+ "port": 53,
50
+ "target_dns": "127.0.0.1"
52
51
  }
53
52
  ],
54
53
  "vnc": [
55
54
  {
56
- "port": 5901,
55
+ "port": 5900,
57
56
  "version": "RFB_38"
58
57
  }
59
58
  ],
60
- "mssql": [
61
- {
62
- "port": 1433,
63
- "version": "2019"
64
- }
65
- ],
66
59
  "mysql": [
67
60
  {
68
61
  "port": 3306,
@@ -70,20 +63,16 @@
70
63
  "auth_plugin": "mysql_native_password"
71
64
  }
72
65
  ],
73
- "rdp": [
74
- {
75
- "port": 3389
76
- }
77
- ],
78
- "telnet": [
66
+ "mssql": [
79
67
  {
80
- "port": 2323,
81
- "version": "Cisco router telnetd / IOS"
68
+ "port": 1433,
69
+ "version": "2019",
70
+ "hostname": "SQL01"
82
71
  }
83
72
  ],
84
- "snmp": [
73
+ "postgres": [
85
74
  {
86
- "port": 9161
75
+ "port": 5432
87
76
  }
88
77
  ],
89
78
  "ldap": [
@@ -98,16 +87,39 @@
98
87
  "level": "WinThreshold"
99
88
  }
100
89
  ],
90
+ "rdp": [
91
+ {
92
+ "port": 3389,
93
+ "version": "2019",
94
+ "ntlm_hostname": "WIN-RDP",
95
+ "ntlm_domain": "WORKGROUP"
96
+ }
97
+ ],
98
+ "telnet": [
99
+ {
100
+ "port": 23,
101
+ "version": "Cisco router telnetd / IOS"
102
+ }
103
+ ],
104
+ "snmp": [
105
+ {
106
+ "port": 161
107
+ }
108
+ ],
101
109
  "rsync": [
102
110
  {
103
- "port": 8873,
111
+ "port": 873,
104
112
  "version": "31.0",
105
- "modules": ["Backup", "Users"]
113
+ "modules": [
114
+ "Backup",
115
+ "Users"
116
+ ]
106
117
  }
107
118
  ]
108
119
  },
109
120
  "logger": {
110
- "name": "JsonLogger",
121
+ "output": "terminal",
122
+ "format": "default",
111
123
  "kwargs": {}
112
124
  }
113
125
  }
@@ -3,25 +3,40 @@ import struct
3
3
  # details of dns packet : https://courses.cs.duke.edu/fall16/compsci356/DNS/DNS-primer.pdf
4
4
  # code from https://stackoverflow.com/questions/16977588/reading-dns-packets-in-python
5
5
 
6
+ import struct
7
+
6
8
  def decode_labels(message, offset):
7
9
  labels = []
10
+ return_offset = None
11
+ # Each pointer must jump strictly backward, so the max legal target
12
+ # shrinks monotonically. This bounds cycles and long chains.
13
+ max_allowed_pointer = len(message)
8
14
 
9
15
  while True:
16
+ if offset >= len(message):
17
+ raise ValueError("label offset out of bounds")
18
+
10
19
  length, = struct.unpack_from("!B", message, offset)
11
20
 
12
21
  if (length & 0xC0) == 0xC0:
13
22
  pointer, = struct.unpack_from("!H", message, offset)
14
- offset += 2
15
-
16
- return labels + decode_labels(message, pointer & 0x3FFF), offset
23
+ # Remember where to resume only for the first pointer followed.
24
+ if return_offset is None:
25
+ return_offset = offset + 2
26
+ target = pointer & 0x3FFF
27
+ if target >= max_allowed_pointer:
28
+ raise ValueError("invalid DNS compression pointer")
29
+ max_allowed_pointer = target
30
+ offset = target
31
+ continue
17
32
 
18
33
  if (length & 0xC0) != 0x00:
19
- raise "unknown label encoding"
34
+ raise ValueError("unknown label encoding")
20
35
 
21
36
  offset += 1
22
37
 
23
38
  if length == 0:
24
- return labels, offset
39
+ return labels, return_offset if return_offset is not None else offset
25
40
 
26
41
  labels.append(*struct.unpack_from("!%ds" % length, message, offset))
27
42
  try:
@@ -85,4 +100,4 @@ def decode_dns_message(message):
85
100
  "additional_count": arcount,
86
101
  "questions": questions}
87
102
 
88
- return result
103
+ return result
@@ -0,0 +1,28 @@
1
+ import logging
2
+
3
+ from .api import ApiLogger
4
+ from .base import BaseLogger
5
+ from .ecs import EcsLogger
6
+ from .factory import set_logger
7
+ from .file import FileLogger
8
+ from .json import JsonLogger
9
+ from .output import OutputLogger
10
+ from .redis import RedisLogger
11
+
12
+
13
+ logging.basicConfig(
14
+ format="%(asctime)s | %(levelname)-8s | %(message)s",
15
+ datefmt="%Y-%m-%d %H:%M:%S",
16
+ level=logging.INFO,
17
+ )
18
+
19
+ __all__ = [
20
+ "BaseLogger",
21
+ "JsonLogger",
22
+ "FileLogger",
23
+ "RedisLogger",
24
+ "ApiLogger",
25
+ "EcsLogger",
26
+ "OutputLogger",
27
+ "set_logger",
28
+ ]
@@ -0,0 +1,12 @@
1
+ from .output import OutputLogger
2
+
3
+
4
+ class ApiLogger(OutputLogger):
5
+ def __init__(self, node_id, url, headers={}, event_format="default", format_kwargs=None):
6
+ super().__init__(
7
+ node_id=node_id,
8
+ output="api",
9
+ event_format=event_format,
10
+ output_kwargs={"url": url, "headers": headers},
11
+ format_kwargs=format_kwargs or {},
12
+ )