๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐Ÿฆพ ๋ณด์•ˆ ๐Ÿฆพ/๋ฆฌ๋ฒ„์‹ฑ

PE ํŒŒ์ผ ๊ตฌ์กฐ

๋ฐ˜์‘ํ˜•

01. PE (Portable Executable)

  • Microsoft์˜ ์šด์˜ ์ฒด์ œ Window OS์—์„œ ์ง€์›๋˜๋Š” ์‹คํ–‰ ํŒŒ์ผ์˜ ๊ตฌ์กฐ
  • ํŒŒ์ผ์ด ๋‹ค๋ฅธ ๊ณณ์œผ๋กœ ์˜ฎ๊ฒจ์ ธ๋„ ์‹คํ–‰ ๊ฐ€๋Šฅํ•˜๋„๋ก ๋งŒ๋“  ํฌ๋งท์œผ๋กœ ๋‹ค์–‘ํ•œ ์šด์˜์ฒด์ œ์—์„œ์˜ ์ด์‹์„ฑ์„ ๋ณด์—ฌ์ค€๋‹ค๋Š” ์˜๋ฏธ์—์„œ Portable Executable์ด๋ผ๊ณ  ๋ถˆ๋ฆผ
  • Window Loader๊ฐ€ ์ฝ”๋“œ๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” ๋ฐ ํ•„์š”ํ•œ ์ •๋ณด๋ฅผ ์บก์Šํ™”ํ•œ ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ์ฒด
  • ์ฝ”๋“œ ์ •๋ณด, ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์œ ํ˜•, ํ•„์š”ํ•œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ํ•จ์ˆ˜, ๋ฉ”๋ชจ๋ฆฌ ๊ณต๊ฐ„ ์š”๊ตฌ์‚ฌํ•ญ ์ •๋ณด ํฌํ•จ
  • ์ฐธ์กฐํ•  DLL, API import ํ…Œ์ด๋ธ”, ์ž์› ๊ด€๋ฆฌ ๋ฐ์ดํ„ฐ, TLS ๋ฐ์ดํ„ฐ ํฌํ•จ

1.1 PE ํŒŒ์ผ ์ข…๋ฅ˜

  • ์‹คํ–‰ ํŒŒ์ผ ๊ณ„์—ด : EXE, SCR(Screen Saver)
  • ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ๊ณ„์—ด : DLL, OCX(Active X), CPL, DRV
  • ๋“œ๋ผ์ด๋ฒ„ ๊ณ„์—ด: SYS, VXD
  • ์˜ค๋ธŒ์ ํŠธ ํŒŒ์ผ ๊ณ„์—ด : OBJ

1.2 ๋ถ„์„ ๋„๊ตฌ

  • PEview
  • PEiD : header๋ฅผ ๊ฐ„๋‹จํ•˜๊ฒŒ ๋ณด์—ฌ์คŒ.
  • exeinfo
  • pestudio
  • Stud_PE
  • prefram.ph

1.3 PE ํŒŒ์ผ ์ƒ์„ฑ ๊ณผ์ •

Compile

  • ์†Œ์Šค ์ฝ”๋“œ๋ฅผ ์ปดํŒŒ์ผ ํ•˜๋ฉด ํ—ค๋” ํŒŒ์ผ๊ณผ ์†Œ์Šค ํŒŒ์ผ์„ ํ•ฉ์ณ ์–ด์…ˆ๋ธ”๋ฆฌ ์ฝ”๋“œ๊ฐ€ ๋งŒ๋“ค์–ด ์ง„๋‹ค.
  • ์ด ๊ณผ์ •์—์„œ Object ํŒŒ์ผ์ด ๋งŒ๋“ค์–ด์ง€๋ฉฐ ๊ธฐ๊ณ„์–ด ์ฝ”๋“œ, ์‹ฌ๋ณผ ํ…Œ์ด๋ธ”, ๋ฐ์ดํ„ฐ ์„น์…˜ ์ •๋ณด๋ฅผ ๋‹ด๊ณ  ์žˆ๋‹ค.

