当我尝试以下shellcode程序弹出消息框在我的windows 32位系统使用NASM我得到错误。
section .myText progbits alloc exec write align=16
global _WinMain@16
_WinMain@16:
xor eax, eax
xor ebx, ebx
xor ecx, ecx
xor edx, edx
jmp short GetLibrary
LibraryReturn:
pop ecx
mov BYTE [ecx+10], dl
mov ebx, 0x76d62fe4
push ecx
call ebx
jmp short FunctionName
FunctionReturn:
pop ecx
xor edx, edx
mov BYTE [ecx+11], dl
push ecx
push eax ; handle to the module user32.dll
mov ebx, 0x76d616b9 ; GetProcAddress
call ebx
; now eax has the procAddress of 'MessageBoxA'
jmp short Message
MessageReturn:
pop ecx
xor edx, edx
mov BYTE [ecx+16] , dl
push edx
push ecx
push ecx
push edx
call eax ;MessageBoxA(windowhandle,msg,title,type)
ender:
xor edx,edx
push eax
mov eax, 0x76d63176 ;exitprocess(exitcode);
call eax
Message:
call MessageReturn
db 'hello am melvin!'
FunctionName:
call FunctionReturn
db 'MessageBoxAN'
GetLibrary:
call LibraryReturn
db 'user32.dllN'
编制 我
C:SHELL>nasm -f win32 -o msgbox.o msgbox.asm
C:SHELL>ld -o msgbox.exe msgbox.o
没有显示任何错误,但是当我运行这个时,"我得到windows调试窗口-有一条消息:'messagebox.exe'已停止工作' "
我的代码有什么问题?如何在windows环境下执行NASM代码而不出错?
现在我禁用了ASLR。我发现这就是问题所在。
Sample.exe中0x00404003的未处理异常:0xC0000005: Access违规写入位置0x00404019.00404003 C6 41 05 00 mov byte ptr [ecx+10],0
所以我怎么能摆脱AV.我编辑bcdedit.exe。
在Linux中,当我尝试这个时,
section .myText progbits alloc exec write align=16
最后我自己找到了答案.....:yeye::yeye::yeye:: yeye::
我们只需要改变,
"节"
section .myText progbits alloc exec write align=16
并使用"elf32"而不是"win32"编译
nasm -f elf32 -o MessageBox.o MessageBox.asm
gcc -o MessageBox.exe MessageBox.o
就是它,它会工作得很好....:blackhat:别忘了禁用ASLR
注意:elf允许你在SECTION指令行中指定额外的信息,以控制你所声明的节的类型和属性。