【问题标题】:WinExec shellcodeWinExec shellcode
【发布时间】:2018-12-20 16:53:42
【问题描述】:

谁能帮我实现一个 winexec 来执行命令或使用 x86 asm 启动 cmd.exe 吗?

以下是我如何使用 msvcrt.system 生成 cmd.exe 的示例!我想对 winexec 做同样的事情。

00446001   68 65786500      PUSH 657865 // exe
00446006   8BDC             MOV EBX,ESP
00446008   68 636D642E      PUSH 2E646D63 // cmd.
0044600D   8BCC             MOV ECX,ESP
00446010   53               PUSH EBX
00446011   51               PUSH ECX
00446012   E8 B0337E77      CALL msvcrt.system
00446017   90               NOP

【问题讨论】:

    标签: assembly shellcode


    【解决方案1】:

    您可以尝试这两种变体中的一种(其中一种已被注释)

    ;mov eax,1
    ;push eax
    ;call there
    ;db "notepad.exe c:\windows\system32\drivers\etc\hosts",0
    ;there:
    ;call WinExec
    
    push  "sts"
    push  "oh\c"
    push  "te\s"
    push  "revi"
    push  "rd\2"
    push  "3met"
    push  "sys\"
    push  "swod"
    push  "niw\"
    push  ".\:c"
    push  " exe"
    push  ".dap"
    push  "eton"
    mov eax,esp ; the last one pushed is the head of the string
    push 1
    push eax
    call WinExec
    
    add esp,52 ; restore stack state (13 pushes)
    xor eax,eax
    push eax
    call ExitProcess
    

    【讨论】:

    • MASM 实际上是否颠倒了多字符常量的顺序?那很不方便。在 NASM 中,push 'abcd' 将导致内存中的 a、b、c、d 从低地址到高地址,与 db 'abcd' 的顺序相同。
    • @PeterCordes ,是的,它在 MASM 上进行了测试,我没有使用 NASM 的经验。
    • call there 将包含一些零字节,使其不能用作 shellcode。通常你会 jmp rel8 向前和 call 向后,因为负位移不会有任何零字节。但是,要以零结尾的字符串,您可能需要存储一个零,以便 shellcode 可以没有零。
    • @PeterCordes,你是对的。我想演示如何使用 call 推送字符串。在此代码可以用作 shellcode 之前,还有其他问题需要解决。例如:解析函数 WinExec 和 ExitProcess 的地址
    猜你喜欢
    • 2015-07-19
    • 1970-01-01
    • 2014-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-06
    • 2015-01-05
    • 1970-01-01
    相关资源
    最近更新 更多