The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 ....

81
Jon McCoy www.DigitalBodyGuard.com Hacking .NET Applications: The Black Arts(v2) SecTor 2012

Transcript of The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 ....

Page 1: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Jon McCoy www.DigitalBodyGuard.com

Hacking .NET Applications:

The Black Arts(v2) SecTor 2012

Page 2: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Jon McCoy www.DigitalBodyGuard.com

Hacking .NET Applications:

The Black Arts(v2) SecTor 2012

Page 3: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Jon McCoy www.DigitalBodyGuard.com

Page 4: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Hacker VS Attacker

Page 5: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply
Page 6: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Everything New Is Old Again

Page 7: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

IDA-Pro was good…..

Page 8: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Syser follows $198

IDA PRO &

OllyDbg

ASM rocks….

SoftICE → 1987-2006 RIP

Page 9: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

IDA PRO

Page 10: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Back When

Page 11: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Back When 1 Thread(s)

9 Object

9 Classes

1.337 kb of

MEM

Page 12: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

IDA PRO WAS GOOD

Page 13: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

C# - 15

IL - 34

ASM - 77

Lines

C# - 13 Lines Decompile

Page 14: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

IL – Intermediate Language

Code of the Matrix |||| NEW ASM

Page 15: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

C# - 15

IL - 34

ASM - 77

Lines

C# - 13 Lines Decompile

Page 16: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

