-
Notifications
You must be signed in to change notification settings - Fork 4
/
makeFile.ps1
120 lines (104 loc) · 5.24 KB
/
makeFile.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
Write-Output [96m Installing PIP[0m
Write-Output [96m----------------[0m
Write-Output -
Write-Output -
$source = 'https://bootstrap.pypa.io/get-pip.py'
$destination = 'Resources\get-pip.py'
Invoke-WebRequest -Uri $source -OutFile $destination
python Resources\get-pip.py
Write-Output [96m Installing required packages[0m
Write-Output [96m-----------------------------[0m
Write-Output -
Write-Output -
python -m pip install -r requirements.txt
$AESKey = New-Object Byte[] 32
[Security.Cryptography.RNGCryptoServiceProvider]::Create().GetBytes($AESKey)
python add_key.py --key=$AESKey
Write-Output [96m Creating python exe[0m
Write-Output [96m-----------------------------[0m
Write-Output -
Write-Output -
pyinstaller --onefile Service.py
pyinstaller --onefile --key "$AESKey" DLPExporter.py
Write-Output [96m Choose modules to be installed[0m
Write-Output [96m--------------------------------[0m
Write-Output .
$azure=Read-Host "Do you want azure configured on y/n?"
$aws=Read-Host "Do you want aws configured on y/n?"
Write-Output [96m Creating required directories[0m
Write-Output [96m-----------------------------[0m
Write-Output -
Write-Output -
mkdir .\fp-dlp-exporter-aws-azure-v1
mkdir .\fp-dlp-exporter-aws-azure-v1\CloudFormationTemplate
mkdir .\fp-dlp-exporter-aws-azure-v1\Remediation_script
mkdir .\fp-dlp-exporter-aws-azure-v1\Resources
xcopy .\Resources .\fp-dlp-exporter-aws-azure-v1\Resources /s /e
move-item .\dist\DLPExporter.exe .\fp-dlp-exporter-aws-azure-v1
move-item .\dist\Service.exe .\fp-dlp-exporter-aws-azure-v1
move-item .\fp-dlp-exporter-aws-azure-v1\Resources\install.bat .\fp-dlp-exporter-aws-azure-v1
mkdir .\fp-dlp-exporter-aws-azure-v1\ServiceScripts
move-item .\fp-dlp-exporter-aws-azure-v1\Resources\restart.bat .\fp-dlp-exporter-aws-azure-v1\ServiceScripts
move-item .\fp-dlp-exporter-aws-azure-v1\Resources\stopService.bat .\fp-dlp-exporter-aws-azure-v1\ServiceScripts
move-item .\fp-dlp-exporter-aws-azure-v1\Resources\removeService.bat .\fp-dlp-exporter-aws-azure-v1\ServiceScripts
move-item .\fp-dlp-exporter-aws-azure-v1\Resources\changePassword.bat .\fp-dlp-exporter-aws-azure-v1\ServiceScripts
xcopy .\CloudFormationTemplate .\fp-dlp-exporter-aws-azure-v1\CloudFormationTemplate /s /e
xcopy .\Remediation_script .\fp-dlp-exporter-aws-azure-v1\Remediation_script /s /e
xcopy .\config.json .\fp-dlp-exporter-aws-azure-v1
Remove-Item –path .\fp-dlp-exporter-aws-azure-v1\Resources\get-pip.py –recurse
$awsInstall=$false
if ($aws -eq 'y' -or $aws -eq "Y") {
$awsInstall=$true
}
if ($awsInstall -eq $false) {
Remove-Item –path .\fp-dlp-exporter-aws-azure-v1\Resources\AWSDate.json –recurse
Remove-Item –path .\fp-dlp-exporter-aws-azure-v1\Resources\Insights.json –recurse
Remove-Item –path .\fp-dlp-exporter-aws-azure-v1\Resources\InsightARN.json –recurse
Remove-Item –path .\fp-dlp-exporter-aws-azure-v1\CloudFormationTemplate –recurse
Remove-Item –path .\fp-dlp-exporter-aws-azure-v1\Remediation_script –recurse
$LineNumber = 2
$Contents = Get-Content .\fp-dlp-exporter-aws-azure-v1\config.json
$Contents -replace $Contents[$LineNumber -1],"" | Set-Content .\fp-dlp-exporter-aws-azure-v1\config.json
$LineNumber = 3
$Contents = Get-Content .\fp-dlp-exporter-aws-azure-v1\config.json
$Contents -replace $Contents[$LineNumber -1],"" | Set-Content .\fp-dlp-exporter-aws-azure-v1\config.json
$LineNumber = 4
$Contents = Get-Content .\fp-dlp-exporter-aws-azure-v1\config.json
$Contents -replace $Contents[$LineNumber -1],"" | Set-Content .\fp-dlp-exporter-aws-azure-v1\config.json
$LineNumber = 5
$Contents = Get-Content .\fp-dlp-exporter-aws-azure-v1\config.json
$Contents -replace $Contents[$LineNumber -1],"" | Set-Content .\fp-dlp-exporter-aws-azure-v1\config.json
$LineNumber = 6
$Contents = Get-Content .\fp-dlp-exporter-aws-azure-v1\config.json
$Contents -replace $Contents[$LineNumber -1],"" | Set-Content .\fp-dlp-exporter-aws-azure-v1\config.json
}
$azureInstall=$false
if ($azure -eq 'y' -or $azure -eq "Y") {
$azureInstall=$true
}
if ($azureInstall -eq $false) {
Remove-Item –path .\fp-dlp-exporter-aws-azure-v1\Resources\azureDate.json –recurse
$LineNumber = 18
$Contents = Get-Content .\fp-dlp-exporter-aws-azure-v1\config.json
$Contents -replace $Contents[$LineNumber -1],"" | Set-Content .\fp-dlp-exporter-aws-azure-v1\config.json
$LineNumber = 19
$Contents = Get-Content .\fp-dlp-exporter-aws-azure-v1\config.json
$Contents -replace $Contents[$LineNumber -1],"" | Set-Content .\fp-dlp-exporter-aws-azure-v1\config.json
}
Write-Output [96m Creating fp-dlp-exporter-aws-azure-v1-9-1.zip[0m
Write-Output [96m-----------------------------[0m
Write-Output -
Write-Output -
Compress-Archive .\fp-dlp-exporter-aws-azure-v1 .\fp-dlp-exporter-aws-azure-v1-9-1.zip
Write-Output [96m Clean up[0m
Write-Output [96m-----------------------------[0m
Write-Output -
Write-Output -
Remove-Item –path .\__pycache__ –recurse
Remove-Item –path .\fp-dlp-exporter-aws-azure-v1 –recurse
Remove-Item –path .\build –recurse
Remove-Item –path .\dist –recurse
Remove-Item –path .\DLPExporter.spec –recurse
Remove-Item –path .\Service.spec –recurse
Remove-Item –path .\Resources\get-pip.py –recurse
python add_key.py --key=None