Skip to content

Commit

Permalink
Add SSH module (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zawadidone authored Jul 18, 2023
1 parent 5dfee08 commit e97f1eb
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions acquire/acquire.py
Original file line number Diff line number Diff line change
Expand Up @@ -1330,6 +1330,7 @@ class Boot(Module):
@register_module("--home")
class Home(Module):
SPEC = [
# TODO: Use from_user_home if supported for osx
("glob", "/root/.*[akz]sh*"),
("dir", "/root/.config"),
("glob", "/home/*/.*[akz]sh*"),
Expand All @@ -1338,6 +1339,7 @@ class Home(Module):
("glob", "/home/*/*/.config"),
# OS-X home (aka /Users)
("glob", "/Users/*/.*[akz]sh*"),
("glob", "/Users/*/.config"),
("glob", "/Users/*/.bash_sessions/*"),
("glob", "/Users/*/Library/LaunchAgents/*"),
("glob", "/Users/*/Library/Logs/*"),
Expand All @@ -1346,6 +1348,36 @@ class Home(Module):
]


@register_module("--ssh")
class SSH(Module):
@classmethod
def _run(cls, target: Target, collector):
user_pattern = ".ssh/*"

# Gather user paths
# TODO: Use from_user_home if supported for osx
if target._os.os == "osx":
iterator = [f"/Users/*/{user_pattern}"]
else:
iterator = list(from_user_home(target, user_pattern))

# Acquire SSH configuration in sshd directories
iterator += ["/etc/ssh/*", "sysvol/ProgramData/ssh/*"]

globbed_path = (path for pattern in iterator for path in target.fs.glob(pattern))
for path in globbed_path:
if target.fs.path(path).is_dir():
collector.collect_dir(path)
continue

with target.fs.path(path).open("rt") as file:
if "PRIVATE KEY" in file.readline():
# Detected a private key, skipping.
continue

collector.collect_file(path, outpath=path)


@register_module("--var")
class Var(Module):
SPEC = [
Expand Down Expand Up @@ -1919,17 +1951,20 @@ def upload_files(
QuarantinedFiles,
RemoteAccess,
WindowsNotifications,
SSH,
],
"linux": [
Etc,
Boot,
Home,
History,
SSH,
Var,
],
"bsd": [
Etc,
Boot,
SSH,
Home,
Var,
BSD,
Expand All @@ -1938,13 +1973,15 @@ def upload_files(
Bootbanks,
ESXi,
VMFS,
SSH,
],
"osx": [
Etc,
Home,
Var,
OSX,
History,
SSH,
],
},
"default": {
Expand Down Expand Up @@ -1975,19 +2012,22 @@ def upload_files(
Etc,
Boot,
Home,
SSH,
Var,
],
"bsd": [
Etc,
Boot,
Home,
SSH,
Var,
BSD,
],
"esxi": [
Bootbanks,
ESXi,
VMFS,
SSH,
],
"osx": [
Etc,
Expand All @@ -2012,18 +2052,21 @@ def upload_files(
Etc,
Boot,
Home,
SSH,
Var,
],
"bsd": [
Etc,
Boot,
Home,
SSH,
Var,
BSD,
],
"esxi": [
Bootbanks,
ESXi,
SSH,
],
"osx": [
Etc,
Expand Down

0 comments on commit e97f1eb

Please sign in to comment.