dementor 1.0.0.dev12__tar.gz → 1.0.0.dev13__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.
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/PKG-INFO +11 -1
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/README.md +11 -1
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/__init__.py +1 -1
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/database.py +1 -1
- dementor-1.0.0.dev13/dementor/log/hexdump.py +24 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/log/logger.py +5 -5
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/protocols/http.py +10 -7
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/protocols/imap.py +3 -3
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/protocols/ipp.py +8 -4
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/protocols/ldap.py +6 -2
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/protocols/msrpc/rpc.py +1 -1
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/protocols/mssql.py +8 -10
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/protocols/mysql.py +30 -10
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/protocols/smb.py +9 -5
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/protocols/upnp.py +5 -2
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/protocols/x11.py +2 -2
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/servers.py +15 -1
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/standalone.py +22 -18
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor.egg-info/PKG-INFO +11 -1
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor.egg-info/SOURCES.txt +1 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/docs/README.pypi.md +11 -1
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/pyproject.toml +1 -1
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/LICENSE +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/__main__.py +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/assets/Dementor.toml +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/assets/banner.txt +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/assets/www/error_page.html +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/assets/www/upnp-default/dd.xml +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/assets/www/upnp-default/present.html +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/assets/www/upnp-default/scpd.xml +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/assets/www/wpad.dat +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/config/__init__.py +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/config/attr.py +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/config/session.py +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/config/toml.py +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/config/util.py +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/filters.py +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/loader.py +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/log/__init__.py +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/log/stream.py +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/paths.py +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/protocols/__init__.py +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/protocols/ftp.py +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/protocols/kerberos.py +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/protocols/llmnr.py +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/protocols/mdns.py +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/protocols/msrpc/__init__.py +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/protocols/msrpc/dcom.py +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/protocols/msrpc/epm.py +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/protocols/msrpc.py +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/protocols/netbios.py +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/protocols/ntlm.py +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/protocols/pop3.py +1 -1
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/protocols/quic.py +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/protocols/smtp.py +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/protocols/spnego.py +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor/protocols/ssdp.py +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor.egg-info/dependency_links.txt +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor.egg-info/entry_points.txt +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor.egg-info/requires.txt +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/dementor.egg-info/top_level.txt +0 -0
- {dementor-1.0.0.dev12 → dementor-1.0.0.dev13}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dementor
|
|
3
|
-
Version: 1.0.0.
|
|
3
|
+
Version: 1.0.0.dev13
|
|
4
4
|
Summary: LLMNR/NBT-NS/mDNS Poisoner and rogue service provider
|
|
5
5
|
Author: MatrixEditor
|
|
6
6
|
Maintainer: MatrixEditor
|
|
@@ -114,3 +114,13 @@ Take a look at the [Documentation on GitHub-Pages](https://matrixeditor.github.i
|
|
|
114
114
|
## License
|
|
115
115
|
|
|
116
116
|
Distributed under the MIT License. See LICENSE for more information.
|
|
117
|
+
|
|
118
|
+
## Disclaimer
|
|
119
|
+
|
|
120
|
+
**Dementor** is intended only for lawful educational purposes: learning, testing
|
|
121
|
+
in your own lab, or assessments on systems where you have explicit written
|
|
122
|
+
authorization. You agree not to use this software to access, damage, interfere
|
|
123
|
+
with, or exfiltrate data from systems for which you do not have permission.
|
|
124
|
+
We make no promises about safety, completeness, or fitness for any purpose. Use
|
|
125
|
+
at your own risk. If you discover a vulnerability, please follow responsible
|
|
126
|
+
disclosure by using the private disclosing feature offered by GitHub.
|
|
@@ -56,4 +56,14 @@ Take a look at the [Documentation on GitHub-Pages](https://matrixeditor.github.i
|
|
|
56
56
|
|
|
57
57
|
## License
|
|
58
58
|
|
|
59
|
-
Distributed under the MIT License. See LICENSE for more information.
|
|
59
|
+
Distributed under the MIT License. See LICENSE for more information.
|
|
60
|
+
|
|
61
|
+
## Disclaimer
|
|
62
|
+
|
|
63
|
+
**Dementor** is intended only for lawful educational purposes: learning, testing
|
|
64
|
+
in your own lab, or assessments on systems where you have explicit written
|
|
65
|
+
authorization. You agree not to use this software to access, damage, interfere
|
|
66
|
+
with, or exfiltrate data from systems for which you do not have permission.
|
|
67
|
+
We make no promises about safety, completeness, or fitness for any purpose. Use
|
|
68
|
+
at your own risk. If you discover a vulnerability, please follow responsible
|
|
69
|
+
disclosure by using the private disclosing feature offered by GitHub.
|
|
@@ -207,7 +207,7 @@ class DementorDB:
|
|
|
207
207
|
username_text = "(blank)"
|
|
208
208
|
|
|
209
209
|
full_name = (
|
|
210
|
-
f" for [b]{
|
|
210
|
+
f" for [b]{markup.escape(domain)}[/]/[b]{username_text}[/]"
|
|
211
211
|
if domain
|
|
212
212
|
else f" for [b]{username_text}[/]"
|
|
213
213
|
)
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
|
|
21
|
+
# just reusing impacket's hexdump
|
|
22
|
+
from impacket.structure import hexdump
|
|
23
|
+
|
|
24
|
+
__all__ = ["hexdump"]
|
|
@@ -34,6 +34,7 @@ from dementor.config import util
|
|
|
34
34
|
from dementor.config.toml import TomlConfig, Attribute as A
|
|
35
35
|
from dementor.log import dm_print, dm_console
|
|
36
36
|
|
|
37
|
+
|
|
37
38
|
class LoggingConfig(TomlConfig):
|
|
38
39
|
_section_ = "Log"
|
|
39
40
|
_fields_ = [
|
|
@@ -234,11 +235,10 @@ class ProtocolLogger(logging.LoggerAdapter):
|
|
|
234
235
|
if not config.log_enable:
|
|
235
236
|
return
|
|
236
237
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
dm_logger.add_logfile(str(workspace / log_name))
|
|
238
|
+
log_dir: pathlib.Path = session.resolve_path(config.log_dir or "logs")
|
|
239
|
+
log_dir.mkdir(parents=True, exist_ok=True)
|
|
240
|
+
log_name = f"dm_log-{util.now()}.log"
|
|
241
|
+
dm_logger.add_logfile(str(log_dir / log_name))
|
|
242
242
|
|
|
243
243
|
|
|
244
244
|
class ProtocolLoggerMixin:
|
|
@@ -328,7 +328,7 @@ class HTTPHandler(BaseHTTPRequestHandler):
|
|
|
328
328
|
else:
|
|
329
329
|
script = self.server.render_page("wpad.dat")
|
|
330
330
|
if self.config.http_wpad_enabled and not script:
|
|
331
|
-
self.logger.
|
|
331
|
+
self.logger.fail("WPAD enabled but script not configured")
|
|
332
332
|
return self.send_error(HTTPStatus.NOT_FOUND)
|
|
333
333
|
|
|
334
334
|
self.logger.success("Serving WPAD script to client")
|
|
@@ -381,7 +381,7 @@ class HTTPHandler(BaseHTTPRequestHandler):
|
|
|
381
381
|
message = ntlm.NTLM_HTTP.get_instance(f"NTLM {token}")
|
|
382
382
|
except Exception:
|
|
383
383
|
# invalid value
|
|
384
|
-
logger.
|
|
384
|
+
logger.fail(f"Invalid negotiate authentication: {token}")
|
|
385
385
|
self.send_error(HTTPStatus.INTERNAL_SERVER_ERROR, "Internal Server Error")
|
|
386
386
|
return
|
|
387
387
|
|
|
@@ -414,7 +414,7 @@ class HTTPHandler(BaseHTTPRequestHandler):
|
|
|
414
414
|
self.finish_request(logger)
|
|
415
415
|
|
|
416
416
|
case _:
|
|
417
|
-
logger.
|
|
417
|
+
logger.fail(f"Invalid negotiate authentication: {token}")
|
|
418
418
|
self.send_error(
|
|
419
419
|
HTTPStatus.INTERNAL_SERVER_ERROR, "Internal Server Error"
|
|
420
420
|
)
|
|
@@ -437,7 +437,7 @@ class HTTPHandler(BaseHTTPRequestHandler):
|
|
|
437
437
|
try:
|
|
438
438
|
username, password = base64.b64decode(token).decode().split(":", 1)
|
|
439
439
|
except ValueError:
|
|
440
|
-
logger.
|
|
440
|
+
logger.fail(f"Invalid basic authentication: {token}")
|
|
441
441
|
self.send_error(HTTPStatus.INTERNAL_SERVER_ERROR, "Internal Server Error")
|
|
442
442
|
return
|
|
443
443
|
|
|
@@ -532,9 +532,12 @@ class HTTPServer(ThreadingHTTPServer):
|
|
|
532
532
|
ThreadingHTTPServer.server_bind(self)
|
|
533
533
|
|
|
534
534
|
def finish_request(self, request, client_address) -> None:
|
|
535
|
-
|
|
536
|
-
self.
|
|
537
|
-
|
|
535
|
+
try:
|
|
536
|
+
self.RequestHandlerClass(
|
|
537
|
+
self.config, self.server_config, request, client_address, self
|
|
538
|
+
)
|
|
539
|
+
except ConnectionResetError:
|
|
540
|
+
pass
|
|
538
541
|
|
|
539
542
|
def render_error(
|
|
540
543
|
self, code: int, message: str | None = None, explain: str | None = None
|
|
@@ -220,7 +220,7 @@ class IMAPHandler(BaseProtoHandler):
|
|
|
220
220
|
tag, cmd, *args = shlex.split(line)
|
|
221
221
|
self.seq_id = tag
|
|
222
222
|
except ValueError:
|
|
223
|
-
self.logger.debug(f"Unknown command: {line!r}")
|
|
223
|
+
self.logger.debug(f"Unknown command: {line.encode()!r}")
|
|
224
224
|
self.bad("Invalid command")
|
|
225
225
|
continue
|
|
226
226
|
|
|
@@ -231,7 +231,7 @@ class IMAPHandler(BaseProtoHandler):
|
|
|
231
231
|
except StopHandler:
|
|
232
232
|
break
|
|
233
233
|
else:
|
|
234
|
-
self.logger.debug(f"Unknown command: {line!r}")
|
|
234
|
+
self.logger.debug(f"Unknown command: {line.encode()!r}")
|
|
235
235
|
# 7.1.5. BYE Response
|
|
236
236
|
self._push("BYE Unknown command", seq=False)
|
|
237
237
|
break
|
|
@@ -240,7 +240,7 @@ class IMAPHandler(BaseProtoHandler):
|
|
|
240
240
|
data = self.rfile.readline(size)
|
|
241
241
|
if data:
|
|
242
242
|
text = data.decode("utf-8", errors="replace").strip()
|
|
243
|
-
self.logger.debug(repr(
|
|
243
|
+
self.logger.debug(repr(data), is_client=True)
|
|
244
244
|
return text
|
|
245
245
|
|
|
246
246
|
# implementation
|
|
@@ -210,8 +210,9 @@ class IPPHandler(BaseHTTPRequestHandler):
|
|
|
210
210
|
)
|
|
211
211
|
|
|
212
212
|
def send_response(self, code: int, message=None, document=None) -> None:
|
|
213
|
+
path = getattr(self, "path", "<invalid>")
|
|
213
214
|
self.logger.debug(
|
|
214
|
-
markup.escape(f"{self.command} {
|
|
215
|
+
markup.escape(f"{self.command} {path} {code}"), is_server=True
|
|
215
216
|
)
|
|
216
217
|
if not hasattr(self, "_headers_buffer"):
|
|
217
218
|
self._headers_buffer = []
|
|
@@ -421,6 +422,9 @@ class IPPServer(ThreadingHTTPServer):
|
|
|
421
422
|
return super().server_bind()
|
|
422
423
|
|
|
423
424
|
def finish_request(self, request, client_address) -> None:
|
|
424
|
-
|
|
425
|
-
self.
|
|
426
|
-
|
|
425
|
+
try:
|
|
426
|
+
self.RequestHandlerClass(
|
|
427
|
+
self.config, self.server_config, request, client_address, self
|
|
428
|
+
)
|
|
429
|
+
except ConnectionError:
|
|
430
|
+
pass
|
|
@@ -39,6 +39,7 @@ from pyasn1.codec.ber import encoder as BEREncoder, decoder as BERDecoder
|
|
|
39
39
|
from dementor.config.toml import TomlConfig, Attribute as A
|
|
40
40
|
from dementor.config.session import SessionConfig
|
|
41
41
|
from dementor.config.util import get_value
|
|
42
|
+
from dementor.log import hexdump
|
|
42
43
|
from dementor.log.logger import ProtocolLogger
|
|
43
44
|
from dementor.servers import (
|
|
44
45
|
ThreadingTCPServer,
|
|
@@ -245,7 +246,7 @@ class LDAPHandler(BaseProtoHandler):
|
|
|
245
246
|
# we expect this to be a NTLM message
|
|
246
247
|
data = bytes(bind_auth["credentials"])
|
|
247
248
|
if not data.startswith(b"NTLMSSP"):
|
|
248
|
-
self.logger.debug(f"Unsupported SASL mechanism
|
|
249
|
+
self.logger.debug(f"Unsupported SASL mechanism:\n{hexdump.hexdump(data)}")
|
|
249
250
|
return False
|
|
250
251
|
|
|
251
252
|
# negotiate message will have message type 0x01
|
|
@@ -346,7 +347,10 @@ class LDAPHandler(BaseProtoHandler):
|
|
|
346
347
|
try:
|
|
347
348
|
message, _ = BERDecoder.decode(data, asn1Spec=LDAPMessage())
|
|
348
349
|
except Exception as e:
|
|
349
|
-
self.logger.
|
|
350
|
+
self.logger.fail("Received invalid LDAP - terminating connection...")
|
|
351
|
+
self.logger.debug(
|
|
352
|
+
f"Invalid LDAP packet: {str(e.__class__)}\n{hexdump.hexdump(data)}"
|
|
353
|
+
)
|
|
350
354
|
return
|
|
351
355
|
|
|
352
356
|
return message
|
|
@@ -166,7 +166,7 @@ class RPCHandler(BaseProtoHandler):
|
|
|
166
166
|
try:
|
|
167
167
|
header = rpcrt.MSRPCHeader(data)
|
|
168
168
|
except struct.error:
|
|
169
|
-
self.logger.
|
|
169
|
+
self.logger.fail("Data is not a valid MSRPC header, closing connection")
|
|
170
170
|
return
|
|
171
171
|
|
|
172
172
|
match header["type"]:
|
|
@@ -42,6 +42,7 @@ from caterpillar.py import (
|
|
|
42
42
|
|
|
43
43
|
from dementor.database import _CLEARTEXT
|
|
44
44
|
from dementor.config.toml import TomlConfig, Attribute as A
|
|
45
|
+
from dementor.log.hexdump import hexdump
|
|
45
46
|
from dementor.log.logger import ProtocolLogger
|
|
46
47
|
from dementor.protocols.ntlm import (
|
|
47
48
|
NTLM_AUTH_CreateChallenge,
|
|
@@ -314,29 +315,26 @@ class MSSQLHandler(BaseProtoHandler):
|
|
|
314
315
|
|
|
315
316
|
try:
|
|
316
317
|
packet = tds.TDSPacket(data)
|
|
317
|
-
except Exception as
|
|
318
|
-
self.logger.
|
|
319
|
-
|
|
320
|
-
)
|
|
318
|
+
except Exception as e:
|
|
319
|
+
self.logger.fail("Closing connection on invalid MSSQL packet")
|
|
320
|
+
self.logger.debug(f"Invalid MSSQL packet: {str(e)}\n{hexdump(data)}")
|
|
321
321
|
break
|
|
322
322
|
|
|
323
323
|
try:
|
|
324
324
|
code = None
|
|
325
325
|
match packet["Type"]:
|
|
326
|
-
case 18: #
|
|
326
|
+
case 18: # TDS_PRELOGIN
|
|
327
327
|
code = self.handle_pre_login(packet)
|
|
328
|
-
|
|
329
328
|
case 16: # TDS_LOGIN
|
|
330
329
|
code = self.handle_login(packet)
|
|
331
|
-
|
|
332
330
|
case 17:
|
|
333
331
|
code = self.handle_sspi(packet)
|
|
334
|
-
|
|
335
332
|
case _:
|
|
336
333
|
self.send_error(packet)
|
|
337
334
|
code = 1
|
|
338
335
|
except Exception as e:
|
|
339
|
-
self.logger.
|
|
336
|
+
self.logger.fail("Error while handling MSSQL packet: invalid payload")
|
|
337
|
+
self.logger.debug(f"Invalid MSSQL packet: {str(e)}\n{hexdump(data)}")
|
|
340
338
|
self.send_error(packet)
|
|
341
339
|
code = 1
|
|
342
340
|
|
|
@@ -413,7 +411,7 @@ class MSSQLHandler(BaseProtoHandler):
|
|
|
413
411
|
negotiate.fromString(sspi_buffer)
|
|
414
412
|
except Exception:
|
|
415
413
|
# invalid packet
|
|
416
|
-
self.logger.debug(f"Invalid NTLMSSP packet
|
|
414
|
+
self.logger.debug(f"Invalid NTLMSSP packet:\n{hexdump(sspi_buffer)}")
|
|
417
415
|
self.send_error(packet)
|
|
418
416
|
return 1
|
|
419
417
|
|
|
@@ -48,6 +48,7 @@ from caterpillar.py import (
|
|
|
48
48
|
)
|
|
49
49
|
from caterpillar.exception import DynamicSizeError, StructException
|
|
50
50
|
|
|
51
|
+
from dementor.log.hexdump import hexdump
|
|
51
52
|
from dementor.servers import (
|
|
52
53
|
ThreadingTCPServer,
|
|
53
54
|
ServerThread,
|
|
@@ -79,13 +80,17 @@ def apply_config(session):
|
|
|
79
80
|
|
|
80
81
|
|
|
81
82
|
def create_server_threads(session):
|
|
82
|
-
return
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
83
|
+
return (
|
|
84
|
+
[
|
|
85
|
+
ServerThread(
|
|
86
|
+
session,
|
|
87
|
+
MySQLServer,
|
|
88
|
+
server_address=(session.bind_address, session.mysql_config.mysql_port),
|
|
89
|
+
)
|
|
90
|
+
]
|
|
91
|
+
if session.mysql_enabled
|
|
92
|
+
else []
|
|
93
|
+
)
|
|
89
94
|
|
|
90
95
|
|
|
91
96
|
# --- MySQL Protocol ---
|
|
@@ -368,6 +373,7 @@ class MySQLHandler(BaseProtoHandler):
|
|
|
368
373
|
self.send(pack(packet))
|
|
369
374
|
|
|
370
375
|
def recv_unpack(self) -> Any:
|
|
376
|
+
data = None
|
|
371
377
|
try:
|
|
372
378
|
data = self.recv(8192)
|
|
373
379
|
if not data:
|
|
@@ -378,7 +384,9 @@ class MySQLHandler(BaseProtoHandler):
|
|
|
378
384
|
raise # will terminate the connection
|
|
379
385
|
|
|
380
386
|
except Exception as e:
|
|
381
|
-
self.logger.
|
|
387
|
+
self.logger.fail("Received invalid MySQL packet, closing connection...")
|
|
388
|
+
data = data or b""
|
|
389
|
+
self.logger.debug(f"Failed to decode MySQL packet: {e}\n({hexdump(data)})")
|
|
382
390
|
return None
|
|
383
391
|
|
|
384
392
|
def setup(self) -> None:
|
|
@@ -427,7 +435,13 @@ class MySQLHandler(BaseProtoHandler):
|
|
|
427
435
|
try:
|
|
428
436
|
ssl_request: SSLRequest = unpack(SSLRequest, packet.payload)
|
|
429
437
|
except Exception as e:
|
|
430
|
-
|
|
438
|
+
self.logger.fail(
|
|
439
|
+
"Received invalid MySQL SSLRequest. Terminating connection: "
|
|
440
|
+
)
|
|
441
|
+
self.logger.debug(
|
|
442
|
+
f"Invalid MySQL SSLRequest packet: {str(e)}\n{hexdump(packet.payload)}"
|
|
443
|
+
)
|
|
444
|
+
return
|
|
431
445
|
|
|
432
446
|
if ssl_request.capabilities & CLIENT_SSL != 0:
|
|
433
447
|
if not self.mysql_config.use_ssl:
|
|
@@ -452,7 +466,13 @@ class MySQLHandler(BaseProtoHandler):
|
|
|
452
466
|
try:
|
|
453
467
|
response: HandshakeResponse = unpack(HandshakeResponse, packet.payload)
|
|
454
468
|
except Exception as e:
|
|
455
|
-
|
|
469
|
+
self.logger.fail(
|
|
470
|
+
"Failed to decode MySQL HandshakeResponse. Terminating connection... "
|
|
471
|
+
)
|
|
472
|
+
self.logger.debug(
|
|
473
|
+
f"Invalid MySQL HandshakeResponse packet: {str(e)}\n{hexdump(packet.payload)}"
|
|
474
|
+
)
|
|
475
|
+
return
|
|
456
476
|
|
|
457
477
|
resp_plugin_name = response.client_plugin_name or plugin_name
|
|
458
478
|
if resp_plugin_name != plugin_name:
|
|
@@ -434,6 +434,10 @@ class SMBHandler(BaseProtoHandler):
|
|
|
434
434
|
# 2. Step: decode SMB packet
|
|
435
435
|
# The protocol identifier for SMBv1 is 0xFF 0x53 0x4C 0x49 0x53 0x4E 0x00:
|
|
436
436
|
raw_smb_data = packet.get_trailer()
|
|
437
|
+
if len(raw_smb_data) == 0:
|
|
438
|
+
self.logger.debug("Received empty SMB packet")
|
|
439
|
+
continue
|
|
440
|
+
|
|
437
441
|
smbv1 = False
|
|
438
442
|
match raw_smb_data[0]:
|
|
439
443
|
case 0xFF: # SMB1
|
|
@@ -442,7 +446,7 @@ class SMBHandler(BaseProtoHandler):
|
|
|
442
446
|
case 0xFE: # SMB2/SMB3
|
|
443
447
|
packet = smb2.SMB2Packet(data=raw_smb_data)
|
|
444
448
|
case _:
|
|
445
|
-
self.logger.
|
|
449
|
+
self.logger.debug(f"Unknown SMB packet type: {raw_smb_data[0]}")
|
|
446
450
|
break
|
|
447
451
|
|
|
448
452
|
# 3. Step: handle SMB packet
|
|
@@ -461,7 +465,7 @@ class SMBHandler(BaseProtoHandler):
|
|
|
461
465
|
except Exception as e:
|
|
462
466
|
self.logger.exception(f"Error in {title}: {e}")
|
|
463
467
|
else:
|
|
464
|
-
self.logger.
|
|
468
|
+
self.logger.fail(f"{title} not implemented")
|
|
465
469
|
raise BaseProtoHandler.TerminateConnection
|
|
466
470
|
|
|
467
471
|
def log_client(self, msg, command=None):
|
|
@@ -497,7 +501,7 @@ class SMBHandler(BaseProtoHandler):
|
|
|
497
501
|
if mech_type != TypesMech[SPNEGO_NTLMSSP_MECH]:
|
|
498
502
|
# reject this request by providing the NTLM mechanism
|
|
499
503
|
name = MechTypes.get(mech_type, "<unknown>")
|
|
500
|
-
self.logger.
|
|
504
|
+
self.logger.fail(
|
|
501
505
|
f"<{command_name}> Unsupported mechanism: {name} ({mech_type.hex()})"
|
|
502
506
|
)
|
|
503
507
|
|
|
@@ -523,7 +527,7 @@ class SMBHandler(BaseProtoHandler):
|
|
|
523
527
|
|
|
524
528
|
# NTLM authentication below
|
|
525
529
|
if len(token) < 8:
|
|
526
|
-
self.logger.
|
|
530
|
+
self.logger.fail(
|
|
527
531
|
f"<{command_name}> Invalid NTLM token length: {len(token)}"
|
|
528
532
|
)
|
|
529
533
|
raise BaseProtoHandler.TerminateConnection
|
|
@@ -559,7 +563,7 @@ class SMBHandler(BaseProtoHandler):
|
|
|
559
563
|
# shouldn't happen
|
|
560
564
|
if not is_gssapi:
|
|
561
565
|
self.log_client("NTLMSSP_CHALLENGE_MESSAGE", command_name)
|
|
562
|
-
self.logger.
|
|
566
|
+
self.logger.debug("NTLM challenge message not supported!")
|
|
563
567
|
raise BaseProtoHandler.TerminateConnection
|
|
564
568
|
|
|
565
569
|
case 0x03: # AUTHENTICATE
|
|
@@ -134,7 +134,7 @@ class UPnPHandler(BaseHTTPRequestHandler):
|
|
|
134
134
|
|
|
135
135
|
def do_GET(self):
|
|
136
136
|
self.logger.debug(f"Request for {self.path}", is_client=True)
|
|
137
|
-
user_agent = escape(self.headers
|
|
137
|
+
user_agent = escape(self.headers.get("User-Agent", "<no-user-agent>"))
|
|
138
138
|
if len(user_agent) > 50:
|
|
139
139
|
user_agent = user_agent[:47] + "..."
|
|
140
140
|
|
|
@@ -203,7 +203,10 @@ class UPnPServer(ThreadingHTTPServer):
|
|
|
203
203
|
return super().server_bind()
|
|
204
204
|
|
|
205
205
|
def finish_request(self, request, client_address) -> None:
|
|
206
|
-
|
|
206
|
+
try:
|
|
207
|
+
self.RequestHandlerClass(self.config, request, client_address, self)
|
|
208
|
+
except ConnectionError:
|
|
209
|
+
pass
|
|
207
210
|
|
|
208
211
|
def render(self, template, **kwargs):
|
|
209
212
|
return self.env.get_template(template).render(
|
|
@@ -229,14 +229,14 @@ class X11Handler(BaseProtoHandler):
|
|
|
229
229
|
ResponseTy = xConnSetupPrefixBE
|
|
230
230
|
endian_name = "BE"
|
|
231
231
|
case _:
|
|
232
|
-
return self.logger.
|
|
232
|
+
return self.logger.debug(
|
|
233
233
|
f"Unknown byteorder type in X11 request: '{data[0]:#x}'"
|
|
234
234
|
)
|
|
235
235
|
|
|
236
236
|
try:
|
|
237
237
|
request: RequestTy = py.unpack(RequestTy, data)
|
|
238
238
|
except Exception as e:
|
|
239
|
-
return self.logger.
|
|
239
|
+
return self.logger.debug(f"Invalid X11 request: {e}")
|
|
240
240
|
|
|
241
241
|
error_message = X_AUTH_MISSING
|
|
242
242
|
if request.authProto:
|
|
@@ -17,6 +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
|
+
import traceback
|
|
20
21
|
import pathlib
|
|
21
22
|
import socket
|
|
22
23
|
import socketserver
|
|
@@ -25,10 +26,12 @@ import struct
|
|
|
25
26
|
import abc
|
|
26
27
|
import ssl
|
|
27
28
|
|
|
29
|
+
from io import StringIO
|
|
28
30
|
from typing import Tuple
|
|
29
31
|
from socketserver import BaseRequestHandler
|
|
30
32
|
|
|
31
33
|
from dementor import database
|
|
34
|
+
from dementor.log import hexdump
|
|
32
35
|
from dementor.log.logger import ProtocolLoggerMixin, dm_logger
|
|
33
36
|
from dementor.log.stream import log_host
|
|
34
37
|
from dementor.config.session import SessionConfig
|
|
@@ -85,6 +88,7 @@ class BaseProtoHandler(BaseRequestHandler, ProtocolLoggerMixin):
|
|
|
85
88
|
pass
|
|
86
89
|
|
|
87
90
|
def handle(self) -> None:
|
|
91
|
+
data = None
|
|
88
92
|
try:
|
|
89
93
|
if isinstance(self.request, tuple):
|
|
90
94
|
data, transport = self.request
|
|
@@ -103,7 +107,17 @@ class BaseProtoHandler(BaseRequestHandler, ProtocolLoggerMixin):
|
|
|
103
107
|
if e.errno not in (32, 104): # EPIPE, ECONNRESET
|
|
104
108
|
self.logger.exception(e)
|
|
105
109
|
except Exception as e:
|
|
106
|
-
self.logger.
|
|
110
|
+
self.logger.fail(
|
|
111
|
+
f"Error handling request from client ({e.__class__.__name__}) "
|
|
112
|
+
+ "- use --debug|--verbose to see traceback"
|
|
113
|
+
)
|
|
114
|
+
out = StringIO()
|
|
115
|
+
traceback.print_exc(file=out)
|
|
116
|
+
data = data or b""
|
|
117
|
+
self.logger.debug(
|
|
118
|
+
f"Error while handling request. Traceback:\n{out.getvalue()}\n"
|
|
119
|
+
+ f"Client request:\n{hexdump.hexdump(data)}"
|
|
120
|
+
)
|
|
107
121
|
|
|
108
122
|
def recv(self, size: int) -> bytes:
|
|
109
123
|
if isinstance(self.request, tuple):
|
|
@@ -172,17 +172,24 @@ def parse_options(options: List[str]) -> dict:
|
|
|
172
172
|
for option in options:
|
|
173
173
|
key, raw_value = option.split("=", 1)
|
|
174
174
|
# Each definition is a key=value pair with an optional section prefix
|
|
175
|
+
section_dict = {}
|
|
175
176
|
if key.count(".") > 1:
|
|
176
|
-
|
|
177
|
-
|
|
177
|
+
# create missing sections
|
|
178
|
+
*sections, key = key.split(".")
|
|
179
|
+
current = result
|
|
180
|
+
for section in sections:
|
|
181
|
+
current = current.setdefault(section, {})
|
|
178
182
|
|
|
179
|
-
|
|
180
|
-
key = key.removesuffix("+")
|
|
181
|
-
if "." in key:
|
|
182
|
-
section, key = key.rsplit(".", 1)
|
|
183
|
+
section_dict = current
|
|
183
184
|
else:
|
|
184
|
-
|
|
185
|
+
if key.count(".") == 1:
|
|
186
|
+
section, key = key.rsplit(".", 1)
|
|
187
|
+
section_dict = result.setdefault(section, {})
|
|
188
|
+
else:
|
|
189
|
+
section_dict = result.setdefault("Dementor", {})
|
|
185
190
|
|
|
191
|
+
append_value = key.endswith("+")
|
|
192
|
+
key = key.removesuffix("+")
|
|
186
193
|
match raw_value.strip().lower():
|
|
187
194
|
case "true" | "on" | "yes":
|
|
188
195
|
value = True
|
|
@@ -202,15 +209,10 @@ def parse_options(options: List[str]) -> dict:
|
|
|
202
209
|
if value is None:
|
|
203
210
|
value = raw_value.removeprefix('"').removesuffix('"')
|
|
204
211
|
|
|
205
|
-
if section not in result:
|
|
206
|
-
result[section] = {}
|
|
207
|
-
|
|
208
212
|
if append_value:
|
|
209
|
-
|
|
210
|
-
result[section][key] = []
|
|
211
|
-
result[section][key].append(value)
|
|
213
|
+
section_dict.setdefault(key, []).append(value)
|
|
212
214
|
else:
|
|
213
|
-
|
|
215
|
+
section_dict[key] = value
|
|
214
216
|
return result
|
|
215
217
|
|
|
216
218
|
|
|
@@ -305,8 +307,11 @@ def main_print_options(session: SessionConfig, interface: str, config_path: str)
|
|
|
305
307
|
console.print("[bold]Configuration Paths:[/]")
|
|
306
308
|
console.print(main_format_config("DB Directory", f"{session.workspace_path}"))
|
|
307
309
|
console.print(main_format_config("Config Paths", f"[0] {config_paths[0]}"))
|
|
308
|
-
|
|
309
|
-
|
|
310
|
+
pos = 1
|
|
311
|
+
for extra_config_path in config_paths[1:]:
|
|
312
|
+
if pathlib.Path(extra_config_path).exists():
|
|
313
|
+
console.print(" " * 39 + f"[{pos}] {extra_config_path}")
|
|
314
|
+
pos += 1
|
|
310
315
|
|
|
311
316
|
console.rule(style="white", title="Log")
|
|
312
317
|
console.print()
|
|
@@ -397,10 +402,9 @@ def main(
|
|
|
397
402
|
if not quiet:
|
|
398
403
|
main_print_options(session, interface, config_path)
|
|
399
404
|
|
|
400
|
-
|
|
401
405
|
if not ignore_prompt and not analyze:
|
|
402
406
|
result = Prompt.ask(
|
|
403
|
-
"[bold red]CAUTION:[/bold red] [red] You are about to start Dementor in [i]attack[/]
|
|
407
|
+
"[bold red]CAUTION:[/bold red] [red] You are about to start Dementor in [i]attack[/] mode, "
|
|
404
408
|
+ "protentially breaking some network connections for certain devices temporarily. "
|
|
405
409
|
+ "\nAre you sure you want to continue? [/] (Y/n)",
|
|
406
410
|
choices=["y", "n", "Y", "N"],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dementor
|
|
3
|
-
Version: 1.0.0.
|
|
3
|
+
Version: 1.0.0.dev13
|
|
4
4
|
Summary: LLMNR/NBT-NS/mDNS Poisoner and rogue service provider
|
|
5
5
|
Author: MatrixEditor
|
|
6
6
|
Maintainer: MatrixEditor
|
|
@@ -114,3 +114,13 @@ Take a look at the [Documentation on GitHub-Pages](https://matrixeditor.github.i
|
|
|
114
114
|
## License
|
|
115
115
|
|
|
116
116
|
Distributed under the MIT License. See LICENSE for more information.
|
|
117
|
+
|
|
118
|
+
## Disclaimer
|
|
119
|
+
|
|
120
|
+
**Dementor** is intended only for lawful educational purposes: learning, testing
|
|
121
|
+
in your own lab, or assessments on systems where you have explicit written
|
|
122
|
+
authorization. You agree not to use this software to access, damage, interfere
|
|
123
|
+
with, or exfiltrate data from systems for which you do not have permission.
|
|
124
|
+
We make no promises about safety, completeness, or fitness for any purpose. Use
|
|
125
|
+
at your own risk. If you discover a vulnerability, please follow responsible
|
|
126
|
+
disclosure by using the private disclosing feature offered by GitHub.
|
|
@@ -55,4 +55,14 @@ Take a look at the [Documentation on GitHub-Pages](https://matrixeditor.github.i
|
|
|
55
55
|
|
|
56
56
|
## License
|
|
57
57
|
|
|
58
|
-
Distributed under the MIT License. See LICENSE for more information.
|
|
58
|
+
Distributed under the MIT License. See LICENSE for more information.
|
|
59
|
+
|
|
60
|
+
## Disclaimer
|
|
61
|
+
|
|
62
|
+
**Dementor** is intended only for lawful educational purposes: learning, testing
|
|
63
|
+
in your own lab, or assessments on systems where you have explicit written
|
|
64
|
+
authorization. You agree not to use this software to access, damage, interfere
|
|
65
|
+
with, or exfiltrate data from systems for which you do not have permission.
|
|
66
|
+
We make no promises about safety, completeness, or fitness for any purpose. Use
|
|
67
|
+
at your own risk. If you discover a vulnerability, please follow responsible
|
|
68
|
+
disclosure by using the private disclosing feature offered by GitHub.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -166,8 +166,8 @@ class POP3Handler(BaseProtoHandler):
|
|
|
166
166
|
# The POP3 session is now in the AUTHORIZATION state. The client must
|
|
167
167
|
# now identify and authenticate itself to the POP3 server.
|
|
168
168
|
while line := self.rfile.readline(1024):
|
|
169
|
-
line = line.decode("utf-8", errors="replace").strip()
|
|
170
169
|
self.logger.debug(repr(line), is_client=True)
|
|
170
|
+
line = line.decode("utf-8", errors="replace").strip()
|
|
171
171
|
|
|
172
172
|
args = line.split(" ")
|
|
173
173
|
if len(args) > 0:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|