Skip to content

Commit

Permalink
Packaging: support w/o LZMA with Rust short
Browse files Browse the repository at this point in the history
  • Loading branch information
byeongkeunahn committed Dec 26, 2024
1 parent 08e1ecf commit 76375f7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions scripts/templates/static-pie-prestub-amd64-shorter.asm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
; (prestub: the code that runs before the stub and sets the stage)
;
; build: nasm -f bin -O9 static-pie-prestub-amd64-shorter.asm -o static-pie-prestub-amd64-shorter.bin
; note: after building with the above command, run static-pie-prestub-amd64-print.py static-pie-prestub-amd64-shorter.bin --octa
; note: after building with the above command, run static-pie-prestub-amd64-print.py static-pie-prestub-amd64-shorter.bin --no-asciz
; to obtain the form that can be embedded in Rust as inline assembly.

BITS 64
Expand All @@ -19,7 +19,7 @@ _svc_alloc_rwx:
xor r9d, r9d ; offset
push rsi ; save rsi
xor edi, edi ; rdi=0
mov esi, eax ; size (anything in [1, 4096])
mov rsi, qword [rel _end] ; size in bytes
mov dl, 7 ; protect (safe since we have ensured rdx=0)
push 0x22
pop r10 ; flags
Expand Down Expand Up @@ -64,4 +64,7 @@ _jump_to_entrypoint:
and rsp, 0xfffffffffffffff0
xor ecx, ecx
push rcx
call rdi
call rdi

align 8, db 0x90 ; zero padding
_end:
Binary file modified scripts/templates/static-pie-prestub-amd64-shorter.bin
Binary file not shown.
2 changes: 1 addition & 1 deletion scripts/templates/static-pie-template-amd64-shorter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
$$$$solution_src$$$$
}
// SOLUTION END
#[no_link]extern crate std;#[no_mangle]unsafe fn _start(){std::arch::asm!(".octa 226a07b2c689ff3156c931459958096ah,0de0c11fb097485e050f5841ff6a5a41h,5bc06b242cac91c8fe1676232cc931ach,0ff4f86e0ebf77510c4f608e8c1aac801h,0ff51c931f0e48348f87f2b48dc74aaf3h,215",in("rsi")r$$$$binary_raw_base91$$$$.as_ptr())}
#[no_link]extern crate std;#[no_mangle]unsafe fn _start(){std::arch::asm!(".quad 56c931459958096ah,47358b48ff31h,6a5a41226a07b200h,97485e050f5841ffh,0c931ac0de0c11fb0h,0ac91c8fe1676232ch,0aac8015bc06b242ch,0f77510c4f608e8c1h,74aaf3ff4f86e0ebh,0e48348f87f2b48dch,9090d7ff51c931f0h,$$$$code_raw_len$$$$",in("rsi")r$$$$binary_raw_base91$$$$.as_ptr())}

0 comments on commit 76375f7

Please sign in to comment.