閱讀文章分享@若渴 2016.1.24

17
閱閱閱閱閱閱 @ 閱閱 2016.1.24 <[email protected]> AJMachine https://cve4fun.hackpad.com/

Transcript of 閱讀文章分享@若渴 2016.1.24

閱讀文章分享 @ 若渴2016.1.24

<[email protected]>AJMachine

https://cve4fun.hackpad.com/

關注動態方式• 閱讀文章我先找出• 有沒有 fb 粉專• 有沒有 YouTube 訂閱• Twitter

• FB 其實蠻好用的• 粉專 -> 點讚 -> 搶先看• 每天打開 fb 看的都是關於資安的新聞• 分享至自己動態,告知自己要看什麼

SMI 到底是軟還是硬呢 XD? 可軟可硬• SMM code completely unaccessible from OS and OS can’t even notice when

exactly SMI is being executed. There’s a several ways to generate SMI:• Ring 0 code can trigger software SMI at any time by writing some byte value to APMC

I/O port B2h.• Internal chipset registers (SMI_EN, GEN_PMCON_1 and others) that accessible via

PCI config space allows to enable or disable different kind of hardware SMI sources.• You can route hardware interrupts into SMM by reconfiguring of advanced

programmable interrupt controller (APIC) that integrated into CPU. • I/O instruction restart CPU feature (chapter 34.12 of IA-32 Architectures Software

Developer’s Manual) allows to generate SMI on any I/O port access by IN or OUT processor instruction.

節錄 Building reliable SMM backdoor for UEFI based platforms

Outline•The memory sinkhole •Undefined behavior: what happed to my code •The impact of GPU-assisted malware on memory forensics: a case study•SLOTH•ATM

HTTPS bicycle attack

The Memory Sinkhole • In Intel, Ring 3 – Userland, Ring 0 – Kernel, Ring-1 - Hypervisor, Ring-2 – SMM

has the firmware, all the most critical security checks • SMM hides from Ring 0

• System Management RAM (SMRAM) is only accessible to SMM• SMM handler • System Management Interrupt (SMI) toggles SMM

• SMM handler • 抓 DSC structure(Global Descriptor Table, Segment selectors,..) 來對此結構初始化

• Attack 技巧• 使用 APIC remap ,把 APIC payload ( 都為 0) 對應至 DSC structure (SMRAM)• 經過 SMM handler 執行完會跳至 0x10:0x8077 的位置去執行。

SMM Security

節錄 The Memory Sinkhole : An architectural privilege escalation vulnerability

The APIC Remap Attack

節錄 The Memory Sinkhole : An architectural privilege escalation vulnerability

節錄 The Memory Sinkhole : An architectural privilege escalation vulnerability

Undefined Behavior: What Happed to my Code • Undefined behavior• Null Pointer Dereference• Oversize Shit• Singed Integer Overflow• Out-of-Bounds Pointer• Type-Punned Point Deference• Uninitialized Read

• 程式碼的行為在 C 規格書上沒有定義,而 c 沒有定義的行為,各個 compiler 會有不同狀況的處理,有可能把 code 移除,造成跟預期結果不一樣,產生漏洞主角 : compiler 。 = =||

Out-of-Bounds Pointer• 指標的加減是 Undefined behavior ,所以要來看 compiler 會做什麼事,如下

code

• end < buf 會被 Clang 轉成 • buf + size < buf • size < 0 • 之後它會刪除 if (end < buf) { ... } 整個 branch ,原本要避免 Singed Integer Overflow (!!)

Type-Punned Point Deference• C 有嚴格限制 aliasing( 兩個指標指向同一個記憶體做存取 ) ,但你往往會 aliasing 導致 undefined behavior ,此行為會導致 compiler沒辦法最佳化• 使用 C 的 union ,告知 compiler 我們是 一樣的,如以下 code

節錄 http://stackoverflow.com/questions/98650/what-is-the-strict-aliasing-rule

PIC/GSM Address Space Layout on Intel Haswell• PIC bus for GPU or DMA

• CPU view• MMIO 有一部分保留給 PIC bus

• DRAM view• MMIO 記憶體範圍是看不到的,所以就看不到 PIC bus

• Intel 解法• 在 CPU view 上設定位置 TOLUD 至 4GB 給 MMIO ,所以 DRAM view 就可以看到相同的位置空間。

• Graphic Stolen Memory (GSM)• CPU view 大部分不能存取的,有 GTT 部分可以存取。• 組成

• Graphics Translation Tables (GTT) : 告知 GPU virtual-to-physical 可由 BIOS 階段設定• Data Range (programming space)

The Impact of GPU-assisted Malware on Memory Forensics: a Case Study• 建立 buffer object 在 Graphics Execution Manage (GEM)

subsystem( 不在 GSM 裡 ) ,可被 CPU 和 GPU domains 看到,使用不同的 virtual address• OS page table• graphic page table

• 攻擊手法• GPU 修改在 GSM 的 graphic page table ,原本對應 buffer object 但可經由修改存取到 CPU 使用 memory 的資料。

只是想了解為什麼 hash collision 跟 TLS 有關SLOTH(CVE-2015-7575)源自 Transcript Collision Attacks:Breaking Authentication in TLS, IKE, and SSH

Client 認證可過,代表 MitMA 可以假裝 Client C

Tyupkin ATM

malware in the ATM

你知道台灣人怎做嗎 ?