ch_12: aarch64 shellcode

This commit is contained in:
Sylvain Kerkour
2021-10-14 15:06:30 +00:00
committed by GitHub
parent d0954cdad8
commit a8a7eb0715
4 changed files with 35 additions and 16 deletions
+1 -10
View File
@@ -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)
+30 -2
View File
@@ -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
```
+1 -1
View File
@@ -11,4 +11,4 @@ panic = "abort"
panic = "abort"
opt-level = "z"
lto = true
codegen-units = 1
codegen-units = 1
+3 -3
View File
@@ -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)