Skip to main content

WebClientServiceIPScanner.py

This script works with webclientservicescanner and lets you scan a whole list of systems (from a text file). This is handy for when you don't want to scan huge subnet ranges and already have a list of IPs/hosts you want to scan.

The script will prompt you for domain, user, password, input text file and a file to dump results to.

import subprocess

# Prompt for user inputs
domain = input("Enter the domain name: ")
username = input("Enter the username: ")
password = input("Enter the password: ")
input_file = input("Enter the path to the input file containing hostnames: ")
output_file = input("Enter the path to the output file: ")

# Read the hostnames from the input file
with open(input_file, 'r') as file:
hostnames = [line.strip() for line in file.readlines()]

# Open the output file for writing
with open(output_file, 'w') as outfile:
for hostname in hostnames:
command = f"webclientservicescanner {domain}/{username}:'{password}'@{hostname}"
print(f"Running command for {hostname}...")
outfile.write(f"Results for {hostname}:\n")
try:
result = subprocess.run(command, shell=True, capture_output=True, text=True, check=True)
# Print and write the output to the file
print(result.stdout)
outfile.write(result.stdout)
except subprocess.CalledProcessError as e:
# Print and write the error to the file
print(e.stderr)
outfile.write(e.stderr)
print("-" * 50)
outfile.write("\n" + "-"*50 + "\n")

After you get your output file written, do a little awk magic to extract just the hostnames (alphbetized) of the machines running WebClient service:

grep "RUNNING" output.txt | awk -F '[][]' '{print $2}' | sort > webclient-running.txt