dementor 1.0.0.dev14__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.
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/PKG-INFO +16 -11
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/README.md +16 -10
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/__init__.py +1 -1
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/assets/Dementor.toml +11 -2
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/db/connector.py +15 -2
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/filters.py +1 -1
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/log/logger.py +25 -4
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/paths.py +5 -1
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/protocols/ldap.py +1 -1
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/protocols/netbios.py +9 -3
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/protocols/smb.py +50 -8
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/standalone.py +48 -4
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor.egg-info/PKG-INFO +16 -11
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/docs/README.pypi.md +15 -10
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/pyproject.toml +1 -1
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/LICENSE +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/__main__.py +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/assets/banner.txt +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/assets/www/error_page.html +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/assets/www/upnp-default/dd.xml +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/assets/www/upnp-default/present.html +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/assets/www/upnp-default/scpd.xml +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/assets/www/wpad.dat +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/config/__init__.py +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/config/attr.py +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/config/session.py +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/config/toml.py +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/config/util.py +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/db/__init__.py +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/db/model.py +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/loader.py +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/log/__init__.py +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/log/hexdump.py +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/log/stream.py +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/protocols/__init__.py +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/protocols/ftp.py +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/protocols/http.py +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/protocols/imap.py +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/protocols/ipp.py +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/protocols/kerberos.py +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/protocols/llmnr.py +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/protocols/mdns.py +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/protocols/msrpc/__init__.py +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/protocols/msrpc/dcom.py +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/protocols/msrpc/epm.py +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/protocols/msrpc/rpc.py +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/protocols/msrpc.py +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/protocols/mssql.py +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/protocols/mysql.py +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/protocols/ntlm.py +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/protocols/pop3.py +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/protocols/quic.py +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/protocols/smtp.py +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/protocols/spnego.py +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/protocols/ssdp.py +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/protocols/upnp.py +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/protocols/x11.py +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor/servers.py +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor.egg-info/SOURCES.txt +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor.egg-info/dependency_links.txt +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor.egg-info/entry_points.txt +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor.egg-info/requires.txt +0 -0
- {dementor-1.0.0.dev14 → dementor-1.0.0.dev16}/dementor.egg-info/top_level.txt +0 -0
- {dementor-1.0.0.dev14 → 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.
|
|
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
|
-
│
|
|
100
|
-
│
|
|
101
|
-
│
|
|
102
|
-
│
|
|
103
|
-
│
|
|
104
|
-
│
|
|
105
|
-
│
|
|
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
|
-
│
|
|
43
|
-
│
|
|
44
|
-
│
|
|
45
|
-
│
|
|
46
|
-
│
|
|
47
|
-
│
|
|
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
|
|
@@ -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
|
-
# -
|
|
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
|
-
|
|
@@ -17,7 +17,8 @@
|
|
|
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
|
-
|
|
20
|
+
# pyright: reportUninitializedInstanceVariable=false
|
|
21
|
+
import typing
|
|
21
22
|
from sqlalchemy import Engine, create_engine
|
|
22
23
|
|
|
23
24
|
from dementor.config.session import SessionConfig
|
|
@@ -36,6 +37,13 @@ class DatabaseConfig(TomlConfig):
|
|
|
36
37
|
A("db_driver", "Driver", None),
|
|
37
38
|
]
|
|
38
39
|
|
|
40
|
+
if typing.TYPE_CHECKING:
|
|
41
|
+
db_raw_path: str | None
|
|
42
|
+
db_path: str
|
|
43
|
+
db_duplicate_creds: bool
|
|
44
|
+
db_dialect: str | None
|
|
45
|
+
db_driver: str | None
|
|
46
|
+
|
|
39
47
|
|
|
40
48
|
def init_dementor_db(session: SessionConfig) -> Engine | None:
|
|
41
49
|
engine = init_engine(session)
|
|
@@ -57,7 +65,12 @@ def init_engine(session: SessionConfig) -> Engine | None:
|
|
|
57
65
|
|
|
58
66
|
if dialect == "sqlite":
|
|
59
67
|
if path != ":memory:":
|
|
60
|
-
|
|
68
|
+
real_path = session.resolve_path(path)
|
|
69
|
+
if not real_path.parent.exists():
|
|
70
|
+
dm_logger.debug(f"Creating database directory {real_path.parent}")
|
|
71
|
+
real_path.parent.mkdir(parents=True, exist_ok=True)
|
|
72
|
+
|
|
73
|
+
path = f"/{real_path}"
|
|
61
74
|
|
|
62
75
|
# see https://docs.sqlalchemy.org/en/20/core/engines.html#database-urls
|
|
63
76
|
raw_path = f"{dialect}+{driver}://{path}"
|
|
@@ -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("
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
218
|
+
try:
|
|
219
|
+
datagram = netbios.NBTDatagram(data)
|
|
217
220
|
|
|
218
|
-
|
|
219
|
-
|
|
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(
|
|
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,
|
|
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
|
-
|
|
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
|
|
@@ -71,6 +71,8 @@ def serve(
|
|
|
71
71
|
if session is None:
|
|
72
72
|
session = SessionConfig()
|
|
73
73
|
|
|
74
|
+
workspace_path = pathlib.Path(session.workspace_path)
|
|
75
|
+
workspace_path.mkdir(parents=True, exist_ok=True)
|
|
74
76
|
logger.init()
|
|
75
77
|
logger.ProtocolLogger.init_logfile(session)
|
|
76
78
|
log_stream.init_streams(session)
|
|
@@ -333,7 +335,7 @@ def main(
|
|
|
333
335
|
metavar="NAME",
|
|
334
336
|
help="Network interface to use (required for poisoning)",
|
|
335
337
|
),
|
|
336
|
-
],
|
|
338
|
+
] = None,
|
|
337
339
|
analyze: Annotated[
|
|
338
340
|
bool,
|
|
339
341
|
typer.Option(
|
|
@@ -394,14 +396,54 @@ def main(
|
|
|
394
396
|
quiet: Annotated[
|
|
395
397
|
bool,
|
|
396
398
|
typer.Option(
|
|
397
|
-
"--quiet",
|
|
399
|
+
"--quiet",
|
|
400
|
+
"-q",
|
|
401
|
+
help="Don't print banner at startup",
|
|
402
|
+
show_default=False,
|
|
403
|
+
),
|
|
404
|
+
] = False,
|
|
405
|
+
version: Annotated[
|
|
406
|
+
bool,
|
|
407
|
+
typer.Option(
|
|
408
|
+
"--version",
|
|
409
|
+
help="Show Dementor's version number",
|
|
410
|
+
show_default=False,
|
|
398
411
|
),
|
|
399
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,
|
|
400
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
|
+
|
|
401
435
|
main_print_banner(quiet)
|
|
436
|
+
if version:
|
|
437
|
+
return
|
|
402
438
|
|
|
403
439
|
# prepare options
|
|
404
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
|
+
|
|
405
447
|
if config_path:
|
|
406
448
|
try:
|
|
407
449
|
config.init_from_file(config_path)
|
|
@@ -436,8 +478,10 @@ def main(
|
|
|
436
478
|
loader = ProtocolLoader()
|
|
437
479
|
session = SessionConfig()
|
|
438
480
|
session.analysis = analyze
|
|
439
|
-
|
|
481
|
+
workspace_path = pathlib.Path(session.workspace_path)
|
|
482
|
+
workspace_path.mkdir(parents=True, exist_ok=True)
|
|
440
483
|
|
|
484
|
+
session.protocols = loader.get_protocols(session)
|
|
441
485
|
if not quiet:
|
|
442
486
|
main_print_options(session, interface, config_path)
|
|
443
487
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dementor
|
|
3
|
-
Version: 1.0.0.
|
|
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
|
-
│
|
|
100
|
-
│
|
|
101
|
-
│
|
|
102
|
-
│
|
|
103
|
-
│
|
|
104
|
-
│
|
|
105
|
-
│
|
|
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
|
-
│
|
|
42
|
-
│
|
|
43
|
-
│
|
|
44
|
-
│
|
|
45
|
-
│
|
|
46
|
-
│
|
|
47
|
-
│
|
|
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?
|
|
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
|
|
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
|