This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ================================================================================ | |
| Jmp to Data Memory. (PIE, NO-PIE ๊ด๊ณ ์์.) | |
| ============= | |
| Pattern 1. | |
| clang_m64_smc10.ll | |
| %6 = getelementptr inbounds [24 x i8], [24 x i8]* %2, i64 0, i64 0 | |
| %7 = bitcast i8* %6 to void (...)* | |
| call void (...) %7() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ================================================================================ | |
| Write Executable Memory. ์ ๋ถ NO-PIE ํจํด | |
| ========== | |
| Pattern 1. | |
| x86_smc1.out.ll | |
| (๋ฐ๋ก ์ฐ๊ธฐ) | |
| store i8 1, i8* @data_804807b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| =============================================================================== | |
| POINTER in LLVM IR | |
| =============================================================================== | |
| 1. Pointer Type | |
| inttoptr | |
| ptrtoint | |
| getelementptr | |
| bitcast |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| =============================================================================== | |
| Anderson Algorithm | |
| =============================================================================== | |
| 0. Basic | |
| C์ธ์ด์์ pointer ๋ ๋ค์ ์ธ๊ฐ์ง์ ๊ฐ์ ๊ฐ์ง๋ค. | |
| 0.1 Example Code | |
| ```c | |
| int main(){ | |
| int *pointerA; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| =============================================================================== | |
| SourceFiles | |
| =============================================================================== | |
| 1. x86 nasm code | |
| 1.1. x86_smc1 | |
| 1.2. x86_smc2 | |
| 1.3. x86_smc3 | |
| 1.4. x86_smc4 | |
| 1.5. x86_smc5 | |
| 1.6. x86_smc6 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| =============================================================================== | |
| SMC Codes in LL From Binary | |
| =============================================================================== | |
| X86, X64 Binary ํ์ผ๋ก๋ถํฐ Mcsema์ ์ด์ฉํ์ฌ Lifting๋ LL ํ์ผ์ ๋ํ์ฌ ์ค๋ช ํ๋ค. | |
| ๋ช ๋ น์ด ํํ์ ์ํฅ์ ์ฃผ๋ ๊ธฐ์ค 1. | |
| 1.1. NO-PIE SMC ์ฝ๋ | |
| 1.2. PIE SMC ์ฝ๋ | |
| ๋ช ๋ น์ด ํํ์ ์ํฅ์ ์ฃผ๋ ๊ธฐ์ค 2. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| =============================================================================== | |
| SMC Codes in C -> ll | |
| =============================================================================== | |
| C์ธ์ด์์ ์์ฑํ SMC ์ฝ๋๊ฐ, LL ํ์ผ์์ ๋ํ๋๋ ํํ์ ๋ํ์ฌ ๋งํ๋ค. | |
| =============================================================================== | |
| 1. ์ฝ๋ ์์ญ์ ์ง์ ์์ ํ๋ ๊ฒฝ์ฐ | |
| =============================================================================== | |
| 1.1. PIE SMC ์ฝ๋ | |
| C์ธ์ด์์ .text ์์ญ ๋ค์์ .data ์์ญ์ด ์ค๋ฏ๋ก, offset์ด function์ธ ๊ฒฝ์ฐ ์์์ด๊ณ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| =============================================================================== | |
| SMC Codes in C | |
| =============================================================================== | |
| C์ธ์ด๋ฅผ ํตํ์ฌ ๋ง๋ค ์ ์๋ SMC ์ฝ๋. | |
| =============================================================================== | |
| 1. ์ฝ๋ ์์ญ์ ์์ ํ๋ ๊ฒฝ์ฐ. | |
| =============================================================================== | |
| 1.1. PIE ์ฝ๋์ ๊ฒฝ์ฐ. | |
| address๊ฐ ๊ฒฐ์ ๋์ง ์์์ผ๋ฏ๋ก, directํ๊ฒ ๋ช ์ํ์ฌ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ์์ ํ ์ ์๋ค. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| =============================================================================== | |
| C ์ธ์ด์์ ๋ํ๋๋ SMC ์ฝ๋. | |
| =============================================================================== | |
| C ์ธ์ด์์์ ๋ฉ๋ชจ๋ฆฌ ๋ชจ๋ธ์ ๋ค์๊ณผ ๊ฐ๋ค. | |
| High Address | |
| stack (almost end of address. in gcc-x86 is 0xfffffff0, gcc-x64 is 0xfffffffffffffff0) | |
| heap | |
| uninitialized data | |
| initalized data (data ์์ญ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| =============================================================================== | |
| GCC ์์ PIE์ Non-PIE์ ์ง์ ์ ์ธ ์ฐจ์ด์ . | |
| ๋ณธ ๊ธ์ GCC์ C์ธ์ด์ ๋ํด์ ๋งํ๊ณ ์๋ค. | |
| ๋ค์ด๊ฐ๊ธฐ์ ์์ ์ฃผ์ํ ์ฌํญ. | |
| 1. PIE์ Non-PIE๋ ํ๋์จ์ด ์ํคํ ์ฒ์ ๋ฌผ๋ฆฌ์ ์ธ ํน์ฑ์ด ์๋๋ค. | |
| 2. PIE์ Non-PIE๋ ์ปดํ์ผ๋ฌ์ Linker์ ์ํํธ์จ์ด์ ์ธ ํน์ฑ์ด๋ค. | |
| 3. X86 ์ํคํ ์ฒ์์๋ EIP๋ฅผ ๊ฒฝ์ ํ๋ ๋ช ๋ น์ด๊ฐ ์กด์ฌํ์ง ์์์ Helper Assembly | |
| Procedure๋ฅผ ์ฌ์ฉํ๋ค. (GCC์ ๊ฒฝ์ฐ get_thunk_pc, clang์ ๊ฒฝ์ฐ ๋ณ๋์ Procedure๋ | |
| ์๊ณ call ๋ช ๋ น์ด์ pop ๋ช ๋ น์ด๋ง์ผ๋ก ์ด๋ฅผ ๊ตฌํํ๋ค.) |