본문 바로가기

Reversing16

static 안티 디버깅 PEB(+0x2) BeingDebugged 검사 : 디버깅 중이면 1, 일반 실행은 0을 가진다. 관련 함수 : IsDebuggerPresent() - BeingDebugged 값 반환 PEB(+0x68) NtGlobalFlag 검사 : 디버깅 중이면 0x70, 일반 실행은 0을 가진다. [*] 실행 후 attach한 경우에는 그대로 0을 가짐. ex) mov eax, fs:[0x18]; mov eax, dword ptr [eax+0x30]; movzx eax, byte ptr [eax+0x68]; ntdll의 NtQueryInformationProceses() 함수 PROCESSINFOCLASS 구조체에서 디버거 탐지에 사용되는 필드 ProcessDebugPort(0x7), ProcessDebugObj.. 2013. 1. 3.
PE의 IAT입력 과정 IMAGE_DIRECTORY_ENTRY_IMPORT |-------------------| | VirtualAddress | |-------------------| | Size | |-------------------| VirtualAddress + ImageBase가 IMAGE_IMPORT_DESCRIPTOR의 가상주소를 가진다. IMAGE_IMPORT_DESCRIPTOR (임포트 테이블) |----------------------| | OriginalFirstThunk | -> INT(IMPORT_NAME_TABLE) 주소 |----------------------| | TimeDateStamp | |----------------------| | ForwarderChain | |------------.. 2012. 10. 31.
함수 호출 규약 함수 호출 규약 cdecl test(1, 2, 3, 4) push 4 push 3 push 2 push 1 call test add esp, 16 stdcall test(1, 2, 3, 4) push 4 push 3 push 2 push 1 call test --> test함수 내부에서 ret 16 수행 fastcall 파라미터 : CPU 레지스터 2개 이용. (ECX, EDX) test(1, 2, 3, 4) push 4 push 3 mov edx, 2 mov ecx, 1 call test --> test함수 내부에서 ret 16 수행 c++ 호출 규약 비주얼 c++ : this를 ecx에 넣고 stdcall 처럼 동작. g++ : 첫 번째 파라미터에 암시적으로 this를 넣고 cdecl 처럼 동작. 2012. 10. 16.
Windbg 명령어 요약 [ WinDbg 명령어 요약 ] - Debugger Commands : 일반적인 디버거 명령 A (Assemble), U (Unassemble) BL (Breakpoint List), BC (Breakpoint clear) BD (Breakpoint Disable), BE (Breakpoint Enable) BA (Break on Access) BP, BU (Set Breakpoint) // BU : (unresolved - bp유지) D, DA, DB, DW, DD (Display Memory) Dds (Display words and Symbols) DL (Display Linked List) LIST_ENTRY or SINGLE_LIST_ ... DS, Ds (Display String) DT (D.. 2012. 10. 13.