This repository has been archived by the owner on Mar 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
/
make.ps1
198 lines (153 loc) · 5.51 KB
/
make.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
#Set-PSDebug -Trace 1
$cwd=(Get-Item -Path ".\").FullName
Add-Type -AssemblyName System.IO.Compression.FileSystem
Add-Type -AssemblyName Microsoft.VisualBasic
function Unzip {
param([string]$zipfile, [string]$outpath)
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath)
}
Function InstallDependencies {
python -m pip install -r requirements.txt
python setup.py develop
}
Function DynamioRioInstall {
$dynamorioDir = "dynamorio"
$dynamorioBase = "DynamoRIO-Windows-7.0.17721-0"
If ( Test-Path $dynamorioDir ) {
$dynamorioDir + " already exists "
return
}
$url="https://github.com/DynamoRIO/dynamorio/releases/download/cronbuild-7.0.17721/${dynamorioBase}.zip"
[Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]'Tls,Tls11,Tls12'
$client = New-Object System.Net.WebClient
$zip = $cwd + "\dr.zip"
"Downloading " + $url
$client.DownloadFile($url, $zip)
"Unzipping " + $zip
Unzip $zip $cwd
mv $dynamorioBase $dynamorioDir
}
Function Doc {
$url="http://ftp.stack.nl/pub/users/dimitri/doxygen-1.8.14-setup.exe"
"Install doxygen from ${url}"
doxygen Doxyfile.in
}
Function Build {
taskkill.exe /IM fuzzgoat.exe /F
taskkill.exe /IM test_application.exe /F
Push-Location
InstallDependencies
DynamioRioInstall
#if not exist "build" mkdir build
New-Item -ItemType Directory -Force -Path build
cd build
$dynamorioCmake="${cwd}\dynamorio\cmake"
cmake -G"Visual Studio 15 Win64" "-DDynamoRIO_DIR=${dynamorioCmake}" ..
cmake --build .
Pop-Location
}
Function SafeDelete {
param( [string]$path )
if ( Test-Path "$path" ) {
"Deleting ${path}"
Remove-Item $path -Force -Recurse
}
}
Function Reconfig {
taskkill.exe /IM test_application.exe /F
taskkill.exe /IM server.exe /F
[Microsoft.VisualBasic.FileIO.FileSystem]::Deletedirectory("$env:APPDATA\Trail of Bits\sl2",'OnlyErrorDialogs','SendToRecycleBin')
}
Function Clean {
Reconfig
SafeDelete "build"
"It's clean!"
}
Function Dep {
SafeDelete "dr.zip"
SafeDelete "dynamorio"
}
Function Deploy {
"Rebuilding Code Files"
Build
"Rebuilding Documentation"
Doc
"Creating Deploy Directory"
Remove-Item sl2-deploy -Recurse -ErrorAction Ignore
mkdir sl2-deploy
"Creating Binary Directories"
New-Item sl2-deploy\build\common -Type Directory
New-Item sl2-deploy\build\corpus\test_application -Type Directory
New-Item sl2-deploy\build\fuzzer -Type Directory
New-Item sl2-deploy\build\fuzzgoat -Type Directory
New-Item sl2-deploy\build\server -Type Directory
New-Item sl2-deploy\build\tracer -Type Directory
New-Item sl2-deploy\build\triage -Type Directory
New-Item sl2-deploy\build\winchecksec -Type Directory
New-Item sl2-deploy\build\wizard -Type Directory
New-Item sl2-deploy\pypy -Type Directory
"Copying Compiled Binaries"
Copy-Item build\common\Debug sl2-deploy\build\common -Recurse -Force
Copy-Item build\corpus\test_application\Debug sl2-deploy\build\corpus\test_application -Recurse -Force
Copy-Item build\fuzzer\Debug sl2-deploy\build\fuzzer -Recurse -Force
Copy-Item build\fuzzgoat\Debug sl2-deploy\build\fuzzgoat -Recurse -Force
Copy-Item build\server\Debug sl2-deploy\build\server -Recurse -Force
Copy-Item build\tracer\Debug sl2-deploy\build\tracer -Recurse -Force
Copy-Item build\triage\Debug sl2-deploy\build\triage -Recurse -Force
Copy-Item build\winchecksec\Debug sl2-deploy\build\winchecksec -Recurse -Force
Copy-Item build\wizard\Debug sl2-deploy\build\wizard -Recurse -Force
"Copying Documentation"
New-Item sl2-deploy\doc -Type Directory
Copy-Item doc\html sl2-deploy\doc -Recurse -Force
"Copying DynamoRIO"
Copy-Item -Recurse dynamorio sl2-deploy
"Copying Python Files"
Copy-Item sl2 sl2-deploy -Recurse -Force
"Copying Helper Files"
Copy-Item deploy\* sl2-deploy
Copy-Item setup.py sl2-deploy
Copy-Item README.md sl2-deploy
Copy-Item requirements.txt sl2-deploy
$url="https://www.python.org/ftp/python/3.7.0/python-3.7.0-amd64.exe"
[Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]'Tls,Tls11,Tls12'
$client = New-Object System.Net.WebClient
"Downloading Python from " + $url
$exe = "$cwd\sl2-deploy\python_install.exe"
$client.DownloadFile($url, $exe)
"Downloading Python Dependencies"
python -m pip download -d sl2-deploy\pypy -r requirements.txt
"Compressing Deployment Archive"
if (-not (test-path "$env:ProgramFiles\7-Zip\7z.exe")) {throw "$env:ProgramFiles\7-Zip\7z.exe missing"}
set-alias zip "$env:ProgramFiles\7-Zip\7z.exe"
zip a -r -mx=9 sl2-deploy.zip sl2-deploy\*
}
Function Help {
@'
Usage: make1.ps [clean|dep|reconfig|help]
make1.ps without any options will build
clean
Cleans build directory and configuration (reconfigs)
dep
Rebuild dependencies
reconfig
Deletes sl2 directory with run configuration
help
This info
'@
}
function Regress {
sl2-test
}
$cmd = $args[0]
switch( $cmd ) {
"clean" { Clean }
"dep" { Dep }
"reconfig" { Reconfig }
"regress" { Regress }
"help" { Help }
"doc" { Doc }
"deploy" { Deploy }
default { Build }
}