Skip to content

Commit ccd061c

Browse files
committed
Removed 'choco_packages', now uses the profile to install package
1 parent d834a6d commit ccd061c

7 files changed

Lines changed: 53 additions & 63 deletions

File tree

malboxes/config-example.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
// This example profile will attempt to load profiles/maldoc.js
2929
// For more information on profiles check an example profile:
3030
// https://github.com/GoSecure/malboxes/blob/master/malboxes/profile-example.js
31-
//"profile": "maldoc",
31+
"profile": "default",
3232
//"input_locale": "fr-FR",
3333

3434
// Provision settings
@@ -53,10 +53,6 @@
5353
// Windows Updates: true means enabled, false means disabled. Default is false.
5454
//"windows_updates": "false",
5555

56-
// Chocolatey packages to install on the VM
57-
// TODO re-add dependencywalker and regshot once upstream choco package provides a checksum
58-
"choco_packages": "sysinternals windbg 7zip putty fiddler4 processhacker apm wireshark",
59-
6056
// Setting the IDA Path will copy the IDA remote debugging tools into the guest
6157
//"ida_path": "/path/to/your/ida",
6258

malboxes/malboxes.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,10 @@ def prepare_config(args):
206206
config.update(profile_config)
207207

208208
packer_tmpl = prepare_packer_template(config, args)
209-
210209
# merge/update with template config
211210
with open(packer_tmpl, 'r') as f:
212-
config.update(json.loads(f.read()))
211+
a = f.read()
212+
config.update(json.loads(a))
213213

214214
return config, packer_tmpl
215215

@@ -331,10 +331,14 @@ def run_packer(packer_tmpl, args):
331331
return 254
332332

333333
# run packer with relevant config minified
334+
# (removes "profiles" as packer do not support arrays in var-file)
334335
configfile = os.path.join(DIRS.user_config_dir, 'config.js')
335336
with open(configfile, 'r') as config:
337+
config = json.loads(jsmin(config.read()))
338+
if "profile_config" in config.keys():
339+
del config["profile_config"]
336340
f = create_cachefd('packer_var_file.json')
337-
f.write(jsmin(config.read()))
341+
f.write(json.dumps(config))
338342
f.close()
339343

340344
flags = ['-var-file={}'.format(f.name)]
@@ -486,6 +490,8 @@ def prepare_profile(config, args):
486490

487491
profile = load_profile(profile_name)
488492

493+
config["profile_config"] = profile
494+
489495
fd = create_cachefd('profile-{}.ps1'.format(profile_name))
490496

491497
if "registry" in profile:
@@ -500,9 +506,9 @@ def prepare_profile(config, args):
500506
for doc_mod in profile["document"]:
501507
document(profile_name, doc_mod["modtype"], doc_mod["docpath"], fd)
502508

503-
if "package" in profile:
504-
for package_mod in profile["package"]:
505-
package(profile_name, package_mod["package"], fd)
509+
if "packages" in profile:
510+
for pkg in profile["packages"]:
511+
package(profile_name, pkg, fd)
506512

507513
if "packer" in profile:
508514
packer = profile["packer"]
@@ -560,7 +566,7 @@ def directory(profile_name, modtype, dirpath, fd):
560566

561567
def package(profile_name, package_name, fd):
562568
""" Adds a package to install with Chocolatey."""
563-
line = "choco install {} -y\r\n".format(package_name)
569+
line = "choco install -y {}\r\n".format(package_name)
564570
print("Adding Chocolatey package: {}".format(package_name))
565571

566572
fd.write(line)

malboxes/profile-example.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
{
2-
"package": [{"package": "thunderbird"}],
2+
"packages": [
3+
// "dependencywalker --ignorechecksum",
4+
// "regshot --ignorechecksum",
5+
"npcap --package-parameters '/winpcap_mode=yes' -y",
6+
"sysinternals",
7+
"windbg",
8+
"7zip",
9+
"putty",
10+
"fiddler4",
11+
"processhacker",
12+
"apm",
13+
"wireshark"
14+
],
315
"document": [{"modtype": "add", "docpath": "C:\\Test.doc"}],
416
"directory": [{"modtype": "add", "dirpath": "C:\\mlbxs\\"}],
517
"registry": [

malboxes/templates/snippets/provision_powershell.json

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,34 @@
66
{% if hypervisor == "virtualbox" %}
77
"{{ dir }}/scripts/windows/vmtools.ps1",
88
{% endif %}
9-
"{{ dir }}/scripts/windows/installtools.ps1",
10-
{% if profile is defined %}"{{ cache_dir }}/profile-{{ profile }}.ps1",{% endif %}
119
"{{ dir }}/scripts/windows/malware_analysis.ps1"
1210
]
1311
}
14-
{% if choco_packages %},
12+
{% if profile and profile_config.packages and profile_config.packages|length > 0 %}
13+
,
1514
{
16-
"type": "windows-shell",
17-
"inline": [
18-
"choco install npcap --package-parameters '/winpcap_mode=yes' -y",
19-
"choco install {{ choco_packages }} -y"
15+
"type": "powershell",
16+
"elevated_user": "{{ username }}",
17+
"elevated_password": "{{ password }}",
18+
"scripts": [
19+
"{{ dir }}/scripts/windows/installtools.ps1"
20+
],
21+
"valid_exit_codes": [ 0, 5888 ]
22+
}
23+
{% endif %}
24+
{% if "win7" in template %}
25+
{# Windows 7 needs to reboot after .net installation #}
26+
,
27+
{
28+
"type": "windows-restart"
29+
}
30+
{% endif %}
31+
{% if profile is defined %}
32+
,
33+
{
34+
"type": "powershell",
35+
"scripts": [
36+
"{{ cache_dir }}/profile-{{ profile }}.ps1"
2037
]
2138
}
2239
{% endif %}

malboxes/templates/snippets/provision_powershell_win7.json

Lines changed: 0 additions & 41 deletions
This file was deleted.

malboxes/templates/win7_32_analyst.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
"provisioners": [
2929

30-
{% include 'snippets/provision_powershell_win7.json' %}
30+
{% include 'snippets/provision_powershell.json' %}
3131

3232
{% if tools_path %},
3333
{% include 'snippets/tools.json' %}

malboxes/templates/win7_64_analyst.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
"provisioners": [
2929

30-
{% include 'snippets/provision_powershell_win7.json' %}
30+
{% include 'snippets/provision_powershell.json' %}
3131

3232
{% if tools_path %},
3333
{% include 'snippets/tools.json' %}

0 commit comments

Comments
 (0)