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
9 changes: 7 additions & 2 deletions implants/imix/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,20 @@ impl<T: Transport + 'static> Agent<T> {
// Report output from each handle
let mut idx = 0;
while idx < self.handles.len() {
// Report task output
// Moving this before the if even though it double reports.
// Seems to resolve an issue with IO blocked and fast tasks
// running at the same time.
// https://github.com/spellshift/realm/issues/754
self.handles[idx].report(&mut tavern).await?;

// Drop any handles that have completed
if self.handles[idx].is_finished() {
let mut handle = self.handles.remove(idx);
handle.report(&mut tavern).await?;
continue;
}

// Otherwise report and increment
self.handles[idx].report(&mut tavern).await?;
idx += 1;
}

Expand Down
1 change: 0 additions & 1 deletion tavern/tomes/arp_scan/main.eldritch
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ def arp_scan():
res = pivot.arp_scan(all_ips)
print(res)

time.sleep(1)
arp_scan()
4 changes: 3 additions & 1 deletion tavern/tomes/file_list/main.eldritch
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ name = {
"Link": "Link"
}


def print_file(f):
"""Pretty Print a file"""
perms = f['permissions']
Expand All @@ -18,6 +19,7 @@ def print_file(f):

print(f"{perms}\t{owner}\t{group}\t{size}\t{modified}\t{ftype}\t{absolute_path}")


def file_list(path):
res = file.list(path)
if len(res) > 0:
Expand All @@ -26,5 +28,5 @@ def file_list(path):
else:
eprint(f"No files found at '{path}'")

time.sleep(1)

file_list(input_params['path'])
2 changes: 1 addition & 1 deletion tavern/tomes/file_mkdir/main.eldritch
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ def main():
return
file.mkdir(new_dir, parent)

time.sleep(1)

main()
22 changes: 12 additions & 10 deletions tavern/tomes/file_tree/main.eldritch
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
block_list = ["/proc","/sys","/lib","/libx32","/lib32","/lib64","/boot","/srv","/usr","/snap","/run","/dev","/cores"]
block_list = ["/proc", "/sys", "/lib", "/libx32", "/lib32", "/lib64",
"/boot", "/srv", "/usr", "/snap", "/run", "/dev", "/cores"]


def file_list(path,tree):
tree=f"|\t{tree}"
def file_list(path, tree):
tree = f"|\t{tree}"
files = file.list(path)
for f in files:
file_name = f['file_name']
Expand All @@ -11,26 +12,27 @@ def file_list(path,tree):
continue
if f['type'] == "Directory":
print(f"{tree}|---{path}/{file_name}")
file_list(f"{path}/{file_name}",tree)
file_list(f"{path}/{file_name}", tree)
if f['type'] == "Link":
print(f"{tree}|---{file_name}")
if f['type'] == "File":
print(f"{tree}|---{file_name}")


def main(path):
tree=""
tree = ""
if file.is_dir(path):
print(path+"")
if path == "/":
print("It looks like you're trying to list every file on the system.")
print("This generates a lot of data so I'm going to exclude less helpful directories")
print("If you really really want everything including /proc and /sys specify \"//\"")
file_list(path,tree)
print(
"This generates a lot of data so I'm going to exclude less helpful directories")
print(
"If you really really want everything including /proc and /sys specify \"//\"")
file_list(path, tree)
elif file.is_file(path):
eprint(f"Error: Invalid Path ({path})")

time.sleep(1)

input_params['path']="/"
main(input_params['path'])
print("")
7 changes: 4 additions & 3 deletions tavern/tomes/file_write/main.eldritch
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ def main():

# if file parent directory does not exist, error and exit.
if not file.exists(new_file_parent_dir):
eprint(f"[ERROR] Parent Directory for File does not exist at path: '{new_file_path}'.")
eprint(
f"[ERROR] Parent Directory for File does not exist at path: '{new_file_path}'.")
eprint(f"[ERROR] Exiting...")
return

# if file exists, remove it.
if file.exists(new_file_path):
print("[INFO] File was detected at the path before write. Trying to remove the file...")
print(
"[INFO] File was detected at the path before write. Trying to remove the file...")
file.remove(new_file_path)
print("[INFO] File was successfully removed!")

Expand All @@ -22,6 +24,5 @@ def main():
# Print a Success!
print(f"[INFO] The file '{new_file_path}' was successfully written!")

time.sleep(1)

main()
1 change: 0 additions & 1 deletion tavern/tomes/get_env/main.eldritch
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ def get_env():

return

time.sleep(1)

get_env()
4 changes: 2 additions & 2 deletions tavern/tomes/get_net_info/main.eldritch
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ def print_table(rows: list[list]):
row.append(rpad(c, counts[i]+2))
print("".join(row))


def ifconfig():
print("HOSTNAME "+ sys.hostname())
print("HOSTNAME " + sys.hostname())
rows = [["IFACE", "IP", "MAC"]]
ip_res = sys.get_ip()
for interface in ip_res:
for ip in interface['ips']:
rows.append([interface['name'], ip, interface['mac']])
print_table(rows)

time.sleep(1)

