-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.ps1
More file actions
56 lines (35 loc) · 1.37 KB
/
Copy pathexample.ps1
File metadata and controls
56 lines (35 loc) · 1.37 KB
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
param(
[Parameter(Mandatory)]
[string]$Example
)
$ErrorActionPreference = "Stop"
$language = $Example.Split("/")[1]
$env:OUTPUT_DIRECTORY = "$PWD/api/generated"
$env:TEMPLATES_DIRECTORY = "$PWD/api/templates"
cargo build --package markers
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
cargo build --bin obfuscator
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
switch ($language) {
"rust" {
cargo build --manifest-path "$Example/Cargo.toml"
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
$metadata = cargo metadata --manifest-path "$Example/Cargo.toml" --format-version 1 --no-deps | ConvertFrom-Json
$package = $metadata.packages[0]
$target = $package.targets | Where-Object { $_.kind -contains "bin" } | Select-Object -First 1
$source = Join-Path $metadata.target_directory "debug\$($target.name).exe"
}
"cpp" {
g++ "$Example/main.cpp"
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
$source = Join-Path $PWD "a.exe"
}
}
& "target/debug/obfuscator.exe" --virtualization $source
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
$destination = [System.IO.Path]::ChangeExtension($source, ".protected.exe")
& $destination
$code = $LASTEXITCODE
Remove-Item $source -Force -ErrorAction SilentlyContinue
Remove-Item $destination -Force -ErrorAction SilentlyContinue
exit $code