Tag Archive for 'jscript'

[생활속의 Debugging] dexplore.exe ?? ecx는 어디서 나온거지 ??

짜증나는 Link Error가 계속적으로 나타나길래 무언가 보기위해서 과감히 F1 키를 눌렀습니다. 근데 dexplore.exe가 Exception을 남기면서 죽어 버리는 것이 아닌가 -_- 젠장 ..  다행이도 Windbg가 기본 Debugger로 설정되어 있는지라 훔 -_- 안전하게 덤프를 생성( .dump /f filename ) … 무언가하고 유심히 덤프를 열어보니..

FAULTING_IP:
jscript+368b
772a368b 83bb4002000000 cmp dword ptr [ebx+240h],0
EXCEPTION_RECORD: ffffffff -- (.exr 0xffffffffffffffff)
ExceptionAddress: 772a368b (jscript+0x0000368b)
ExceptionCode: c0000005 (Access violation)
ExceptionFlags: 00000000
NumberParameters: 2
Parameter[0]: 00000000
Parameter[1]: 00000240
Attempt to read from address 00000240
FAULTING_THREAD: 00000ffcDEFAULT_BUCKET_ID: APPLICATION_FAULTPROCESS_NAME: dexplore.exeERROR_CODE: (NTSTATUS) 0xc0000005 - "0x%08lx"READ_ADDRESS: 00000240

BUGCHECK_STR: ACCESS_VIOLATION

NTGLOBALFLAG: 0
… 중략

jscript+368b 이 Instruction이 문제를 발생시켰군 ebx가 NULL 인가 ?? 진정 ??

0:000> r ebx
ebx=00000000

진정 NULL 이었다. 그래서 다시 그 Instruction 부분의 Code를 리버싱.. 고고싱 운좋게 Prologue 부분을 찾는데 성공 ( 난 정말 운이 좋은거 같다 -_- )

0:000> uf 772a3670
jscript+0x3670:
772a3670 8bff mov edi,edi
772a3672 55 push ebp
772a3673 8bec mov ebp,esp
772a3675 83ec50 sub esp,50h

772a3678 a128213077 mov eax,dword ptr [jscript!DllRegisterServer+0x2f9d8 (77302128)]
772a367d 53 push ebx
772a367e 56 push esi
772a367f 57 push edi
772a3680 8d7508 lea esi,[ebp+8]
772a3683 8d7dc4 lea edi,[ebp-3Ch]
772a3686 a5 movs dword ptr es:[edi],dword ptr [esi]
772a3687 a5 movs dword ptr es:[edi],dword ptr [esi]
772a3688 a5 movs dword ptr es:[edi],dword ptr [esi]
772a3689 8bd9 mov ebx,ecx
772a368b 83bb4002000000 cmp dword ptr [ebx+240h],0
772a3692 8945fc mov dword ptr [ebp-4],eax
772a3695 a5 movs dword ptr es:[edi],dword ptr [esi]
772a3696 7414 je jscript+0×36ac (772a36ac)
jscript+0x3698:
772a3698 8b8340020000 mov eax,dword ptr [ebx+240h]
772a369e 8b08 mov ecx,dword ptr [eax]
772a36a0 50 push eax
772a36a1 ff5114 call dword ptr [ecx+14h]
772a36a4 85c0 test eax,eax
772a36a6 0f84b6070200 je jscript!DllCanUnloadNow+0xe4c2 (772c3e62)
jscript+0x36ac:
772a36ac 33c0 xor eax,eax
jscript+0x36ae:
772a36ae 8b4dfc mov ecx,dword ptr [ebp-4]
772a36b1 5f pop edi
772a36b2 5e pop esi
772a36b3 5b pop ebx
772a36b4 e8c7f4ffff call jscript+0×2b80 (772a2b80)
772a36b9 c9 leave
772a36ba c21400 ret 14h

일단 ret 14h 구문을 봐서는 Fastcall 아니면 stdcall 이다.  ebx의 값에 왜 NULL 이 들어가 있는것인가 ?? ecx의 값이 들어가 있기 때문인데 그럼 ecx의 값은 어디서 ??? Fastcall로 가정 했을때 아마도 첫번째 Parameter가 아닐까 추정이 된다. ( Fastcall읜 ecx와 edx를 이용해서 Parameter를 넘긴다 . ) 간단히 NULL Pointer 체크를 해주는 코드가 없어서 발생한 것으로 생각이 되는군.

진정 MS도 간혹은 실수를 하는구나 ㅜ.ㅜ … 회사에 쌓여 있는 덤프들을 봐야하는데 난 지금 머하는 짓인지 ㅜ.ㅜ