From d64fbdeeb4a6cf6458c49175570e96ddc285c399 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Tue, 4 Dec 2018 15:44:38 +0100 Subject: [PATCH] Add audit --- WAPT/control | 2 +- setup.py | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/WAPT/control b/WAPT/control index d5dceee..a1e73b6 100644 --- a/WAPT/control +++ b/WAPT/control @@ -1,5 +1,5 @@ package : fws-fusioninventory -version : 2.4.2-3 +version : 2.4.2-4 architecture : all section : base priority : optional diff --git a/setup.py b/setup.py index 9791a44..a13e3d3 100644 --- a/setup.py +++ b/setup.py @@ -5,13 +5,20 @@ import json uninstallkey = [] +print('Reading variables') +key = open(makepath(programfiles32,'wapt','private','symetric.txt'),'r').read() +f = Fernet(key) +variables = json.loads(f.decrypt(open(makepath(programfiles32,'wapt','private','variables.txt'),'r').read())) +if not 'fusinv_server' in variables: + error('Missing fusinv_server variable') + def install(): print('Reading variables') key = open(makepath(programfiles32,'wapt','private','symetric.txt'),'r').read() f = Fernet(key) variables = json.loads(f.decrypt(open(makepath(programfiles32,'wapt','private','variables.txt'),'r').read())) if not 'fusinv_server' in variables: - error('Missing fusinv_server variable') + error('Missing fusinv_server variable') parameters = '/S /acceptlicense /server="%s" /execmode=service /runnow' % (variables['fusinv_server']) if 'fusinv_user' in variables and 'fusinv_pass' in variables: parameters = parameters + ' /user="%s" /password="%s"' % (variables['fusinv_user'],variables['fusinv_pass']) @@ -74,6 +81,32 @@ def update_package(): print('Download ' + url86) wget(url86,filenamex86) + +def audit(): + if not registry_readstring(HKEY_LOCAL_MACHINE,makepath('SOFTWARE','FusionInventory-Agent'),'server'): + print(r"key HKEY_LOCAL_MACHINE\SOFTWARE\FusionInventory-Agent\server doesn't exist") + return "ERROR" + val_server = registry_readstring(HKEY_LOCAL_MACHINE,makepath('SOFTWARE','FusionInventory-Agent'),'server') + if val_server != variables['fusinv_server'] : + print("server config is not %, it's % instead" % (variables['fusinv_server'], val_server) ) + return "WARNING" + if 'fusinv_user' in variables and 'fusinv_pass' in variables: + if not registry_readstring(HKEY_LOCAL_MACHINE,makepath('SOFTWARE','FusionInventory-Agent'),'user'): + print(r"key HKEY_LOCAL_MACHINE\SOFTWARE\FusionInventory-Agent\user doesn't exist") + return "ERROR" + val_user = registry_readstring(HKEY_LOCAL_MACHINE,makepath('SOFTWARE','FusionInventory-Agent'),'user') + if val_user != variables['fusinv_user'] : + print("user config is not %s, it's %s instead" % (variables['fusinv_user'],val_user) ) + return "WARNING" + if not registry_readstring(HKEY_LOCAL_MACHINE,makepath('SOFTWARE','FusionInventory-Agent'),'password'): + print(r"key HKEY_LOCAL_MACHINE\SOFTWARE\FusionInventory-Agent\password doesn't exist") + return "ERROR" + val_pass = registry_readstring(HKEY_LOCAL_MACHINE,makepath('SOFTWARE','FusionInventory-Agent'),'password') + if val_pass != variables['fusinv_pass'] : + print("password doesn't match what's set") + return "WARNING" + return "OK" + if __name__ == '__main__': update_package()