+ All Categories
Home > Technology > Troopers Diffray v1.1

Troopers Diffray v1.1

Date post: 06-May-2015
Category:
Upload: pinkflawd
View: 3,713 times
Download: 0 times
Share this document with a friend
Description:
slides from our troopers talk march 2014
57
What Happens In Windows 7 Stays In Windows 7 Moti Joseph & Marion Marschalek Troopers Conference 2014
Transcript
Page 1: Troopers Diffray v1.1

What Happens In Windows 7 Stays In Windows 7 Moti Joseph & Marion Marschalek

Troopers Conference 2014

Page 2: Troopers Diffray v1.1

About Us Moti Joseph

Security Researcher

Marion Marschalek

Malware Analyst

Page 3: Troopers Diffray v1.1

Agenda

• Vulnerabilities

• Automated Vulnerability Search

• An Approach

• A Solution as Proof of Concept

• Demo ;)

• Whats next?

TROOPERS 2014

Page 4: Troopers Diffray v1.1

Intro

Page 5: Troopers Diffray v1.1

Got a bug in your

software?

Can I haz it??

Page 6: Troopers Diffray v1.1

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.

TROOPERS 2014

Page 7: Troopers Diffray v1.1
Page 8: Troopers Diffray v1.1

How to find vulnerabilities?

• Application Penetration Testing

• Fuzzing

• Reverse Engineering

• Source Code Review

• Or.. Being more advanced:

– Tracking software bugs, introducing bugs into software, reversing security patches

TROOPERS 2014

Page 9: Troopers Diffray v1.1

Who is interested in finding them?

Hackers

Software Companies

Criminals

Governments

Media

Page 10: Troopers Diffray v1.1

How much does a 0-day vulnerability cost?

TROOPERS 2014

Page 11: Troopers Diffray v1.1

“White Market”

When or why to sell to white market?

TROOPERS 2014

Page 12: Troopers Diffray v1.1

“BlackMarket”

Broker?

Money?

Trust?

TROOPERS 2014

Page 13: Troopers Diffray v1.1

What happens when you sell to the black market?

TROOPERS 2014

Page 14: Troopers Diffray v1.1
Page 15: Troopers Diffray v1.1

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

TROOPERS 2014

Page 16: Troopers Diffray v1.1

The Approach

Page 17: Troopers Diffray v1.1

What happens in Windows7 stays in Windows7...

Win7 Win8

quartz.dll quartz.dll

lea ecx, [ebp+cb]

push ecx

push 4

push eax

mov [esi], eax

call ?ULongMult@@YGJKKPAK@Z

test eax, eax

...

push [ebp+cb] ; cb

call

ds:__imp__CoTaskMemAlloc@4

xor eax, eax

inc eax

shl eax, cl

...

shl eax, 2

push eax ; cb

call

ds:__imp__CoTaskMemAlloc@4

Patch it!

TROOPERS 2014

Page 18: Troopers Diffray v1.1

Counting Function Calls

Win7 quartz.lib

Win8 quartz.lib

Page 19: Troopers Diffray v1.1

Spot The Patch Win7 quartz.lib Win8 quartz.lib

TROOPERS 2014

Page 20: Troopers Diffray v1.1

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‘

TROOPERS 2014

Page 21: Troopers Diffray v1.1

‚Safe Functions‘ UInt8Add UShortAdd UIntAdd ULongAdd SizeTAdd ULongLongAdd UInt8Sub UShortSub UIntSub ULongSub SizeTSub ULongLongSub

UInt8ToInt8 UInt8ToChar ByteToInt8 ByteToChar ShortToInt8 ShortToUChar ShortToChar UShortToUInt8 UShortToShort IntToInt8 IntToUChar IntToChar

StringCbGets StringCbGetsEx StringCbLength StringCbPrintf StringCbPrintfEx StringCbVPrintf StringCbVPrintfEx StringCchCat StringCchCatEx StringCchCatN StringCchCatNEx StringCchCopy

... and many many more ....

TROOPERS 2014

Page 22: Troopers Diffray v1.1

The Approach Flexible.

Extendible.

Awesome.

Windows Library

Parsing to DB

Checking for Vulnerability

