[2008 CodeEngn Conference 02] graylynx - 정적 링크된 Stripped ELF 바이너리 상에서의 함수 탐지 기법
[2013 CodeEngn Conference 09] Park.Sam - 게임 해킹툴의 변칙적 공격 기법 분석
-
Upload
gangseok-lee -
Category
Education
-
view
751 -
download
0
description
Transcript of [2013 CodeEngn Conference 09] Park.Sam - 게임 해킹툴의 변칙적 공격 기법 분석
게임 해킹툴의변칙적 공격 기법 분석
게임 해킹툴의변칙적 공격 기법 분석
박근영2013.11.30
www.CodeEngn.com2013 CodeEngn Conference 09
ContentsContents
[ 공격기법 1 ] 게임코드조작 By OpenProcess
[ 방어기법 1 ] OpenProcess 접근방어
[ 공격기법 2 ] 게임코드조작 By BrainSwitching
[ 공격기법 3 ] 게임코드조작 By DLL-Injection
[ 방어기법 2 ] 메모리 CRC 비교
[ 공격기법 4 ] 게임코드조작 By DR 조작
01
02
03
04
05
06
01
02
03
04
05
06
© AhnLab, Inc. All rights reserved.
기사 자료
© AhnLab, Inc. All rights reserved.
실험 대상
TargetFPS.exe
© AhnLab, Inc. All rights reserved.
TargetFPS.exe
코드 조작 by OpenProcess
CodeModify.exe
szPatchedByte[0] = 0x90;szPatchedByte[1] = 0x90;szPatchedByte[2] = 0x90;
WriteProcessMemory(hProcess, 0x4071e7, szPatchedByte, 3, ..)
hProcess =OpenProcess(…,TargetFPS_PID)
VirtualProtectEx(hProcess, 0x4071e7, 0x3, PAGE_EXECUTE_READWRITE , ..)
게임 코드 조작 By OpenProcess[공격 기법 1]
© AhnLab, Inc. All rights reserved.
Protector_dll.dll
OpenProcess접근 방어
[방어 기법 1] OpenProcess 접근 방어
CodeModify.exe
코드 조작 by OpenProcess
TargetFPS.exe
IF (OpenProcess 대상 PID==TargetFPS PID) IF (접근 시도 Process != OS Process)
return FAIL
szPatchedByte[0] = 0x90;szPatchedByte[1] = 0x90;szPatchedByte[2] = 0x90;
WriteProcessMemory(hProcess, 0x4071e7, szPatchedByte, 3, ..)
hProcess =OpenProcess(…,TargetFPS_PID)
VirtualProtectEx(hProcess, 0x4071e7, 0x3, PAGE_EXECUTE_READWRITE , ..)
© AhnLab, Inc. All rights reserved.
Protector_dll.dll
OpenProcess접근 방어
[공격 기법 2] 게임 코드 조작 By BrainSwitching
CodeModify.exe
코드 조작 by OpenProcess
BrainSwitching.exe
TargetFPS.exe
IF (OpenProcess 대상 PID==TargetFPS PID) IF (접근 시도 Process != OS Process)
return FAIL
© AhnLab, Inc. All rights reserved.
CreateProcess(.. ”TaskMgr.exe”, .. ,CREATE_SUSPENDED, .. , &TaskMgr_PI)
[공격 기법 2] 게임 코드 조작 By BrainSwitching
NtDll ! UnmapViewOfSection(TaskMgr_PI->hProcess, TaskMgr.이미지베이스)pTaskMgr_Image = VirtualAllocEx(TaskMgr_PI->hProcess, CodeModify.이미지베이스, CodeModify.이미지전체사이즈, ..)WriteProcessMemory(TaskMgr_PI->hProcess, pTaskMgr_Image , CodeModify.헤더 데이타, ..)WriteProcessMemory(TaskMgr_PI->hProcess, pTaskMgr_Image + CodeModify.섹션별VA, CodeModify.섹션별 데이타, ..) X 섹션개수GetThreadContext(TaskMgr_PI->hProcess, &Context)Context.Eax = (CodeModify.이미지베이스 + CodeModify.엔트리포인트주소)SetThreadContext(TaskMgr_PI->hProcess, &Context)ResumeThread(TaskMgr_PI->hThread)
CreateProcess(..)
NtDll ! UnmapViewOfSection(..)
VirtualAllocEx(..)
WriteProcessMemory(..)
WriteProcessMemory(..)
GetThreadContext(..)
Ctx.Eax = CodeModify.이미지
SetThreadContext(..)
ResumeThread(..)
BrainSwitching.exeCodeModify.exe
TaskMgr.exe(Process)
.text
.rdata
.data
.rsrc
header
CodeModify.exe(File-base)
CodeModify.exe(File-base)
.text
.rdata
.data
.rsrc
headerheader
.text
.rdata
.data
.rsrc
© AhnLab, Inc. All rights reserved.
[공격 기법 3] 게임 코드 조작 By DLL-Injection
Protector_dll.dll
OpenProcess접근 방어
IF (OpenProcess 대상 PID==TargetFPS PID) IF (접근 시도 Process != OS Process)
return FAIL
CodeModify.exeCodeModify.exe
코드 조작 by OpenProcess코드 조작 by OpenProcess
BrainSwitching.exeBrainSwitching.exeBrainSwitching.exe
TargetFPS.exe
CodeModify_dll.dll
코드 조작 by DLL-인젝션
DLL_Injector.exe
VirtualProtect(0x4071e7, 0x3, PAGE_EXECUTE_READWRITE , ..)
szPatchedByte[0] = 0x90;szPatchedByte[1] = 0x90;szPatchedByte[2] = 0x90;
memcpy((LPVOID) 0x4071e7, szPatchedCodes, 3);
© AhnLab, Inc. All rights reserved.
[방어 기법 2] 메모리 CRC 비교
CodeModify.exeCodeModify.exe
코드 조작 by OpenProcess코드 조작 by OpenProcess
BrainSwitching.exeBrainSwitching.exeBrainSwitching.exe
CodeModify_dll.dll
코드 조작 by DLL-인젝션
DLL_Injector.exe
Protector_dll.dll
OpenProcess접근 방어
Memory CRC 비교
if (원본Mem_Crc32 != 현재Mem_Crc32)코드조작 감지!
TargetFPS.exe
© AhnLab, Inc. All rights reserved.
게임 코드 조작 By DR 조작
CodeModify.exeCodeModify.exe
코드 조작 by OpenProcess코드 조작 by OpenProcess
BrainSwitching.exeBrainSwitching.exeBrainSwitching.exe
CodeModify_dll.dll
코드 조작 by DLL-인젝션
DLL_Injector.exe
Protector_dll.dll
OpenProcess접근 방어
Memory CRC 비교
DR_Modify_dll.dll
코드 조작 by DR 조작
TargetFPS.exe
[공격 기법 4]
© AhnLab, Inc. All rights reserved.
TargetFPS.exe
[공격 기법 4] 게임 코드 조작 By DR 조작
Kernel32 ! AddVectoredExceptionHandler(0, DebugHookHandler)hThread = OpenThread( THREAD_SUSPEND_RESUME | THREAD_GET_CONTEXT | THREAD_SET_CONTEXT |THREAD_QUERY_INFORMATION, FALSE, TargetThreadID )SuspendThread( hThread )ctx.ContextFlags = CONTEXT_DEBUG_REGISTERS;ctx.Dr0 = (DWORD) 0x004071e7ctx.Dr7 |= 0x00000001SetThreadContext( hThread, &ctx )ResumeThread( hThread )
LONG __stdcall DebugHookHandler(PEXCEPTION_POINTERS ExceptionInfo) { …
if(ExceptionInfo->예외발생주소 == 0x4071e7){
ExceptionInfo->ContextRecord->Eip = 0x004071e7 + 0x3; Return..;} …
}
AddVectoredExceptionHandler(..)
hThread = OpenThread(..)
SuspendThread( hThread )
ctx.ContextFlags= CONTEXT_DEBUG_REGISTERS;ctx.Dr0 = 0x4071e7;ctx.Dr7 |= 0x00000001;
SetThreadContext( hThread,&ctx );
ResumeThread( hThread );
DR_Modify_dll.dll
코드 조작 by DR 조작
© AhnLab, Inc. All rights reserved.
[공격 기법 4] 게임 코드 조작 By DR 조작
Kernel32 ! AddVectoredExceptionHandler(0, DebugHookHandler)
hThread = OpenThread( THREAD_SUSPEND_RESUME | THREAD_GET_CONTEXT | THREAD_SET_CONTEXT |THREAD_QUERY_INFORMATION, FALSE, TargetThreadID )
SuspendThread( hThread )
ctx.ContextFlags = CONTEXT_DEBUG_REGISTERS;ctx.Dr0 = (DWORD) 0x004071e7ctx.Dr7 |= 0x00000001
SetThreadContext( hThread, &ctx )ResumeThread( hThread )
LONG __stdcall DebugHookHandler(PEXCEPTION_POINTERS ExceptionInfo) { …
if(ExceptionInfo->예외발생주소 == 0x4071e7){
ExceptionInfo->ContextRecord->Eip = 0x004071e7 + 0x3; Return..;} …
}
© AhnLab, Inc. All rights reserved.
인터럽트 1
[예외 핸들러]
인터럽트 발생 당시
의 CPU 레지스터 정
보를 갖고 있음
DR0 = BP 주소
게임 코드 조작 By DR 조작[공격 기법 4]
Debug Register
© AhnLab, Inc. All rights reserved.
• Debug Register: 디버깅 목적으로 프로세서에서 사용하는 레지스터
• DR0 ~ DR3
• BreakPoint를 설정할 주소를 저장
• DR6
• 디버그 상태 레지스터
• DR7
• 디버그 제어 레지스터 : breakpoint 상태를 선택적으로 활성화/비활성화
• Debug Register: 디버깅 목적으로 프로세서에서 사용하는 레지스터
• DR0 ~ DR3
• BreakPoint를 설정할 주소를 저장
• DR6
• 디버그 상태 레지스터
• DR7
• 디버그 제어 레지스터 : breakpoint 상태를 선택적으로 활성화/비활성화
게임 코드 조작 By DR 조작[공격 기법 4]
Debug Register
© AhnLab, Inc. All rights reserved.
조작 기법별 테크맵
CodeModify.exeCodeModify.exe
코드 조작 by OpenProcess코드 조작 by OpenProcess
BrainSwitching.exeBrainSwitching.exeBrainSwitching.exe
CodeModify_dll.dll
코드 조작 by DLL-인젝션
DLL_Injector.exe
Protector_dll.dll
OpenProcess접근 방어
Memory CRC 비교
DR_Modify_dll.dll
코드 조작 by DR 조작
TargetFPS.exe
© AhnLab, Inc. All rights reserved.
Thank you
Q&Awww.CodeEngn.com2013 CodeEngn Conference 09