dementor 1.0.0.dev18__tar.gz → 1.0.0.dev19__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 (77) hide show
  1. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/PKG-INFO +4 -25
  2. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/__init__.py +1 -1
  3. dementor-1.0.0.dev19/dementor/__main__.py +22 -0
  4. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/assets/Dementor.toml +127 -31
  5. dementor-1.0.0.dev19/dementor/config/__init__.py +89 -0
  6. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/config/session.py +22 -7
  7. dementor-1.0.0.dev19/dementor/config/toml.py +252 -0
  8. dementor-1.0.0.dev19/dementor/config/util.py +222 -0
  9. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/db/__init__.py +23 -1
  10. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/db/connector.py +57 -11
  11. dementor-1.0.0.dev19/dementor/db/model.py +468 -0
  12. dementor-1.0.0.dev19/dementor/filters.py +314 -0
  13. dementor-1.0.0.dev19/dementor/loader.py +221 -0
  14. dementor-1.0.0.dev19/dementor/log/__init__.py +73 -0
  15. dementor-1.0.0.dev19/dementor/log/logger.py +544 -0
  16. dementor-1.0.0.dev19/dementor/log/stream.py +448 -0
  17. dementor-1.0.0.dev19/dementor/protocols/ftp.py +252 -0
  18. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/protocols/http.py +9 -5
  19. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/protocols/imap.py +8 -4
  20. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/protocols/ldap.py +14 -10
  21. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/protocols/msrpc/rpc.py +8 -4
  22. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/protocols/mssql.py +8 -4
  23. dementor-1.0.0.dev19/dementor/protocols/ntlm.py +1207 -0
  24. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/protocols/pop3.py +8 -4
  25. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/protocols/quic.py +3 -3
  26. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/protocols/smb.py +10 -13
  27. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/protocols/smtp.py +15 -10
  28. dementor-1.0.0.dev19/dementor/servers.py +568 -0
  29. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/standalone.py +4 -4
  30. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor.egg-info/PKG-INFO +4 -25
  31. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor.egg-info/requires.txt +1 -1
  32. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/docs/README.pypi.md +1 -1
  33. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/pyproject.toml +16 -4
  34. dementor-1.0.0.dev18/dementor/__main__.py +0 -3
  35. dementor-1.0.0.dev18/dementor/config/__init__.py +0 -53
  36. dementor-1.0.0.dev18/dementor/config/toml.py +0 -134
  37. dementor-1.0.0.dev18/dementor/config/util.py +0 -92
  38. dementor-1.0.0.dev18/dementor/db/model.py +0 -301
  39. dementor-1.0.0.dev18/dementor/filters.py +0 -150
  40. dementor-1.0.0.dev18/dementor/loader.py +0 -113
  41. dementor-1.0.0.dev18/dementor/log/__init__.py +0 -24
  42. dementor-1.0.0.dev18/dementor/log/logger.py +0 -304
  43. dementor-1.0.0.dev18/dementor/log/stream.py +0 -234
  44. dementor-1.0.0.dev18/dementor/protocols/ftp.py +0 -112
  45. dementor-1.0.0.dev18/dementor/protocols/ntlm.py +0 -257
  46. dementor-1.0.0.dev18/dementor/servers.py +0 -271
  47. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/LICENSE +0 -0
  48. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/README.md +0 -0
  49. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/assets/banner.txt +0 -0
  50. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/assets/www/error_page.html +0 -0
  51. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/assets/www/upnp-default/dd.xml +0 -0
  52. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/assets/www/upnp-default/present.html +0 -0
  53. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/assets/www/upnp-default/scpd.xml +0 -0
  54. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/assets/www/wpad.dat +0 -0
  55. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/config/attr.py +0 -0
  56. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/log/hexdump.py +0 -0
  57. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/paths.py +0 -0
  58. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/protocols/__init__.py +0 -0
  59. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/protocols/ipp.py +0 -0
  60. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/protocols/kerberos.py +0 -0
  61. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/protocols/llmnr.py +0 -0
  62. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/protocols/mdns.py +0 -0
  63. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/protocols/msrpc/__init__.py +0 -0
  64. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/protocols/msrpc/dcom.py +0 -0
  65. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/protocols/msrpc/epm.py +0 -0
  66. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/protocols/msrpc.py +0 -0
  67. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/protocols/mysql.py +0 -0
  68. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/protocols/netbios.py +0 -0
  69. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/protocols/spnego.py +0 -0
  70. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/protocols/ssdp.py +0 -0
  71. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/protocols/upnp.py +0 -0
  72. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor/protocols/x11.py +0 -0
  73. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor.egg-info/SOURCES.txt +0 -0
  74. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor.egg-info/dependency_links.txt +0 -0
  75. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor.egg-info/entry_points.txt +0 -0
  76. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/dementor.egg-info/top_level.txt +0 -0
  77. {dementor-1.0.0.dev18 → dementor-1.0.0.dev19}/setup.cfg +0 -0
