Skip to content
Open
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
22 changes: 15 additions & 7 deletions dissect/target/plugins/os/unix/log/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,22 @@ def parse(cls, message: str) -> dict[str, str | int]:
additional_fields["port"] = int(port.group(1))
if user := cls.RE_USER.search(message):
additional_fields["user"] = user.group(1)
# Accepted publickey for test_user from 8.8.8.8 IP port 12345 ssh2: RSA SHA256:123456789asdfghjklertzuio

if "Accepted publickey" in message:
ssh_protocol, encryption_algo, key_info = message.split()[-3:]
hash_algo, key_hash = key_info.split(":")
additional_fields["ssh_protocol"] = ssh_protocol.strip(":")
additional_fields["encryption_algorithm"] = encryption_algo
additional_fields["hash_algorithm"] = hash_algo
additional_fields["key_hash"] = key_hash
try:
# Accepted publickey for test_user from 8.8.8.8 IP port 12345 ssh2: RSA SHA256:123456789asdfghjklertzuio
if message.split()[-3].endswith(":"):
ssh_protocol, encryption_algo, key_info = message.split()[-3:]
hash_algo, key_hash = key_info.split(":")
additional_fields["ssh_protocol"] = ssh_protocol.strip(":")
additional_fields["encryption_algorithm"] = encryption_algo
additional_fields["hash_algorithm"] = hash_algo
additional_fields["key_hash"] = key_hash
# Accepted publickey for test_user from 8.8.8.8 IP port 12345 ssh2
else:
additional_fields["ssh_protocol"] = message.split()[-1]
except ValueError:
pass
if (failed := "Failed" in message) or "Accepted" in message:
action_type = "failed" if failed else "accepted"
additional_fields["action"] = f"{action_type} authentication"
Expand Down
4 changes: 2 additions & 2 deletions tests/_data/plugins/os/unix/log/auth/auth.log
Git LFS file not shown