dementor 1.0.0.dev15__tar.gz → 1.0.0.dev16__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.dev16}/PKG-INFO +16 -11
  2. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/README.md +16 -10
  3. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/__init__.py +1 -1
  4. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/assets/Dementor.toml +11 -2
  5. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/filters.py +1 -1
  6. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/log/logger.py +25 -4
  7. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/paths.py +5 -1
  8. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/protocols/ldap.py +1 -1
  9. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/protocols/netbios.py +9 -3
  10. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/protocols/smb.py +50 -8
  11. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/standalone.py +43 -3
  12. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor.egg-info/PKG-INFO +16 -11
  13. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/docs/README.pypi.md +15 -10
  14. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/pyproject.toml +1 -1
  15. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/LICENSE +0 -0
  16. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/__main__.py +0 -0
  17. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/assets/banner.txt +0 -0
  18. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/assets/www/error_page.html +0 -0
  19. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/assets/www/upnp-default/dd.xml +0 -0
  20. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/assets/www/upnp-default/present.html +0 -0
  21. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/assets/www/upnp-default/scpd.xml +0 -0
  22. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/assets/www/wpad.dat +0 -0
  23. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/config/__init__.py +0 -0
  24. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/config/attr.py +0 -0
  25. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/config/session.py +0 -0
  26. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/config/toml.py +0 -0
  27. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/config/util.py +0 -0
  28. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/db/__init__.py +0 -0
  29. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/db/connector.py +0 -0
  30. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/db/model.py +0 -0
  31. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/loader.py +0 -0
  32. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/log/__init__.py +0 -0
  33. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/log/hexdump.py +0 -0
  34. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/log/stream.py +0 -0
  35. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/protocols/__init__.py +0 -0
  36. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/protocols/ftp.py +0 -0
  37. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/protocols/http.py +0 -0
  38. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/protocols/imap.py +0 -0
  39. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/protocols/ipp.py +0 -0
  40. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/protocols/kerberos.py +0 -0
  41. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/protocols/llmnr.py +0 -0
  42. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/protocols/mdns.py +0 -0
  43. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/protocols/msrpc/__init__.py +0 -0
  44. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/protocols/msrpc/dcom.py +0 -0
  45. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/protocols/msrpc/epm.py +0 -0
  46. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/protocols/msrpc/rpc.py +0 -0
  47. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/protocols/msrpc.py +0 -0
  48. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/protocols/mssql.py +0 -0
  49. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/protocols/mysql.py +0 -0
  50. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/protocols/ntlm.py +0 -0
  51. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/protocols/pop3.py +0 -0
  52. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/protocols/quic.py +0 -0
  53. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/protocols/smtp.py +0 -0
  54. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/protocols/spnego.py +0 -0
  55. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/protocols/ssdp.py +0 -0
  56. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/protocols/upnp.py +0 -0
  57. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/protocols/x11.py +0 -0
  58. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor/servers.py +0 -0
  59. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor.egg-info/SOURCES.txt +0 -0
  60. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor.egg-info/dependency_links.txt +0 -0
  61. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor.egg-info/entry_points.txt +0 -0
  62. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor.egg-info/requires.txt +0 -0
  63. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/dementor.egg-info/top_level.txt +0 -0
  64. {dementor-1.0.0.dev15 → dementor-1.0.0.dev16}/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.dev16
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.dev16"
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,
@@ -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
 
@@ -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")
@@ -104,13 +104,13 @@ class SMBServerConfig(TomlConfig):
104
104
  self.smb_error_code = nt_errors.STATUS_SMB_BAD_UID
105
105
 
106
106
 
107
- def apply_config(session):
107
+ def apply_config(session: SessionConfig):
108
108
  session.smb_config = list(
109
109
  map(SMBServerConfig, get_value("SMB", "Server", default=[]))
110
110
  )
111
111
 
112
112
 
113
- def create_server_threads(session):
113
+ def create_server_threads(session: SessionConfig):
114
114
  servers = []
115
115
  if session.smb_enabled:
116
116
  for server_config in session.smb_config:
@@ -131,8 +131,26 @@ def SMB_get_server_time():
131
131
  return value + 116444736000000000
132
132
 
133
133
 
134
+ def SMB_get_command_name(command: int, smb_version: int) -> str:
135
+ match smb_version:
136
+ case 0x01:
137
+ for key, value in vars(smb.SMB).items():
138
+ if key.startswith("SMB_COM") and value == command:
139
+ return key
140
+
141
+ case 0x02:
142
+ if 0 <= command < 0x13:
143
+ for key, value in vars(smb2).items():
144
+ if key.startswith("SMB2_") and value == command:
145
+ return key
146
+ case _:
147
+ pass
148
+
149
+ return "Unknown"
150
+
151
+
134
152
  # --- SMB2/3 ---
