Dav*_*vid 6 assembly masm nasm shellcode
我是StackOverflow的新手.最近,我开始研究汇编,对于汇编来说还是一个新手,对shellcode来说是全新的.我正在使用RadAsm使用MASM汇编程序进行编译,我尝试从这个网站shellcoding for Linux和Windows学习shellcode
我在Windows 64位上使用RadAsm.我使用的代码几乎相同,只是我使用函数的绝对名称而不是DLL中函数的地址.shellcode应该使用带参数的sleep函数5000.
这是我在MASM中使用的代码.
.386
.model flat, stdcall
option casemap:none
include kernel32.inc
includelib kernel32.lib
.code
_start:
xor eax, eax ; zero out eax
mov ebx, Sleep ; function sleep goes in ebx
mov ax, 5000 ; parameter goes in ax
push eax ; parameter on stack
call ebx ; call Sleep
end _start
end
Run Code Online (Sandbox Code Playgroud)
这在MASM中没有错误地组装.
生成的shellcode具有空值,与网站略有不同.它如下.
我objdump -d nameofexecutable.exe以前得到了反汇编.
Disassembly of section .text
00401000 <.text>:
401000: 33 c0 xor %eax,%eax
401002: bb 0e 10 40 00 mov $0x40100e,%
401007: 66 b8 88 13 mov $0x1388,%ax
40100b: 50 push %eax
40100c: ff d3 call *%ebx
40100e: ff 25 00 20 40 00 jmp *0x402000
Run Code Online (Sandbox Code Playgroud)
但在网站上,没有00十六进制代码.
Disassembly of section .text:
08048080 <_start>:
8048080: 31 c0 xor %eax,%eax
8048082: bb ea 1b e6 77 mov $0x77e61bea,%ebx
8048087: 66 b8 88 13 mov $0x1388,%ax
804808b: 50 push %eax
804808c: ff d3 call *%ebx
Run Code Online (Sandbox Code Playgroud)
可能是因为我使用x64编译或因为我间接调用函数?
任何帮助将不胜感激,谢谢.
简单的答案是 MASM 很糟糕!
引用自此处“过去,我使用免费开源的 Netwide Assembler (NASM) 开发了 32 位 shellcode,但是在学习 64 位品种的练习时,我想我会尝试使用 Microsoft汇编器 (MASM) 相反。一个问题很快就变得显而易见:MASM 无法提供(据我所知)生成原始二进制机器代码而不是 .exe 文件的方法!不过,一切都没有丢失,代码字节可以从.exe 文件很容易(但将来我可能会回到 NASM)。”,创建 shellcode 更困难。
我使用 NASM 为一个程序创建 shellcode,该程序从您在 Windows x64 上提供的链接中显示“嘿”,这是我实现的结果,没有空字节。事实证明,睡眠示例可能无法正常工作,但第二个示例功能齐全。
"\x31\xc0\x31\xdb\x31\xc9\x31\xd2\xeb\x2f\x59\x88\x51\x0a"
"\xbb\x82\xf8\x60\x77\x51\xff\xd3\xeb\x31\x59\x31\xd2"
"\x88\x51\x0b\x51\x50\xbb\xe6\x4d\x61\x77\x59\x31\xd2"
"\x88\x51\x03\x31\xd2\x52\x51\x51\x52\x31\x32\xd2\x50"
"\xb8\xca\x3a\x61\x77\xe8\xcc\xff\xff\xff\x75\x73\x65"
"\x72\x33\x32\x2e\x64\x6c\x6c\x4e\xe8\xca\xff\xff\xff"
"\x4d\x65\x73\x73\x61\x67\x65\x42\x6f\x78\x41\x4e\xe8"
"\xc6\xff\xff\xff\x48\x65\x79\x4e"
Run Code Online (Sandbox Code Playgroud)
注意:将 nameofexecutable.o 与 objdump 一起使用
IE。objdump -o nameofexecutable.o 获取 shellcode 而不是 nameofexecutable.exe