@@ -1,37 +1,15 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dementor
3
- Version: 1.0.0.dev18
3
+ Version: 1.0.0.dev19
4
4
  Summary: LLMNR/NBT-NS/mDNS Poisoner and rogue service provider
5
5
  Author: MatrixEditor
6
6
  Maintainer: MatrixEditor
7
- License: The MIT License (MIT)
8
-
9
- Copyright (c) 2025-present MatrixEditor
10
-
11
- Permission is hereby granted, free of charge, to any person obtaining a copy
12
- of this software and associated documentation files (the "Software"), to deal
13
- in the Software without restriction, including without limitation the rights
14
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
- copies of the Software, and to permit persons to whom the Software is
16
- furnished to do so, subject to the following conditions:
17
-
18
- The above copyright notice and this permission notice shall be included in all
19
- copies or substantial portions of the Software.
20
-
21
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
- SOFTWARE.
28
7
  Project-URL: homepage, https://matrixeditor.github.io/dementor
29
8
  Project-URL: documentation, https://matrixeditor.github.io/dementor
30
9
  Project-URL: source, https://github.com/MatrixEditor/dementor
31
10
  Classifier: Development Status :: 4 - Beta
32
11
  Classifier: Intended Audience :: Developers
33
12
  Classifier: Intended Audience :: Science/Research
34
- Classifier: License :: OSI Approved :: MIT License
35
13
  Classifier: Programming Language :: Python :: 3
36
14
  Classifier: Programming Language :: Python :: 3.13
37
15
  Classifier: Programming Language :: Python :: 3 :: Only
@@ -41,6 +19,7 @@ Classifier: Topic :: System :: Networking
41
19
  Classifier: Typing :: Typed
42
20
  Classifier: Operating System :: POSIX
43
21
  Classifier: Operating System :: Unix
22
+ Requires-Python: >=3.10
44
23
  Description-Content-Type: text/markdown
45
24
  License-File: LICENSE
46
25
  Requires-Dist: rich
@@ -52,7 +31,7 @@ Requires-Dist: pyasn1
52
31
  Requires-Dist: aioquic
53
32
  Requires-Dist: typer
54
33
  Requires-Dist: jinja2
55
- Requires-Dist: caterpillar-py
34
+ Requires-Dist: caterpillar-py>=2.8.1
56
35
  Requires-Dist: pyipp
57
36
  Dynamic: license-file
58
37
 
@@ -113,7 +92,7 @@ Let's take a look.
113
92
 
114
93
  ## You need more?
115
94
 
