使用YASM编程 -07 模拟导入表

  • 模拟导入表
  • 导入表的调用方式
    • call xxx ; xxx 是导入函数的名称
    • xxx: jmp DWORD [fn] ; 是远程间接跳转
    • fn : DD 0x12345678 ; 跳到全局地址继续执行
    • 这个0X12345678 是在运行的时候输入,然后就可以从这里继续执行
    • 我们把OutputDebugStringA 的地址从kernel32 中获取,然后传过去
    • 这样我们就能调用API了
  • 远程注入的话我们可以这样进行处理。
    • 将需要注入的代码编译成obj,然后用到的函数在变量区,我们在目标进程空间查找需要的API然后写入到变量区,然后再执行注入的代码,就能够很好的执行了
  • 下面是代码,很简单,不解释了。
bits 32
extern _scanf
extern _exit
extern _printf
;
;yasm -f win32 -o sim_imp.obj sim_imp.asm
;rem /entry:mainCRTStartup /verbose
;D:\masm32\bin\link.exe  /entry:start /Release /PDB:sim_imp.pdb /subsystem:console /machine:x86 /out:sim_imp.exe /verbose:lib /version:5.1 /libpath:"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\LIB" kernel32.lib user32.lib sim_imp.obj msvcrt.lib  
;
;extern _mainCRTStartup
section .data
hello db "hello imp",0ah,0
outputDebugString DD 0
format db "%d",0
section .text
global _start
_start:
call _mainCRTStartup
global _main
_main:
push input_promot
call _printf
add esp,4
push outputDebugString
push format
call _scanf
add esp,8

push hello
call xxx
push 0
call _exit
ret
section .data
xxx:
jmp DWORD [outputDebugString]
;db 0xff,0x25
;DD outputDebugString

猜你喜欢

转载自blog.csdn.net/justin_bkdrong/article/details/78022178
今日推荐