我正在學習x64 shellcode
關於exploit.courses linux容器和我運行hello world x64 shellcode的問題我寫了。 我正在嘗試將「Hi there」緩衝區直接移動到一個寄存器,因此我不使用.data
部分。xll helloworld shellcode不打印任何東西
section .data
;msg db "Hi there"
section .text
global _start
_start:
;zeroed out these registers
xor rax, rax
xor rbx, rbx
xor rsi, rsi
xor rdi, rdi
xor rdx, rdx
;write (int fd, char *msg, unsigned int len);
mov rax,1 ; syscall 1 is write in 64bit arch
mov rdi,1 ; rdi is fd
mov rbx, 0x6572656874206948
mov rdx, 9; rdx is size (9 for null byte)
syscall ; instead of int 0x80 for 32 bit architecture
;exit (int ret)
mov rax, 60 ; syscall 60 is exit in 64bit arch
mov rdi, 0 ; rdi is error code
syscall
我組裝和運行代碼:
$nasm -f elf64 -o print2.o print2.asm
$ld -o print2 print2.o
$./print2
並沒有任何反應,雖然print2似乎正常退出...有人能解釋一下爲什麼?
對不起,如果這個問題已經被問到。我試圖尋找一個類似的,但找不到任何東西。
使用'strace'。爲什麼當你通過rsi = NULL作爲緩衝區時,你期望它打印什麼? 'rbx'不是系統調用參數寄存器之一。請參閱https://stackoverflow.com/questions/2535989/what-are-the-calling-conventions-for-unix-linux-system-calls-on-x86-64。而且你總是需要傳遞一個指向內存中數據的指針write()。另見https://stackoverflow.com/tags/x86/info –
@PeterCordes對不起,我現在只看到你的評論 – invictus1306
@ invictus1306:我確定這是一個重複的東西,但我沒有花時間去看着。即使已經對答案進行了評論,您也不需要爲發佈答案而道歉。 SO想要真正的答案。唯一錯誤的是回答一個問題,該問題應該作爲許多傳遞數據中的一個而不是指針問題的重複來解決(除非這個問題甚至沒有在正確的寄存器中,所以IDK)。 –