116
- Take a look at the [Documentation on GitHub-Pages](https://matrixeditor.github.io/dementor/)
95
+ Take a look at the [Documentation on GitHub-Pages](https://matrixeditor.github.io/dementor/) or at the [Blog Series](https://matrixeditor.github.io/posts/dementor-part-1/).
117
96
 
118
97
 
119
98
  ## License
@@ -18,5 +18,5 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
19
  # SOFTWARE.
20
20
 
21
- __version__ = "1.0.0.dev18"
21
+ __version__ = "1.0.0.dev19"
22
22
  __author__ = "MatrixEditor"
@@ -0,0 +1,22 @@
1
+ # Copyright (c) 2025-Present MatrixEditor
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
20
+ from dementor.standalone import run_from_cli
21
+
22
+ run_from_cli()
@@ -10,11 +10,16 @@
10
10
  #
11
11
  # Value Resolution:
12
12
  # -----------------
13
- # All values are resolved in the following order:
14
- # 1. Most local section (e.g. [[SMB.Server]] or [QUIC])
15
- # 2. Local (protocol) section (e.g. [SMB] or [Log])
16
- # 3. Global section ([Globals]) — used only in specific cases.
17
- # Refer to the online documentation for a complete list.
13
+ # All values are resolved in the following order (highest priority first):
14
+ # 1. Per-server entry (e.g. [[SMB.Server]], [[HTTP.Server]])
15
+ # 2. Protocol section (e.g. [SMB], [HTTP])
16
+ #
17
+ # The three NTLM settings (Challenge, DisableExtendedSessionSecurity,
18
+ # DisableNTLMv2) additionally fall back through two more levels:
19
+ # 3. [NTLM] section — shared default for all NTLM-enabled protocols
20
+ # 4. [Globals] section — last resort
21
+ #
22
+ # All other settings stop at step 2.
18
23
  #
19
24
  # Note: Some settings can only be used in the most local section (e.g. "Port").
20
25
  # These are also described in the docs.
@@ -266,6 +271,14 @@ SMB2Support = true
266
271
 
267
272
  ErrorCode = "STATUS_SMB_BAD_UID"
268
273
 
274
+ # NTLM settings: Challenge, DisableExtendedSessionSecurity, DisableNTLMv2
275
+ # Not set here → falls back to [NTLM]. Set here to override [NTLM] for all
276
+ # SMB servers, or inside [[SMB.Server]] to override for a single server only.
277
+
278
+ # Challenge = "1337LEET"
279
+ # DisableExtendedSessionSecurity = false
280
+ # DisableNTLMv2 = false
281
+
269
282
  # You can define multiple SMB server instances to listen on different ports or use
270
283
  # different configurations.
271
284
  [[SMB.Server]]
@@ -273,8 +286,14 @@ Port = 139
273
286
 
274
287
  [[SMB.Server]]
275
288
  Port = 445
276
- # e.g.
277
- # ExtendedSessionSecurity = false
289
+ # Per-server overrides (highest priority — override [SMB] and [NTLM] for this port only):
290
+ # FQDN = "other.corp.com"
291
+ # ServerOS = "Windows Server 2022"
292
+ # ErrorCode = "STATUS_ACCESS_DENIED"
293
+ # SMB2Support = true
294
+ # Challenge = "hex:aabbccddeeff0011"
295
+ # DisableExtendedSessionSecurity = false
296
+ # DisableNTLMv2 = false
278
297
 
279
298
 
280
299
  # =============================================================================
@@ -308,6 +327,14 @@ Downgrade = true
308
327
 
309
328
  RequireSTARTTLS = false
310
329
 
330
+ # NTLM settings: Challenge, DisableExtendedSessionSecurity, DisableNTLMv2
331
+ # Not set here → falls back to [NTLM]. Set here to override [NTLM] for all
332
+ # SMTP servers, or inside [[SMTP.Server]] to override for a single server only.
333
+
334
+ # Challenge = "1337LEET"
335
+ # DisableExtendedSessionSecurity = false
336
+ # DisableNTLMv2 = false
337
+
311
338
  # Example servers
312
339
  [[SMTP.Server]]
313
340
  Port = 25
@@ -324,20 +351,64 @@ Port = 25
324
351
 
325
352
 
326
353
  # =============================================================================
327
- # NTLM Configuration
354
+ # NTLM Authentication
328
355
  # =============================================================================
356
+ # This section provides shared defaults for all NTLM-enabled protocols:
357
+ # SMB, HTTP, SMTP, LDAP, RPC, MSSQL, POP3, and IMAP.
358
+ #
359
+ # Resolution order for these three settings (highest priority first):
360
+ # 1. [[Protocol.Server]] entry — per-server override (list-based protocols only:
361
+ # SMB, HTTP, SMTP, LDAP, POP3, IMAP)
362
+ # 2. [Protocol] section — per-protocol override (e.g. [SMB], [HTTP])
363
+ # 3. [NTLM] section — this section; the shared default
364
+ # 4. [Globals] section — broadest fallback
365
+ #
366
+ # If a protocol section does not define Challenge, DisableExtendedSessionSecurity,
367
+ # or DisableNTLMv2, it inherits the values set here. This lets you configure one
368
+ # shared challenge for all protocols while still being able to override it for a
369
+ # specific protocol or a single server instance within that protocol.
370
+ #
371
+
329
372
  [NTLM]
330
373
 
331
- # Server challenge value used in NTLM authentication.
332
- # Should be a fixed 8-byte string.
374
+ # The 8-byte ServerChallenge nonce placed in the NTLM CHALLENGE_MESSAGE.
375
+ # Also used verbatim when formatting captured hashes for hashcat.
376
+ #
377
+ # Accepted formats:
378
+ # "hex:1122334455667788" explicit hex (preferred, unambiguous)
379
+ # "ascii:1337LEET" explicit ASCII (preferred)
380
+ # "1122334455667788" 16 hex characters — auto-detected as hex
381
+ # "1337LEET" 8 ASCII characters — auto-detected as ASCII
382
+ # omitted / not set cryptographically random 8 bytes per run
383
+ #
384
+ # A fixed Challenge combined with DisableExtendedSessionSecurity = true makes
385
+ # NTLMv1 hashes crackable with precomputed rainbow tables.
333
386
 
334
387
  Challenge = "1337LEET"
335
388
 
336
- # Enable Extended Session Security (ESS) for NTLM authentication.
337
- # ESS results in NTLMv1/v2-SSP hashes instead of regular NTLMv1/v2 hashes.
338
-
339
- ExtendedSessionSecurity = true
389
+ # When true, the ESS flag (NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY) is
390
+ # stripped from the CHALLENGE_MESSAGE sent to the client.
391
+ #
392
+ # false (default): ESS is echoed back when the client requests it. Clients
393
+ # that support ESS produce NTLMv1-ESS hashes (hashcat mode 5500 with
394
+ # MD5-mixed challenge). This is the modern, common NTLMv1 variant.
395
+ #
396
+ # true: ESS is suppressed regardless of what the client requests. Clients
397
+ # fall back to plain NTLMv1 (DES-only). With a fixed Challenge above,
398
+ # these hashes are vulnerable to precomputed rainbow table attacks.
399
+
400
+ DisableExtendedSessionSecurity = false
401
+
402
+ # When true, TargetInfoFields are omitted from the CHALLENGE_MESSAGE.
403
+ # Without TargetInfoFields clients cannot construct the NTLMv2 Blob
404
+ # (MS-NLMP §3.3.2), which has the following effect by client security level:
405
+ # Level 0–2 (older Windows, manually downgraded): fall back to NTLMv1.
406
+ # Level 3+ (all modern Windows defaults): refuse to authenticate — zero
407
+ # hashes captured from these clients.
408
+ #
409
+ # Leave false unless specifically targeting legacy NTLMv1-only environments.
340
410
 
411
+ DisableNTLMv2 = false
341
412
 
342
413
  # =============================================================================
343
414
  # FTP Server(s)
@@ -403,6 +474,14 @@ TLS = false
403
474
 
404
475
  # ErrorCode = "unwillingToPerform"
405
476
 
477
+ # NTLM settings: Challenge, DisableExtendedSessionSecurity, DisableNTLMv2
478
+ # Not set here → falls back to [NTLM]. Set here to override [NTLM] for all
479
+ # LDAP servers, or inside [[LDAP.Server]] to override for a single server only.
480
+
481
+ # Challenge = "1337LEET"
482
+ # DisableExtendedSessionSecurity = false
483
+ # DisableNTLMv2 = false
484
+
406
485
  [[LDAP.Server]]
407
486
  Connectionless = false
408
487
  Port = 389
@@ -476,9 +555,13 @@ AuthSchemes = ["Basic", "Negotiate", "NTLM", "Bearer"]
476
555
 
477
556
  WebDAV = true
478
557
 
479
- # Challenge and ExtendedSessionSecurity are defined in the NTLM section and can
480
- # be applied here too.
558
+ # NTLM settings: Challenge, DisableExtendedSessionSecurity, DisableNTLMv2
559
+ # Not set here → falls back to [NTLM]. Set here to override [NTLM] for all
560
+ # HTTP servers, or inside [[HTTP.Server]] to override for a single server only.
481
561
 
562
+ # Challenge = "1337LEET"
563
+ # DisableExtendedSessionSecurity = false
564
+ # DisableNTLMv2 = false
482
565
 
483
566
  # Indicates whether WPAD/PAC file serving is enabled. This setting is enabled by
484
567
  # default.Refer to the [Proxy] section for configuring the WPAD script source.
@@ -524,9 +607,13 @@ Port = 80
524
607
  # =============================================================================
525
608
  [RPC]
526
609
 
527
- # Similar to HTTP, SMTP, and SMB services, the RPC service also utilizes
528
- # the FQDN, Challenge, and ExtendedSessionSecurity settings defined in the
529
- # [NTLM] section.
610
+ # NTLM settings: Challenge, DisableExtendedSessionSecurity, DisableNTLMv2
611
+ # Not set here → falls back to [NTLM]. RPC uses a single server instance so
612
+ # there is no per-server item level; only [RPC] or [NTLM] apply.
613
+
614
+ # Challenge = "1337LEET"
615
+ # DisableExtendedSessionSecurity = false
616
+ # DisableNTLMv2 = false
530
617
 
531
618
  # Specifies the RPC error code to be returned upon successful authentication.
532
619
 
@@ -568,10 +655,13 @@ TargetPort = 49000
568
655
  # =============================================================================
569
656
  [MSSQL]
570
657
 
571
- # The following NTLM-related settings can be inherited from the [NTLM] section:
572
- # - FQDN
573
- # - Challenge
574
- # - ExtendedSessionSecurity
658
+ # NTLM settings: Challenge, DisableExtendedSessionSecurity, DisableNTLMv2
659
+ # Not set here → falls back to [NTLM]. MSSQL uses a single server instance so
660
+ # there is no per-server item level; only [MSSQL] or [NTLM] apply.
661
+
662
+ # Challenge = "1337LEET"
663
+ # DisableExtendedSessionSecurity = false
664
+ # DisableNTLMv2 = false
575
665
 
576
666
  # Defines the error response configuration used to simulate MSSQL authentication
577
667
  # failure or control behavior.
@@ -628,10 +718,13 @@ InstanceName = "MSSQLServer"
628
718
  # =============================================================================
629
719
  [POP3]
630
720
 
631
- # The following NTLM-related settings can be inherited from the [NTLM] section:
632
- # - FQDN (global)
633
- # - Challenge
634
- # - ExtendedSessionSecurity
721
+ # NTLM settings: Challenge, DisableExtendedSessionSecurity, DisableNTLMv2
722
+ # Not set here → falls back to [NTLM]. Set here to override [NTLM] for all
723
+ # POP3 servers, or inside [[POP3.Server]] to override for a single server only.
724
+
725
+ # Challenge = "1337LEET"
726
+ # DisableExtendedSessionSecurity = false
727
+ # DisableNTLMv2 = false
635
728
 
636
729
  # TLS configuration is also available and will be applied if TLS is set to true.
637
730
  # Therefore, it is recommended to use the TLS setting only within a server block.
@@ -670,10 +763,13 @@ Port = 110
670
763
  # =============================================================================
671
764
  [IMAP]
672
765
 
673
- # The following NTLM-related settings can be inherited from the [NTLM] section:
674
- # - FQDN (global)
675
- # - Challenge
676
- # - ExtendedSessionSecurity
766
+ # NTLM settings: Challenge, DisableExtendedSessionSecurity, DisableNTLMv2
767
+ # Not set here → falls back to [NTLM]. Set here to override [NTLM] for all
768
+ # IMAP servers, or inside [[IMAP.Server]] to override for a single server only.
769
+
770
+ # Challenge = "1337LEET"
771
+ # DisableExtendedSessionSecurity = false
772
+ # DisableNTLMv2 = false
677
773
 
678
774
  # TLS configuration is also available and will be applied if TLS is set to true.
679
775
  # Therefore, it is recommended to use the TLS setting only within a server block.
@@ -0,0 +1,89 @@
1
+ # Copyright (c) 2025-Present MatrixEditor
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
20
+ # pyright: reportAny=false, reportExplicitAny=false
21
+ import sys
22
+ import pathlib
23
+ import tomllib
24
+
25
+ from typing import Any
26
+
27
+ from dementor.paths import CONFIG_PATH, DEFAULT_CONFIG_PATH
28
+
29
+ # --------------------------------------------------------------------------- #
30
+ # Global configuration storage
31
+ # --------------------------------------------------------------------------- #
32
+ dm_config: dict[str, Any]
33
+
34
+
35
+ def get_global_config() -> dict[str, Any]:
36
+ """Return the current global configuration dictionary.
37
+
38
+ :return: The configuration mapping, empty if ``init_from_file`` has not
39
+ been called yet.
40
+ :rtype: dict
41
+ """
42
+ return getattr(sys.modules[__name__], "dm_config", {})
43
+
44
+
45
+ def _set_global_config(config: dict[str, Any]) -> None:
46
+ """Replace the current global configuration with *config*.
47
+
48
+ The helper mirrors :func:`get_global_config` and writes the value back to
49
+ the module namespace.
50
+
51
+ :param config: New configuration dictionary.
52
+ :type config: dict
53
+ """
54
+ setattr(sys.modules[__name__], "dm_config", config)
55
+
56
+
57
+ def init_from_file(path: str) -> None:
58
+ """Load a TOML configuration file and merge it into the global config.
59
+
60
+ The function follows a *replace-then-overwrite* strategy: the file at
61
+ *path* is parsed with :mod:`tomllib`. If the file exists and can be
62
+ read, its content completely replaces the previous ``dm_config`` value.
63
+ The caller is responsible for ordering calls to obtain the desired
64
+ precedence.
65
+
66
+ If the file does not exist or is not a regular file the function returns
67
+ silently.
68
+
69
+ :param path: Filesystem path to a TOML file.
70
+ :type path: str
71
+ :raises tomllib.TOMLDecodeError: Propagated if the file exists but contains
72
+ invalid TOML.
73
+ """
74
+ target = pathlib.Path(path)
75
+ if not target.exists() or not target.is_file():
76
+ return
77
+
78
+ # By default we completely replace the existing configuration.
79
+ with target.open("rb") as f:
80
+ new_config = tomllib.load(f)
81
+ _set_global_config(new_config)
82
+
83
+
84
+ # --------------------------------------------------------------------------- #
85
+ # Default initialisation - performed on import so that the rest of the
86
+ # package can rely on ``dementor.config.dm_config`` being available.
87
+ # --------------------------------------------------------------------------- #
88
+ init_from_file(DEFAULT_CONFIG_PATH) # 1. bundled defaults
89
+ init_from_file(CONFIG_PATH) # 2. user-provided overrides
@@ -21,7 +21,7 @@
21
21
  import asyncio
22
22
  import typing
23
23
 
24
- from typing import Any
24
+ from typing import Any, override
25
25
  from pathlib import Path
26
26
 
27
27
  from dementor.config.toml import TomlConfig, Attribute
@@ -123,8 +123,9 @@ class SessionConfig(TomlConfig):
123
123
  upnp_config: upnp.UPNPConfig
124
124
  x11_config: x11.X11Config
125
125
 
126
- ntlm_challange: bytes
127
- ntlm_ess: bool
126
+ ntlm_challenge: bytes
127
+ ntlm_disable_ess: bool
128
+ ntlm_disable_ntlmv2: bool
128
129
  analysis: bool
129
130
  loop: asyncio.AbstractEventLoop
130
131
 
@@ -152,21 +153,21 @@ class SessionConfig(TomlConfig):
152
153
  upnp_enabled: bool
153
154
 
154
155
  def __init__(self) -> None:
155
- super().__init__(config._get_global_config().get("Dementor", {}))
156
+ super().__init__(config.get_global_config().get("Dementor", {}))
156
157
  # global options that are not loaded from configuration
157
158
  self.ipv6 = None
158
159
  self.ipv4 = None
159
160
  self.interface = None
160
161
  self.analysis = False
161
- self.loop = asyncio.get_event_loop()
162
+ self.loop = asyncio.new_event_loop()
162
163
  self.protocols = {}
163
164
 
164
165
  # SMTP configuration
165
166
  self.smtp_servers = []
166
167
 
167
168
  # NTLM configuration
168
- self.ntlm_challange = b"1337LEET"
169
- self.ntlm_ess = True
169
+ self.ntlm_disable_ess = False
170
+ self.ntlm_disable_ntlmv2 = False
170
171
 
171
172
  def is_bound_to_all(self) -> bool:
172
173
  # REVISIT: this should raise an exception
@@ -188,3 +189,17 @@ class SessionConfig(TomlConfig):
188
189
  return Path(raw_path).resolve()
189
190
 
190
191
  return (Path(self.workspace_path) / raw_path).resolve()
192
+
193
+ @override
194
+ def __getitem__(self, key: str) -> Any:
195
+ section, *parts = key.split(".")
196
+ attr = f"{section.lower()}_config"
197
+ if not hasattr(self, attr):
198
+ raise KeyError(f"unknown protocol: {attr}")
199
+
200
+ config: TomlConfig = getattr(self, attr)
201
+ if not parts:
202
+ return config
203
+
204
+ return config[".".join(parts)]
205
+