# 自我檢查項目
## 隔離執行環境的建構
Traditional Apporach -> "known-bad"
TXT -> "known-good focus"
* 目標: 在惡意軟體**發行之前**就檢查到
* 方法: 從 bad list 方法轉為 good list
* 只紀錄哪些軟體是可信任的, 針對這些項目去追蹤 ( Luanch Control Policy )
* 相較於以往的方式, 現在不需要紀錄惡意程式的 list
---
### Trusted Execution Environment (TEE) 的應用
Nvidia TLK (Trusted Little Kernel)
* 基於 TrustZone 理念開發
* 將每個處理器都劃分成兩個虛擬的 Cores
* Secure
* Non-Secure
* 加入一個新的 core mode
* Monitor Mode
* do context-switch between two states (Secure & Non-Secure)
* 限止只有某些 mechanisms 能進入 Monitor Mode
* system(master) 和 TLK(slave) software operate in a master-slave relationship
* TLK 由下列幾個環境和元件組成
* Non-Secure Environment (NSE)
* 在 normal mode 執行的作業系統或其他程式
* Open Trusted Environment (OTE)
* A separate, software-partitioned, environment that provides trusted operations
* e.g. OTE 確保在 OTE 底下執行的應用程式的內容與原先取得的信任情況的內容並無不同
* Monitor
* Handles all communication between the NSE and OTE
* Secure storage
* consists of several components that work together to store and access secured and encrypted data in a folder
* 參考資料
* [TEE介绍與應用](http://blog.csdn.net/wed110/article/details/53894927)
* [TLK: A FOSS Stack for Secure Hardware Tokens](https://www.google.com.tw/url?sa=t&rct=j&q=&esrc=s&source=web&cd=4&cad=rja&uact=8&ved=0ahUKEwjz_qO99r_XAhWLQpQKHWySDYkQFgg-MAM&url=https%3A%2F%2Fwww.w3.org%2F2012%2Fwebcrypto%2Fwebcrypto-next-workshop%2Fpapers%2Fwebcrypto2014_submission_25.pdf&usg=AOvVaw3LIQk6LjBbF6f8xX8WBX5t)
* [TRUSTED LITTLE KERNEL (TLK) FOR TEGRA: FOSS EDITION](https://www.google.com.tw/url?sa=t&rct=j&q=&esrc=s&source=web&cd=3&cad=rja&uact=8&ved=0ahUKEwiVucKF_L_XAhUBnpQKHSOgCdAQFgg1MAI&url=http%3A%2F%2Fnv-tegra.nvidia.com%2Fgitweb%2F%3Fp%3D3rdparty%2Fote_partner%2Ftlk.git%3Ba%3Dblob_plain%3Bf%3Ddocumentation%2FTegra_BSP_for_Android_TLK_FOSS_Reference.pdf%3Bhb%3DHEAD&usg=AOvVaw3k5wG-x9OHmdRutNImoFeW)
---
### 是否已詳細閱讀 Moxie 處理器架構的 Architecture 文件?能否用 Moxie 組合語言寫出迴圈版本的 Fibonacci 數列程式?
Moxie processor
* general purpose bi-endian load-store processor
* 16 個 32-bit general purpose registers
| Name | Description |
| -------- | -------- |
| $fp | frame pointer |
| $sp | stack pointer |
| $r0 through $r13 | general purpose registers |
* comprehensive ISA
* 原始設計目的: ideal target for the **GNU Compiler Collection**
* Instruction Set
* 參考 [Moxie Architecture](http://moxielogic.org/blog/pages/architecture.html)
---
### binutils, gcc, glibc, qemu 到 libffi 這些專案的作用
* binutils (GNU Binary Utilities)
* a collection of binary tools
* 包含 linker, assembler 及其他工具程式
* gcc (GNU Compiler Collection)
* 程式語言編譯器套件
* 可處理 C, C++, Pascal, Objective-C, Java 等其他語言
* glibc (GNU C Library)
* 一種C函式庫,是程式執行時使用到的一些API集合
* qemu
* generic and open source machine emulator and virtualizer
* 模擬處理器
* 可以在一種架構(如x86 PC機器)下執行另一種架構(如ARM)下的作業系統和程式
* QEMU能模擬至接近真實電腦的速度
* 有 User mode 和 System mode 模擬模式
* libffi
---
### Intel 的 Software Guard Extensions 關鍵特性為何?並舉出共筆以外的應用案例
SGX 使用特殊的指令和軟體, 將應用程式和數據放入一個「圍圈」(enclave) 中, 使其不會受到解密或修改, enclave 是一個在 memory 中受到保護的區段
* hardware-assisted trusted execution environment with the smallest possible attack surface: the CPU boundary
---
### moxiebox 打造出隔離執行 (sandbox) 的運作環境該如何與外界溝通?列出對應的程式碼並解讀
---
### 是否已詳閱文件 [sandbox execution environment](https://github.com/sysprog21/moxiebox/blob/master/sandbox-design.md) 呢? 解釋 法國的加密貨幣硬體錢包公司 Ledger 的 BOLOS 運作原理
---
### 何謂 cross compiler 呢?我們為何需要?
---
### ELF 執行檔格式包含哪些 section 呢?又在哪裡可見到詳細描述?
---
### 是否已掌握 GNU gprof 的使用?運作原理為何?
* 提示: 參閱 [raytracing](https://hackmd.io/s/HyuBWDwYl) 作業規範和共筆成果
---
### 是否已操作 remote GDB 呢?如何在執行時期檢驗載入的 ELF 執行檔裡頭 `.text` 和 `.data` section 內容呢?
---
### 是否詳讀文件 [遠端除錯](http://www.study-area.org/cyril/opentools/opentools/x1265.html) 並記錄心得呢?是否在 GNU/Linux 實際照著操作?又,遇到什麼問題呢?
* 提示: 硬體架構以不同,文章提及 IA32,但現在已是 x86_64 架構
---
### GDB 命令如 `step` 是如何透過 GDB stub 傳遞到 [moxiebox](https://github.com/sysprog21/moxiebox) 裡頭呢?兩邊的通訊協定又為何?
* 提示: 需要對照看 [moxiebox](https://github.com/sysprog21/moxiebox) 的 `src/sandbox.cc` 檔案內容和 [GDB Remote Serial Protocol](https://sourceware.org/gdb/onlinedocs/gdb/Remote-Protocol.html)
---
### 是否理解 GDB Macro 和 [Command Files](https://sourceware.org/gdb/onlinedocs/gdb/Command-Files.html) 呢?能否透過 [moxiebox](https://github.com/sysprog21/moxiebox) 進行練習呢?