Linking

  • ๋‹ค์ˆ˜์˜ Object ํŒŒ์ผ์„ ํ•˜๋‚˜์˜ ์‹คํ–‰ ํŒŒ์ผ๋กœ ๊ฒฐํ•ฉํ•œ๋‹ค.
  • ํ•„์š”ํ•œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ํŒŒ์ผ(.lib, .dll)์„ ์ฐธ์กฐํ•˜์—ฌ ํ”„๋กœ๊ทธ๋žจ์ด ํ•„์š”๋กœ ํ•˜๋Š” ์™ธ๋ถ€ ํ•จ์ˆ˜๋‚˜ ๋ฐ์ดํ„ฐ๋ฅผ ์—ฐ๊ฒฐํ•œ๋‹ค.
  • ํ”„๋กœ๊ทธ๋žจ์˜ ์—”ํŠธ๋ฆฌ ํฌ์ธํŠธ๊ฐ€ ๊ฒฐ์ •๋˜๊ณ , ํ”„๋กœ๊ทธ๋žจ ๋‚ด์˜ ์‹ฌ๋ณผ๋“ค์ด ์ฃผ์†Œ๋กœ ๋ณ€ํ™˜๋œ๋‹ค.

PE file

  • ๋งํ‚น ๊ณผ์ •์ด ์™„๋ฃŒ๋˜๋ฉด, ๋ง์ปค๋Š” PE ํŒŒ์ผ์˜ ๊ตฌ์กฐ๋ฅผ ์ƒ์„ฑํ•œ๋‹ค.

 

 

02. PE ํŒŒ์ผ ๊ตฌ์กฐ

 

PE ํŒŒ์ผ์€ ํฌ๊ฒŒ PE ํ—ค๋”์™€ ์„น์…˜ ๋ถ€๋ถ„์œผ๋กœ ๊ตฌ์„ฑ๋œ๋‹ค. PE ํ—ค๋”๋Š” ํŒŒ์ผ์„ ์‹คํ–‰ํ•˜๊ธฐ ์œ„ํ•œ ์ „๋ฐ˜์ ์ธ ์ •๋ณด๊ฐ€ ๊ตฌ์กฐ์ฒด ํ˜•์‹์œผ๋กœ ์ €์žฅ๋˜์–ด ์žˆ๊ณ , ์„น์…˜ ๋ถ€๋ถ„์€ ํŒŒ์ผ์˜ ์‹ค์ œ ์ฝ”๋“œ,. ๋ฐ์ดํ„ฐ, ๋ฆฌ์†Œ์Šค ๋“ฑ์˜ ๋‚ด์šฉ์ด ์กด์žฌํ•œ๋‹ค.

 

2.1 DOS Header

  • “4D 5A”๋กœ ์‹œ์ž‘ํ•˜๋ฉฐ PE ๊ตฌ์กฐ๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ํŒŒ์ผ์ธ์ง€ ํŒ๋‹จํ•˜๋Š”๋ฐ ์‚ฌ์šฉ๋œ๋‹ค.
  • ์‹œ์ž‘ ๋ถ€๋ถ„๋ถ€ํ„ฐ 64byte๊นŒ์ง€ Image Dos Header ๋ถ€๋ถ„์ด๋‹ค.
