@@ -469,7 +469,6 @@ Start-Sleep 1
469
469
$configXml = [xml ](Get-Content $configPath )
470
470
471
471
if (-not $noGui.IsPresent ) {
472
-
473
472
$errorColor = [System.Drawing.ColorTranslator ]::FromHtml(" #c80505" )
474
473
$successColor = [System.Drawing.ColorTranslator ]::FromHtml(" #417505" )
475
474
@@ -542,10 +541,31 @@ if (-not $noGui.IsPresent) {
542
541
return $packagesByCategory
543
542
}
544
543
544
+ # Function that returns an array of all the packages that are displayed sorted by category from $packagesByCategory
545
+ function Get-AllPackages {
546
+ $listedPackages = $packagesByCategory.Values | ForEach-Object { $_ } | Select-Object - ExpandProperty PackageName
547
+ return $listedPackages
548
+ }
549
+
550
+ # Function that returns additional packages from the config that are not displayed in the textboxes
551
+ # which includes both Choco packages and packages from excluded categories
552
+ function Get-AdditionalPackages {
553
+ $additionalPackages = @ ()
554
+
555
+ # Packages from the config that are not displayed
556
+ $additionalPackages = $packagesToInstall | where-Object { $listedPackages -notcontains $_ }
557
+ return $additionalPackages
558
+ }
559
+
545
560
# Gather lists of packages
546
561
$envs = [ordered ]@ {}
547
562
$configXml.config.envs.env.ForEach ({ $envs [$_.name ] = $_.value })
563
+ $excludedCategories = @ (' Command and Control' , ' Credential Access' , ' Exploitation' , ' Forensic' , ' Lateral Movement' , ' Payload Development' , ' Privilege Scalation' , ' Reconnaissance' , ' Wordlists' , ' Web Application' )
564
+ # Read packages to install from the config
565
+ $packagesToInstall = $configXml.config.packages.package.name
548
566
$packagesByCategory = Get-Packages - Categories
567
+ $listedPackages = Get-AllPackages
568
+ $additionalPackages = Get-AdditionalPackages
549
569
550
570
$formEnv = New-Object system.Windows.Forms.Form
551
571
$formEnv.ClientSize = New-Object System.Drawing.Point(750 , 350 )
@@ -804,14 +824,15 @@ if (-not $noGui.IsPresent) {
804
824
}
805
825
806
826
# Function that adds a new package to the listBox of additional packages
827
+ # If the package already exists it returns $false
807
828
function Add-NewPackage {
808
829
param (
809
830
[Parameter (Mandatory = $true )]
810
831
[string ]$packageName
811
832
)
812
-
813
- if ( $packageName -notin $listedPackages )
814
- {
833
+ # $packageName = $packageName.Trim()
834
+ $packageName = $packageName -replace ' ^\s+|\s+$ ' , ' '
835
+ if ( $packageName -notin $additionalPackagesBox .Items ) {
815
836
$additionalPackagesBox.Items.Add ($packageName ) | Out-Null
816
837
return $true
817
838
}
@@ -871,37 +892,38 @@ if (-not $noGui.IsPresent) {
871
892
872
893
Add-Type - AssemblyName System.Windows.Forms
873
894
[System.Windows.Forms.Application ]::EnableVisualStyles()
874
- $excludedCategories = @ (' Command and Control' , ' Credential Access' , ' Exploitation' , ' Forensic' , ' Lateral Movement' , ' Payload Development' , ' Privilege Scalation' , ' Reconnaissance' , ' Wordlists' )
875
- # Read packages to install from the config
876
- $packagesToInstall = $configXml.config.packages.package.name
877
- $packagesByCategory = Get-Packages - Categories
878
- $listedPackages = Get-AllPackages
879
- $additionalPackages = Get-AdditionalPackages
880
895
881
896
$formCategories = New-Object system.Windows.Forms.Form
882
897
$formCategories.ClientSize = New-Object System.Drawing.Point(1015 , 850 )
883
- $formCategories.text = " FLAREVM Package selection"
898
+ $formCategories.text = " FLARE-VM Package selection"
884
899
$formCategories.StartPosition = ' CenterScreen'
885
900
$formCategories.TopMost = $true
886
901
887
902
if ([string ]::IsNullOrEmpty($customConfig )) {
888
- $textLabel = " Select packages to install. The default configuration (recommended for reverse engineering ) is pre-selected.`n Click on the reset button to restore the default configuration."
903
+ $textLabel = " The default configuration (recommended) is pre-selected. Click on the reset button to restore the default configuration."
889
904
} else {
890
- $textLabel = " Select packages to install. The provided custom configuration is pre-selected.`n Click on the reset button to restore the custom configuration."
905
+ $textLabel = " The provided custom configuration is pre-selected. Click on the reset button to restore the custom configuration."
891
906
}
892
907
893
908
$labelCategories = New-Object system.Windows.Forms.Label
894
- $labelCategories.text = $textLabel
909
+ $labelCategories.text = " Select packages to install "
895
910
$labelCategories.AutoSize = $true
896
911
$labelCategories.width = 25
897
912
$labelCategories.height = 10
898
913
$labelCategories.location = New-Object System.Drawing.Point(30 , 20 )
899
- $labelCategories.Font = New-Object System.Drawing.Font(' Microsoft Sans Serif' , 10 )
914
+ $labelCategories.Font = New-Object System.Drawing.Font(' Microsoft Sans Serif' , 10 , [System.Drawing.FontStyle ]([System.Drawing.FontStyle ]::Bold))
915
+
916
+
917
+ $labelCategories2 = New-Object system.Windows.Forms.Label
918
+ $labelCategories2.text = $textLabel
919
+ $labelCategories2.AutoSize = $true
920
+ $labelCategories2.location = New-Object System.Drawing.Point(30 , 40 )
921
+ $labelCategories2.Font = New-Object System.Drawing.Font(' Microsoft Sans Serif' , 10 )
900
922
901
923
$panelCategories = New-Object system.Windows.Forms.Panel
902
- $panelCategories.height = 580
924
+ $panelCategories.height = 550
903
925
$panelCategories.width = 970
904
- $panelCategories.location = New-Object System.Drawing.Point(30 , 30 )
926
+ $panelCategories.location = New-Object System.Drawing.Point(30 , 60 )
905
927
$panelCategories.AutoScroll = $true
906
928
907
929
$resetButton = New-Object system.Windows.Forms.Button
@@ -953,7 +975,7 @@ if (-not $noGui.IsPresent) {
953
975
# Create checkboxes for each package
954
976
$checkboxesPackages = New-Object System.Collections.Generic.List[System.Object ]
955
977
# Initial vertical position for checkboxes
956
- $verticalPosition = 30
978
+ $verticalPosition = 25
957
979
$numCheckBoxPackages = 1
958
980
$packages = @ ()
959
981
foreach ($category in $packagesByCategory.Keys | Sort-Object ) {
@@ -999,20 +1021,20 @@ if (-not $noGui.IsPresent) {
999
1021
Set-InitialPackages
1000
1022
1001
1023
$additionalPackagesLabel = New-Object system.Windows.Forms.Label
1002
- $additionalPackagesLabel.text = " Additional packages to install: "
1024
+ $additionalPackagesLabel.text = " Additional packages to install"
1003
1025
$additionalPackagesLabel.AutoSize = $true
1004
1026
$additionalPackagesLabel.width = 25
1005
1027
$additionalPackagesLabel.height = 10
1006
- $additionalPackagesLabel.location = New-Object System.Drawing.Point(50 , 615 )
1007
- $additionalPackagesLabel.Font = New-Object System.Drawing.Font(' Microsoft Sans Serif' , 10 )
1028
+ $additionalPackagesLabel.location = New-Object System.Drawing.Point(30 , 615 )
1029
+ $additionalPackagesLabel.Font = New-Object System.Drawing.Font(' Microsoft Sans Serif' , 10 , [ System.Drawing.FontStyle ]([ System.Drawing.FontStyle ]::Bold) )
1008
1030
1009
1031
$additionalPackagesBox = New-Object system.Windows.Forms.ListBox
1010
1032
$additionalPackagesBox.text = " listBox"
1011
1033
$additionalPackagesBox.SelectionMode = ' MultiSimple'
1012
1034
$additionalPackagesBox.Sorted = $true
1013
1035
$additionalPackagesBox.width = 130
1014
- $additionalPackagesBox.height = 155
1015
- $additionalPackagesBox.location = New-Object System.Drawing.Point(50 , 635 )
1036
+ $additionalPackagesBox.height = 140
1037
+ $additionalPackagesBox.location = New-Object System.Drawing.Point(50 , 640 )
1016
1038
1017
1039
$deletePackageButton = New-Object system.Windows.Forms.Button
1018
1040
$deletePackageButton.text = " -"
@@ -1023,40 +1045,45 @@ if (-not $noGui.IsPresent) {
1023
1045
$deletePackageButton.Font = New-Object System.Drawing.Font(' Microsoft Sans Serif' , 12 , [System.Drawing.FontStyle ]::Bold)
1024
1046
$deletePackageButton.Add_Click ({Remove-SelectedPackages })
1025
1047
1026
-
1027
- $groupAbout = New-Object system.Windows.Forms.Groupbox
1028
- $groupAbout.height = 85
1029
- $groupAbout.width = 360
1030
- $groupAbout.location = New-Object System.Drawing.Point(280 , 620 )
1031
- $groupAbout.Text = " About"
1032
-
1033
-
1034
1048
$packageLabel = New-Object system.Windows.Forms.Label
1035
- $packageLabel.text = " FLARE-VM uses Chocolatey packages. You can add Community packages from"
1036
- $packageLabel.width = 230
1049
+ $packageLabel.text = " FLARE-VM uses Chocolatey packages. You can add additional packages from: "
1050
+ $packageLabel.width = 260
1037
1051
$packageLabel.height = 35
1038
- $packageLabel.location = New-Object System.Drawing.Point(300 , 620 )
1039
- $packageLabel.Font = New-Object System.Drawing.Font(' Microsoft Sans Serif' , 9 )
1040
-
1041
- $packageUrlLabel = New-Object system.Windows.Forms.Label
1042
- $packageUrlLabel.text = " https://community.chocolatey.org/packages"
1043
- $packageUrlLabel.width = 250
1044
- $packageUrlLabel.height = 21
1045
- $packageUrlLabel.location = New-Object System.Drawing.Point(300 , 652 )
1046
- $packageUrlLabel.Font = New-Object System.Drawing.Font(' Microsoft Sans Serif' , 9 , [System.Drawing.FontStyle ]([System.Drawing.FontStyle ]::Underline))
1047
-
1048
- $packageVMLabel = New-Object system.Windows.Forms.Label
1049
- $packageVMLabel.text = " and VM-Packages"
1050
- $packageVMLabel.width = 120
1051
- $packageVMLabel.height = 22
1052
- $packageVMLabel.location = New-Object System.Drawing.Point(548 , 652 )
1053
- $packageVMLabel.Font = New-Object System.Drawing.Font(' Microsoft Sans Serif' , 9 )
1054
-
1055
- $packageUrl2Label = New-Object system.Windows.Forms.Label
1056
- $packageUrl2Label.text = " https://github.com/mandiant/VM-Packages/wiki/Packages"
1057
- $packageUrl2Label.AutoSize = $true
1058
- $packageUrl2Label.location = New-Object System.Drawing.Point(300 , 670 )
1059
- $packageUrl2Label.Font = New-Object System.Drawing.Font(' Microsoft Sans Serif' , 9 , [System.Drawing.FontStyle ]([System.Drawing.FontStyle ]::Underline))
1052
+ $packageLabel.AutoSize = $true
1053
+ $packageLabel.location = New-Object System.Drawing.Point(300 , 640 )
1054
+ $packageLabel.Font = New-Object System.Drawing.Font(' Microsoft Sans Serif' , 10 )
1055
+
1056
+ $labelChoco = New-Object System.Windows.Forms.Label
1057
+ $labelChoco.Location = New-Object System.Drawing.Point(300 , 660 )
1058
+ $labelChoco.Size = New-Object System.Drawing.Size(280 , 20 )
1059
+ $labelChoco.AutoSize = $true
1060
+ $labelChoco.Font = New-Object System.Drawing.Font(' Microsoft Sans Serif' , 10 )
1061
+ $labelChoco.Text = " Community Packages"
1062
+
1063
+ $linkLabelChoco = New-Object System.Windows.Forms.linkLabel
1064
+ $linkLabelChoco.Location = New-Object System.Drawing.Point(440 , 660 )
1065
+ $linkLabelChoco.AutoSize = $true
1066
+ $linkLabelChoco.Font = New-Object System.Drawing.Font(' Microsoft Sans Serif' , 10 )
1067
+ $linkLabelChoco.LinkColor = " BLUE"
1068
+ $linkLabelChoco.ActiveLinkColor = " RED"
1069
+ $linkLabelChoco.Text = " https://community.chocolatey.org/packages"
1070
+ $linkLabelChoco.add_Click ({[system.Diagnostics.Process ]::start(" https://community.chocolatey.org/packages" )})
1071
+
1072
+ $labelFlarevm = New-Object System.Windows.Forms.Label
1073
+ $labelFlarevm.Location = New-Object System.Drawing.Point(300 , 680 )
1074
+ $labelFlarevm.Size = New-Object System.Drawing.Size(280 , 20 )
1075
+ $labelFlarevm.AutoSize = $true
1076
+ $labelFlarevm.Font = New-Object System.Drawing.Font(' Microsoft Sans Serif' , 10 )
1077
+ $labelFlarevm.Text = " FLARE-VM Packages"
1078
+
1079
+ $linkLabelFlarevm = New-Object System.Windows.Forms.linkLabel
1080
+ $linkLabelFlarevm.Location = New-Object System.Drawing.Point(440 , 680 )
1081
+ $linkLabelFlarevm.AutoSize = $true
1082
+ $linkLabelFlarevm.Font = New-Object System.Drawing.Font(' Microsoft Sans Serif' , 10 )
1083
+ $linkLabelFlarevm.LinkColor = " BLUE"
1084
+ $linkLabelFlarevm.ActiveLinkColor = " RED"
1085
+ $linkLabelFlarevm.Text = " https://github.com/mandiant/VM-Packages/wiki/Packages"
1086
+ $linkLabelFlarevm.add_Click ({[system.Diagnostics.Process ]::start(" https://github.com/mandiant/VM-Packages/wiki/Packages" )})
1060
1087
1061
1088
Set-AdditionalPackages
1062
1089
@@ -1065,56 +1092,59 @@ if (-not $noGui.IsPresent) {
1065
1092
$chocoPackageLabel.AutoSize = $true
1066
1093
$chocoPackageLabel.width = 25
1067
1094
$chocoPackageLabel.height = 10
1068
- $chocoPackageLabel.location = New-Object System.Drawing.Point(300 , 705 )
1095
+ $chocoPackageLabel.location = New-Object System.Drawing.Point(300 , 715 )
1069
1096
$chocoPackageLabel.Font = New-Object System.Drawing.Font(' Microsoft Sans Serif' , 10 )
1070
1097
1071
1098
$packageTextBox = New-Object system.Windows.Forms.TextBox
1072
1099
$packageTextBox.multiline = $false
1073
1100
$packageTextBox.width = 210
1074
1101
$packageTextBox.height = 20
1075
- $packageTextBox.location = New-Object System.Drawing.Point(300 , 725 )
1102
+ $packageTextBox.location = New-Object System.Drawing.Point(300 , 735 )
1076
1103
$packageTextBox.Font = New-Object System.Drawing.Font(' Microsoft Sans Serif' , 10 )
1104
+ $packageTextBox.Add_TextChanged ({
1105
+ if ($addPackageButton.Enabled -eq $true ){
1106
+ $addPackageButton.Enabled = $false
1107
+ }
1108
+
1109
+ })
1077
1110
1078
1111
$chocoPackageErrorLabel = New-Object system.Windows.Forms.Label
1079
1112
$chocoPackageErrorLabel.text = " "
1080
1113
$chocoPackageErrorLabel.AutoSize = $true
1081
1114
$chocoPackageErrorLabel.visible = $false
1082
1115
$chocoPackageErrorLabel.width = 25
1083
1116
$chocoPackageErrorLabel.height = 10
1084
- $chocoPackageErrorLabel.location = New-Object System.Drawing.Point(300 , 755 )
1117
+ $chocoPackageErrorLabel.location = New-Object System.Drawing.Point(300 , 765 )
1085
1118
$chocoPackageErrorLabel.Font = New-Object System.Drawing.Font(' Microsoft Sans Serif' , 10 , [System.Drawing.FontStyle ]([System.Drawing.FontStyle ]::Bold))
1086
1119
1087
1120
$findPackageButton = New-Object system.Windows.Forms.Button
1088
1121
$findPackageButton.text = " Find Package"
1089
1122
$findPackageButton.width = 118
1090
1123
$findPackageButton.height = 30
1091
1124
$findPackageButton.enabled = $true
1092
- $findPackageButton.location = New-Object System.Drawing.Point(520 , 720 )
1125
+ $findPackageButton.location = New-Object System.Drawing.Point(520 , 730 )
1093
1126
$findPackageButton.Font = New-Object System.Drawing.Font(' Microsoft Sans Serif' , 10 )
1094
1127
$findPackageButton.Add_Click ({
1095
- $chocoPackageErrorLabel.Visible = $false
1096
- $vmPackage = Get-VMPackage - PackageName $packageTextBox.Text
1128
+ $chocoPackageErrorLabel.Visible = $true
1129
+ $chocoPackageErrorLabel.text = " Finding package ..."
1130
+ $vmPackage = Get-VMPackage - PackageName $packageTextBox.Text.Trim ()
1097
1131
if ($vmPackage ){
1098
1132
$packageName = $vmPackage | Select-Object - ExpandProperty Name
1099
1133
$chocoPackageErrorLabel.text = " Found VM package"
1100
1134
$chocoPackageErrorLabel.ForeColor = $successColor
1101
- $chocoPackageErrorLabel.Visible = $true
1102
1135
$packageTextBox.Text = $packageName
1103
1136
$addPackageButton.enabled = $true
1104
- } else {
1137
+ } else {
1105
1138
$chocoPackage = Get-ChocoPackage - PackageName $packageTextBox.Text
1106
- if ($chocoPackage ) {
1107
- $chocoPackageErrorLabel.text = " Found Choco package"
1108
- $chocoPackageErrorLabel.ForeColor = $successColor
1109
- $chocoPackageErrorLabel.Visible = $true
1110
- $addPackageButton.enabled = $true
1111
- }else {
1112
- $chocoPackageErrorLabel.text = " package not found"
1113
- $chocoPackageErrorLabel.ForeColor = $errorColor
1114
- $chocoPackageErrorLabel.Visible = $true
1115
- $addPackageButton.enabled = $false
1139
+ if ($chocoPackage ) {
1140
+ $chocoPackageErrorLabel.text = " Found Choco package"
1141
+ $chocoPackageErrorLabel.ForeColor = $successColor
1142
+ $addPackageButton.enabled = $true
1143
+ } else {
1144
+ $chocoPackageErrorLabel.text = " Package not found"
1145
+ $chocoPackageErrorLabel.ForeColor = $errorColor
1146
+ $addPackageButton.enabled = $false
1116
1147
}
1117
-
1118
1148
}
1119
1149
})
1120
1150
@@ -1123,23 +1153,21 @@ if (-not $noGui.IsPresent) {
1123
1153
$addPackageButton.width = 118
1124
1154
$addPackageButton.height = 30
1125
1155
$addPackageButton.enabled = $false
1126
- $addPackageButton.location = New-Object System.Drawing.Point(400 , 775 )
1156
+ $addPackageButton.location = New-Object System.Drawing.Point(650 , 730 )
1127
1157
$addPackageButton.Font = New-Object System.Drawing.Font(' Microsoft Sans Serif' , 10 )
1128
1158
$addPackageButton.Add_Click ({
1129
- If ($packageTextBox.Text -ne " " ){
1130
1159
if (Add-NewPackage - PackageName $packageTextBox.Text ){
1131
1160
$chocoPackageErrorLabel.ForeColor = $successColor
1132
1161
$chocoPackageErrorLabel.text = " Package added"
1133
1162
}else {
1134
1163
$chocoPackageErrorLabel.ForeColor = $errorColor
1135
- $chocoPackageErrorLabel.text = " Error to add the package"
1164
+ $chocoPackageErrorLabel.text = " Error to add the package: duplicated "
1136
1165
}
1137
- }
1138
- $addPackageButton.enabled = $false
1166
+ $addPackageButton.enabled = $false
1139
1167
})
1140
1168
1141
- $formCategories.controls.AddRange (@ ($additionalPackagesLabel , $packageLabel , $packageUrlLabel , $packageUrl2Label , $packageVMLabel , $additionalPackagesBox , $deletePackageButton , $chocoPackageButton , $chocoPackageLabel , $packageTextBox , $chocoPackageErrorLabel , $findPackageButton , $addPackageButton ))
1142
- $formCategories.controls.AddRange (@ ($labelCategories , $panelCategories , $installButton , $resetButton , $allPackagesButton , $cancelButton , $clearPackagesButton ))
1169
+ $formCategories.controls.AddRange (@ ($additionalPackagesLabel , $packageLabel , $labelChoco , $labelFlarevm , $linkLabelChoco , $linkLabelFlarevm , $linkLabelFlarevm , $additionalPackagesBox , $deletePackageButton , $chocoPackageButton , $chocoPackageLabel , $packageTextBox , $chocoPackageErrorLabel , $findPackageButton , $addPackageButton ))
1170
+ $formCategories.controls.AddRange (@ ($labelCategories , $labelCategories2 , $ panelCategories, $installButton , $resetButton , $allPackagesButton , $cancelButton , $clearPackagesButton ))
1143
1171
$formCategories.Add_Shown ({$formCategories.Activate ()})
1144
1172
$resultCategories = $formCategories.ShowDialog ()
1145
1173
if ($resultCategories -eq [System.Windows.Forms.DialogResult ]::OK){
@@ -1150,9 +1178,6 @@ if (-not $noGui.IsPresent) {
1150
1178
exit 1
1151
1179
}
1152
1180
1153
-
1154
-
1155
-
1156
1181
# ###############################################################################
1157
1182
# # END GUI
1158
1183
# ###############################################################################
0 commit comments