SlideShare a Scribd company logo
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

PPTX
Windows reversing study_basic_3
J J
 
PPTX
System+os study 1
J J
 
PDF
리눅스 커널 기초 태스크관리
Seungyong Lee
 
PDF
1. 악성코드 진단 기법 개론
Youngjun Chang
 
PPTX
Filemerge성능분석
선 유
 
PPTX
파이썬 파일처리 이해하기
Yong Joon Moon
 
PDF
악성코드 분석 도구
Youngjun Chang
 
PDF
2. windows system과 file format
Youngjun Chang
 
Windows reversing study_basic_3
J J
 
System+os study 1
J J
 
리눅스 커널 기초 태스크관리
Seungyong Lee
 
1. 악성코드 진단 기법 개론
Youngjun Chang
 
Filemerge성능분석
선 유
 
파이썬 파일처리 이해하기
Yong Joon Moon
 
악성코드 분석 도구
Youngjun Chang
 
2. windows system과 file format
Youngjun Chang
 

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

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

More from fromitive (6)

PDF
Project of kshield_jr_open_seminar
fromitive
 
PDF
Dll search order hijacking
fromitive
 
PDF
Reverse Engineering 2015.02.09
fromitive
 
PDF
Malware Traffic analysis
fromitive
 
PDF
Load of Buffer Overflow 문제풀이
fromitive
 
PDF
해커스쿨 FTZ 문제 풀이
fromitive
 
Project of kshield_jr_open_seminar
fromitive
 
Dll search order hijacking
fromitive
 
Reverse Engineering 2015.02.09
fromitive
 
Malware Traffic analysis
fromitive
 
Load of Buffer Overflow 문제풀이
fromitive
 
해커스쿨 FTZ 문제 풀이
fromitive
 
Ad

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

  • 1. PE Header 개요 이무송 [email protected] 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이 변해요