Skip to content

Commit

Permalink
Merge pull request #615 from SuCicada/master
Browse files Browse the repository at this point in the history
fix: add parse_xml in rdpmanager
  • Loading branch information
AlessandroZ authored Apr 11, 2023
2 parents 0938b34 + 44c53da commit 8c9f962
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions Windows/lazagne/softwares/sysadmin/rdpmanager.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
import base64

from xml.etree.cElementTree import ElementTree
Expand All @@ -17,7 +17,8 @@ def __init__(self):
def decrypt_password(self, encrypted_password):
try:
decoded = base64.b64decode(encrypted_password)
password_decrypted_bytes = Win32CryptUnprotectData(decoded, is_current_user=constant.is_current_user, user_dpapi=constant.user_dpapi)
password_decrypted_bytes = Win32CryptUnprotectData(decoded, is_current_user=constant.is_current_user,
user_dpapi=constant.user_dpapi)
password_decrypted = password_decrypted_bytes.decode("utf-8")
password_decrypted = password_decrypted.replace('\x00', '')
except Exception:
Expand Down Expand Up @@ -95,3 +96,32 @@ def run(self):
pass

return pwd_found

def parse_xml(self, xml_file):
import xml.etree.ElementTree as ET
tree = ET.parse(xml_file)
root = tree.getroot()
res = []
for server in root.findall('.//server'):
# get the name element
host = None
username = None
password = None

hostTag = server.find('properties/name')
if hostTag is not None:
host = hostTag.text

# get the username and password elements
usernameTag = server.find('logonCredentials/userName')
if usernameTag is not None:
username = usernameTag.text
passwordTag = server.find('logonCredentials/password')
if passwordTag is not None:
password = passwordTag.text
password = self.decrypt_password(password)

# print the results
print(f"host: {host}, Username: {username}, Password: {password}")
res += [{'URL': host, 'Login': username, 'Password': password}]
return res

0 comments on commit 8c9f962

Please sign in to comment.