virus writing techniques - thotcon · [email protected] thotcon 0x1. my background ... demo. caveats...

52
Virus Writing Techniques How lessons from the past can help us change the direction of the malware arms race. Tim Sally [email protected] THOTCON 0x1

Upload: truongxuyen

Post on 12-Jul-2018

220 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

Virus Writing Techniques

How lessons from the past can help us change the direction of the malware arms race.

Tim [email protected]

THOTCON 0x1

Page 2: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

My BackgroundCS Undergrad Past Intern

Future Intern

Cyber Security Scholar

Undergrad RA

Page 3: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

The Next 45 Minutes‣ Motivation

‣ Virus Writing 101

‣ New Tools!

‣ Evading AV (Demo)

‣ Wrap up

Page 4: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

Motivation

Page 5: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

Hate Chart

48%

25%

25%

2%

Dan K Web 2.0PHP Programs Anti-virus

Page 6: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

What’s the Problem?‣ AV marketing prevents average

customers from making informed choices.

‣ Signatures are a Cold War approach to !ghting malware.

‣ The is no “full disclosure” for AV.

Page 7: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

AV Marketing

Page 8: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

Bullets and Viruses: Serious Business

http://www."ickr.com/photos/ringai/3911794367/http://www."ickr.com/photos/warzauwynn/4191357929/

Page 9: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

Protection: Body Armor and AV

Page 10: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

Protection: Body Armor and AV

http://www.securityprousa.com/bodyarmor.html

Page 11: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

Protection: Body Armor and AV

http://www.avg.com/ww-en/internet-security http://www.securityprousa.com/bodyarmor.html

Page 12: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

Protection: Body Armor and AV Part 2

Page 13: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

Protection: Body Armor and AV Part 2

http://www.bodyarmor.com/

Page 15: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

This Is A Market Failure

If customers can’t understand the merits of products, the best product

will not win.

Page 16: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

Lessons From The Cold War

Page 17: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

Cold War: Build More Missiles

http://www."ickr.com/photos/wallyg/3685388901/http://www."ickr.com/photos/wallyg/3685389045/

Page 19: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

Growth of Malware: 2002-2008 ICBMS

http://www.symantec.com/connect/sites/default/!les/b-whitepaper_internet_security_threat_report_xiv_04-2009.en-us.pdf

Page 20: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

Cold War: How Did They Fix It?

http://upload.wikimedia.org/wikipedia/commons/6/66/Reagan_and_Gorbachev_hold_discussions.jpg

Page 21: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

Failed Solution: “Star Wars”

http://en.wikipedia.org/wiki/File:Sdilogo.svg

Page 22: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

Successful Solution: INF

h

Page 23: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

How Can We Adjust Our AV Approach?

Page 24: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

Failed Solution: Malware Signatures

‣ One-for-one approach never works.

‣ The defensive tech is an order of magnitude harder than o#ensive tech.

‣ Historical track record of failure.

Page 25: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

McAfee Incident

‣ “At 11 AM today, 4/21, McAfee released an update to its customers that improperly identi!ed a critical component of Windows as having a virus.”

http://gist.github.com/raw/374154/9ab3cd7bef81fd3a8bc9398fd7051403eb72160f/gist!le1.txt

Page 26: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

McAfee Incident

‣ “Roughly 800,000 PCs ... are not experiences repetitive reboots.”

Page 27: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

McAfee Incident

‣ “NOTE: Your computer does not have a virus, but McAfee VirusScan incorrectly believes it does.”

Page 28: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

: -(

Page 29: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

New (Old?) Solution: Full Disclosure

‣ In part responsible for the gains in network and OS security since the 90’s.

‣ Vendors can’t a#ord to employ enough people, must involve public.

‣ In turn, vendors are held accountable.

Page 30: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

Involving the Community Works

Page 31: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

There’s No Public Red Team for AV!

‣ We have cryptanalysts.

‣ We have penetration testers.

‣ We have public disclosure of vulns.

‣ We DON’T have anything public for AV.

Page 32: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

FD Implementation?‣ Security community needs to help AV

vendors.

‣ Produce open source tools to evaluate the e#ectiveness of existing AV.

‣ Good guys need to study virus writing techniques and publish results.

Page 33: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

Virus Writing 101

Page 34: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

Clumsy Evasion

‣ Encryption

‣ Anti-disassembly/Anti-debugging

‣ Virtualization detection

‣ Anti-anti-virus

Page 35: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

Elegant Evasion‣ Metamorphic techniques

‣ Binary -> Intermediate Representation (IR)

‣ Add/subtract from IR

‣ Perform transformations on IR

‣ IR -> Binary

Page 36: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

Why It’s Scary‣ Takes some expertise to implement, but

very di$cult to detect.

‣ “Theoretically” accurate signatures are impossible.

‣ Bonus prize: better cross platform support than your average enterprise application!

Page 37: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

Tools

Page 38: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

Introducing Parable: A Tool To Help The

Development of AV

Page 39: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

Overview‣ Based on Alessandro Warth’s OMeta.

‣ Parser/transformer for assembly (currently only x86).

‣ Can be extended in an OO way.

‣ Extremely fast and "exible development.

http://tinlizzie.org/ometa/

Page 40: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

Parser/Transformer

‣ Takes ASCII assembly in, writes ASCII assembly out.

‣ Disassembly and assembly of binaries are scripted.

‣ Transformations written in Ruby!

Page 41: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

Extending With OO

meta x86++ <: x86 {

stmt ::= <space>* ‘rand_garbage’ => ...

| <super stmt>;

}

‣ Parsing: random garbage instruction

Page 42: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

Extending With OO

meta x86++ <: x86 {

stmt ::= <space>* ‘encrypt_func’ => ...

| <super stmt>;

}

‣ Parsing: pluggable code modules

Page 43: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

Extending With OO

‘encrypt_func’ => { gen_rand_encrypt()

# just code normal Ruby!

}

‣ Transformation: pluggable code modules

Page 44: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

Current Capabilities

‣ Entry point obscuring.

‣ Instruction and method permutation.

‣ Attempt at data structure permutation and mimicking system binaries.

Page 45: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

Demo

Page 46: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

Caveats

‣ Not a true metamorphic engine.

‣ Could be implemented in C/x86....

‣ Ruby implementation deters plug and play script kiddies.

Page 47: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

Caveats II

‣ Complete evasion is not the goal.

‣ Just need to make signature based detection completely impractical.

‣ Provide a testbed for experimentation for AV vendors and security professionals.

Page 48: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

Wrapping Up

Page 49: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

Related Tool: SLIPFEST

‣ SLIPFEST (http://slipfest.cr0.org/)

‣ HIPS Evaluation, similar motivation

‣ Di#erence: AV isn’t a strict target

Page 50: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

Related Tool: Metasm‣ Metasm (http://metasm.cr0.org/)

‣ Binary !le manipulation

‣ Pure Ruby!

‣ Di#erence: Parable focuses on rapid development and o#ensive testing.

Page 51: Virus Writing Techniques - THOTCON · tss@timsally.com THOTCON 0x1. My Background ... Demo. Caveats ‣ Not a true ... ‣ Ruby implementation deters plug and play script kiddies

Final Thoughts

‣ Security community at large can help make AV stronger.

‣ We need to adopt the same standards for AV that we have in every other area.