SlideShare a Scribd company logo
1 of 20
PE Header 개요
이무송
fromitive@gmail.com
HEX Editor로
PE HEADER 분석하기
목차
지난시간
PE HEADER
지난 시간
컴퓨터 핵심 논리 구조 (폰노이만 구조)
“컴퓨터는 CPU와 MEMORY그리고 COMMON BUS로 구성되며”
메모리 안의 데이터(binary)를 처리하는 기계다
ALU
(계산하는 장치)
Control Unit
(데이터를 가져오는 장치)
010101011010
COMMON BUS
지난 시간
컴퓨터 핵심 논리 구조 (폰노이만 구조)
메모리 안은 binary 데이터가 저장 되어 있다
명령어와 처리 데이터를 구분하지 않는다
CPU에서 데이터를 가져오기 위해 주소(Offset)정보를 이용함
지난 시간
PE file format
컴퓨터의 다양한 요구사항에 맞춰진,
윈도우(운영체제)에서 사용하는 실행 파일 양식이다
실행에 필요한 정보와 처리 할 데이터가 들어있다.
compiler
source code
Excutable file
(PE file format)
지난 시간
PE file format
윈도우에서 사용하는 실행 파일 양식이다
실행에 필요한 정보와 처리 할 데이터가 들어있다.
Hex editor로 본 Executable file
문서가 아닌 binary로 되어있다.
지난 시간
PE file format 구성 요소
Excutable File
HEADER
SECTIONS
SECTIONS
SECTION
PE는 HEADER(실행에 필요한 정보) 와
SECTION(처리할 데이터)로 구성되어 있다.
지난 시간
PE file format 구성 요소 - HEADER의 내부 구조
HEADER
IMAGE_DOS_HEADER
IMAGE_NT_HEADERS
IMAGE_OPTIONAL_HEADER
SECTION_TABLES
지난 시간
PE Header들에게 얻을 수 있는 것들
● IMAGE_DOS_HEADER
○ IMAGE_NT_HEADER (PE 헤더) 의 시작 주소 값을 얻을 수 있다.
● IMAGE_NT_HEADERS
○ 실행 할 수 있는 CPU type과
section의 개수를 얻을 수 있다.
지난 시간
PE Header들에게 얻을 수 있는 것들
● IMAGE_OPTIONAL_HEADER
○ 실행에 필요한 offset(주소 값)과 크기 그리고
실행에 필요한 함수(EXE) 와 제공하는 함수(DLL) 정보를 가지고
있다 (DATA_DIRECTORY)
● SECTION tables
○ 각 section의 offset과 크기
그리고 속성(읽기, 쓰기, 실행 등..)을 알 수 있다.
지난 시간
참고 자료
● Low-Level Programming: C, Assembly, and Program Execution on Intel® 64
Architecture 1st ed. Edition - chapter 1. Basic computer Architecture
● Learning Malware Analysis: Explore the concepts, tools, and techniques to analyze and
investigate Windows malware
● An In-Depth Look into the Win32 Portable Executable File Format - Part 1
● An In-Depth Look into the Win32 Portable Executable File Format - Part 2
● http://www.openrce.org/reference_library/files/reference/PE%20Format.pdf
● https://github.com/corkami/pics/blob/master/binary/pe101/pe101ko.png
PE HEADER
Hex Editor로 분석하면 좋은 이유
● PE를 다루는 프로그램 개발 가능 (Peviewer,Debugger,packer … 등등)
○ Binary로 읽어 들여야 하기 때문에 Binary 분석에 익숙 해지기 위해서!
○ binary 분석이 재밌(?)어짐 - 친해지면 재밌고 신나잖아요?
PE HEADER
IMAGE_DOS_HEADER
실행 파일의 맨 첫부분,
MZ로 시작,
PE 헤더 구조체의
offset값 획득 가능
** PE File은 Little-endian Byte order로 데이터가 저장되
어 있음!
PE HEADER
IMAGE_NT_HEADERS
NT_HEADERS 안에
FILE_HEADER와 OPTIONAL_HEADER가 포함되어 있음!
PE HEADER
IMAGE_OPTIONAL_HEADER
0x00 WORD magic
0x10 DWORD AddressOfEntryPoint
0x1C DWORD ImageBase
PE HEADER
IMAGE_OPTIONAL_HEADER - DataDirectory[16]
0x60 DataDirectory[16]
DataDirectory 배열의 Element들은
각자 다른 구조체의 포인터와 그 구조체의 크기를 저장함
각 Element는 순서가 정해져 있음
PE HEADER
SECTION_HEADERS
Section Header 구조체는
NumberOfSection의 값 만큼 가지고 있음
(eg . 이 프로그램은 5개의 SectionHeader가 저장됨)
각 섹션의 Offset과 size를 획득할 수 있어요!
PE HEADER
SECTION_HEADERS
각 section의
memory 안 에서의Offset과 size값(노란색)
file에서의 Offset과 size값(빨간색)
PE HEADER
SECTION_HEADERS
File Memory
섹션 명 size Offset size Offset
.text 0xe00 0x400 0xd47 0x1000
.rdata 0xc00 0x1200 0xb2a 0x2000
.data 0x200 0x1e00 0x388 0x3000
.rsrc 0x200 0x2000 0x1e0 0x4000
.reloc 0x200 0x2200 0x158 0x5000
PE HEADER
SECTION_HEADERS
HEADER HEADER
.text
.rdata
.data
.text
.rdata
.data
.rsrc
.reloc
.rsrc
.reloc
Header까지의 Offset은 같음
(헤더 길이가 일정하기 때문에)
섹션들은
size와 Offset이 변해요

