Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dementor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

__version__ = "1.0.0.dev24"
__version__ = "1.0.0.dev25"
__author__ = "MatrixEditor"
3 changes: 2 additions & 1 deletion dementor/assets/Dementor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1201,8 +1201,9 @@ PresentationUri = "/present.html"
[Log]

# Enable logging output to a file
# Changed in v1.0.0.dev25 - now enabled by default

Enabled = false
Enabled = true

# Specify custom log directory under the current workspace

Expand Down
18 changes: 9 additions & 9 deletions dementor/assets/banner.txt

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions dementor/config/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,10 @@ def __getitem__(self, key: str) -> Any:
def set_interface(self, interface: str) -> None:
self.interface = interface
self.ipv4 = get_if_addr(self.interface)
self.ipv6 = next(
(ip[0] for ip in in6_getifaddr() if ip[2] == self.interface),
None,
)
try:
self.ipv6 = next(
(ip[0] for ip in in6_getifaddr() if ip[2] == self.interface),
None,
)
except Exception:
self.ipv6 = None # see issue #40
9 changes: 2 additions & 7 deletions dementor/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import sys
import glob
import pathlib
import warnings
import fnmatch

from typing import Any

Expand Down Expand Up @@ -63,12 +63,7 @@ def __init__(self, target: str, extra: dict[str, Any] | None = None) -> None:
self.target = self.target[2:]
# glob.translate is only available since 3.13
if (sys.version_info.major, sys.version_info.minor) < (3, 13):
warnings.warn(
"glob.translate is only available since 3.13, "
+ "using basic-string instead",
stacklevel=2,
)
self.pattern = None
self.pattern = re.compile(fnmatch.translate(self.target))
else:
self.pattern = re.compile(glob.translate(self.target))
else:
Expand Down
5 changes: 4 additions & 1 deletion dementor/log/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,10 @@ def add_logfile(self, log_file_path: str) -> None:

handler.setFormatter(formatter)
self.logger.addHandler(handler)
self.logger.info(f"Created log file handler for {log_file_path}")
self.success(
f"Logging session to {log_file_path}", host=" ", port=" ", protocol="LOG"
)
# self.logger.info(f"Created log file handler for {log_file_path}")

@staticmethod
def init_logfile(session: SessionConfig) -> None:
Expand Down
18 changes: 15 additions & 3 deletions dementor/log/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,12 @@ def __init__(self, path: str | Path, config: HostsStreamConfig) -> None:
self.hosts: set[str] = set()
self.ipv4: bool = config.log_ipv4
self.ipv6: bool = config.log_ipv6
dm_logger.info(f"Logging host IPs to {path} (IPv4={self.ipv4}, IPv6={self.ipv6})")
dm_logger.success(
f"Logging host IPs to {path} (IPv4={self.ipv4}, IPv6={self.ipv6})",
host=" ",
port=" ",
protocol="LOG",
)

@override
def add(self, **kwargs: Any) -> None:
Expand Down Expand Up @@ -259,7 +264,9 @@ def __init__(self, path: str | Path, config: DNSNamesStreamConfig) -> None:
"""
super().__init__(path, config)
self.hosts: dict[str, set[str]] = defaultdict(set)
dm_logger.info(f"Logging DNS names to {path}")
dm_logger.success(
f"Logging DNS names to {path}", host=" ", port=" ", protocol="LOG"
)

@override
def add(self, **kwargs: Any) -> None:
Expand Down Expand Up @@ -325,7 +332,12 @@ def __init__(self, path: str | Path, config: HashesStreamConfig) -> None:
super().__init__(path if not config.split else "/dev/null", config)
self.path: Path = Path(path)
self.start_time: str = util.now()
dm_logger.info(f"Logging hashes to {path} (split files: {config.split})")
dm_logger.success(
f"Logging hashes to {path} (split files: {config.split})",
host=" ",
port=" ",
protocol="LOG",
)

@override
def add(self, **kwargs: Any) -> None:
Expand Down
16 changes: 4 additions & 12 deletions dementor/protocols/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,11 @@ def set_proxy_script(

path = pathlib.Path(script["file"])
if not path.exists() or not path.is_file():
dm_logger.error(
f"WPAD script at {path} does not exist - ignoring..."
)
dm_logger.error(f"WPAD script at {path} does not exist - ignoring...")
return

if not path.is_file():
dm_logger.error(
f"WPAD script at {path} is not a file - ignoring..."
)
dm_logger.error(f"WPAD script at {path} is not a file - ignoring...")
return

self.proxy_script = path.read_text()
Expand Down Expand Up @@ -341,9 +337,7 @@ def version_string(self) -> str:
def log_message(self, format: str, *args) -> None:
# let us log mssages
text = format % args
msg = text.translate(
self._control_char_table
) # ty:ignore[unresolved-attribute]
msg = text.translate(self._control_char_table) # ty:ignore[unresolved-attribute]
self.logger.debug(msg)

def send_response(self, code: int, message: str | None = None) -> None:
Expand Down Expand Up @@ -514,9 +508,7 @@ def auth_ntlm(

case _:
logger.fail(f"Invalid negotiate authentication: {token}")
self.send_error(
HTTPStatus.INTERNAL_SERVER_ERROR, "Internal Server Error"
)
self.send_error(HTTPStatus.INTERNAL_SERVER_ERROR, "Internal Server Error")

def auth_bearer(self, token: str, logger: "ProtocolLogger") -> None:
self.display_request("Bearer", logger)
Expand Down
Loading
Loading