How Much Code Do you need to read`

C# - 15 IL - 34 ASM - 77

Page 17: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply
Page 18: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

IDA PRO WAS GOOD

Page 19: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply
Page 20: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

why….

Page 21: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

15 Threads

Over 9,000

Object Over 90

Classes

Over 1,337 MB

of MEM

Page 22: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

15 Threads

Over 9,000

Object Over 90

Classes

Over 1,337 MB

of MEM

Page 23: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

C# - 50->N/A

IL - 1337

ASM - 9000

Lines ObFu$c4T3d

Page 24: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Back When

Page 25: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Attacking .NET

Attack The code on disk

Page 26: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

GrayWolf

On Disk edit

Page 27: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Attacking on Disk

Page 28: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Attack security

Microsoft

Media Center

Page 29: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Crack

Password

Page 30: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Crack

DEMO GOD MODE

GSGE.ConfigOptions::.cctor() 439 ldc.i4.1

Page 31: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Crack

Password

Return True;

Page 33: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Attacking .NET

Attack While The app is running

Page 34: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Attacking .NET Applications: At runtime

Page 35: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Graydragon

Injection

Page 36: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Run and Inject

SECURITY

SYSTEMS

Page 37: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

FileProtector

Protect ME

THANKS OWASP

Page 38: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Graydragon

Injection

DEMO

Page 39: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

101 - Attack on Disk

Decompile - Get code/tech

Infect - Change the target's code

Remold/Recompile - WIN

Exploit - Take advantage

Connect/Open - Access Code

Page 40: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

The weak spots

Flip The Check

Set Value is “True”

Cut The Logic

Return True

Access Value

Page 41: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Flip The Check Set Value to “TRUE”

bool Registered = false;

bool Registered = true;

bool Registered = false;

If(a!=b) If(a==b) If(a==b)

Page 42: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Return True

bool IsRegistered()

{

Return TRUE;

........................

}

Page 43: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Cut the Logic

string sqlClean(string x)

{

Return x;

}

Page 44: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Hack The login

DEMO pass the key Show the key

Page 46: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Crack the Key

Public/Private

3/B==Name*ID*7

Call Server

Demo = True;

Complex Math

==

==

==

==

== Complex Math

Change Key

ASK what is /B?

Hack the Call

Set Value

1% of the time the KeyGen is given

Page 47: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Public/Private Key

If you can beat them

Why join them

Key = “F5PA11JS32DA”

Key = “123456ABCDE”

Page 48: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Reg code replay

Name:

Code: ==

JON DOE

98qf3uy !=

*C 5G9P3

FAIL

Page 49: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Name:

Code:

*C

5G9P3

Reg code replay

Page 50: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Reg code replay

Name:

Code: ==

JON DOE

5G9P3

*C 5G9P3

WIN

Page 51: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Server Call/Phone Home

1.Fake the Call

2.Fake the Request

3.Fake the Reply

4.Win

Call Web Server = www.LocalHost.com

=>ID=123456789

=>*Registered = True*

=>Reg Code = f3V541

=> www.HackME.com

Page 52: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Complex math

1. Chop up the Math

2. Attack the Weak

3. ??????????

4. Profit

Page 53: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Static Crypto Key

Vector init = 0

Clear TXT Password Storage

Encrypted Data

Page 54: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

What Stops this?

What is the security?

Page 55: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Protection on disk

Protection - Security by 0b$cur17y Code Obfuscation

Shells / Packers / Encrypted(code)

Logic Obfuscation

Unmanaged calls…to C/C++/ASM

Try to SHUTDOWN

Decompilation

Page 56: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply
Page 57: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply
Page 58: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Crack - FAIL

DEMO Fail

Page 59: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Protection on disk 0bfu$ca7ed

DEMO Fail

Page 60: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Protection on disk

Shells

Pack/Encrypt the EXE

Like MalWareZ

Page 61: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

review Dotfuscator

Obfuscation will only

slows the attacker

Obfuscation applied

programmatically is not

100% effective

Causes low or no

Bugs

Does no add

vulnerabilities

Phone Home

If Tampered

Page 62: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply
Page 63: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Unprotected / Protected

Page 64: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

the best defense is a good sniper

If you know the enemy and know

yourself, you need not fear the

results of a hundred battles. - Sun Tzu

Page 65: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

It can be that ez

What is the security? What is the security?

’t ‘T

Page 66: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply
Page 67: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Visual Studio Exploit – Run arbitrary code

First noted in 2004

Demo

Get developer Keys Attack the SVN & DB

ATTACK VECTOR

I LUV MALWARE == M$

Page 68: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Hacking/RE/Cracking

SandBoxxie •Find your target

•Dissect your target

•Attack your target

www.sandboxie.com

Page 69: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Hacking/RE/Cracking

VirtualBox

•Trap your target

•Secure your target

•Lie/Deceive your target

www.virtualbox.org

Page 70: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Hacking/RE/Cracking

Processes Explore

win hex www.x-ways.net

technet.microsoft.com/sysinternals/bb896653.aspx

FireWalls - outbound www.theyoungturks.com

Universal Extractor legroom.net/software/uniextract

Page 71: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Security

TOR

Convergence www.convergence.io

www.torproject.org

tRUEcRYPT www.truecrypt.org

Page 72: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

HACKING

www.pretentiousname.com/misc/

win7_uac_whitelist2.html

Encode EXE

POWERSHELL / CMD

Windows 7 UAC whitelist

Page 73: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Look inside

Page 74: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Don’t look

Page 75: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Security

The Login security check is

Does A == B

Does MD5%5 == X

Is the Pass the Crypto Key

Page 76: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

DATA LEAK

The Data sent home is

Application Info

User / Registartion Info

Security / System Info

Page 77: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

KEY

The Crypto Key is

A Hard Coded Key

The Licence Number

A MD5 Hash of the Pass

6Salt 6MD5 Hash of the Pass

Page 78: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

CRYPTO

The Crypto is

DES 64

Tripple DES 192

Rijndael AES 256

Home MIX (secure/unsecure)

Page 79: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

Thanks

All the people that make SecTor happen

Page 80: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

FIN

Page 81: The Black Arts(v2) McCoy - Hacking dotN… · NET Applications: The Black Arts(v2) SecTor 2012 . Jon McCoy Hacking. NET Applications: ... Title: PowerPoint Presentation Author: rapply

www.DigitalBodyGuard.com [email protected]

More information @:

FIN = 1