mirror of
https://github.com/skerkour/black-hat-rust
synced 2026-06-08 17:29:34 +00:00
ch_12: aarch64 shellcode
This commit is contained in:
@@ -36,11 +36,6 @@ fmt:
|
||||
.PHONY: hello_world_aarch64
|
||||
hello_world_aarch64:
|
||||
docker run --rm -ti -v `pwd`:/app $(AARCH64_DOCKER_IMAGE)
|
||||
# cd hello_world && cargo +nightly build --release --target aarch64-unknown-linux-gnu
|
||||
# aarch64-linux-gnu-strip -s hello_world/target/aarch64-unknown-linux-gnu/release/hello_world
|
||||
# aarch64-linux-gnu-objcopy -O binary hello_world/target/aarch64-unknown-linux-gnu/release/hello_world shellcode.bin
|
||||
# cp shellcode.bin executor/
|
||||
# #docker run --rm -ti -v `pwd`:/app $(AARCH64_DOCKER_IMAGE)
|
||||
|
||||
.PHONY: hello_world_aarch64_docker
|
||||
hello_world_aarch64_docker:
|
||||
@@ -53,11 +48,6 @@ hello_world_aarch64_docker:
|
||||
.PHONY: hello_world_x86_64
|
||||
hello_world_x86_64:
|
||||
docker run --rm -ti -v `pwd`:/app $(x86_64_DOCKER_IMAGE)
|
||||
# cd hello_world && cargo +nightly build --release --target x86_64-unknown-linux-gnu
|
||||
# strip -s hello_world/target/x86_64-unknown-linux-gnu/release/hello_world
|
||||
# objcopy -O binary hello_world/target/x86_64-unknown-linux-gnu/release/hello_world shellcode.bin
|
||||
# cp shellcode.bin executor/
|
||||
#docker run --rm -ti -v `pwd`:/app $(x86_64_DOCKER_IMAGE)
|
||||
|
||||
.PHONY: hello_world_x86_64_docker
|
||||
hello_world_x86_64_docker:
|
||||
@@ -81,3 +71,4 @@ dump_hello_world_x86_64:
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf hello_world/target/ executor/target/ shellcode.bin
|
||||
docker rmi $(x86_64_DOCKER_IMAGE) $(AARCH64_DOCKER_IMAGE)
|
||||
|
||||
@@ -1,5 +1,33 @@
|
||||
## Hello World
|
||||
# Cross-platform shellcode in Rust
|
||||
|
||||
## Setup
|
||||
|
||||
```shell
|
||||
$ make run_hello_world
|
||||
$ make docker
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
|
||||
### x86_64
|
||||
|
||||
```shell
|
||||
$ make hello_world_x86_64
|
||||
$ make dump_hello_world_x86_64
|
||||
$ make execute_x86_64
|
||||
```
|
||||
|
||||
### Aarch64
|
||||
|
||||
```shell
|
||||
$ make hello_world_aarch64
|
||||
$ make dump_hello_world_aarch64
|
||||
$ make execute_aarch64
|
||||
```
|
||||
|
||||
|
||||
## Clean
|
||||
|
||||
```shell
|
||||
$ make clean
|
||||
```
|
||||
|
||||
@@ -11,4 +11,4 @@ panic = "abort"
|
||||
panic = "abort"
|
||||
opt-level = "z"
|
||||
lto = true
|
||||
codegen-units = 1
|
||||
codegen-units = 1
|
||||
|
||||
@@ -20,16 +20,16 @@ const SYS_WRITE: u64 = 64;
|
||||
const SYS_EXIT: u64 = 93;
|
||||
|
||||
const STDOUT: u64 = 1;
|
||||
static MESSAGE: &str = "hello world\n";
|
||||
|
||||
#[no_mangle]
|
||||
fn _start() {
|
||||
unsafe {
|
||||
let message: &str = "hello world\n";
|
||||
syscalls::syscall3(
|
||||
SYS_WRITE,
|
||||
STDOUT,
|
||||
MESSAGE.as_ptr() as u64,
|
||||
MESSAGE.len() as u64,
|
||||
message.as_ptr() as u64,
|
||||
message.len() as u64,
|
||||
);
|
||||
|
||||
syscalls::syscall1(SYS_EXIT, 0)
|
||||
|
||||
Reference in New Issue
Block a user