More Related Content

Similar to 이무송 스터디 HEX Editor로 PE 분석하기.pptx

Cb기술조사 김동혁
Cb기술조사 김동혁Cb기술조사 김동혁
Cb기술조사 김동혁kpad2
 
Exynos4210 beginnerrev10
Exynos4210 beginnerrev10Exynos4210 beginnerrev10
Exynos4210 beginnerrev10mimul
 
Linux 강의자료 ed10
Linux 강의자료 ed10Linux 강의자료 ed10
Linux 강의자료 ed10hungrok
 
caanoo Device driver
caanoo Device drivercaanoo Device driver
caanoo Device driverjumiss
 
제로부터시작하는오픈소스
제로부터시작하는오픈소스제로부터시작하는오픈소스
제로부터시작하는오픈소스Mario Cho
 
Foss open sorucesw_6902
Foss open sorucesw_6902Foss open sorucesw_6902
Foss open sorucesw_6902승우 백
 
Ssscon forensic pt
Ssscon forensic ptSsscon forensic pt
Ssscon forensic pt윤아 황
 
(Fios#02) 7. 윈도우 10 포렌식 분석
(Fios#02) 7. 윈도우 10 포렌식 분석(Fios#02) 7. 윈도우 10 포렌식 분석
(Fios#02) 7. 윈도우 10 포렌식 분석INSIGHT FORENSIC
 
PE File Format and Packer - Inc0gnito 2016
PE File Format and Packer - Inc0gnito 2016PE File Format and Packer - Inc0gnito 2016
PE File Format and Packer - Inc0gnito 2016Hajin Jang
 
빌드관리 및 디버깅 (2010년 자료)
빌드관리 및 디버깅 (2010년 자료)빌드관리 및 디버깅 (2010년 자료)
빌드관리 및 디버깅 (2010년 자료)YEONG-CHEON YOU
 
191221 unreal engine 4 editor 확장하기
191221 unreal engine 4 editor 확장하기191221 unreal engine 4 editor 확장하기
191221 unreal engine 4 editor 확장하기KWANGIL KIM
 
Mint64 os개발이야기 한승훈
Mint64 os개발이야기 한승훈Mint64 os개발이야기 한승훈
Mint64 os개발이야기 한승훈Seunghun han
 
안드로이드 플랫폼 설명
안드로이드 플랫폼 설명안드로이드 플랫폼 설명
안드로이드 플랫폼 설명Peter YoungSik Yun
 
[231]나는서버를썰터이니너는개발만하여라 양지욱
[231]나는서버를썰터이니너는개발만하여라 양지욱[231]나는서버를썰터이니너는개발만하여라 양지욱
[231]나는서버를썰터이니너는개발만하여라 양지욱NAVER D2
 
(160820) #fitalk fileless malware forensics
(160820) #fitalk    fileless malware forensics(160820) #fitalk    fileless malware forensics
(160820) #fitalk fileless malware forensicsINSIGHT FORENSIC
 
운영체제 인트로
운영체제 인트로운영체제 인트로
운영체제 인트로Junnie Jobs
 
한글시계웍샵_SW
한글시계웍샵_SW한글시계웍샵_SW
한글시계웍샵_SW영광 송
 

Similar to 이무송 스터디 HEX Editor로 PE 분석하기.pptx (20)

Cb기술조사 김동혁
Cb기술조사 김동혁Cb기술조사 김동혁
Cb기술조사 김동혁
 
Exynos4210 beginnerrev10
Exynos4210 beginnerrev10Exynos4210 beginnerrev10
Exynos4210 beginnerrev10
 
Linux 강의자료 ed10
Linux 강의자료 ed10Linux 강의자료 ed10
Linux 강의자료 ed10
 
caanoo Device driver
caanoo Device drivercaanoo Device driver
caanoo Device driver
 
제로부터시작하는오픈소스
제로부터시작하는오픈소스제로부터시작하는오픈소스
제로부터시작하는오픈소스
 
Foss open sorucesw_6902
Foss open sorucesw_6902Foss open sorucesw_6902
Foss open sorucesw_6902
 
Ssscon forensic pt
Ssscon forensic ptSsscon forensic pt
Ssscon forensic pt
 
(Fios#02) 7. 윈도우 10 포렌식 분석
(Fios#02) 7. 윈도우 10 포렌식 분석(Fios#02) 7. 윈도우 10 포렌식 분석
(Fios#02) 7. 윈도우 10 포렌식 분석
 
PE File Format and Packer - Inc0gnito 2016
PE File Format and Packer - Inc0gnito 2016PE File Format and Packer - Inc0gnito 2016
PE File Format and Packer - Inc0gnito 2016
 
빌드관리 및 디버깅 (2010년 자료)
빌드관리 및 디버깅 (2010년 자료)빌드관리 및 디버깅 (2010년 자료)
빌드관리 및 디버깅 (2010년 자료)
 
191221 unreal engine 4 editor 확장하기
191221 unreal engine 4 editor 확장하기191221 unreal engine 4 editor 확장하기
191221 unreal engine 4 editor 확장하기
 
Mint64 os개발이야기 한승훈
Mint64 os개발이야기 한승훈Mint64 os개발이야기 한승훈
Mint64 os개발이야기 한승훈
 
안드로이드 플랫폼 설명
안드로이드 플랫폼 설명안드로이드 플랫폼 설명
안드로이드 플랫폼 설명
 
[231]나는서버를썰터이니너는개발만하여라 양지욱
[231]나는서버를썰터이니너는개발만하여라 양지욱[231]나는서버를썰터이니너는개발만하여라 양지욱
[231]나는서버를썰터이니너는개발만하여라 양지욱
 
Pe+file+format
Pe+file+formatPe+file+format
Pe+file+format
 
컴퓨터개론06
컴퓨터개론06컴퓨터개론06
컴퓨터개론06
 
(160820) #fitalk fileless malware forensics
(160820) #fitalk    fileless malware forensics(160820) #fitalk    fileless malware forensics
(160820) #fitalk fileless malware forensics
 
운영체제 인트로
운영체제 인트로운영체제 인트로
운영체제 인트로
 
JetsonTX2 Python
 JetsonTX2 Python  JetsonTX2 Python
JetsonTX2 Python
 
한글시계웍샵_SW
한글시계웍샵_SW한글시계웍샵_SW
한글시계웍샵_SW
 

More from fromitive

Higher order procedure2 with conventional interface
Higher order procedure2 with conventional interface Higher order procedure2 with conventional interface
Higher order procedure2 with conventional interface fromitive
 
Project of kshield_jr_open_seminar
Project of kshield_jr_open_seminarProject of kshield_jr_open_seminar
Project of kshield_jr_open_seminarfromitive
 
Dll search order hijacking
Dll search order hijacking Dll search order hijacking
Dll search order hijacking fromitive
 
Reverse Engineering 2015.02.09
Reverse Engineering 2015.02.09Reverse Engineering 2015.02.09
Reverse Engineering 2015.02.09fromitive
 
Malware Traffic analysis
Malware Traffic analysisMalware Traffic analysis
Malware Traffic analysisfromitive
 
Load of Buffer Overflow 문제풀이
Load of Buffer Overflow 문제풀이Load of Buffer Overflow 문제풀이
Load of Buffer Overflow 문제풀이fromitive
 
해커스쿨 FTZ 문제 풀이
해커스쿨 FTZ 문제 풀이해커스쿨 FTZ 문제 풀이
해커스쿨 FTZ 문제 풀이fromitive
 

More from fromitive (7)

Higher order procedure2 with conventional interface
Higher order procedure2 with conventional interface Higher order procedure2 with conventional interface
Higher order procedure2 with conventional interface
 
Project of kshield_jr_open_seminar
Project of kshield_jr_open_seminarProject of kshield_jr_open_seminar
Project of kshield_jr_open_seminar
 
Dll search order hijacking
Dll search order hijacking Dll search order hijacking
Dll search order hijacking
 
Reverse Engineering 2015.02.09
Reverse Engineering 2015.02.09Reverse Engineering 2015.02.09
Reverse Engineering 2015.02.09
 
Malware Traffic analysis
Malware Traffic analysisMalware Traffic analysis
Malware Traffic analysis
 
Load of Buffer Overflow 문제풀이
Load of Buffer Overflow 문제풀이Load of Buffer Overflow 문제풀이
Load of Buffer Overflow 문제풀이
 
해커스쿨 FTZ 문제 풀이
해커스쿨 FTZ 문제 풀이해커스쿨 FTZ 문제 풀이
해커스쿨 FTZ 문제 풀이
 

이무송 스터디 HEX Editor로 PE 분석하기.pptx

  • 1. PE Header 개요 이무송 fromitive@gmail.com HEX Editor로 PE HEADER 분석하기
  • 3. 지난 시간 컴퓨터 핵심 논리 구조 (폰노이만 구조) “컴퓨터는 CPU와 MEMORY그리고 COMMON BUS로 구성되며” 메모리 안의 데이터(binary)를 처리하는 기계다 ALU (계산하는 장치) Control Unit (데이터를 가져오는 장치) 010101011010 COMMON BUS
  • 4. 지난 시간 컴퓨터 핵심 논리 구조 (폰노이만 구조) 메모리 안은 binary 데이터가 저장 되어 있다 명령어와 처리 데이터를 구분하지 않는다 CPU에서 데이터를 가져오기 위해 주소(Offset)정보를 이용함
  • 5. 지난 시간 PE file format 컴퓨터의 다양한 요구사항에 맞춰진, 윈도우(운영체제)에서 사용하는 실행 파일 양식이다 실행에 필요한 정보와 처리 할 데이터가 들어있다. compiler source code Excutable file (PE file format)
  • 6. 지난 시간 PE file format 윈도우에서 사용하는 실행 파일 양식이다 실행에 필요한 정보와 처리 할 데이터가 들어있다. Hex editor로 본 Executable file 문서가 아닌 binary로 되어있다.
  • 7. 지난 시간 PE file format 구성 요소 Excutable File HEADER SECTIONS SECTIONS SECTION PE는 HEADER(실행에 필요한 정보) 와 SECTION(처리할 데이터)로 구성되어 있다.
  • 8. 지난 시간 PE file format 구성 요소 - HEADER의 내부 구조 HEADER IMAGE_DOS_HEADER IMAGE_NT_HEADERS IMAGE_OPTIONAL_HEADER SECTION_TABLES
  • 9. 지난 시간 PE Header들에게 얻을 수 있는 것들 ● IMAGE_DOS_HEADER ○ IMAGE_NT_HEADER (PE 헤더) 의 시작 주소 값을 얻을 수 있다. ● IMAGE_NT_HEADERS ○ 실행 할 수 있는 CPU type과 section의 개수를 얻을 수 있다.
  • 10. 지난 시간 PE Header들에게 얻을 수 있는 것들 ● IMAGE_OPTIONAL_HEADER ○ 실행에 필요한 offset(주소 값)과 크기 그리고 실행에 필요한 함수(EXE) 와 제공하는 함수(DLL) 정보를 가지고 있다 (DATA_DIRECTORY) ● SECTION tables ○ 각 section의 offset과 크기 그리고 속성(읽기, 쓰기, 실행 등..)을 알 수 있다.
  • 11. 지난 시간 참고 자료 ● Low-Level Programming: C, Assembly, and Program Execution on Intel® 64 Architecture 1st ed. Edition - chapter 1. Basic computer Architecture ● Learning Malware Analysis: Explore the concepts, tools, and techniques to analyze and investigate Windows malware ● An In-Depth Look into the Win32 Portable Executable File Format - Part 1 ● An In-Depth Look into the Win32 Portable Executable File Format - Part 2 ● http://www.openrce.org/reference_library/files/reference/PE%20Format.pdf ● https://github.com/corkami/pics/blob/master/binary/pe101/pe101ko.png
  • 12. PE HEADER Hex Editor로 분석하면 좋은 이유 ● PE를 다루는 프로그램 개발 가능 (Peviewer,Debugger,packer … 등등) ○ Binary로 읽어 들여야 하기 때문에 Binary 분석에 익숙 해지기 위해서! ○ binary 분석이 재밌(?)어짐 - 친해지면 재밌고 신나잖아요?
  • 13. PE HEADER IMAGE_DOS_HEADER 실행 파일의 맨 첫부분, MZ로 시작, PE 헤더 구조체의 offset값 획득 가능 ** PE File은 Little-endian Byte order로 데이터가 저장되 어 있음!
  • 14. PE HEADER IMAGE_NT_HEADERS NT_HEADERS 안에 FILE_HEADER와 OPTIONAL_HEADER가 포함되어 있음!
  • 15. PE HEADER IMAGE_OPTIONAL_HEADER 0x00 WORD magic 0x10 DWORD AddressOfEntryPoint 0x1C DWORD ImageBase
  • 16. PE HEADER IMAGE_OPTIONAL_HEADER - DataDirectory[16] 0x60 DataDirectory[16] DataDirectory 배열의 Element들은 각자 다른 구조체의 포인터와 그 구조체의 크기를 저장함 각 Element는 순서가 정해져 있음
  • 17. PE HEADER SECTION_HEADERS Section Header 구조체는 NumberOfSection의 값 만큼 가지고 있음 (eg . 이 프로그램은 5개의 SectionHeader가 저장됨) 각 섹션의 Offset과 size를 획득할 수 있어요!
  • 18. PE HEADER SECTION_HEADERS 각 section의 memory 안 에서의Offset과 size값(노란색) file에서의 Offset과 size값(빨간색)
  • 19. PE HEADER SECTION_HEADERS File Memory 섹션 명 size Offset size Offset .text 0xe00 0x400 0xd47 0x1000 .rdata 0xc00 0x1200 0xb2a 0x2000 .data 0x200 0x1e00 0x388 0x3000 .rsrc 0x200 0x2000 0x1e0 0x4000 .reloc 0x200 0x2200 0x158 0x5000
  • 20. PE HEADER SECTION_HEADERS HEADER HEADER .text .rdata .data .text .rdata .data .rsrc .reloc .rsrc .reloc Header까지의 Offset은 같음 (헤더 길이가 일정하기 때문에) 섹션들은 size와 Offset이 변해요