CLD
;store hash
push 0x1234567 ;hash of MessageBox
push 0x1e1f1212; hash of ExitProcess
push 0x0c917432; hash of LoadLibraryA
mov esi, esp ;esi = addr of the first function hash
lea edi, [esi - 0xc]; edi = addr to start writing function
;make some stack space
xor ebx, ebx
mov bh, 0x04
sub esp, ebx
;push a pointer to "user32" onto stack
mov bx, 0x3233 ; rest of ebx is null
push ebx
push 0x72657375 ; 不懂这个值怎么得来得,是不是就是user32这个字符串呢
push esp; 为什么要把ESP入栈,LZ依然不懂
xor edx, edx
;find base addr of kernel32.dll
***************
;这里由于代码没有相关性就省略掉了
; find_lib_functions:
lodsd ;load next hash into al and increment esi
cmp eax,0x1234567 ; hash of MessageBoxA - trigger LoadLibrary("user32")
jne find_functions
xchg eax, ebp ; save current hash
call [edi - 0x8]; LoadLibraryA LZ不理解作者为什么这样写
xchg eax, ebp; restore current hash, and update ebp with base address of user32.dll
好了,代码到此为止
LZ有几点 不明白
1.lea edi, [esi - 0xc] ;这句里头为什么是0xc而不是0x9或者其他数字,是不是和后面代码有联系
2.call [edi - 0x8]; 执行这句话的时候,edi指向哪里? 为什么后面要减0x8,看注释貌似这就是loadlibrary函数的地址了,但是loadlibrary是带参数的,call前不是应该先push一个参数进去的吗?不懂呢
3.xchg是交换两个值,call指令执行过后,如果有返回值,是不是默认保存在eax寄存器里的 - 这样的话就能解释通 xchg eax, loadlibrary应该是返回某个DLL的地址,那么eax收到的就是那个dll的基址,然后通过xchg指令交换给了ebp,这样ebp的值就更新为user32.dll的基址了,而eax最后还是保存函数的hash值
不知道这样理解对不对