typedef struct _IMAGE_DOS_HEADER {
    WORD e_magic;
    WORD e_cblp;
    WORD e_cp;
    WORD e_crlc;
    WORD e_cparhdr;
    WORD e_minalloc;
    WORD e_maxalloc;
    WORD e_ss;
    WORD e_sp;
    WORD e_csum;
    WORD e_ip;
    WORD e_cs;
    WORD e_lfarlc;
    WORD e_ovno;
    WORD e_res[4];
    WORD e_oemid;
    WORD e_oeminfo;
    WORD e_res2[10];
    LONG e_lfanew;
} IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
  • Image Dos Header ์— ๋“ค์–ด๊ฐˆ ๋‚ด์šฉ์€ WinNT.H ํ—ค๋” ํŒŒ์ผ์— ๊ตฌ์กฐ์ฒด์˜ ํ˜•์‹์œผ๋กœ ์„ค์ •๋˜์–ด ์žˆ๋‹ค.
  • ์ด ๊ตฌ์กฐ์ฒด์˜ ํฌ๊ธฐ๋ฅผ ๊ณ„์‚ฐํ•˜๋ฉฐ 64byte ์ด๋‹ค.
  • e_magic : PE ๊ตฌ์กฐ๋ฅผ ๊ฐ€์ง„ ํŒŒ์ผ์ธ์ง€ ํ™•์ธํ•  ๋•Œ . ํ”„๋กœ๊ทธ๋žจ์„ ์‹คํ–‰ํ•˜๋ฉด ๊ฐ€์žฅ ๋จผ์ € ์ด ๋ถ€๋ถ„์˜ 2Byte๋ฅผ ์ฝ์–ด์˜จ ํ›„ “4D 5A”๊ฐ€ ๋งž๋Š”์ง€ ํ™•์ธํ•œ๋‹ค.
  • e_lfanew : Image_NT_Header์˜ ์‹œ์ž‘ ์ฃผ์†Œ๋ฅผ ๋‚˜ํƒ€๋‚ธ๋‹ค. ํŒŒ์ผ์— ๋”ฐ๋ผ ๋‹ค๋ฅธ ๊ฐ’์ด ์ €์žฅ๋œ๋‹ค.

 

2.2 DOS Stub

  • DOS ๋ชจ๋“œ์—์„œ ์‹คํ–‰๋˜์—ˆ์„ ๋•Œ ์‹คํ–‰ํ•  ๋‚ด์šฉ์„ ์ €์žฅ
  • DOS ๋ชจ๋“œ๋กœ ์‹คํ–‰๋˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ “This program cannot be run in DOS mode”๋ผ๋Š” ๋ฉ”์‹œ์ง€๋ฅผ ๋‚˜ํƒ€๋‚ธ๋‹ค.

 

2.3 NT Header

IMAGE_NT_HEADERS

typedef struct _IMAGE_NT_HEADERS {
    DWORD Signature;
    IMAGE_FILE_HEADER FileHeader;
    IMAGE_OPTIONAL_HEADER OptionalHeader;
} IMAGE_NT_HEADERS, *PIMAGE_NT_HEADERS;
  • “50 45 00 00”(PE..) ์œผ๋กœ ์‹œ์ž‘ํ•˜๋Š” ์ง€์ ์ด NT_Header์˜ ์‹œ์ž‘ ๋ถ€๋ถ„์ด๋‹ค.
  • WinNT.H์˜ ๊ตฌ์กฐ์ฒด์—์„œ e_lfanew์— ์ €์žฅ๋œ ์ฃผ์†Œ๊ฐ’์ด ๊ฐ€๋ฅดํ‚ค๋Š” ๋ถ€๋ถ„์ด ์ด ๋ถ€๋ถ„์ด๋‹ค.
  • ๋™์ž‘ํ•˜๋Š” CPU, ์„น์…˜์˜ ์ˆ˜, ์ƒ์„ฑ ์‹œ๊ฐ„ ๋“ฑ ํŒŒ์ผ์˜ ์‹คํ–‰์— ํ•„์š”ํ•œ ์ฃผ์š” ์ •๋ณด๋“ค์„ ์ €์žฅํ•œ๋‹ค.

IMAGE_FILE_HEADER

