From 52b515041d99bda78e41cce1e6134d484de14cc1 Mon Sep 17 00:00:00 2001 From: Camille Moncelier Date: Wed, 6 Sep 2017 11:48:59 +0200 Subject: [PATCH] Added support for defining custom provisioners in profile Signed-off-by: Camille Moncelier --- malboxes/malboxes.py | 5 +++++ malboxes/profile-example.js | 11 ++++++++++- malboxes/templates/win10_32_analyst.json | 6 +++++- malboxes/templates/win10_64_analyst.json | 6 +++++- malboxes/templates/win7_32_analyst.json | 6 +++++- malboxes/templates/win7_64_analyst.json | 14 +++++++++----- 6 files changed, 39 insertions(+), 9 deletions(-) diff --git a/malboxes/malboxes.py b/malboxes/malboxes.py index f36bea5..b7f2821 100644 --- a/malboxes/malboxes.py +++ b/malboxes/malboxes.py @@ -487,6 +487,11 @@ def prepare_profile(template, config): for package_mod in profile["package"]: package(profile_name, package_mod["package"], fd) + if "packer" in profile: + packer = profile["packer"] + if "provisioners" in packer: + config["packer_extra_provisioners"] = packer["provisioners"] + fd.close() return config diff --git a/malboxes/profile-example.js b/malboxes/profile-example.js index 53ddd78..382605c 100644 --- a/malboxes/profile-example.js +++ b/malboxes/profile-example.js @@ -13,5 +13,14 @@ {"modtype": "delete", "key": "HKLM:\\SYSTEM\\ControlSet001\\Services", "name": "VBoxService"}, {"modtype": "delete", "key": "HKLM:\\SYSTEM\\ControlSet001\\Services", "name": "VBoxSF"}, {"modtype": "delete", "key": "HKLM:\\SYSTEM\\ControlSet001\\Services", "name": "VBoxVideo"}, - {"modtype": "add", "key": "HKLM:\\HARDWARE\\DEVICEMAP\\Scsi\\Scsi Port 0\\Scsi Bus 0\\Target Id 0\\Logical Unit Id 0", "value": "Malboxes", "name": "Identifier", "valuetype": "String"}] + {"modtype": "add", "key": "HKLM:\\HARDWARE\\DEVICEMAP\\Scsi\\Scsi Port 0\\Scsi Bus 0\\Target Id 0\\Logical Unit Id 0", "value": "Malboxes", "name": "Identifier", "valuetype": "String"}], + "packer": { + "_comment": "See https://www.packer.io/docs/templates/provisioners.html for syntax" + "provisioners": [ + { + "type": "powershell", + "inline": ["dir c:\\"] + } + ] + } } diff --git a/malboxes/templates/win10_32_analyst.json b/malboxes/templates/win10_32_analyst.json index 90449dc..689b936 100644 --- a/malboxes/templates/win10_32_analyst.json +++ b/malboxes/templates/win10_32_analyst.json @@ -38,6 +38,10 @@ {% if ida_path %}, {% include 'snippets/ida_remote_32.json' %} {% endif %} - + {% if packer_extra_provisioners %} + {% for p in packer_extra_provisioners %} + ,{{ p | tojson }} + {% endfor %} + {% endif %} ] } diff --git a/malboxes/templates/win10_64_analyst.json b/malboxes/templates/win10_64_analyst.json index 57b3f67..911e6fe 100644 --- a/malboxes/templates/win10_64_analyst.json +++ b/malboxes/templates/win10_64_analyst.json @@ -37,6 +37,10 @@ {% include 'snippets/ida_remote_64.json' %}, {% include 'snippets/ida_remote_32.json' %} {% endif %} - + {% if packer_extra_provisioners %} + {% for p in packer_extra_provisioners %} + ,{{ p | tojson }} + {% endfor %} + {% endif %} ] } diff --git a/malboxes/templates/win7_32_analyst.json b/malboxes/templates/win7_32_analyst.json index 4c489b8..dd96af2 100644 --- a/malboxes/templates/win7_32_analyst.json +++ b/malboxes/templates/win7_32_analyst.json @@ -34,6 +34,10 @@ {% if ida_path %}, {% include 'snippets/ida_remote_32.json' %} {% endif %} - + {% if packer_extra_provisioners %} + {% for p in packer_extra_provisioners %} + ,{{ p | tojson }} + {% endfor %} + {% endif %} ] } diff --git a/malboxes/templates/win7_64_analyst.json b/malboxes/templates/win7_64_analyst.json index 6e192e9..be0094e 100644 --- a/malboxes/templates/win7_64_analyst.json +++ b/malboxes/templates/win7_64_analyst.json @@ -31,10 +31,14 @@ {% if tools_path %}, {% include 'snippets/tools.json' %} {% endif %} - {% if ida_path %}, - {% include 'snippets/ida_remote_64.json' %}, - {% include 'snippets/ida_remote_32.json' %} - {% endif %} - + {% if ida_path %}, + {% include 'snippets/ida_remote_64.json' %}, + {% include 'snippets/ida_remote_32.json' %} + {% endif %} + {% if packer_extra_provisioners %} + {% for p in packer_extra_provisioners %} + ,{{ p | tojson }} + {% endfor %} + {% endif %} ] }