what happens in windows 8 stays in windows 8 moti joseph & marion marschalek defcamp 2014

37
What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014

Upload: june-leonard

Post on 29-Dec-2015

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014

What Happens In Windows 8 Stays In Windows 8

Moti Joseph & Marion Marschalek

Defcamp 2014

Page 2: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014

About UsMoti Joseph

Security Researcher

Marion Marschalek

Malware Analyst

Page 3: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014

Agenda

Vulnerabilities

Automated Vulnerability Search

An Approach

A Solution as Proof of Concept

Demo ;)

Whats next?

Page 4: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014

Intro

Page 5: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014

Got a bug in your

software?

Can I haz it??

Page 6: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014

Chuck Norris On Security.

Vulnerabilities are software mistakes in specification and design, but mostly mistakes in programming. Any large software package will have thousands of mistakes. Once discovered, they can be used to attack systems. This is the point of security patching: eliminating known vulnerabilities. But many systems don't get patched, so the Internet is filled with known, exploitable vulnerabilities.

Page 7: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014
Page 8: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014

How to find vulnerabilities?

Application Penetration TestingFuzzingReverse EngineeringSource Code Review

Or.. Being more advanced:Tracking software bugs, introducing bugs into software, reversing security patches

Page 9: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014

Who is interested in

finding them?

HackersSoftware Companies

Criminals Governments

Media

Page 10: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014

How much does a 0-day vulnerability cost?

Page 11: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014

“White Market”

When or why to sell to white market?

Page 12: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014

“BlackMarket”

Broker? Money? Trust?

Page 13: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014

What happens when you sell to the black market?

Page 14: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014
Page 15: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014

And why automate it?

It‘s faster!!• The hacker – can break more• The software company – can fix faster• Criminals – can make more money•Governments – can ... [SECRET]•Media – has more to write about

Page 16: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014

The Approach

Page 17: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014

What happens in Windows 8 stays in Windows 8...

WinA WinB

lea ecx, [ebp+cb]push ecx push 4 push eax mov [esi], eaxcall ?ULongMult@@YGJKKPAK@Z test eax, eax...push [ebp+cb] ; cbcall ds:__imp__CoTaskMemAlloc@4

xor eax, eaxinc eaxshl eax, cl...shl eax, 2push eax ; cbcall ds:__imp__CoTaskMemAlloc@4

Patch it!

Page 18: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014

Counting Function Calls

quartz.lib

quartz.lib

Page 19: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014

Intsafe.h & Strsafe.h

•Searching for security patches:• Type Conversion• Safe Math Functions• Buffer Boundary Checks on Strings

•Set of 130 Signatures of ‚Safe Functions‘

Page 20: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014

‚Safe Functions‘UInt8AddUShortAddUIntAddULongAddSizeTAddULongLongAddUInt8SubUShortSubUIntSubULongSubSizeTSubULongLongSub

UInt8ToInt8UInt8ToCharByteToInt8ByteToCharShortToInt8ShortToUCharShortToCharUShortToUInt8UShortToShortIntToInt8IntToUCharIntToChar

StringCbGetsStringCbGetsExStringCbLengthStringCbPrintfStringCbPrintfExStringCbVPrintfStringCbVPrintfExStringCchCatStringCchCatExStringCchCatNStringCchCatNExStringCchCopy

... and many many more ....

Page 21: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014

The Approach

Flexible. Extendible.

Awesome.

Windows Library

Parsing to DB

Checking for

Vulnerability

Decompilationor

Disassembly

Diffing Library with New Version

Page 22: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014

The Solution

Page 23: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014

Pretty, eh??

Page 24: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014

Getting the .C

Library Conversion using IDA Pro

means: .dll -> .idb -> .c

Page 25: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014

Library Parsing• DiffRay on

https://github.com/pinkflawd/DiffRay

• Parses a library / directory of libraries

• Manages libraries , functions and signature hits

• Diff libraries functionwise• Based on library ID

or library name pattern

Page 26: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014

The Database

MSSql or SQLite

Page 27: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014

Diff it!

• Compare libraries on a function basis

• Extract hits per function per signature

Page 28: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014

DiffRay HowTo: Configuration

• signatures.conf – whatever symbols you‘re searching for

• sig_mappings.conf – mappings for signatures

• logger.conf – logging output and formatting, details to be found at http://docs.python.org/2/howto/logging.html

• mssql.conf – MSSql access credentials

Page 29: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014

DiffRay HowTo: CMD ParsingMaintenance:

python [dir]\src\Main.py --create-scheme --update-sigs

python [dir]\src\Main.py --parse [library_path] --os [WinA|WinB] --type [C|LST]

python [dir]\src\Main.py --dirparse [directory_path] --os [WinA|WinB] --type [C|LST]

python [dir]\src\Main.py --flushall

Switches:--backend [mssql|sqlite]

--no-flush

Page 30: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014

DiffRay HowTo: CMD Diffing

Info Output & Diffing:

python [dir]\src\Main.py –-search_libs [libname_pattern]

python [dir]\src\Main.py –-lib_all_info [lib_id]

python [dir]\src\Main.py –-diff --lib_1 [winAlib] --lib_2 [winBlib]

python [dir]\src\Main.py –-diff_byname [libname_pattern]

Page 31: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014

WELCOME

to ze

FUTURE

Page 32: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014

BOOM

Page 33: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014

Win8Win10

Page 34: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014

Triggerable? Or not

triggerable?

Page 35: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014

Callstack

Smb2ExecuteCreate -> Smb2ExecuteCreateReal -> SrvCreateFile ->Smb2RkfReadStateAndResume -> Smb2RkfReadState -> Smb2RkfpConvertDeprecatedBlob

Page 36: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014
Page 37: What Happens In Windows 8 Stays In Windows 8 Moti Joseph & Marion Marschalek Defcamp 2014

Happy Diffing.