typedef struct _IMAGE_FILE_HEADER {
    WORD  Machine;
    WORD  NumberOfSections;
    DWORD TimeDateStamp;
    DWORD PointerToSymbolTable;
    DWORD NumberOfSymbols;
    WORD  SizeOfOptionalHeader;
    WORD  Characteristics;
} IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
๋ณ€์ˆ˜๋ช… ์„ค๋ช…
Machine ํŒŒ์ผ์ด ๋™์ž‘ํ•  ์ˆ˜ ์žˆ๋Š” CPU ์ข…๋ฅ˜
Number Of Sections ์ด ํŒŒ์ผ์ด ๊ฐ€์ง„ ์„ธ์…˜์˜ ๊ฐœ์ˆ˜๋ฅผ ์•Œ๋ฆผ
์ผ๋ฐ˜์ ์œผ๋กœ .text, .rdata, .data, .rsrc 4๊ฐœ ์„น์…˜์ด ์กด์žฌ  
Time Data Stamp obj → PE ํŒŒ์ผ์„ ๋งŒ๋“  ์‹œ๊ฐ„์„ ์•Œ๋ฆผ
Size Of Optional Header MAGE_OPTIONAL_HEADER32์˜ ๊ตฌ์กฐ์ฒด ํฌ๊ธฐ๋ฅผ ์•Œ๋ฆผ.
์šด์˜์ฒด์ œ๋งˆ๋‹ค ํฌ๊ธฐ๊ฐ€ ๋‹ค๋ฅผ ์ˆ˜ ์žˆ์–ด PE๋กœ๋”์—์„œ๋Š” ์ด ๊ฐ’์„ ๋จผ์ € ํ™•์ธ  
Characteristics ํ˜„์žฌ ํŒŒ์ผ ํ˜•์‹

IMAGE_OPTIONAL_HEADER

typedef struct _IMAGE_OPTIONAL_HEADER {
    WORD   Magic;
    BYTE   MajorLinkerVersion;
    BYTE   MinorLinkerVersion;
    DWORD  SizeOfCode;
    DWORD  SizeOfInitializedData;
    DWORD  SizeOfUninitializedData;
    DWORD  AddressOfEntryPoint;
    DWORD  BaseOfCode;
    DWORD  BaseOfData;
    DWORD  ImageBase;
    DWORD  SectionAlignment;
    DWORD  FileAlignment;
    WORD   MajorOperatingSystemVersion;
    WORD   MinorOperatingSystemVersion;
    WORD   MajorImageVersion;
    WORD   MinorImageVersion;
    WORD   MajorSubsystemVersion;
    WORD   MinorSubsystemVersion;
    DWORD  Win32VersionValue;
    DWORD  SizeOfImage;
    DWORD  SizeOfHeaders;
    DWORD  CheckSum;
    WORD   Subsystem;
    WORD   DllCharacteristics;
    DWORD  SizeOfStackReserve;
    DWORD  SizeOfStackCommit;
    DWORD  SizeOfHeapReserve;
    DWORD  SizeOfHeapCommit;
    DWORD  LoaderFlags;
    DWORD  NumberOfRvaAndSizes;
    IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
} IMAGE_OPTIONAL_HEADER32, *PIMAGE_OPTIONAL_HEADER32;
๋ณ€์ˆ˜๋ช… ์„ค๋ช…
Magic 32bit → 0x10B
64bit → 0x20B  
Major Linker Version
Minor Linker Version
์‚ฌ์šฉํ•œ ์ปดํŒŒ์ผ๋Ÿฌ ๋ฒ„์ „
Size Of Code ์ฝ”๋“œ ์–‘์˜ ์ „์ฒด ํฌ๊ธฐ
- ์•…์„ฑ์ฝ”๋“œ : ์ด ๊ฐ’์„ ์ฐธ๊ณ ํ•˜์—ฌ ์ž์‹ ์˜ ์ฝ”๋“œ๋ฅผ ๋ณต์ œํ•  ์œ„์น˜ ๊ธฐ์ค€์„ ์žก์Œ
- ์†”๋ฃจ์…˜ : ์ฝ”๋“œ ์„น์…˜์˜ ๋ฌด๊ฒฐ์„ฑ ๊ฒ€์‚ฌ
Address Of Entry Point ํŒŒ์ผ์ด ๋ฉ”๋ชจ๋ฆฌ์—์„œ ์‹œ์ž‘๋˜๋Š” ์ง€์ .
Base Of Code ์‹คํ–‰ ์ฝ”๋“œ ์œ„์น˜.
- ImageBase ์™€ BaseOfCode ๋ฅผ ๋”ํ•œ ๊ฐ’๋ถ€ํ„ฐ ์ฝ”๋“œ ์‹œ์ž‘
Image Base ๋กœ๋“œํ•  ๊ฐ€์ƒ ๋ฉ”๋ชจ๋ฆฌ ์ฃผ์†Œ
Section Alignment
File Alignment
๊ฐ ์„ธ์…˜์„ ์ •๋ ฌํ•˜๊ธฐ ์œ„ํ•œ ์ •๋ ฌ ๋‹จ์œ„
๊ธฐ๋ณธ๊ฐ’ 0x1000
Size Of Image EXE/DLL์ด ๋ฉ”๋ชจ๋ฆฌ์— ๋กœ๋”ฉ๋์„ ๋•Œ ์ „์ฒดํฌ๊ธฐ
Size Of Headers PEํ—ค๋”์˜ ํฌ๊ธฐ๋ฅผ ์•Œ๋ฆผ
๊ธฐ๋ณธ๊ฐ’ 0x1000
IMAGE_DATA_DIRECTORY ๊ตฌ์กฐ์ฒด - VirtualAddress์™€ Size ํ•„๋“œ
- Export, Import, Rsrc ๋””๋ ‰ํ„ฐ๋ฆฌ์™€ IAT ๋“ฑ์˜ ๊ฐ€์ƒ ์ฃผ์†Œ์™€ ํฌ๊ธฐ ์ •๋ณด

 

 

