From a2e8033defe98578ffb20a5327b1601da94ac100 Mon Sep 17 00:00:00 2001 From: snakems Date: Mon, 25 Sep 2017 09:21:03 +0300 Subject: [PATCH 1/2] Improve registry mod Improve registry mod Fix print --- malboxes/malboxes.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/malboxes/malboxes.py b/malboxes/malboxes.py index b7f2821..966df6f 100644 --- a/malboxes/malboxes.py +++ b/malboxes/malboxes.py @@ -501,6 +501,9 @@ def registry(profile_name, reg_mod, fd): Adds a registry key modification to a profile with PowerShell commands. """ if reg_mod["modtype"] == "add": + reg_key_line = 'if ( -not (Test-Path "{0}") ){{New-Item "{0}" -Force}}\r\n' \ + .format(reg_mod["key"]) + fd.write(reg_key_line) command = "New-ItemProperty" line = '{} -Path "{}" -Name "{}" -Value "{}" -PropertyType "{}"\r\n' \ .format(command, reg_mod["key"], reg_mod["name"], reg_mod["value"], @@ -560,7 +563,7 @@ def document(profile_name, modtype, docpath, fd): line = '{0} -Path "{1}"\r\n'.format(command, docpath) print("Removing file: {}".format(docpath)) else: - print("Directory modification type invalid.") + print("Document modification type invalid.") print("Valid ones are: add, delete.") fd.write(line) From e9b4177a540827ed75124b6174ad03a9d10045ac Mon Sep 17 00:00:00 2001 From: snakems Date: Tue, 26 Sep 2017 08:02:25 +0300 Subject: [PATCH 2/2] Improve code --- malboxes/malboxes.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/malboxes/malboxes.py b/malboxes/malboxes.py index 966df6f..fb1cd98 100644 --- a/malboxes/malboxes.py +++ b/malboxes/malboxes.py @@ -501,9 +501,11 @@ def registry(profile_name, reg_mod, fd): Adds a registry key modification to a profile with PowerShell commands. """ if reg_mod["modtype"] == "add": + # Creates registry path if it doesn't exist reg_key_line = 'if ( -not (Test-Path "{0}") ){{New-Item "{0}" -Force}}\r\n' \ .format(reg_mod["key"]) fd.write(reg_key_line) + command = "New-ItemProperty" line = '{} -Path "{}" -Name "{}" -Value "{}" -PropertyType "{}"\r\n' \ .format(command, reg_mod["key"], reg_mod["name"], reg_mod["value"],