pe文件学习笔记2-----动态获取api

作者在 2007-08-23 04:15:00 发布以下内容

在kernel中搜索api地址

.386
.model flat,stdcall
option casemap:none
include windows.inc
GetApiA         proto    :DWORD,:DWORD
;;--------------

 

.code
k32Base         dd ?
;#############################################
sGetModuleHandle       db "GetModuleHandleA",0
sGetProcAddress        db "GetProcAddress",0
sExitProcess           db "ExitProcess",0
sLoadLibrary           db "LoadLibraryA",0
sMessageBoxA           db "MessageBoxA",0

aGetModuleHandle                dd 0
aGetProcAddress                 dd 0
aExitProcess                    dd 0
aLoadLibrary                    dd 0
aMessageBoxA                    dd 0

 

u32                     db "User32.dll",0
k32                     db "Kernel32.dll",0

sztit                   db "by 无理取闹",0
szMsg                 db "没有导入表哦!",0

lpApiAddrs      label   near
              dd      offset sGetModuleHandle
              dd      offset sGetProcAddress
              dd      offset sExitProcess
              dd      offset sLoadLibrary
       dd      offset sMessageBoxA
              dd      0
;#############################################
start:
 call    @F
@@: 
 pop     ebp                            
 sub     ebp,offset @B                ;重定位
 mov ecx,[esp]
 xor edx,edx
 and ecx,0FFFF0000h
getK32:      ;动态获取kernel.dll的地址
 sub ecx,010000h
 cmp word ptr [ecx],IMAGE_DOS_SIGNATURE
 jnz getK32
 mov esi,ecx
 add esi,[esi+3ch]
 cmp dword ptr [esi],IMAGE_NT_SIGNATURE
 jnz getK32
 mov k32Base,ecx
 ;#######################################
 lea     edi,[ebp+offset aGetModuleHandle]
 lea     esi,[ebp+offset lpApiAddrs]
loop_get:
 lodsd
 cmp     eax,0
 jz      End_Get
 

默认分类 | 阅读 2949 次
文章评论,共0条
游客请输入验证码
文章分类
最新评论