2.4 SECTION_HEADER

๊ฐ ์„ธ์…˜์— ๋Œ€ํ•œ ์ด๋ฆ„, ์‹œ์ž‘ ์ฃผ์†Œ, ์‚ฌ์ด์ฆˆ ๋“ฑ์˜ ์ •๋ณด๋ฅผ ํฌํ•จํ•˜๋Š” ๊ตฌ์กฐ์ฒด์ด๋‹ค.

typedef struct _IMAGE_SECTION_HEADER {
    BYTE  Name[IMAGE_SIZEOF_SHORT_NAME]; 
    union {
        DWORD PhysicalAddress;
        DWORD VirtualSize;
    } Misc;
    DWORD VirtualAddress;               
    DWORD SizeOfRawData;                 
    DWORD PointerToRawData;              
    DWORD PointerToRelocations;        
    DWORD PointerToLinenumbers;         
    WORD  NumberOfRelocations;           
    WORD  NumberOfLinenumbers;           
    DWORD Characteristics;              
} IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER;

๋ณ€์ˆ˜๋ช… ์„ค๋ช…
Name ์„น์…˜์˜ ์ด๋ฆ„(์˜ˆ: .text, .data, .rsrc ๋“ฑ)
Virtual Size ์„น์…˜์˜ ํฌ๊ธฐ
Virtual Address ์„น์…˜์ด ๋ฉ”๋ชจ๋ฆฌ์— ๋กœ๋“œ๋  ๋•Œ์˜ ์ฃผ์†Œ.
Size Of Raw Data ํŒŒ์ผ ๋‚ด์—์„œ ์„น์…˜์ด ์ฐจ์ง€ํ•˜๋Š” ํฌ๊ธฐ.
Pointer To Raw Data ํŒŒ์ผ ๋‚ด์—์„œ ์„น์…˜ ๋ฐ์ดํ„ฐ๊ฐ€ ์‹œ์ž‘๋˜๋Š” ์œ„์น˜

 

2.5 Section

PEํŒŒ์ผ ์—์„œ ์„น์…˜์€ ํ”„๋กœ๊ทธ๋žจ์˜ ์‹ค์ œ ๋‚ด์šฉ์„ ๋‹ด๊ณ  ์žˆ๋Š” ๋ธ”๋ก. ๊ฐ ์„น์…˜์—์„œ ๋‹ด๊ณ  ์žˆ๋Š” ์ •๋ณด๋“ค์€ ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

Section ์ข…๋ฅ˜

์„น์…˜ ์ด๋ฆ„ ์„ค๋ช…