135
- def smb2_negotiate(handler, target_revision: int):
153
+ def smb2_negotiate(handler: "SMBHandler", target_revision: int):
136
154
  command = smb2.SMB2Negotiate_Response()
137
155
  command["SecuityMode"] = 0x01 # signing enabled, but not enforced
138
156
  command["DialectRevision"] = target_revision
@@ -151,7 +169,7 @@ def smb2_negotiate(handler, target_revision: int):
151
169
  return command
152
170
 
153
171
 
154
- def smb2_negotiate_protocol(handler, packet: smb2.SMB2Packet) -> None:
172
+ def smb2_negotiate_protocol(handler: "SMBHandler", packet: smb2.SMB2Packet) -> None:
155
173
  req = smb3.SMB2Negotiate(data=packet["Data"])
156
174
  # Let's take the first dialect the clients wan't us to use
157
175
  req_dialects = req["Dialects"][: req["DialectCount"]]
@@ -174,11 +192,14 @@ def smb2_negotiate_protocol(handler, packet: smb2.SMB2Packet) -> None:
174
192
  raise BaseProtoHandler.TerminateConnection
175
193
 
176
194
  command = smb2_negotiate(handler, dialect)
177
- handler.log_server(f"selected dialect: {SMB2_DIALECTS.get(dialect, hex(dialect))}", "SMB2_NEGOTIATE")
195
+ handler.log_server(
196
+ f"selected dialect: {SMB2_DIALECTS.get(dialect, hex(dialect))}",
197
+ "SMB2_NEGOTIATE",
198
+ )
178
199
  handler.send_smb2_command(command.getData())
179
200
 
180
201
 
181
- def smb2_session_setup(handler, packet: smb2.SMB2Packet) -> None:
202
+ def smb2_session_setup(handler: "SMBHandler", packet: smb2.SMB2Packet) -> None:
182
203
  req = smb2.SMB2SessionSetup(data=packet["Data"])
183
204
  command = smb2.SMB2SessionSetup_Response()
184
205
 
@@ -194,6 +215,20 @@ def smb2_session_setup(handler, packet: smb2.SMB2Packet) -> None:
194
215
  )
195
216
 
196
217
 
218
+ def smb2_logoff(handler: "SMBHandler", packet: smb2.SMB2Packet) -> None:
219
+ handler.log_client("Client requested logoff", "SMB2_LOGOFF")
220
+ handler.logger.display("Client requested logoff")
221
+
222
+ response = smb2.SMB2Logoff_Response()
223
+ handler.authenticated = False
224
+ return handler.send_smb2_command(
225
+ response.getData(),
226
+ packet,
227
+ # REVISIT: maybe this value should be configurable too
228
+ status=nt_errors.STATUS_SUCCESS,
229
+ )
230
+
231
+
197
232
  # --- SMB1 ---
198
233
  def smb1_negotiate_protocol(handler, packet: smb.NewSMBPacket) -> None:
199
234
  resp = smb.NewSMBPacket()
@@ -314,7 +349,12 @@ class SMBHandler(BaseProtoHandler):
314
349
  STATE_AUTH = 1
315
350
 
316
351
  def __init__(
317
- self, config: SessionConfig, server_config, request, client_address, server
352
+ self,
353
+ config: SessionConfig,
354
+ server_config: SMBServerConfig,
355
+ request,
356
+ client_address,
357
+ server,
318
358
  ) -> None:
319
359
  # initialize session data
320
360
  self.authenticated = False
@@ -326,6 +366,7 @@ class SMBHandler(BaseProtoHandler):
326
366
  self.smb2_commands = {
327
367
  smb2.SMB2_NEGOTIATE: smb2_negotiate_protocol,
328
368
  smb2.SMB2_SESSION_SETUP: smb2_session_setup,
369
+ smb2.SMB2_LOGOFF: smb2_logoff,
329
370
  }
330
371
  super().__init__(config, request, client_address, server)
331
372
 
@@ -465,7 +506,8 @@ class SMBHandler(BaseProtoHandler):
465
506
 
466
507
  def handle_smb_packet(self, packet, smbv1=False):
467
508
  command = packet["Command"]
468
- title = f"SMBv{1 if smbv1 else 2} command {command:#x}"
509
+ command_name = SMB_get_command_name(command, 1 if smbv1 else 2)
510
+ title = f"SMBv{1 if smbv1 else 2} command {command_name} ({command:#04x})"
469
511
  handler_map = self.smb1_commands if smbv1 else self.smb2_commands
470
512
  handler = handler_map.get(command)
471
513
  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.dev16
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.dev16"
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