Presentation is loading. Please wait.

Presentation is loading. Please wait.

X64 아키텍쳐 분석과 x64와 x86 비교 분석 손충호 (StolenByte).

Similar presentations


Presentation on theme: "X64 아키텍쳐 분석과 x64와 x86 비교 분석 손충호 (StolenByte)."— Presentation transcript:

1 x64 아키텍쳐 분석과 x64와 x86 비교 분석 손충호 (StolenByte)

2 Agenda Intro of x64 The x64 Architecture
Difference between x86 and x64 Quiz Time Question

3 Intro of x64

4 Intro of x64 Linux - x86_64 Debian/Ubuntu – amd64 Intel
IA-32e EM64T Intel 64 Oracle x64 BSD – amd64 Linux - x86_64 Debian/Ubuntu – amd64 Fedora/SuSE – x86_64 Solaris – amd64

5 Intro of x64 1999년 2000년 2001년 2003년 2011년 AMD x86-64 발표 AMD 사양 공개
Linux에 최초 적용 2003년 AMD64 Operton 출시 2011년 Windows 7 사용자 중 약 40%가 x64사용자

6 The x64 Architecture

7 The x64 Architecture 32bit의 한계 사용 가능한 가상메모리(Virtual Memory) 64bit
사용 가능한 물리메모리(Physical Memory) 52bit Intel은 40bit까지 지원

8 The x64 Architecture 64bit Registers (GPRs) 32bit Register에서 64bit로 확장
EAX -> RAX ESP -> RSP EIP -> RIP 64bit Register 8개 추가 r8, r9, r10, r11, r12, r13, r14, r15

9 The x64 Architecture Register Operation

10 The x64 Architecture 64bit Registers (Media Register)
x86에 기존 8개 Register 존재 xmm0, xmm1, xmm2, … xmm7 128bit XMM(SSE) Register 8개 추가 xmm8, xmm9, xmm10, … xmm15 Vector 및 부동소수점 사용

11 The x64 Architecture 64bit Registers

12 The x64 Architecture Intel/AMD AVX AVX 256bit Register 8개 추가
Adavanced Vector Extension 256bit Register 8개 추가 ymm0, ymm1, ymm2, … ymm7 AVX의 하위 128는 XMM(SSE) Register와 Overlap xmm0, xmm1, xmm, … xmm7 AVX가 최초 적용된 CPU는 Intel Sandy Bridge

13 Difference between x86 and x64

14 Difference between x86 and x64
Operating Model

15 Difference between x86 and x64
Address space

16 Difference between x86 and x64
Debugging Tool for x64

17 Difference between x86 and x64
Debugging Tool for x64 – Visual Studio

18 Difference between x86 and x64
Debugging Tool for x64 - WinDbg

19 Difference between x86 and x64
Debugging Tool for x64 - IDA

20 Difference between x86 and x64
Debugging Tool for x64 – Visual DuxDebugger

21 Difference between x86 and x64
64bit Instructions CDQE Quardword에서 Doubleword로 변환(ex. RAX -> EAX) CMPSQ RSI와 RDI를 비교 CMPXCHG16B RDX:RAX와 m128와 비교 m128은 128bit Register를 가리키는 메모리 주소 LODSQ RSI주소에 있는 값을 RAX에 로드 MOVSQ RSI의 주소를 RDI로 이동

22 Difference between x86 and x64
64bit Instructions STOSQ RDI의 주소를 RAX에 보관 SYSCALL Fast System Call, SYSENTER SYSRET Fast System Call, SYSEXIT

23 Difference between x86 and x64
RIP-Relative Addressing x86에서 RIP는 사용 불가 x64에서는 RIP를 통해 데이터 Access가 가능 mov rax, qword ptr [rip+100h]

24 Difference between x86 and x64
x64 Application Binary Interface - Microsoft 하나의 Calling Convention만 사용 cdecl/stdcall 등 사용하지 않음 Calling convention의 모델은 fastcall 처음 4개의 Parameter는 Register를 사용하고, 그 이후는 Stack을 사용 RAX와 XMM0으로 Return 처음 4개의 Parameter에 사용되는 Register RCX, RDX, R8, R9 (정수형) XMM0, XMM1, XMM2, XMM3 (소수형) XMM0은 Float, Double, 128bit 타입에 대한 모든 Return