ifconfig()
4 changes: 2 additions & 2 deletions tavern/tomes/get_registry/main.eldritch
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ def pad_key(key, max_len):
res = key+" "*(max_len-len(key))
return res


def get_registry(hive, path):
res = sys.get_reg(hive, path)
key_lengths = [len(i) for i in res.keys()]
Expand All @@ -10,10 +11,9 @@ def get_registry(hive, path):
max_len = max(key_lengths)
for k in res:
v = res[k]
pk = pad_key(k,max_len)
pk = pad_key(k, max_len)
print(f"{pk} : {v}")

time.sleep(1)

get_registry(input_params['hive'], input_params['path'])
print()
1 change: 0 additions & 1 deletion tavern/tomes/kill_process/main.eldritch
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
process.kill(int(input_params['pid']))
time.sleep(1)
print("")
2 changes: 0 additions & 2 deletions tavern/tomes/netstat/main.eldritch
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,4 @@ def netstat():
print_table(rows)


time.sleep(1)

netstat()
6 changes: 3 additions & 3 deletions tavern/tomes/process_info/main.eldritch
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ def process_info(pid):
for nested_value in value.split(" "):
print("\t- {}".format(nested_value))
elif key == "environ":
print("env_variables=")
for nested_value in value.split(","):
print("env_variables=")
for nested_value in value.split(","):
print("\t- {}".format(nested_value))
else:
print("{}={}".format(key, value))

time.sleep(1)

process_info(int(input_params['pid']))
print("")
7 changes: 4 additions & 3 deletions tavern/tomes/process_list/main.eldritch
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ def print_table(rows: list[list]):
row.append(rpad(c, counts[i]+2))
print("".join(row))


def process_list(cmd_substring):

if cmd_substring == '*':
cmd_substring = ''

procs = process.list()

rows = [["PID", "PPID", "USER","COMMAND"]]
rows = [["PID", "PPID", "USER", "COMMAND"]]
for proc in procs:
if cmd_substring in proc['command']:
current_proc_command = proc['command']
Expand All @@ -33,11 +34,11 @@ def process_list(cmd_substring):
str(proc['pid']),
str(proc['ppid']),
proc['username'],
current_proc_command.replace("\n","\\n")
current_proc_command.replace("\n", "\\n")
])

print_table(rows)

time.sleep(1)

process_list(input_params['cmd_substring'])
print("")
37 changes: 20 additions & 17 deletions tavern/tomes/process_tree/main.eldritch
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
def pad_pid(pid):
pid_column_width = 16
padding = pid_column_width - len(pid)
return pid + " "*padding
return pid + " "*padding

def pad_username (username):

def pad_username(username):
username_column_width = 32
padding = username_column_width - len(username)
return username + " "*padding
return username + " "*padding


def depth_first_search(visited, process_tree, current_proc_pid, padding, process_list_dictionary):
if current_proc_pid not in visited:
Expand All @@ -18,27 +20,29 @@ def depth_first_search(visited, process_tree, current_proc_pid, padding, process

if current_proc_pid != "0" and current_proc_pid in process_list_dictionary:
print(
pad_pid(current_proc_pid) +\
pad_pid(process_list_dictionary[current_proc_pid]["ppid"]) +\
pad_username(process_list_dictionary[current_proc_pid]["username"]) +\
padding_string + process_list_dictionary[current_proc_pid]["command"].replace("\n","\\n")
pad_pid(current_proc_pid) +
pad_pid(process_list_dictionary[current_proc_pid]["ppid"]) +
pad_username(process_list_dictionary[current_proc_pid]["username"]) +
padding_string +
process_list_dictionary[current_proc_pid]["command"].replace(
"\n", "\\n")
)
else:
print(
pad_pid(current_proc_pid) +\
pad_pid("???") +\
pad_username("???") +\
padding_string + "???".replace("\n","\\n")
pad_pid(current_proc_pid) +
pad_pid("???") +
pad_username("???") +
padding_string + "???".replace("\n", "\\n")
)



padding = padding + 1

visited.append(current_proc_pid)

for process_pid in process_tree[current_proc_pid]:
depth_first_search(visited, process_tree, process_pid, padding, process_list_dictionary)
depth_first_search(visited, process_tree,
process_pid, padding, process_list_dictionary)


def process_tree(cmd_substring):

Expand Down Expand Up @@ -79,10 +83,9 @@ def process_tree(cmd_substring):
process_tree[current_proc_ppid] = []
visited = []
for pid in process_tree:
depth_first_search(visited, process_tree, pid, 0, process_list_dictionary)
depth_first_search(visited, process_tree, pid,
0, process_list_dictionary)

time.sleep(1)

process_tree(input_params['cmd_substring'])
print("")

2 changes: 0 additions & 2 deletions tavern/tomes/remove_file/main.eldritch
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
file.remove(input_params['path'])
print("")

time.sleep(1)
2 changes: 1 addition & 1 deletion tavern/tomes/shell_cmd/main.eldritch
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ def shell_cmd(cmd):
print("stderr:", res['stderr'])
print("status:", res['status'])

time.sleep(1)

shell_cmd(input_params['cmd'])
print("")
Loading