์„น์…˜ ์ด๋ฆ„  ์„ค๋ช…
.text ์ฝ”๋“œ ์„น์…˜ - ํ”„๋กœ๊ทธ๋žจ์„ ์‹คํ–‰ํ•˜๊ธฐ ์œ„ํ•œ ์ฝ”๋“œ๋ฅผ ๋‹ด๋Š” ์„น์…˜
- CPU์˜ ๋ช…๋ น ํฌ์ธํ„ฐ๊ฐ€ ๋˜๋Š” IP ๋ ˆ์ง€์Šคํ„ฐ๋Š” ์ด ์„น์…˜ ๋‚ด์— ์กด์žฌํ•˜๋Š” ์ง€๋ฅผ ๊ฐ€์ง
- 32๋น„ํŠธ์˜ ๊ฒฝ์šฐ VC++ 7.0๋ถ€ํ„ฐ ์‹คํ–‰ ๊ธฐ๋Šฅ์„ ๊ฐ€์ง„ ๋™์‹œ์— ์ดˆ๊ธฐํ™”๋˜์ง€ ์•Š์€ ๋ฐ์ดํ„ฐ๋ฅผ ๋‹ด์€ .text ์„น์…˜์ด ์กด์žฌ
.data ๋ฐ์ดํ„ฐ ์„น์…˜ - ์ดˆ๊ธฐํ™”๋œ ์ „์—ญ ๋ณ€์ˆ˜๋“ค์„ ๋‹ด๊ณ  ์žˆ๋Š” ์ฝ๊ณ  ์“ฐ๊ธฐ๊ฐ€ ๊ฐ€๋Šฅํ•œ ์„น์…˜
- ์ด์ „์—๋Š” ์ดˆ๊ธฐํ™”๋˜์ง€ ์•Š์€ ๋ฐ์ดํ„ฐ๋ฅผ ์œ„ํ•œ ๋ฐ์ดํ„ฐ ์„น์…˜์œผ๋กœ .bss ์„น์…˜์„ ์ œ๊ณต. ๊ฐ€์ƒ ๋ฉ”๋ชจ๋ฆฌ์— ๋งคํ•‘๋  ๋•Œ ๋ณดํ†ต .data ์„น์…˜์— ๋ณ‘ํ•ฉ
- 64๋น„ํŠธ์—์„œ๋Š” PE ํŒŒ์ผ์—์„œ๋ถ€ํ„ฐ .bss ์„น์…˜๊ณผ .data ์„น์…˜์— ๋ณ‘ํ•ฉ
.rdata ์ฝ๊ธฐ ์ „์šฉ ๋ฐ์ดํ„ฐ ์„น์…˜ - ๋ฌธ์ž์—ด ์ƒ์ˆ˜๋‚˜ C++ ๊ฐ€์ƒ ํ•จ์ˆ˜ ํ…Œ์ด๋ธ” ๋“ฑ์„ ๋ฐฐ์น˜
- ์ฝ”๋“œ ์ƒ์— ์ฐธ์กฐํ•˜๋Š” ์ฝ๊ธฐ ์ „์šฉ ๋ฐ์ดํ„ฐ(.edata, .debug ๋“ฑ)๋„ ์ด ์„น์…˜์— ๋ณ‘ํ•ฉ
.reloc ๊ธฐ์ค€ ์žฌ๋ฐฐ์น˜ ์„น์…˜ - ์‹คํ–‰ ํŒŒ์ผ์— ๋Œ€ํ•œ ๊ธฐ์ค€ ์žฌ๋ฐฐ์น˜ ์ •๋ณด๋ฅผ ๋‹ด๊ณ  ์žˆ๋Š” ์„น์…˜
.edata ๋‚ด๋ณด๋‚ด๊ธฐ(export) ์„น์…˜ - ๋‚ด๋ณด๋‚ผ ํ•จ์ˆ˜์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ๋‹ด๊ณ  ์žˆ๋Š” ์„น์…˜
- .rdata์— ๋ณ‘ํ•ฉ๋˜๊ธฐ ๋•Œ๋ฌธ์— DLL์—์„œ ๋ณ„๋„์˜ ์„ธ์…˜์ด ์กด์žฌํ•˜์ง€ ์•Š์Œ
.idata ๊ฐ€์ ธ์˜ค๊ธฐ(import) ์„น์…˜ - ๊ฐ€์ ธ์˜ฌ dll๊ณผ ๊ทธ ํ•จ์ˆ˜ ๋ฐ ๋ณ€์ˆ˜์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ๋‹ด๊ณ  ์žˆ๋Š” ์„น์…˜
- IAT(Import Address Table)์ด ์กด์žฌ
- .rdata์— ๋ณ‘ํ•ฉ
.didat ์ง€์—ฐ ๋กœ๋“œ ์„น์…˜ - ์ง€์—ฐ ๋กœ๋”ฉ(Delay-Loading)์„ ์œ„ํ•œ ์„น์…˜
.tls TLS ์„น์…˜ _declspec(thread) ์ง€์‹œ์–ด์™€ ํ•จ๊ป˜ ์„ ์–ธ๋˜๋Š” ์Šค๋ ˆ๋“œ ์ง€์—ญ ์ €์žฅ์†Œ(Thread Local Storage)๋ฅผ ์œ„ํ•œ ์„น์…˜
.rsrc ๋ฆฌ์†Œ์Šค ์„น์…˜ ๋Œ€ํ™”์ƒ์ž, ์•„์ด์ฝ˜, ์ปค์„œ, ๋ฒ„์ „ ์ •๋ณด ๋“ฑ์˜ ์œˆ๋„์šฐ PE ํŒŒ์ผ์ด ๋‹ด๊ณ  ์žˆ๋Š” ๋ฆฌ์†Œ์Šค ๊ด€๋ จ ๋ฐ์ดํ„ฐ๋“ค์ด ๋ฐฐ์น˜
.debug ๋””๋ฒ„๊น… ์„น์…˜ - ๋””๋ฒ„๊น… ์ •๋ณด๋ฅผ ํฌํ•จ
- MS๋Š” ์˜ค๋ž˜์ „๋ถ€ํ„ฐ ์ด ์„น์…˜์— ๋””๋ฒ„๊น… ๊ด€๋ จ ๊ธฐ์ดˆ ์ •๋ณด๋งŒ์„ ๋‹ด๊ณ , ์‹ค์ œ ์ •๋ณด๋Š” PDB ํŒŒ์ผ์— ๋ณ„๋„๋กœ ๋ณด๊ด€

 

