Skip to main content

Merge Active Directory computer description + WebClient status

This script takes output from a netexec WebClient scan, and then lets you take a list of list of machines and their descriptions from another file like from jq output of machine names + descriptions and then merge them together.

# Ask for the input and output file names
output_file_name = input("Enter the name of the output file (e.g., output.txt): ")
runningwebdav_file_name = input("Enter the name of the runningwebdav file (e.g., runningwebdav.txt): ")
merged_file_name = input("Enter the name of the merged output file (e.g., merged.txt): ")

# Read the output file into a dictionary
with open(output_file_name, 'r') as output_file:
output_data = {}
for line in output_file:
host, description = line.strip().split(',', 1)
output_data[host] = description

# Create a list to store the matching hosts and descriptions
matching_entries = []

# Read the runningwebdav file and find matches
with open(runningwebdav_file_name, 'r') as runningwebdav_file:
for line in runningwebdav_file:
host, ip = line.strip().split(',', 1)
if host in output_data:
matching_entries.append((host, output_data[host]))

# Sort the list by the host field (index 0)
matching_entries.sort(key=lambda x: x[0])

# Write the sorted entries to the merged output file
with open(merged_file_name, 'w') as merged_file:
for host, description in matching_entries:
merged_file.write(f"{host},{description}\n")