25 Difference between x86 and x64
x64 Application Binary Interface - Microsoft 함수 호출 방법 MSDN에는 4번째 이후 Parameter에 대한 정보가 없음. - 25페이지 ~ 26페이지 Calling Convention에 대해 MSDN에 없는 이유는 당연히 MS에서 하는것이 아니고, 이미 예전부터 약속이 되어있기 때문에 MS에서 거론을 할 이유가 없는 것이다.

26 Difference between x86 and x64
x64 Application Binary Interface - Microsoft 4번째 이후 Parameter는 rsp+20h부터 +08h

27 Difference between x86 and x64
x64 Application Binary Interface - Microsoft Calling Convention – x86

28 Difference between x86 and x64
x64 Application Binary Interface - Microsoft Calling Convention – x64

29 Difference between x86 and x64
x64 Kernel Patch Guard (KPP) Windows XP x64 부터 도입이 된 기술 악성코드 및 Third Part 개발로 인해 BSOD 발생되는 경우에 OS를 안정화를 도모하기 위해 적용 System Image 보호 Ntoskrnl, NDIS, HAL에 대한 이미지 무결성을 체크 SSDT(System Service Descriptor Table) Windows의 커널이 아닌 다른 메모리가 맵핑되지 않게 Hooking 방지 Processor MSRs(syscall), GDT, IDT 보호 Descriptor Table에 대한 보호를 하여 Hooking 방지

30 Difference between x86 and x64
x64 Application Binary Interface - System Linux, BSD, MAC 등 사용 Microsoft와 전체적으로 다름 Calling Convention에 많은 Register 사용 6개 정수형 Register를 Argument 사용 8개 Float/Double형 Register를 Argument 사용

31 Difference between x86 and x64
x64 Application Binary Interface - System 정수형 Paramter 6개 Register RDI, RSI, RDX, RCX, R8, R9 Float/Double/Vector형 Parameter 8개 Register XMM0, XMM1, XMM2, … XMM7 중복되지 않고 최대 14개의 Parameter를 저장 가능 구조체 Parameter는 Register 사이에서 분할 가능 RAX는 Vector 번호를 가짐 - 31페이지 PE와 ELF의 Calling Convention이 틀린 이유는 컴파일러에 있다.

32 Difference between x86 and x64
x64 Application Binary Interface - System

33 Difference between x86 and x64
x64 Application Binary Interface – System printf("%i %i %f %i %f %i\n", 1, 2, 3.0, 4, 5.0, 6);

34 Quiz Time Microsoft Application Interface 중 처음 4개의 Parameter로 사용되는 소수형 Register? SYSENTER은 대체 Intruction? Kernel Patch Protection은 Windows 버전 몇부터 적용되고, 몇 bit 운영체제에서 적용 되는가?

35 Quiz Time Microsoft Application Interface 중 처음 4개의 Parameter로 사용되는 소수형 Register? XMM0, XMM1, XMM2, XMM3 SYSENTER은 대체 Intruction? Kernel Patch Protection은 Windows 버전 몇부터 적용되고, 몇 bit 운영체제에서 적용 되는가?

36 Quiz Time Microsoft Application Interface 중 처음 4개의 Parameter로 사용되는 소수형 Register? XMM0, XMM1, XMM2, XMM3 SYSENTER은 대체 Intruction? SYSCALL Kernel Patch Protection은 Windows 버전 몇부터 적용되고, 몇 bit 운영체제에서 적용 되는가?

37 Quiz Time Microsoft Application Interface 중 처음 4개의 Parameter로 사용되는 소수형 Register? XMM0, XMM1, XMM2, XMM3 SYSENTER은 대체 Intruction? SYSCALL Kernel Patch Protection은 Windows 버전 몇부터 적용되고, 몇 bit 운영체제에서 적용 되는가? Windows XP SP3, 64bit

38 Question Twitter Facebook : fb.com/stolenbyte


Download ppt "X64 아키텍쳐 분석과 x64와 x86 비교 분석 손충호 (StolenByte)."

Similar presentations


Ads by Google