Jun-19-2018, 02:10 PM
I am facing to a problem, there aren't many sources on the web...
I want to access to the Windows registry of a remote machine. I use the winreg module, but it seems that it doesn't support Active Directory domains.
I found the wmi module, but I don't think it can be very useful.
Have you any idea to gain access to the registry of a remote computer ? Thanks :)
Regards (and sorry for my poor english, I am a f*ckin' french)
Here is my code :
I want to access to the Windows registry of a remote machine. I use the winreg module, but it seems that it doesn't support Active Directory domains.
I found the wmi module, but I don't think it can be very useful.
Have you any idea to gain access to the registry of a remote computer ? Thanks :)
Regards (and sorry for my poor english, I am a f*ckin' french)
Here is my code :
import winreg, hashlib sList = {} ; mList = {}; print() print(" $$\\" + "\n $$ |" + "\n$$$$$$$\\ $$$$$$\\ $$$$$$\\ $$$$$$\\ $$$$$$\\ $$$$$$\\" + "\n$$ __$$\\ $$ __$$\\\\_$$ _| $$ __$$\\ $$ __$$\\ $$ __$$\\" + "\n$$ | $$ |$$$$$$$$ | $$ | $$ | \\__|$$$$$$$$ |$$ / $$ |" + "\n$$ | $$ |$$ ____| $$ |$$\\ $$ | $$ ____|$$ | $$ |" + "\n$$ | $$ |\\$$$$$$$\\ \\$$$$ |$$ | \\$$$$$$$\\ \\$$$$$$$ |" + "\n\__| \\__| \\_______| \\____/ \\__| v1.0 \\_______| \\____$$ |" + "\n $$\\ $$ |" + "\n kwnow softs on your network machines \\$$$$$$ |" + "\n \\______/") print() print("Ce script Python a été développé dans le cadre d'un stage" + "\nau groupe Hospi Grand Ouest (HGO). Il est toutefois adaptable." + "\n\nIl a pour but de rechercher, et énumérer les logiciels installés" + "\nsur les différents postes Windows raccordés au même réseau." + "\n\nDéveloppé par Emmanuel Hery - linkedin.com/in/emmanuel-hery" + "\n" + "-"*60) print("\n"*2) def mGet(mName): global sList, mList tmpList = [] regPath = [r"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", r"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall"] distReg = winreg.ConnectRegistry("\\\\" + mName, winreg.HKEY_LOCAL_MACHINE) for path in regPath: listKey = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, path) i = 0 while True: try: softName = "" softKeyName = winreg.EnumKey(listKey, i) softKey = winreg.OpenKey(listKey, softKeyName) try: softName = winreg.QueryValueEx(softKey, "DisplayName")[0] except: try: softName = winreg.QueryValueEx(softKey, "QuietDisplayName")[0] except: pass softNameHash = hashlib.md5(softName.encode("utf-8")).digest()[:4] softID = str(int.from_bytes(softNameHash, "big")).zfill(10) if softName and "Update" not in softName: if softID not in sList: sList[softID] = softName tmpList.append(softID) i += 1 except WindowsError as e: break sList = dict([(k,v) for v,k in sorted([(v,k) for k,v in sList.items()])]) tmpList = sorted(tmpList, key=lambda x: list(sList.keys()).index(x)) mList[mName] = tmpList print("La liste des logiciels a bien été récupérée sur le poste " + mName + "\n") def sh_sList(mName=None): if mName in mList: trgt = mList[mName] elif not mName: trgt = sList else: print("La machine \"" + mName + "\" n'a as été scannée !!" + "\nEffectuez un scan manuel sur celle-ci, et réessayez") return print("softID softName\n" + "-"*60) for softID in trgt: print(softID + " " + sList[softID]) print("\n" + str(len(sList)) + " logiciels ont été répertoriés\n") def search(softKw): if not sList: print("Merci d'effectuer un scan préalable des machines...") fnd = False for m in mList: for softID in mList[m]: if softKw in sList[softID]: print(softKw + " est bien présent sur le poste " + m); fnd = True; break if not fnd: print("Ancun résultats de trouvé concernant " + softKw) print() mGet("K401LB-Manu") sh_sList("K401LB-Manu") search("Office")
Reply