dementor 1.0.0.dev15__tar.gz → 1.0.0.dev17__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 (64) hide show
  1. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/PKG-INFO +16 -11
  2. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/README.md +16 -10
  3. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/__init__.py +1 -1
  4. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/assets/Dementor.toml +11 -2
  5. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/filters.py +1 -1
  6. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/loader.py +0 -3
  7. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/log/logger.py +25 -4
  8. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/paths.py +5 -1
  9. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/protocols/ldap.py +1 -1
  10. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/protocols/mdns.py +12 -7
  11. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/protocols/mysql.py +49 -44
  12. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/protocols/netbios.py +9 -3
  13. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/protocols/smb.py +177 -18
  14. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/standalone.py +43 -3
  15. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor.egg-info/PKG-INFO +16 -11
  16. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/docs/README.pypi.md +15 -10
  17. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/pyproject.toml +1 -1
  18. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/LICENSE +0 -0
  19. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/__main__.py +0 -0
  20. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/assets/banner.txt +0 -0
  21. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/assets/www/error_page.html +0 -0
  22. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/assets/www/upnp-default/dd.xml +0 -0
  23. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/assets/www/upnp-default/present.html +0 -0
  24. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/assets/www/upnp-default/scpd.xml +0 -0
  25. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/assets/www/wpad.dat +0 -0
  26. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/config/__init__.py +0 -0
  27. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/config/attr.py +0 -0
  28. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/config/session.py +0 -0
  29. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/config/toml.py +0 -0
  30. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/config/util.py +0 -0
  31. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/db/__init__.py +0 -0
  32. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/db/connector.py +0 -0
  33. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/db/model.py +0 -0
  34. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/log/__init__.py +0 -0
  35. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/log/hexdump.py +0 -0
  36. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/log/stream.py +0 -0
  37. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/protocols/__init__.py +0 -0
  38. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/protocols/ftp.py +0 -0
  39. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/protocols/http.py +0 -0
  40. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/protocols/imap.py +0 -0
  41. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/protocols/ipp.py +0 -0
  42. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/protocols/kerberos.py +0 -0
  43. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/protocols/llmnr.py +0 -0
  44. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/protocols/msrpc/__init__.py +0 -0
  45. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/protocols/msrpc/dcom.py +0 -0
  46. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/protocols/msrpc/epm.py +0 -0
  47. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/protocols/msrpc/rpc.py +0 -0
  48. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/protocols/msrpc.py +0 -0
  49. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/protocols/mssql.py +0 -0
  50. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/protocols/ntlm.py +0 -0
  51. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/protocols/pop3.py +0 -0
  52. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/protocols/quic.py +0 -0
  53. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/protocols/smtp.py +0 -0
  54. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/protocols/spnego.py +0 -0
  55. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/protocols/ssdp.py +0 -0
  56. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/protocols/upnp.py +0 -0
  57. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/protocols/x11.py +0 -0
  58. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor/servers.py +0 -0
  59. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor.egg-info/SOURCES.txt +0 -0
  60. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor.egg-info/dependency_links.txt +0 -0
  61. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor.egg-info/entry_points.txt +0 -0
  62. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor.egg-info/requires.txt +0 -0
  63. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/dementor.egg-info/top_level.txt +0 -0
  64. {dementor-1.0.0.dev15 → dementor-1.0.0.dev17}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dementor
3
- Version: 1.0.0.dev15
3
+ Version: 1.0.0.dev17
4
4
  Summary: LLMNR/NBT-NS/mDNS Poisoner and rogue service provider
5
5
  Author: MatrixEditor
6
6
  Maintainer: MatrixEditor