Decompilation or Disassembly

Diffing Library with New Version

TROOPERS 2014

Page 23: Troopers Diffray v1.1

The Solution

Page 24: Troopers Diffray v1.1

Pretty, eh??

Page 25: Troopers Diffray v1.1

Getting the .C

Library Conversion using IDA Pro

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

TROOPERS 2014

Page 26: Troopers Diffray v1.1

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

TROOPERS 2014

Page 27: Troopers Diffray v1.1

The Database

MSSql or SQLite

TROOPERS 2014

Page 28: Troopers Diffray v1.1

Diff it!

• Compare libraries on a function basis

• Extract hits per function per signature

TROOPERS 2014

Page 29: Troopers Diffray v1.1

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

TROOPERS 2014

Page 30: Troopers Diffray v1.1

DiffRay HowTo: CMD Parsing

Maintenance:

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

python [dir]\src\Main.py --parse [library_path]

--os [Win7|Win8] --type [C|LST]

python [dir]\src\Main.py --dirparse [directory_path]

--os [Win7|Win8] --type [C|LST]

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

Switches: --backend [mssql|sqlite]

--no-flush

TROOPERS 2014

Page 31: Troopers Diffray v1.1

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 [win7lib] --lib_2 [win8lib]

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

TROOPERS 2014

Page 32: Troopers Diffray v1.1
Page 33: Troopers Diffray v1.1

DEMO TIME

Page 34: Troopers Diffray v1.1

Findings

Page 35: Troopers Diffray v1.1

Windows 7 (ULongAdd) bcrypt.dll!ConvertRsaPrivateBlobToFullRsa

Page 36: Troopers Diffray v1.1

Windows 8 bcrypt.dll!ConvertRsaPrivateBlobToFullRsa

Page 37: Troopers Diffray v1.1

Windows 8 (ULongAdd) netlogon.dll! NlpAddResourceGroupsToSamInfo

Page 38: Troopers Diffray v1.1

Windows 7 netlogon.dll! NlpAddResourceGroupsToSamInfo

Page 39: Troopers Diffray v1.1

Windows 8 /ULongLongToUint twext.dll! EscapeField

Page 40: Troopers Diffray v1.1

Windows 7 Integer overflow twext.dll! EscapeField

Page 41: Troopers Diffray v1.1

Drrrivers...

Page 42: Troopers Diffray v1.1

Windows 8 cng.dll! ConvertRsaPrivateBlogToFullRsa

Page 43: Troopers Diffray v1.1

Windows 7 cng.dll! ConvertRsaPrivateBlogToFullRsa

Page 44: Troopers Diffray v1.1

Windows 8 ksecdd.dll! SspiCopyAuthIdentity

Page 45: Troopers Diffray v1.1

Windows 7 ksecdd.dll! SspiCopyAuthIdentity

Page 46: Troopers Diffray v1.1

Windows 8 srvnet.dll!

SrvNetAllocatePoolWithTagPriority

Page 47: Troopers Diffray v1.1

Windows 7 srvnet.dll!

SrvNetAllocatePoolWithTagPriority

Page 48: Troopers Diffray v1.1

Triggerable? Or not triggerable?

Page 49: Troopers Diffray v1.1

Windows 7 cryptdlg!DecodeAttrSequence

Page 50: Troopers Diffray v1.1

Windows 8 cryptdlg!DecodeAttrSequence

Page 51: Troopers Diffray v1.1

What’s CryptDll.dll??

TROOPERS 2014

Page 52: Troopers Diffray v1.1

StringCchLength

TROOPERS 2014

Page 53: Troopers Diffray v1.1

CryptDecodeObject API

TROOPERS 2014

Page 54: Troopers Diffray v1.1

Certificate DialogBox

TROOPERS 2014

Page 55: Troopers Diffray v1.1

What‘s Next

Page 56: Troopers Diffray v1.1

Whats Next • Possible Extensions

– Win8, we‘re coming!!

– Extended signatures

– Symbolic Execution FTW

• Improvements

– Transparent DB library

• Known issues

– Duplicate hits, false positives, slooow, output is not handy

TROOPERS 2014

Page 57: Troopers Diffray v1.1

Happy Diffing.


Recommended