[英]Assembly execve failure -14
程序將可執行文件寫入磁盤的第二部分,解密(進入/ tmp / decbd),然后執行(按計划)文件decbd出現在磁盤上,並且可以通過外殼執行,最后execve調用return eax = -14 ,並且在程序結束后,執行將在數據上繼續進行,並出現段錯誤。 http://pastebin.com/KywXTB0X
在使用hexdump和dd編譯后的第二段中,我手動放置了通過openssl加密的回顯二進制文件,當我在上一個int 0x80命令之前停止執行時,我已經能夠使用另一個終端在decbd中運行我的“ echo”了。
man execve
在“錯誤”部分中針對返回碼-14( -EFAULT
)說道:
EFAULT filename points outside your accessible address space.
您將錯誤的指針傳遞給execve()
。
對於第一點,您可能會下降到:
section .text
global _start ;must be declared for linker (ld)
_start:
mov eax,11 ; execve syscall
mov ebx,program ; name of program
mov ecx,[esp+4] ; pointer to argument array
mov ebp,[esp] ; number of arguments
lea edx,[esp+4*ebp+2] ; pointer to environ array
int 0x80
section .data
program db '/bin/echo',0
對於第3點,使用調試器可以看到:
ebx
還行 ebp
還可以 ecx
是錯誤的 edx
是錯誤的 這很容易解決。 ecx
應該加載地址,而不是值,並且edx
應該跳過2個指針,每個指針均為4個字節,因此偏移量應為8
而不是2
。 固定代碼如下所示:
section .text
global _start ;must be declared for linker (ld)
_start:
mov eax,11 ; execve syscall
mov ebx,program ; name of program
lea ecx,[esp+4] ; pointer to argument array
mov ebp,[esp] ; number of arguments
lea edx,[esp+4*ebp+8] ; pointer to environ array (skip argc and NULL)
int 0x80
section .data
program db '/bin/echo',0
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.