@@ -71,7 +71,7 @@ on the [Documentation](https://matrixeditor.github.io/dementor/) page.
71
71
 
72
72
  ## Installation
73
73
 
74
- Installation via `pip` from GitHub or PyPI:
74
+ Installation via `pip`/`pipx` from GitHub or PyPI:
75
75
 
76
76
  ```bash
77
77
  pip install dementor
@@ -95,15 +95,20 @@ Let's take a look.
95
95
  ```
96
96
  Usage: Dementor [OPTIONS]
97
97
 
98
- ╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────╮
99
- │ * --interface -I NAME Network interface to use (required for poisoning) [required] │
100
- │ --analyze -A Only analyze traffic, don't respond to requests │
101
- │ --config -c PATH Path to a configuration file (otherwise standard path is used) │
102
- │ --option -O KEY=VALUE Add an extra option to the global configuration file. │
103
- │ --yes -y Do not ask before starting attack mode. │
104
- │ --quiet -q Don't print banner at startup │
105
- │ --help Show this message and exit. │
106
- ╰──────────────────────────────────────────────────────────────────────────────────────────────────────╯
98
+ ╭─ Options ────────────────────────────────────────────────────────────────────────────────────────╮
99
+ │ --interface -I NAME Network interface to use (required for poisoning) │
100
+ │ --analyze -A Only analyze traffic, don't respond to requests │
101
+ │ --config -c PATH Path to a configuration file (otherwise standard path is used) │
102
+ │ --option -O KEY=VALUE Add an extra option to the global configuration file. │
103
+ │ --yes,--yolo -y Do not ask before starting attack mode. │
104
+ │ --target -t NAME[,...] Target host(s) to attack │
105
+ │ --ignore -i NAME[,...] Target host(s) to ignore │
106
+ │ --quiet -q Don't print banner at startup │
107
+ │ --version Show Dementor's version number │
108
+ │ --ts Log timestamps to terminal output too │
109
+ │ --paths Displays the default configuration paths │
110
+ │ --help Show this message and exit. │
111
+ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
107
112
  ```
108
113
 
109
114
  ## You need more?
@@ -13,7 +13,7 @@ on the [Documentation](https://matrixeditor.github.io/dementor/) page.
13
13
 
14
14
  ## Installation
15
15
 
16
- Installation via `pip` from GitHub or PyPI:
16
+ Installation via `pip`/`pipx` from GitHub or PyPI:
17
17
 
18
18
  ```bash
19
19
  pip install dementor
@@ -38,20 +38,26 @@ Let's take a look.
38
38
  ```
39
39
  Usage: Dementor [OPTIONS]
40
40
 
41
- ╭─ Options ──────────────────────────────────────────────────────────────────────────────────────────╮
42
- │ * --interface -I NAME Network interface to use (required for poisoning) [required] │
43
- │ --analyze -A Only analyze traffic, don't respond to requests │
44
- │ --config -c PATH Path to a configuration file (otherwise standard path is used) │
45
- │ --option -O KEY=VALUE Add an extra option to the global configuration file. │
46
- │ --quiet -q Don't print banner at startup │
47
- │ --help Show this message and exit. │
48
- ╰────────────────────────────────────────────────────────────────────────────────────────────────────╯
41
+ ╭─ Options ────────────────────────────────────────────────────────────────────────────────────────╮
42
+ │ --interface -I NAME Network interface to use (required for poisoning) │
43
+ │ --analyze -A Only analyze traffic, don't respond to requests │
44
+ │ --config -c PATH Path to a configuration file (otherwise standard path is used) │
45
+ │ --option -O KEY=VALUE Add an extra option to the global configuration file. │
46
+ │ --yes,--yolo -y Do not ask before starting attack mode. │
47
+ │ --target -t NAME[,...] Target host(s) to attack │
48
+ │ --ignore -i NAME[,...] Target host(s) to ignore │
49
+ │ --quiet -q Don't print banner at startup │
50
+ │ --version Show Dementor's version number │
51
+ │ --ts Log timestamps to terminal output too │
52
+ │ --paths Displays the default configuration paths │
53
+ │ --help Show this message and exit. │
54
+ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
49
55
  ```
50
56
 
51
57
 
52
58
  ## You need more?
53
59
 
54
- Take a look at the [Documentation on GitHub-Pages](https://matrixeditor.github.io/dementor/)
60
+ 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/).
55
61
 
56
62
 
57
63
  ## 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.dev15"
21
+ __version__ = "1.0.0.dev17"
22
22
  __author__ = "MatrixEditor"
@@ -615,7 +615,7 @@ InstanceName = "MSSQLServer"
615
615
 
616
616
  # The following values can be defined here or inherited from the [Globals] section:
617
617
  # - Ignore
618
- # - AnswerTo
618
+ # - Targets
619
619
 
620
620
  # Specifies the instance-specific response used for SSRP (SQL Server Resolution Protocol).
621
621
  # This can be used to emulate specific server instance behaviors or service identifiers.
@@ -896,6 +896,16 @@ DebugLoggers = [
896
896
  "pyipp.parser",
897
897
  ]
898
898
 
899
+ # Enables/Disables logging timestamps for default terminal output. By default, no
900
+ # timestamps are printed.
901
+
902
+ # Timestamps = false
903
+
904
+ # Defines the timestamp format for terminal output. Only applies if timestamps are
905
+ # enabled.
906
+
907
+ # TimestampFmt = "%H:%M:%S"
908
+
899
909
 
900
910
  [Log.Stream.Hosts]
901
911
 
@@ -933,4 +943,3 @@ DebugLoggers = [
933
943
 
934
944
  # FilePrefix = "{{ hash_type }}-capture"
935
945
  # FileSuffix = ".txt"
936
-
@@ -90,7 +90,7 @@ ATTR_BLACKLIST = Attribute(
90
90
 
91
91
  ATTR_WHITELIST = Attribute(
92
92
  "targets",
93
- "Target",
93
+ "Targets",
94
94
  default_val=None,
95
95
  section_local=False,
96
96
  factory=_optional_filter,
@@ -17,9 +17,6 @@
17
17
  # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
19
  # SOFTWARE.
20
- from typing import Any
21
-
22
-
23
20
  import threading
24
21
  import types
25
22
  import os
@@ -40,6 +40,8 @@ from dementor.config.session import SessionConfig
40
40
  from dementor.config.toml import TomlConfig, Attribute as A
41
41
  from dementor.log import dm_print, dm_console
42
42
 
43
+ LOG_DEFAULT_TIMEFMT = "%H:%M:%S"
44
+
43
45
 
44
46
  class LoggingConfig(TomlConfig):
45
47
  _section_ = "Log"
@@ -47,14 +49,16 @@ class LoggingConfig(TomlConfig):
47
49
  A("log_debug_loggers", "DebugLoggers", list),
48
50
  A("log_dir", "LogDir", "logs"),
49
51
  A("log_enable", "Enabled", True),
50
- A("log_capture_hosts", "CaptureHostsTo", None),
52
+ A("log_timestamps", "Timestamps", False),
53
+ A("log_timestamp_fmt", "TimestampFmt", LOG_DEFAULT_TIMEFMT),
51
54
  ]
52
55
 
53
56
  if typing.TYPE_CHECKING:
54
57
  log_debug_loggers: list[str]
55
58
  log_dir: str
56
59
  log_enable: bool
57
- log_capture_hosts: list[str]
60
+ log_timestamps: bool
61
+ log_timestamp_fmt: str
58
62
 
59
63
 
60
64
  def init():
@@ -106,6 +110,13 @@ def init():
106
110
  class ProtocolLogger(logging.LoggerAdapter):
107
111
  def __init__(self, extra=None) -> None:
108
112
  super().__init__(logging.getLogger("dementor"), extra or {})
113
+ self._log_config = None
114
+
115
+ @property
116
+ def log_config(self) -> LoggingConfig:
117
+ if not self._log_config:
118
+ self._log_config = TomlConfig.build_config(LoggingConfig)
119
+ return self._log_config
109
120
 
110
121
  def _get_extra(self, name: str, extra=None, default=None):
111
122
  value = (self.extra or {}).get(name, default)
@@ -126,15 +137,25 @@ class ProtocolLogger(logging.LoggerAdapter):
126
137
  def format(
127
138
  self, msg: str, *args: typing.Any, **kwargs: typing.Any
128
139
  ) -> tuple[str, dict[str, Any]]:
140
+ ts_prefix = ""
141
+ if self.log_config.log_timestamps:
142
+ ts_prefix = r"\["
143
+ time_now = datetime.datetime.now()
144
+ try:
145
+ ts_prefix = f"{ts_prefix}{time_now.strftime(self.log_config.log_timestamp_fmt)}] "
146
+ except Exception as e:
147
+ # TODO: log that exception
148
+ ts_prefix = f"{ts_prefix}{time_now.strftime(LOG_DEFAULT_TIMEFMT)}] "
149
+
129
150
  if self.extra is None:
130
- return f"{msg}", kwargs
151
+ return f"{ts_prefix}{msg}", kwargs
131
152
 
132
153
  mod = self.get_protocol_name(kwargs)
133
154
  host = self.get_host(kwargs) or "<no-host>"
134
155
  port = self.get_port(kwargs) or "<no-port>"
135
156
  color = self.get_protocol_color(kwargs)
136
157
  return (
137
- f"[bold {color}]{mod:<10}[/] {host:<25} {port:<6} {msg}",
158
+ f"{ts_prefix}[bold {color}]{mod:<10}[/] {host:<25} {port:<6} {msg}",
138
159
  kwargs,
139
160
  )
140
161
 
@@ -28,10 +28,14 @@ BANNER_PATH = os.path.join(ASSETS_PATH, "banner.txt")
28
28
  HTTP_TEMPLATES_PATH = os.path.join(ASSETS_PATH, "www")
29
29
 
30
30
 
31
- if __name__ == "__main__":
31
+ def main() -> None:
32
32
  print(f"DefaultWorkspace : {DEMENTOR_PATH}")
33
33
  print(f"AssetsPath : {ASSETS_PATH}")
34
34
  print(f"ConfigPath : {CONFIG_PATH} (for root: /root/.dementor)")
35
35
  print(f"BannerPath : {BANNER_PATH}")
36
36
  print(f"DefaultConfigPath : {DEFAULT_CONFIG_PATH}")
37
37
  print(f"HTTPTemplatesPath : {HTTP_TEMPLATES_PATH}")
38
+
39
+
40
+ if __name__ == "__main__":
41
+ main()
@@ -363,7 +363,7 @@ class LDAPHandler(BaseProtoHandler):
363
363
  except Exception as e:
364
364
  self.logger.fail("Received invalid LDAP - terminating connection...")
365
365
  self.logger.debug(
366
- f"Invalid LDAP packet: {str(e.__class__)}\n{hexdump.hexdump(data)}"
366
+ f"Invalid LDAP packet: {str(e.__class__)}\n{hexdump.hexdump(data) if data else '<no-data>'}"
367
367
  )
368
368
  return
369
369
 
@@ -39,12 +39,14 @@ from dementor.config.session import SessionConfig
39
39
  if typing.TYPE_CHECKING:
40
40
  from dementor.filters import Filters
41
41
 
42
+ # --- Constants ---------------------------------------------------------------
42
43
  MDNS_IPV4_ADDR = "224.0.0.251"
43
44
  MDNS_IPV6_ADDR = "ff02::fb"
44
45
 
45
46
  QTYPES = {name: value for value, name in dns.dnsqtypes.items()}
46
47
 
47
48
 
49
+ # --- Configuration -----------------------------------------------------------
48
50
  def apply_config(session: SessionConfig) -> None:
49
51
  session.mdns_config = TomlConfig.build_config(MDNSConfig)
50
52
 
@@ -56,13 +58,6 @@ def create_server_threads(session: SessionConfig) -> list[ServerThread]:
56
58
  return [ServerThread(session, MDNSServer)]
57
59
 
58
60
 
59
- def normalized_name(host: str | bytes) -> str:
60
- if isinstance(host, (bytes, bytearray)):
61
- host = host.decode("utf-8", errors="replace")
62
-
63
- return str(host).strip().removesuffix(".").removesuffix(".local")
64
-
65
-
66
61
  class MDNSConfig(TomlConfig):
67
62
  _section_ = "mDNS"
68
63
  _fields_ = [
@@ -85,6 +80,14 @@ class MDNSConfig(TomlConfig):
85
80
  self.mdns_qtypes = [x if isinstance(x, int) else QTYPES[x] for x in value]
86
81
 
87
82
 
83
+ # --- Utilities -----------------------------------------------------------
84
+ def normalized_name(host: str | bytes) -> str:
85
+ if isinstance(host, (bytes, bytearray)):
86
+ host = host.decode("utf-8", errors="replace")
87
+
88
+ return str(host).strip().removesuffix(".").removesuffix(".local")
89
+
90
+
88
91
  # MDNS / LLMNR Answer Packet
89
92
  def build_dns_answer(req_id: int, question: dns.DNSQR, config: SessionConfig):
90
93
  answer = dns.DNSRR(
@@ -112,6 +115,7 @@ def build_dns_answer(req_id: int, question: dns.DNSQR, config: SessionConfig):
112
115
  )
113
116
 
114
117
 
118
+ # --- Poisoner/Server ---------------------------------------------------------
115
119
  class MDNSPoisoner(BaseProtoHandler):
116
120
  def proto_logger(self):
117
121
  return ProtocolLogger(
@@ -150,6 +154,7 @@ class MDNSPoisoner(BaseProtoHandler):
150
154
  if "._tcp" not in normalized_qname and "._udp" not in normalized_qname:
151
155
  if not normalized_qname.endswith(".arpa"):
152
156
  log_to("dns", type="MDNS", name=normalized_qname)
157
+
153
158
  name = markup.escape(normalized_qname)
154
159
  self.logger.display(
155
160
  f"Request for [i]{name}[/i] (class: {qclass}, type: {qtype})"
@@ -17,12 +17,11 @@
17
17
  # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
19
  # SOFTWARE.
20
- # pyright: reportInvalidTypeForm=false, reportCallIssue=false
20
+ # pyright: basic
21
21
  #
22
22
  # Notes:
23
23
  # - Implementation of the MySQL protocol according to the online documentation.
24
24
  # https://dev.mysql.com/doc/dev/mysql-server/latest/PAGE_PROTOCOL.html
25
- # pyright: reportUninitializedInstanceVariable=false
26
25
  import typing
27
26
  import enum
28
27
 
@@ -32,10 +31,13 @@ from collections import OrderedDict
32
31
  from caterpillar.py import (
33
32
  CString,
34
33
  Const,
34
+ Invisible,
35
35
  Prefixed,
36
36
  String,
37
+ f,
37
38
  pack,
38
39
  struct,
40
+ struct_factory,
39
41
  this,
40
42
  uint24,
41
43
  uint8,
@@ -48,6 +50,7 @@ from caterpillar.py import (
48
50
  unpack,
49
51
  )
50
52
  from caterpillar.exception import DynamicSizeError, StructException
53
+ from caterpillar.types import cstr_t, uint16_t, uint24_t, uint32_t, uint8_t
51
54
 
52
55
  from dementor.config.session import SessionConfig
53
56
  from dementor.log.hexdump import hexdump
@@ -176,7 +179,7 @@ class LengthEncodedInteger:
176
179
  def __size__(self, context):
177
180
  raise DynamicSizeError("LengthEncodedInteger is dynamic")
178
181
 
179
- def __unpack__(self, context):
182
+ def __unpack__(self, context) -> int:
180
183
  (size,) = context._io.read(1)
181
184
  if 0 <= size < 251:
182
185
  return size
@@ -194,14 +197,14 @@ class LengthEncodedInteger:
194
197
  case _:
195
198
  raise StructException("invalid length-encoded integer")
196
199
 
197
- def __pack__(self, value: int, context):
200
+ def __pack__(self, obj: int, context):
198
201
  prefix = None
199
- if value < 251:
202
+ if obj < 251:
200
203
  target = uint8
201
- elif value < 0x10000:
204
+ elif obj < 0x10000:
202
205
  prefix = b"\xfc"
203
206
  target = uint16
204
- elif value < 0x1000000:
207
+ elif obj < 0x1000000:
205
208
  prefix = b"\xfd"
206
209
  target = uint24
207
210
  else:
@@ -211,7 +214,7 @@ class LengthEncodedInteger:
211
214
  if prefix:
212
215
  context._io.write(prefix)
213
216
 
214
- target.pack_single(value, context)
217
+ target.pack_single(obj, context)
215
218
 
216
219
 
217
220
  # [Protocol::Packet]
@@ -219,23 +222,23 @@ class LengthEncodedInteger:
219
222
  class Packet:
220
223
  # Length of the payload. The number of bytes in the packet beyond the
221
224
  # initial 4 bytes that make up the packet header.
222
- payload_length: uint24
225
+ payload_length: uint24_t
223
226
 
224
227
  # The sequence-id is incremented with each packet and may wrap around.
225
228
  # It starts at 0 and is reset to 0 when a new command begins in the
226
229
  # Command Phase.
227
- sequence_id: uint8
230
+ sequence_id: uint8_t
228
231
 
229
232
  # payload of the packet
230
- payload: Bytes(this.payload_length)
233
+ payload: f[bytes, Bytes(this.payload_length)]
231
234
 
232
235
 
233
236
  # [ERR_Packet]
234
237
  @struct(order=LittleEndian)
235
238
  class ERR_Packet:
236
- header: Const(0xFF, uint8)
237
- error_code: uint16
238
- error_message: String(...)
239
+ header: f[int, Const(0xFF, uint8)] = Invisible()
240
+ error_code: uint16_t
241
+ error_message: f[str, String(...)]
239
242
 
240
243
 
241
244
  def _auth_plugin_length(context):
@@ -252,40 +255,40 @@ def _has_auth_plugin_data(context):
252
255
 
253
256
 
254
257
  # [Protocol::HandshakeV10]
255
- @struct(order=LittleEndian)
258
+ @struct(order=LittleEndian, kw_only=True)
256
259
  class HandshakeV10:
257
- protocol_version: Const(10, uint8)
258
- server_version: CString()
260
+ protocol_version: f[int, Const(10, uint8)] = Invisible()
261
+ server_version: cstr_t
259
262
 
260
263
  # a.k.a. connection id
261
- thread_id: uint32 = 0
264
+ thread_id: uint32_t = 0
262
265
 
263
266
  # first 8 bytes of the plugin provided data (scramble)
264
- salt: Bytes(8)
267
+ salt: f[bytes, Bytes(8)]
265
268
 
266
269
  # 0x00 byte, terminating the first part of a scramble
267
- filler: Const(0x00, uint8)
270
+ filler: f[int, Const(0x00, uint8)] = Invisible()
268
271
 
269
272
  # Why does it have to be that complicated?
270
273
  # The lower 2 bytes of the Capabilities Flags
271
- flags_lower: uint16 = 0x000
274
+ flags_lower: uint16_t = 0x000
272
275
 
273
276
  # default server a_protocol_character_set, only the lower 8-bits
274
- character_set: uint8 = 0x3F
277
+ character_set: uint8_t = 0x3F
275
278
  status_flags: SERVER_STATUS_flags_enum = 0x00
276
- flags_upper: uint16 = 0x000
279
+ flags_upper: uint16_t = 0x000
277
280
 
278
281
  # length of the combined auth_plugin_data (scramble), if
279
282
  # auth_plugin_data_len is > 0
280
- auth_plugin_data_len: uint8 = 0x00
281
- reserved: Bytes(10) = b"\0" * 10
283
+ auth_plugin_data_len: uint8_t = 0x00
284
+ reserved: f[bytes, Bytes(10)] = b"\0" * 10
282
285
 
283
286
  # Rest of the plugin provided data (scramble), $len=MAX(13, length of
284
287
  # auth-plugin-data - 8)
285
- salt2: Bytes(_auth_plugin_length)
288
+ salt2: f[bytes, Bytes(_auth_plugin_length)]
286
289
 
287
290
  # name of the auth_method that the auth_plugin_data belongs to
288
- auth_plugin_name: CString() // _has_auth_plugin_data
291
+ auth_plugin_name: f[str | None, CString() // _has_auth_plugin_data]
289
292
 
290
293
  def set_flags(self, flags):
291
294
  self.flags_lower = flags & 0xFFFF
@@ -310,41 +313,41 @@ def _client_connect_attrs(context):
310
313
  # [Protocol::SSLRequest]
311
314
  @struct(order=LittleEndian)
312
315
  class SSLRequest:
313
- capabilities: uint32
314
- max_packet_size: uint32
315
- character_set: uint8
316
+ capabilities: uint32_t
317
+ max_packet_size: uint32_t
318
+ character_set: uint8_t
316
319
  # everything else is not used
317
320
 
318
321
 
319
322
  @struct(order=LittleEndian)
320
- class ConnectionAttribute:
323
+ class ConnectionAttribute(struct_factory.mixin):
321
324
  # will be stored as bytes rather than string
322
- key: Prefixed(LengthEncodedInteger)
323
- value: Prefixed(LengthEncodedInteger)
325
+ key: f[bytes, Prefixed(LengthEncodedInteger)]
326
+ value: f[bytes, Prefixed(LengthEncodedInteger)]
324
327
 
325
328
 
326
329
  # [Protocol::HandshakeResponse]
327
- @struct(order=LittleEndian)
330
+ @struct(order=LittleEndian, kw_only=True)
328
331
  class HandshakeResponse:
329
- client_flags: uint32
330
- max_packet_size: uint32
331
- charset: uint8
332
+ client_flags: uint32_t
333
+ max_packet_size: uint32_t
334
+ charset: uint8_t
332
335
 
333
336
  # filler to the size of the handhshake response packet. All 0s.
334
- filler: Bytes(23) = b"\0" * 23
337
+ filler: f[bytes, Bytes(23)] = b"\0" * 23
335
338
 
336
339
  # login user name
337
- username: CString()
340
+ username: cstr_t
338
341
 
339
342
  # opaque authentication response data generated by Authentication Method
340
343
  # indicated by the plugin name field.
341
344
  # NOTE: we always assume a length encoded integer
342
- auth_response: Prefixed(LengthEncodedInteger)
345
+ auth_response: f[bytes, Prefixed(LengthEncodedInteger)]
343
346
 
344
347
  # initial database for the connection. This string should be interpreted
345
348
  # using the character set indicated by character set field.
346
- database: CString() // _client_connect_db
347
- client_plugin_name: CString() // _client_auth_plugin
349
+ database: f[str | None, CString() // _client_connect_db]
350
+ client_plugin_name: f[str | None, CString() // _client_auth_plugin]
348
351
 
349
352
  # From the docs:
350
353
  # if capabilities & CLIENT_CONNECT_ATTRS {
@@ -353,9 +356,11 @@ class HandshakeResponse:
353
356
  # string<lenenc> Value of the 1st client attribute
354
357
  # .. (if more data in length of all key-values, more keys and values parts)
355
358
  # }
356
- conn_attrs: (
359
+ conn_attrs: f[
360
+ list[ConnectionAttribute] | None,
357
361
  Prefixed(LengthEncodedInteger, ConnectionAttribute[...])
358
- ) // _client_connect_attrs
362
+ // _client_connect_attrs,
363
+ ]
359
364
  # zstd_compression_level is dropped here
360
365
 
361
366
 
@@ -28,9 +28,11 @@ from dementor.servers import BaseProtoHandler, ServerThread, ThreadingUDPServer
28
28
  from dementor.log.logger import ProtocolLogger
29
29
  from dementor.config.session import SessionConfig, TomlConfig
30
30
  from dementor.filters import ATTR_BLACKLIST, ATTR_WHITELIST, in_scope
31
+
31
32
  if typing.TYPE_CHECKING:
32
33
  from dementor.filters import Filters
33
34
 
35
+
34
36
  class NBTNSConfig(TomlConfig):
35
37
  _section_ = "NetBIOS"
36
38
  _fields_ = [ATTR_WHITELIST, ATTR_BLACKLIST]
@@ -213,10 +215,14 @@ class NetBiosDSPoisoner(BaseProtoHandler):
213
215
 
214
216
  def handle_data(self, data: bytes, transport) -> None:
215
217
  # we're just her to inspect packets, no poisoning
216
- datagram = netbios.NBTDatagram(data)
218
+ try:
219
+ datagram = netbios.NBTDatagram(data)
217
220
 
218
- if not datagram.haslayer(smb.SMB_Header):
219
- # probably something else, ignore that
221
+ if not datagram.haslayer(smb.SMB_Header):
222
+ # probably something else, ignore that
223
+ return
224
+ except Exception:
225
+ self.logger.fail(f"Invalid NBTDatagram - discarding data...")
220
226
  return
221
227
 
222
228
  source_name = datagram.SourceName.decode("utf-8", errors="replace")
@@ -17,7 +17,7 @@
17
17
  # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
19
  # SOFTWARE.
20
- # pyright: reportUninitializedInstanceVariable=false
20
+ # pyright: basic
21
21
  import uuid
22
22
  import calendar
23
23
  import time
@@ -36,6 +36,15 @@ from impacket import (
36
36
  spnego,
37
37
  smbserver,
38
38
  )
39
+ from caterpillar.py import (
40
+ LittleEndian,
41
+ f,
42
+ struct,
43
+ struct_factory,
44
+ this,
45
+ uint16,
46
+ )
47
+ from caterpillar.types import uint16_t
39
48
 
40
49
  from dementor.config.toml import TomlConfig, Attribute as A
41
50
  from dementor.config.session import SessionConfig
@@ -55,7 +64,7 @@ from dementor.protocols.spnego import (
55
64
  )
56
65
  from dementor.servers import BaseProtoHandler, ThreadingTCPServer, ServerThread
57
66
 
58
-
67
+ # --- Constants ---------------------------------------------------------------
59
68
  SMB2_DIALECTS = {
60
69
  smb2.SMB2_DIALECT_002: "SMB 2.002",
61
70
  smb2.SMB2_DIALECT_21: "SMB 2.1",
@@ -68,7 +77,18 @@ SMB2_DIALECTS = {
68
77
 
69
78
  SMB2_DIALECT_REV = {v: k for k, v in SMB2_DIALECTS.items()}
70
79
 
80
+ SMB2_INTEGRITY_SHA512 = uint16.to_bytes(0x0001, order=LittleEndian)
81
+
71
82
 
83
+ # (missing in impackets struct definitions)
84
+ # 2.2.3.1.7 SMB2_SIGNING_CAPABILITIES
85
+ @struct(order=LittleEndian)
86
+ class SMB2SigningCapabilities(struct_factory.mixin):
87
+ SigningAlgorithmCount: uint16_t
88
+ SigningAlgorithms: f[list[int], uint16[this.SigningAlgorithmCount]]
89
+
90
+
91
+ # --- Config ------------------------------------------------------------------
72
92
  class SMBServerConfig(TomlConfig):
73
93
  _section_ = "SMB"
74
94
  _fields_ = [
@@ -104,13 +124,13 @@ class SMBServerConfig(TomlConfig):
104
124
  self.smb_error_code = nt_errors.STATUS_SMB_BAD_UID
105
125
 
106
126
 
107
- def apply_config(session):
127
+ def apply_config(session: SessionConfig):
108
128
  session.smb_config = list(
109
129
  map(SMBServerConfig, get_value("SMB", "Server", default=[]))
110
130
  )
111
131
 
112
132
 
113
- def create_server_threads(session):
133
+ def create_server_threads(session: SessionConfig):
114
134
  servers = []
115
135
  if session.smb_enabled:
116
136
  for server_config in session.smb_config:
@@ -125,16 +145,87 @@ def create_server_threads(session):
125
145
  return servers
126
146
 
127
147
 
148
+ # --- Functions ---------------------------------------------------------------
128
149
  def SMB_get_server_time():
129
150
  value = calendar.timegm(time.gmtime())
130
151
  value *= 10000000
131
152
  return value + 116444736000000000
132
153
 
133
154
 
134
- # --- SMB2/3 ---
135
- def smb2_negotiate(handler, target_revision: int):
155
+ def SMB_get_command_name(command: int, smb_version: int) -> str:
156
+ match smb_version:
157
+ case 0x01:
158
+ for key, value in vars(smb.SMB).items():
159
+ if key.startswith("SMB_COM") and value == command:
160
+ return key
161
+
162
+ case 0x02:
163
+ if 0 <= command < 0x13:
164
+ for key, value in vars(smb2).items():
165
+ if key.startswith("SMB2_") and value == command:
166
+ return key
167
+ case _:
168
+ pass
169
+
170
+ return "Unknown"
171
+
172
+
173
+ # --- SMB3 --------------------------------------------------------------------
174
+ def SMB3_get_neg_context_pad(data_len: int) -> bytes:
175
+ return b"\xff" * ((8 - (data_len % 8)) % 8)
176
+
177
+
178
+ def SMB3_build_neg_context_list(context_objects: list[tuple[int, bytes]]) -> bytes:
179
+ # build Negotiate Contexts
180
+ context_list = b""
181
+ for caps_type, caps in context_objects:
182
+ context = smb3.SMB2NegotiateContext()
183
+ context["ContextType"] = caps_type
184
+ context["Data"] = caps
185
+ context["DataLength"] = len(caps)
186
+
187
+ context_list += context.getData()
188
+ context_list += SMB3_get_neg_context_pad(context["DataLength"])
189
+ return context_list
190
+
191
+
192
+ def SMB3_get_target_capabilities(
193
+ handler: "SMBHandler", request: smb2.SMB2Negotiate
194
+ ) -> tuple[int, ...]:
195
+ target_cipher = smb3.SMB2_ENCRYPTION_AES128_GCM
196
+ target_sign = 0x001 # SMB2_SIGNING_AES_CMAC
197
+ try:
198
+ context_data = smb3.SMB311ContextData(request["ClientStartTime"])
199
+ raw_context_list = request.rawData[context_data["NegotiateContextOffset"] :]
200
+ offset = 0
201
+ for _ in range(context_data["NegotiateContextCount"]):
202
+ context = smb3.SMB2NegotiateContext(raw_context_list)
203
+ match context["ContextType"]:
204
+ case smb3.SMB2_ENCRYPTION_CAPABILITIES:
205
+ req_enc_caps = smb3.SMB2EncryptionCapabilities(context["Data"])
206
+ target_cipher = uint16.from_bytes(
207
+ req_enc_caps["Ciphers"],
208
+ order=LittleEndian,
209
+ )
210
+ case 0x008:
211
+ req_sign_caps = SMB2SigningCapabilities.from_bytes(context["Data"])
212
+ target_sign = req_sign_caps.SigningAlgorithms[0]
213
+
214
+ offset += context["DataLength"] + 8
215
+ offset += (8 - (offset % 8)) % 8
216
+ except Exception as e:
217
+ handler.logger.debug(f"Warning: invalid negotiate context list: {e}")
218
+ return target_cipher, target_sign
219
+
220
+
221
+ # --- SMB2 --------------------------------------------------------------------
222
+ def smb2_negotiate(
223
+ handler: "SMBHandler",
224
+ target_revision: int,
225
+ request: smb2.SMB2Negotiate | None = None,
226
+ ) -> smb2.SMB2Negotiate_Response:
136
227
  command = smb2.SMB2Negotiate_Response()
137
- command["SecuityMode"] = 0x01 # signing enabled, but not enforced
228
+ command["SecurityMode"] = 0x01 # signing enabled, but not enforced
138
229
  command["DialectRevision"] = target_revision
139
230
  command["ServerGuid"] = secrets.token_bytes(16)
140
231
  command["Capabilities"] = 0x00
@@ -148,10 +239,54 @@ def smb2_negotiate(handler, target_revision: int):
148
239
  blob = negTokenInit([SPNEGO_NTLMSSP_MECH])
149
240
  command["Buffer"] = blob.getData()
150
241
  command["SecurityBufferLength"] = len(command["Buffer"])
242
+
243
+ if target_revision == smb2.SMB2_DIALECT_311:
244
+ # 2.2.3.1.1 SMB2_PREAUTH_INTEGRITY_CAPABILITIES
245
+ # The format of the data in the Data field of this SMB2_NEGOTIATE_CONTEXT MUST
246
+ # take the same form specified in section 2.2.3.1.1 except that the
247
+ # HashAlgorithmCount field MUST be 1.
248
+ int_caps = smb3.SMB2PreAuthIntegrityCapabilities()
249
+ int_caps["HashAlgorithmCount"] = 1
250
+ int_caps["SaltLength"] = 32
251
+ int_caps["HashAlgorithms"] = SMB2_INTEGRITY_SHA512
252
+ int_caps["Salt"] = secrets.token_bytes(32)
253
+
254
+ # 2.2.3.1.2 SMB2_ENCRYPTION_CAPABILITIES
255
+ # The format of the data in the Data field of this SMB2_NEGOTIATE_CONTEXT MUST take
256
+ # the same form specified in section 2.2.3.1.2 except that the CipherCount field
257
+ # MUST be 1
258
+ target_cipher = smb3.SMB2_ENCRYPTION_AES128_GCM
259
+ target_sign = 0x001 # SMB2_SIGNING_AES_CMAC
260
+ if request:
261
+ target_cipher, target_sign = SMB3_get_target_capabilities(handler, request)
262
+
263
+ enc_caps = smb3.SMB2EncryptionCapabilities()
264
+ enc_caps["CipherCount"] = 1
265
+ enc_caps["Ciphers"] = uint16.to_bytes(target_cipher, order=LittleEndian)
266
+
267
+ # 2.2.3.1.7 SMB2_SIGNING_CAPABILITIES are missing in impackets collection
268
+ sign_caps = SMB2SigningCapabilities(
269
+ SigningAlgorithmCount=1, SigningAlgorithms=[target_sign]
270
+ )
271
+
272
+ # build Negotiate Contexts
273
+ context_data = SMB3_build_neg_context_list(
274
+ [
275
+ (smb3.SMB2_PREAUTH_INTEGRITY_CAPABILITIES, int_caps.getData()),
276
+ (smb3.SMB2_ENCRYPTION_CAPABILITIES, enc_caps.getData()),
277
+ (0x0008, sign_caps.to_bytes()),
278
+ ]
279
+ )
280
+
281
+ # print(len(command["Buffer"]))
282
+ command["NegotiateContextOffset"] = 0x80 + command["SecurityBufferLength"] + 2
283
+ command["NegotiateContextList"] = b"\xff\xff" + context_data
284
+ command["NegotiateContextCount"] = 3
285
+
151
286
  return command
152
287
 
153
288
 
154
- def smb2_negotiate_protocol(handler, packet: smb2.SMB2Packet) -> None:
289
+ def smb2_negotiate_protocol(handler: "SMBHandler", packet: smb2.SMB2Packet) -> None:
155
290
  req = smb3.SMB2Negotiate(data=packet["Data"])
156
291
  # Let's take the first dialect the clients wan't us to use
157
292
  req_dialects = req["Dialects"][: req["DialectCount"]]
@@ -162,10 +297,10 @@ def smb2_negotiate_protocol(handler, packet: smb2.SMB2Packet) -> None:
162
297
  )
163
298
 
164
299
  # REVISIT
165
- dialect = None
166
- for candidate in req_dialects:
167
- if candidate < 0x300: # SMBv3 not supported
168
- dialect = candidate
300
+ dialect = req_dialects[-1]
301
+ # for candidate in req_dialects:
302
+ # if candidate < 0x300:
303
+ # dialect = candidate
169
304
 
170
305
  if dialect is None:
171
306
  handler.logger.fail(
@@ -173,12 +308,15 @@ def smb2_negotiate_protocol(handler, packet: smb2.SMB2Packet) -> None:
173
308
  )
174
309
  raise BaseProtoHandler.TerminateConnection
175
310
 
176
- command = smb2_negotiate(handler, dialect)
177
- handler.log_server(f"selected dialect: {SMB2_DIALECTS.get(dialect, hex(dialect))}", "SMB2_NEGOTIATE")
311
+ command = smb2_negotiate(handler, dialect, req)
312
+ handler.log_server(
313
+ f"selected dialect: {SMB2_DIALECTS.get(dialect, hex(dialect))}",
314
+ "SMB2_NEGOTIATE",
315
+ )
178
316
  handler.send_smb2_command(command.getData())
179
317
 
180
318
 
181
- def smb2_session_setup(handler, packet: smb2.SMB2Packet) -> None:
319
+ def smb2_session_setup(handler: "SMBHandler", packet: smb2.SMB2Packet) -> None:
182
320
  req = smb2.SMB2SessionSetup(data=packet["Data"])
183
321
  command = smb2.SMB2SessionSetup_Response()
184
322
 
@@ -194,7 +332,21 @@ def smb2_session_setup(handler, packet: smb2.SMB2Packet) -> None:
194
332
  )
195
333
 
196
334
 
197
- # --- SMB1 ---
335
+ def smb2_logoff(handler: "SMBHandler", packet: smb2.SMB2Packet) -> None:
336
+ handler.log_client("Client requested logoff", "SMB2_LOGOFF")
337
+ handler.logger.display("Client requested logoff")
338
+
339
+ response = smb2.SMB2Logoff_Response()
340
+ handler.authenticated = False
341
+ return handler.send_smb2_command(
342
+ response.getData(),
343
+ packet,
344
+ # REVISIT: maybe this value should be configurable too
345
+ status=nt_errors.STATUS_SUCCESS,
346
+ )
347
+
348
+
349
+ # --- SMB1 --------------------------------------------------------------------
198
350
  def smb1_negotiate_protocol(handler, packet: smb.NewSMBPacket) -> None:
199
351
  resp = smb.NewSMBPacket()
200
352
  resp["Flags1"] = smb.SMB.FLAGS1_REPLY
@@ -314,7 +466,12 @@ class SMBHandler(BaseProtoHandler):
314
466
  STATE_AUTH = 1
315
467
 
316
468
  def __init__(
317
- self, config: SessionConfig, server_config, request, client_address, server
469
+ self,
470
+ config: SessionConfig,
471
+ server_config: SMBServerConfig,
472
+ request,
473
+ client_address,
474
+ server,
318
475
  ) -> None:
319
476
  # initialize session data
320
477
  self.authenticated = False
@@ -326,6 +483,7 @@ class SMBHandler(BaseProtoHandler):
326
483
  self.smb2_commands = {
327
484
  smb2.SMB2_NEGOTIATE: smb2_negotiate_protocol,
328
485
  smb2.SMB2_SESSION_SETUP: smb2_session_setup,
486
+ smb2.SMB2_LOGOFF: smb2_logoff,
329
487
  }
330
488
  super().__init__(config, request, client_address, server)
331
489
 
@@ -465,7 +623,8 @@ class SMBHandler(BaseProtoHandler):
465
623
 
466
624
  def handle_smb_packet(self, packet, smbv1=False):
467
625
  command = packet["Command"]
468
- title = f"SMBv{1 if smbv1 else 2} command {command:#x}"
626
+ command_name = SMB_get_command_name(command, 1 if smbv1 else 2)
627
+ title = f"SMBv{1 if smbv1 else 2} command {command_name} ({command:#04x})"
469
628
  handler_map = self.smb1_commands if smbv1 else self.smb2_commands
470
629
  handler = handler_map.get(command)
471
630
  if handler:
@@ -41,7 +41,7 @@ from rich.panel import Panel
41
41
  from rich.text import Text
42
42
 
43
43
  from dementor import __version__ as DementorVersion
44
- from dementor import config
44
+ from dementor import config, paths
45
45
  from dementor.db.connector import create_db, DatabaseConfig
46
46
  from dementor.config.session import SessionConfig
47
47
  from dementor.config.toml import TomlConfig
@@ -335,7 +335,7 @@ def main(
335
335
  metavar="NAME",
336
336
  help="Network interface to use (required for poisoning)",
337
337
  ),
338
- ],
338
+ ] = None,
339
339
  analyze: Annotated[
340
340
  bool,
341
341
  typer.Option(
@@ -396,14 +396,54 @@ def main(
396
396
  quiet: Annotated[
397
397
  bool,
398
398
  typer.Option(
399
- "--quiet", "-q", help="Don't print banner at startup", show_default=False
399
+ "--quiet",
400
+ "-q",
401
+ help="Don't print banner at startup",
402
+ show_default=False,
400
403
  ),
401
404
  ] = False,
405
+ version: Annotated[
406
+ bool,
407
+ typer.Option(
408
+ "--version",
409
+ help="Show Dementor's version number",
410
+ show_default=False,
411
+ ),
412
+ ] = False,
413
+ timestamps: Annotated[
414
+ bool,
415
+ typer.Option(
416
+ "--ts",
417
+ help="Log timestamps to the terminal too",
418
+ )
419
+ ] = False,
420
+ show_paths: Annotated[
421
+ bool,
422
+ typer.Option(
423
+ "--paths",
424
+ help="Displays the default configuration paths",
425
+ show_default=False,
426
+ )
427
+ ] = False,
402
428
  ) -> None:
429
+ if show_paths:
430
+ return paths.main()
431
+
432
+ if interface is None and not version:
433
+ return print(f"[bold red]Error:[/] Missing option --interface / -I")
434
+
403
435
  main_print_banner(quiet)
436
+ if version:
437
+ return
404
438
 
405
439
  # prepare options
406
440
  extras = parse_options(options or [])
441
+ if timestamps:
442
+ if "Log" not in extras:
443
+ extras["Log"] = {}
444
+
445
+ extras["Log"]["Timestamps"] = True
446
+
407
447
  if config_path:
408
448
  try:
409
449
  config.init_from_file(config_path)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dementor
3
- Version: 1.0.0.dev15
3
+ Version: 1.0.0.dev17
4
4
  Summary: LLMNR/NBT-NS/mDNS Poisoner and rogue service provider
5
5
  Author: MatrixEditor
6
6
  Maintainer: MatrixEditor
@@ -71,7 +71,7 @@ on the [Documentation](https://matrixeditor.github.io/dementor/) page.
71
71
 
72
72
  ## Installation
73
73
 
74
- Installation via `pip` from GitHub or PyPI:
74
+ Installation via `pip`/`pipx` from GitHub or PyPI:
75
75
 
76
76
  ```bash
77
77
  pip install dementor
@@ -95,15 +95,20 @@ Let's take a look.
95
95
  ```
96
96
  Usage: Dementor [OPTIONS]
97
97
 
98
- ╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────╮
99
- │ * --interface -I NAME Network interface to use (required for poisoning) [required] │
100
- │ --analyze -A Only analyze traffic, don't respond to requests │
101
- │ --config -c PATH Path to a configuration file (otherwise standard path is used) │
102
- │ --option -O KEY=VALUE Add an extra option to the global configuration file. │
103
- │ --yes -y Do not ask before starting attack mode. │
104
- │ --quiet -q Don't print banner at startup │
105
- │ --help Show this message and exit. │
106
- ╰──────────────────────────────────────────────────────────────────────────────────────────────────────╯
98
+ ╭─ Options ────────────────────────────────────────────────────────────────────────────────────────╮
99
+ │ --interface -I NAME Network interface to use (required for poisoning) │
100
+ │ --analyze -A Only analyze traffic, don't respond to requests │
101
+ │ --config -c PATH Path to a configuration file (otherwise standard path is used) │
102
+ │ --option -O KEY=VALUE Add an extra option to the global configuration file. │
103
+ │ --yes,--yolo -y Do not ask before starting attack mode. │
104
+ │ --target -t NAME[,...] Target host(s) to attack │
105
+ │ --ignore -i NAME[,...] Target host(s) to ignore │
106
+ │ --quiet -q Don't print banner at startup │
107
+ │ --version Show Dementor's version number │
108
+ │ --ts Log timestamps to terminal output too │
109
+ │ --paths Displays the default configuration paths │
110
+ │ --help Show this message and exit. │
111
+ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
107
112
  ```
108
113
 
109
114
  ## You need more?
@@ -13,7 +13,7 @@ on the [Documentation](https://matrixeditor.github.io/dementor/) page.
13
13
 
14
14
  ## Installation
15
15
 
16
- Installation via `pip` from GitHub or PyPI:
16
+ Installation via `pip`/`pipx` from GitHub or PyPI:
17
17
 
18
18
  ```bash
19
19
  pip install dementor
@@ -37,15 +37,20 @@ Let's take a look.
37
37
  ```
38
38
  Usage: Dementor [OPTIONS]
39
39
 
40
- ╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────╮
41
- │ * --interface -I NAME Network interface to use (required for poisoning) [required] │
42
- │ --analyze -A Only analyze traffic, don't respond to requests │
43
- │ --config -c PATH Path to a configuration file (otherwise standard path is used) │
44
- │ --option -O KEY=VALUE Add an extra option to the global configuration file. │
45
- │ --yes -y Do not ask before starting attack mode. │
46
- │ --quiet -q Don't print banner at startup │
47
- │ --help Show this message and exit. │
48
- ╰──────────────────────────────────────────────────────────────────────────────────────────────────────╯
40
+ ╭─ Options ────────────────────────────────────────────────────────────────────────────────────────╮
41
+ │ --interface -I NAME Network interface to use (required for poisoning) │
42
+ │ --analyze -A Only analyze traffic, don't respond to requests │
43
+ │ --config -c PATH Path to a configuration file (otherwise standard path is used) │
44
+ │ --option -O KEY=VALUE Add an extra option to the global configuration file. │
45
+ │ --yes,--yolo -y Do not ask before starting attack mode. │
46
+ │ --target -t NAME[,...] Target host(s) to attack │
47
+ │ --ignore -i NAME[,...] Target host(s) to ignore │
48
+ │ --quiet -q Don't print banner at startup │
49
+ │ --version Show Dementor's version number │
50
+ │ --ts Log timestamps to terminal output too │
51
+ │ --paths Displays the default configuration paths │
52
+ │ --help Show this message and exit. │
53
+ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
49
54
  ```
50
55
 
51
56
  ## You need more?
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "dementor"
3
- version = "1.0.0.dev15"
3
+ version = "1.0.0.dev17"
4
4
  license = { file = "LICENSE" }
5
5
 
6
6
  description = "LLMNR/NBT-NS/mDNS Poisoner and rogue service provider"
File without changes
File without changes