-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile.toml
127 lines (107 loc) · 3.6 KB
/
Makefile.toml
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
[config]
skip_core_tasks = true
default_to_workspace = false
[env]
CARGO_MAKE_DEFAULT_PROFILE = "x86_64-linux"
[env.x86_64-linux]
IMPLANT_EXT = ""
IMPLANT_TARGET = "x86_64-unknown-linux-gnu"
IMPLANT_RUSTFLAGS = "-C link-arg=-Wl,--verbose -C relocation-model=pic -C link-arg=-T./stardust/scripts/linux.ld -Z fmt-debug=none"
FEATURES = "--features linux"
RUNNER_TARGET = "${IMPLANT_TARGET}"
RUNNER_EXT = ""
[env.i686-linux]
IMPLANT_TARGET = "i686-unknown-linux-gnu"
IMPLANT_EXT = ""
IMPLANT_RUSTFLAGS = "-C link-arg=-Wl,--verbose -C relocation-model=pic -C link-arg=-T./stardust/scripts/linux.ld -Z fmt-debug=none"
FEATURES = "--features linux"
RUNNER_TARGET = "${IMPLANT_TARGET}"
RUNNER_EXT = ""
[env.x86_64-windows]
IMPLANT_EXT = ".exe"
IMPLANT_TARGET = "x86_64-pc-windows-gnu"
IMPLANT_RUSTFLAGS = { script = ["""
RUSTFLAGS="
-C link-arg=-Wl,--verbose
-C codegen-units=1
-C link-arg=-fpack-struct=8
-C link-arg=-falign-jumps=1
-C link-arg=-w
-C link-arg=-Wl,-s,--no-seh,--enable-stdcall-fixup
-C link-arg=-Wl,--subsystem,console
-C link-arg=-Wl,-T./stardust/scripts/windows.x86_64.ld
-C relocation-model=pic
-Z fmt-debug=none";
#-Z location-detail=none";
echo $RUSTFLAGS
"""] }
FEATURES = "--features windows"
RUNNER_TARGET = "${IMPLANT_TARGET}"
RUNNER_EXT = ".exe"
[env.i686-windows]
EXT = ""
IMPLANT_TARGET = "i686-unknown-none.json"
IMPLANT_RUSTFLAGS = "-C link-arg=-Wl,--verbose -C relocation-model=pic -C link-arg=-T./stardust/scripts/linux.ld -Z fmt-debug=none"
FEATURES = "--features windows"
RUNNER_TARGET = "i686-pc-windows-gnu"
RUNNER_EXT = ".exe"
[tasks.default]
description = "Default task that builds the project."
dependencies = ["build"]
[tasks.build]
description = "Clean, build stardust, build runner."
dependencies = ["clean", "build-stardust", "objcopy", "build-runner"]
[tasks.run]
description = "Run startdust as PIC"
dependencies = ["build"]
command = "./target/${RUNNER_TARGET}/debug/runner${RUNNER_EXT}"
[tasks.build-stardust]
description = "Build stardust."
script = '''
#!/usr/bin/env bash
export RUSTFLAGS=$IMPLANT_RUSTFLAGS
cargo build ${FEATURES} -Zbuild-std=core,alloc -Zbuild-std-features=compiler-builtins-mem --package=stardust --release --target ${IMPLANT_TARGET}
'''
[tasks.build-runner]
description = "Build runner."
command = "cargo"
args = ["build", "--package=runner", "--target", "${RUNNER_TARGET}"]
[tasks.clean]
description = "Cleans the project."
script = ["cargo clean", "rm -f ./target"]
[tasks.objcopy]
description = "Copy .text section of the binary to stardust.bin."
script = '''
#!/usr/bin/env bash
objcopy -O binary -j .text target/${IMPLANT_TARGET%.json}/release/stardust${IMPLANT_EXT} target/stardust.bin
echo "Stardust Size: $(stat --format="%s" target/stardust.bin | numfmt --from=auto --to=iec-i --suffix=B)"
'''
[tasks.objdump]
description = "Dumps stardust to stdout using objdump."
command = "objdump"
args = [
"-dzrWC",
"-mi386",
"-Mx86-64",
"-Mintel",
"-j",
".text",
"-z",
"target/${IMPLANT_TARGET%.json}/release/stardust${IMPLANT_EXT}",
]
[tasks.debug]
description = "Debug stardust pic."
command = "rust-gdb"
args = ["target/${RUNNER_TARGET}/debug/runner${RUNNER_EXT}"]
[tasks.r2-bin]
description = "Analyze stardust bin w/ r2."
command = "r2"
args = ["-AA", "target/stardust.bin"]
[tasks.r2]
description = "Analyze stardust bin w/ r2."
command = "r2"
args = [
"-e bin.relocs.apply=true",
"-AA",
"target/${IMPLANT_TARGET%.json}/release/stardust${IMPLANT_EXT}",
]