์„น์…˜ ์ด๋ฆ„์˜ ๊ฒฝ์šฐ ๊ถŒ์žฅ๊ฐ’์ด๋ฏ€๋กœ ์„น์…˜ ์ด๋ฆ„์œผ๋กœ ๋‚ด์šฉ์„ ํŒ๋‹จํ•˜๋ฉด ์•ˆ๋œ๋‹ค. ํŠนํžˆ, ๋ฆด๋ฆฌ์ฆˆ ์˜ต์…˜ ๊ฐ™์€ ๊ฒฝ์šฐ, ์„น์…˜๋“ค์ด ํ•ฉ์ณ์ ธ์„œ ํ•˜๋‚˜์˜ ์„น์…˜์œผ๋กœ ์กด์žฌํ•˜๋Š” ๊ฒฝ์šฐ๋„ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ์„น์…˜ ์ด๋ฆ„์„ ์ด์šฉํ•ด์„œ ์ฐพ๋Š” ๊ฒƒ๋ณด๋‹ค IMAGE_NT_HEADER์— ์žˆ๋Š” Data Directory์˜ ๊ฐ’์„ ์ฐธ์กฐํ•ด์„œ ์ฐพ๋„๋ก ํ•ด์•ผ ํ•œ๋‹ค.

 

 

์ฐธ์กฐ

https://mocharoll.tistory.com/15

PE Format - Win32 apps

pe ๊ตฌ์กฐ ๋ถ„์„

 

๋ฐ˜์‘ํ˜•