141
박 병진 (Posquit0) | B10S / POSTECH CSE | 2012.07 Defcon 20 th : The way to go to Las Vegas [email protected] http://hackcreative.org www.CodeEngn.com CodeEngn ReverseEngineering Conference

[2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Embed Size (px)

DESCRIPTION

2012 CodeEngn Conference 06 데프콘은 매년 라스베이거스에서 열리는 세계적으로 가장 권위 있는 보안 컨퍼런스 중 하나로 CTF 대회를 진행하고 있다. 데프콘 컨퍼런스에서 발표를 한다거나, CTF 본선 대회에 진출하는 것이 “해커들의 꿈” 이라는 말이 오고 갈 정도로 권위 있는 대회라고 할 수 있다. 때문에, 전 세계의 실력 있는 보안 그룹들이 이 CTF 대회의 본선 티켓을 두고 매년 경쟁을 하고 있으며, 올해에도 어김없이 데프콘 CTF를 위한 예선전이 진행되었고 세계적으로 유명한 해킹 그룹들이 참가하였다. 2012년 데프콘 CTF 예선에 출제된 여러 흥미로운 문제들을 풀이해보고, 필자의 본선 경험을 토대로 데프콘 CTF 대회의 전체적인 흐름과 운영 방식 그리고 전략 등에 대하여 설명한다. http://codeengn.com/conference/06

Citation preview

Page 1: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

박 병진 (Posquit0) | B10S / POSTECH CSE | 2012.07

Defcon 20th :The way to go to Las Vegas

[email protected]

http://hackcreative.org

www.CodeEngn.comCodeEngn ReverseEngineering Conference

Page 2: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

1-1 Who

1-2 What

1 WTF is Defcon?

2 For Las Vegas

2-1 Criteria

2-2 How About This Year?

2-3 No Money?

3 Interesting Problems

3-1 So Easiness

3-2 So Bombness

3-3 So Funniness

3-4 So Mathness

3-5 So Puzzlingness

4 In Las Vegas

4-1 Waiting For You

4-2 Capture The Flag

4-3 Advanced Tips

4-4 Conclusions

목차

Page 3: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

WTF is Defcon? :Who

Page 4: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Jeff Moss (The Dark Tangent)

WTF is Defcon?

Who

The founder of the Black Hat and Defcon computer hacker conferences

Show me the money, bro ...

Page 5: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

WTF is Defcon? :What

Page 6: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Defcon

WTF is Defcon?

What

One of the world’s largest annual computer hacker conventions

The dream of many hackers

Every year in Las Vegas, Nevada

I love girl, casino and Las Vegas !!

Page 7: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Defcon CTF (Capture The Flag)

WTF is Defcon?

What

The best known contest among several Defcon Contests.

CTP(Capture The Packet), Open CTF, and etc...

The most prestigious network attack and defense competition in the world

To be best of best !!

Page 8: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

For Las Vegas :Criteria

Page 9: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

If you want to participate in CTF

For Las Vegas

Criteria

+ =

Page 10: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Last Winners

For Las Vegas

Criteria

1 The returning winners from last Defcon CTF

It is the hardest way, but I want to do this way... And you?

History of Capture the Flag

Winners

• DDTEK: 2009 - Present

• KENSHOTO: 2005 – 2008

• GHETTO HACKERS: 2002 - 2004

Organizers

DC Winner OS N (Teams)

16 Sk3wl0fr00t FreeBSD 8 Teams

17 Vedagodz FreeBSD 10 Teams

18 ACME Pharm FreeBSD + Debian 10 Teams

19 The European Nopsled Team FreeBSD 12 Teams

20 WOWHACKER-PLUS or KAIST GoN!?? ????? 20 Teams

Page 11: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

The Other Winners

For Las Vegas

Criteria

8 Winning teams from other CTF events (in DC 20)

May be, it is also good way :D

Other CTF Contests (be qualified in DC 20)

• UCSB iCTF 2011

• CodeGate 2012

• NCCDC

• Hack In The Box 2012 Amsterdam

• Positive Hack Days 2012

• Nuit Du Hack 2012 CTF

• Defcon 19 Open CTF

• RuCTF 2011

Page 12: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Qualification

For Las Vegas

Criteria

10 teams pre-qualify online

It is normal and best way.

For 48 hours. No limit the number of team members.

Making union with another team may possibly be good choice :-)

Page 13: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Qualification (in DC 20)

For Las Vegas

Criteria

Fields

• Grab bag – Web, Network, Programming and etc.

• /urandom – Trivial, Crypto, Algorithm and etc.

• binary l33tness – Reverse Engineering

• Pwnables – Remote Exploits

• Forensics – Digital Forensics

Solved

Not Solved

Not Solved (Any teams)

Solving

Not Opened

Total Score

• 1500 * 5 = 7500 pts

Page 14: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

For Las Vegas :How About This Year?

Page 15: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Last Winners

For Las Vegas

How AboutThis Year? Defcon 19th CTF Winner - European Nopsled Team

Oh, handsome guys :D

Page 16: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

The Other Winners

For Las Vegas

How AboutThis Year?

Years Contests Winner

2011 UCSB iCTF We_0wn_You

2012 CodeGate KAIST GoN

2012 NCCDC Team Hillarious

2012 Hack In The Box Amsterdam SiBears

2012 Positive Hack Days More Smoked Leet Chicken

2012 Nuit Du Hack HackerDom

2011 Defcon 19 Open CTF Team Vand

2011 RuCTF 0ldEur0pe

Page 17: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Qualification

For Las Vegas

How AboutThis Year?

9%

9%

9%

9%8%

8%

8%

8%

8%

8% 8%

8% Hates Irony

PPP

sutegoma2

Shellphish

TwoSixNine

European Nopsled Team

More Smoked Leet

Chicken

4%5%

6%

14%

20%19%

32%

More than 4000 pts 3000 ~ 3900 pts

2000 ~ 2900 pts 1000 ~ 1900 pts

500 ~ 900 pts 200 ~ 400 pts

100 pts

Total 303 Teams

Page 18: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Qualification

For Las Vegas

How AboutThis Year?

Rank Team Score

1 Hates Irony 4900 Qualified!

2 PPP 4800 Qualified!

3 侍 4400 Qualified!

4 sutegoma2 4400 Qualified!

5 Shellphish 4400 Qualified!

6 TwoSixNine 4400 Qualified!

7 European Nopsled Team 4200 DC 19 Winner!

8 More Smoked Leet Chicken 4100 Positive Hack Days Winner!

9 Our name sucks 4100 Qualified!

10 ACME Pharm 4100 Qualified!

11 WOWHACKER-PLUS 4100 Qualified!

12 Routards 3900 Qualified!

Only one team is Korean – WOWHACKER-PLUS

Come back as Defcon 20th CTF Winner :D

Page 19: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

For Las Vegas :No Money?

Page 20: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Defcon CTF Prizes

For Las Vegas

No Money?

No prizes, only honor !

It’s so cool contest :D

Defcon CTF Support

Only support two hotel room for 4 days, not airfares :-(

Not good...

Page 21: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Airfares, Hotel bills and etc ...

For Las Vegas

No Money?

If you are qualified, don’t worry about money :D

May be, it is also good way :D

Sponsors

There are many Security Vendors

They will be your sponsor!

Page 22: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Interesting Problems :So Easiness

Page 23: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Grab Bag 100

Introduction

• Hack the planet_

• It’s so trivial :D

How to solve?

What is last character?

Interesting Problems

So Easiness

Page 24: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Auth Key

Interesting Problems

So Easiness

Page 25: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Interesting Problems :So Bombness

Page 26: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Binary l33tness 200

Introduction

• Running on 140.197.217.155:18703

• ELF 32-bit LSB executable for FreeBSD 9.0, stripped

• Username : grease

• Hash Collision challenge

Interesting Problems

So Bombness

Page 27: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – I. Binary Patch

Interesting Problems

So Bombness

For convenience, patch the SIGALARM code

I used Radare2 to fix binary.

Before the patch

Page 28: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – I. Binary Patch

Interesting Problems

So Bombness

For convenience, patch the SIGALARM code

I used Radare2 to fix binary.

After

Page 29: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – II. Code Analyze (1)

Interesting Problems

So Bombness

Recv Passcode 4 Times

Page 30: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – II. Code Analyze (2)

Interesting Problems

So Bombness

Get Input Size & Two Input

Page 31: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – II. Code Analyze (3)

Interesting Problems

So Bombness

If has collision, success :D

Page 32: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – III. Approach (1)

Interesting Problems

So Bombness

Is it a known Hash Algorithm?

Then, it’s so easy :D

Page 33: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – III. Approach (2)

Interesting Problems

So Bombness

Enter to Hash Function

Unknown table :D

Page 34: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – III. Approach (3)

Interesting Problems

So Bombness

Google is GOD :D

Found !!

The Tangle Hash Function !!

Page 35: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – III. Approach (4)

Interesting Problems

So Bombness

<Untangled> DTU Mathematics, Technical University of Denmark

Tangle Hash Collision

Collision!!

Page 36: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – IV. Attack (1)

Interesting Problems

So Bombness

I used Python :D

Lovely Python !!

4 Passcode forentering Main-routine

Page 37: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – IV. Attack (2)

Interesting Problems

So Bombness

I used Python :D

Lovely Python !!

Length: 40Tangle Hash Collision :D

Page 38: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – V. Result

Interesting Problems

So Bombness

Go! Go! Go!

My Precious :D

Page 39: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Auth Key

Interesting Problems

So Bombness

The key is 437f085141d357c5d28850d5119aacb5

Page 40: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Interesting Problems :So Funniness

Page 41: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

/Urandom 100

Introduction

• How many developers;) did it take to secure Windows 8?

Interesting Problems

So Funniness

Page 42: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve

Interesting Problems

So Funniness

Brute force attack!

I know, you did it, haha.

Page 43: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve

Interesting Problems

So Funniness

Brute force attack!

I know, you did it, haha

Steve Ballmer in Techno Developers!

Omg, is it True !?

Page 44: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve

Interesting Problems

So Funniness

Brute force attack!

I know, you did it, haha

Steve Ballmer in Techno Developers!

Omg, is it True !?

Auth Key

Page 45: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Interesting Problems :So Mathness

Page 46: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Binary l33tness 400

Introduction

• No takebacks! Running on 140.197.217.239:11553

• ELF 64-bit LSB executable for FreeBSD 9.0, stripped

• Username : takeback

• Personally, the most interesting challenge

Interesting Problems

So Mathness

Page 47: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – I. Binary Patch

Interesting Problems

So Mathness

For convenience, patch the SIGALARM code

I used Radare2 to fix binary.

Before the patch

Page 48: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – I. Binary Patch

Interesting Problems

So Mathness

For convenience, patch the SIGALARM code

I used Radare2 to fix binary.

After

Page 49: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – II. Code Analyze (1)

Interesting Problems

So Mathness

Recv Passcode 4 Times

I referenced SapHeads’s pseudo code :D

Page 50: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – II. Code Analyze (2)

Interesting Problems

So Mathness

Get Count for Big Loop

Page 51: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – II. Code Analyze (3)

Interesting Problems

So Mathness

Important Big Loop

Page 52: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – II. Code Analyze (4)

Interesting Problems

So Mathness

Small Loop

Page 53: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – II. Code Analyze (5)

Interesting Problems

So Mathness

If you success

Page 54: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – III. Approach (1)

Interesting Problems

So Mathness

How to satisfy the following conditions?

r14 is 64-bit register :D

Page 55: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – III. Approach (1)

Interesting Problems

So Mathness

r14 register must be 0xFFFFFFFFFFFFFFFF

All of the bits must be switched on.

Page 56: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – III. Approach (2)

Interesting Problems

So Mathness

How to set bits of the r14 register to 1?

One looping makes one of the bits to be 1

Page 57: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – III. Approach (3)

Interesting Problems

So Mathness

Count for Big Loop must be at least 64 :D

Pick 64 !!

Page 58: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – III. Approach (4)

Interesting Problems

So Mathness

We have two restrictions :-(

How can traversal all of the bits?

1st restriction:Offset

Page 59: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – III. Approach (4)

Interesting Problems

So Mathness

We have two restrictions :-(

How can traversal all of the bits?

2nd restriction:modulo 8

Page 60: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – III. Approach (5)

Interesting Problems

So Mathness

Shift is signed int type !!

Very G00D :D

Page 61: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – III. Approach (6)

Interesting Problems

So Mathness

What happen if shift is negative ?

Bye~ modulo 8 :D

Negative % 8 = Negative

Page 62: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – III. Approach (6)

Interesting Problems

So Mathness

What happen if shift is negative ?

Bye~ modulo 8 :D

We can freely pick some offsets:-15, -6, +10, +17

Page 63: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – III. Approach (7)

Interesting Problems

So Mathness

How to select a sequence of numbers?

Think mathematically :D

GCD(-15, 64)= GCD(+17, 64)= 1= generators of additive modulo 64

{X + [n*(-15) or n*(+17)]} mod 64can generate[0 .. 63]

Page 64: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – IV. Attack (1)

Interesting Problems

So Mathness

I used Python :D

Lovely Python !!

4 Passcode forentering Main-routine

Page 65: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – IV. Attack (2)

Interesting Problems

So Mathness

I used Python :D

Lovely Python !!

My Choice: -15

Page 66: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – V. Result

Interesting Problems

So Mathness

Go! Go! Go!

My Precious :D

Page 67: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Auth Key

Interesting Problems

So Mathness

The key is 59e22b484b703801c019d4da0f7a3316

Page 68: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Interesting Problems :So Puzzlingness

Page 69: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Grab Bag 300

Introduction

• This is semi-real. :-(

• 140.197.217.85:10435

• Password: 5fd78efc6620f6

Interesting Problems

So Puzzlingness

Page 70: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – I. Analyze

Interesting Problems

So Puzzlingness

Same Positions :D

Timeout ...

Page 71: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – I. Analyze

Interesting Problems

So Puzzlingness

Same Positions :D

Timeout ...

Page 72: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – I. Analyze

Interesting Problems

So Puzzlingness

Same Positions :D

Timeout ...

Page 73: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – I. Analyze

Interesting Problems

So Puzzlingness

Same Positions :D

Timeout ...

Page 74: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – II. Approach

Interesting Problems

So Puzzlingness

Only 3 steps :D

Try it !!

Parsing

Number Table

Get

PIN Numbers

Calculate

Positions

Page 75: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

How to solve – III. Attack (Demo)

Interesting Problems

So Puzzlingness

Page 76: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Auth Key

Interesting Problems

So Puzzlingness

The key is $9238740982570237012935.32

Page 77: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

In Las Vegas :Waiting For You

Page 78: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Las Vegas

In Las Vegas

Waiting For You

Welcome to Las Vegas!

A beautiful city :D

Page 79: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Casino

In Las Vegas

Waiting For You

Have you ever been to Casino?

Do not become addicted :(

Page 80: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Girls

In Las Vegas

Waiting For You

Anywhere you can see sexy girls

If you have girl friend, avoid it :D

Page 81: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

In Las Vegas :Capture The Flag

Page 82: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Defcon CTF (Capture The Flag)

In Las Vegas

Capture The Flag

This year, the 20 top qualifying teams are pitted against each other in an all out digital war

Last year, only 12 teams

Attack and defend custom services provided to each teams

It’s important

The Winning team will receive coveted Defcon Black Badges.

Hmm... Give me badge! lol

Page 83: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

CTF Blueprint

In Las Vegas

Capture The Flag

Gateway

Team 2Server

Team 1Server

Team 3Server

AuthServer

Team 3

Team 2

Team 1

Page 84: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Defcon CTF Director & USB

In Las Vegas

Capture The Flag

Director provide USB for CTF

• root password

• Home Folder (vulnerable daemons)

• key, cert File for authentication

• readme

Page 85: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Defcon CTF Disposition

In Las Vegas

Capture The Flag

• Contest Room

• Lounge or Anywhere

Contest Room

Lounge or Anywhere

Page 86: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Defcon CTF Disposition

In Las Vegas

Capture The Flag

Contest Room

8 People

Lounge or Anywhere

• Contest Room – 8 Members

• Lounge or Anywhere – No limits :D

Page 87: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Defcon CTF Attack

In Las Vegas

Capture The Flag

Read Key

Steal information

Overwrite Key

Corrupt information

Keys are periodically updated by the contest organizers

Continue to attack

Page 88: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Defcon CTF Attack – Read Key

In Las Vegas

Capture The Flag

Read Other team’s ‘~/key’ file and auth it

Steal information

Team 1

Attacker

Team 2

Vulnerable Daemon

Auth

Server

Period : 600sPeriod : 600s

Page 89: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Defcon CTF Attack – Overwrite Key

In Las Vegas

Capture The Flag

Overwrite Other team’s ‘~/key’ file

Corrupt information

Team 1

Attacker

Team 2

Vulnerable DaemonPeriod : 600sPeriod : 600s

Au

thTeam

1 K

ey

?A

uth

Team

1 K

ey

?

Auth

Server

I don’t know correctly :-(I don’t know correctly :-(

Page 90: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Defcon CTF Attack – Auth

In Las Vegas

Capture The Flag

How to auth?

• Using SSL (Secure Socket Layer)

• Files in USB for SSL

• server.cert

• team_X_key

• team_X_key.cert

Page 91: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Defcon CTF Attack – Auth

In Las Vegas

Capture The Flag

Page 92: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Defcon CTF Attack – Auth

In Las Vegas

Capture The Flag

Page 93: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Defcon CTF Defend

In Las Vegas

Capture The Flag

Patch daemon’s vulnerability

Don’t touch daemon’s service

Fix ‘/bin/’ permission

Prevent remote shell

Page 94: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Defcon CTF Defend – Binary Patch

In Las Vegas

Capture The Flag

Use Hex Editors, or etc.

010 Editors, WinHex, IDA, Radare2, etc.

Radare2 is Disassembler, Hex Editor, Dubugger, etc.

Posted on Phrack :D

Page 95: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Defcon CTF Defend – Binary Patch with Radare2 (1)

In Las Vegas

Capture The Flag

Open binary file with ‘-w’ option

‘-w’ : write mode

Page 96: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Defcon CTF Defend – Binary Patch with Radare2 (2)

In Las Vegas

Capture The Flag

Set address for edit

s : set address

Page 97: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Defcon CTF Defend – Binary Patch with Radare2 (3)

In Las Vegas

Capture The Flag

Analyze Function & Print Disassembled Function

af : Analyze function

pdf: Print disassembled function

Page 98: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Defcon CTF Defend – Binary Patch with Radare2 (4)

In Las Vegas

Capture The Flag

Enter to Visual Mode -> Look like VIM Editor

V : Visual Mode

h, j, k, l : Scroll key

Page 99: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Defcon CTF Defend – Binary Patch with Radare2 (5)

In Las Vegas

Capture The Flag

Change Disassemble Mode : input ‘p’ for changing View-mode

p : Change view mode

Page 100: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Defcon CTF Defend – Binary Patch with Radare2 (6)

In Las Vegas

Capture The Flag

Search a position for patch using cursor : input ‘c’ for enabling cusror

c : Enable cursor

Page 101: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Defcon CTF Defend – Binary Patch with Radare2 (7)

In Las Vegas

Capture The Flag

Edit Code : input ‘w’ for hex or ‘a’ for assembled opcode

w : Change code with hex value

a : Change code with assembled opcode

Page 102: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Defcon CTF Defend – Binary Patch with Radare2 (8)

In Las Vegas

Capture The Flag

Patched :D

Page 103: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Defcon CTF Scoring

In Las Vegas

Capture The Flag

How to calculate

• Each daemon has 100 points

• For a given attacker, V – victim, S – service,

The attacker’s partial score for the service =

their percentage (0-100) of all keys stolen from V via service S

• Overwrite is also same

Page 104: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Defcon CTF Scoring

In Las Vegas

Capture The Flag

How to calculate

Attack : steal or overwrite key

Team 2

Vulnerable Daemon

Team 1

Attacker

Team 3

Attacker

Team 4

Attacker

Team 5

Attacker

Team Auth Score

Team1 10 times 10 pts

Team3 40 times 40 pts

Team4 20 times 20 pts

Team5 30 times 30 pts

Page 105: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Defcon CTF Scoring

In Las Vegas

Capture The Flag

How to calculate

Attack : steal or overwrite key

Team 2

Vulnerable Daemon

Team 1

Attacker

Team 3

Attacker

Team 4

Attacker

Team 5

Attacker

Team Auth Score

Team1 2 times 100 pts

Team3 0 times 0 pts

Team4 0 times 0 pts

Team5 0 times 0 pts

Page 106: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Defcon CTF Scoring

In Las Vegas

Capture The Flag

How to calculate

Attack : steal or overwrite key

Team 2

Vulnerable Daemon

Team 1

Attacker

Team 3

Attacker

Team 4

Attacker

Team 5

Attacker

Team Auth Score

Team1 3 times 75 pts

Team3 1 times 25 pts

Team4 0 times 0 pts

Team5 0 times 0 pts

Page 107: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Defcon CTF Scoring

In Las Vegas

Capture The Flag

How to calculate

Attack : steal or overwrite key

Team 2

Vulnerable Daemon

Team 1

Attacker

Atta

ckA

ttack

Team Auth Score

Team1 1 times for each 1900 pts

AttackAttack

Total 19 Teams

Breakthrough !!

Team 20

Vulnerable Daemon

Page 108: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Defcon CTF Scoring

In Las Vegas

Capture The Flag

How to calculate

Attack : steal or overwrite key

Team 2

Vulnerable Daemon

Team 1

Attacker

Atta

ckA

ttack

Team Auth Score

Team1 1 times for each 3800 pts

AttackAttack

Total 19 Teams

Breakthrough !!

Team 20

Vulnerable Daemon

Read & Overwrite

Page 109: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Defcon CTF Scoring

In Las Vegas

Capture The Flag

How to calculate

Attack : steal or overwrite key

Team 2

Vulnerable Daemon

Team 1

Attacker

Atta

ckA

ttack

Team Auth Score

Team1 1 times for each 3800 pts

AttackAttack

Total 19 Teams

Breakthrough !!

Team 20

Vulnerable Daemon

Read & Overwrite

Page 110: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Defcon CTF Scoring

In Las Vegas

Capture The Flag

+ =

Total Score

• Sum(Steals Score + Defaces Score) * SLA

• SLA - Service Level Availability

• SLA = Average number of daemons running (cumulative)

= Sum(number of daemons running) / Sum(number of daemons)

Page 111: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Defcon CTF Scoring

In Las Vegas

Capture The Flag

VIP (Very Important Points)

• Breakthrough

• SLA (Service Level Availability) –No Shutdown !

Page 112: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

In Las Vegas :Advanced Tips

Page 113: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Network Setting

In Las Vegas

Advanced Tips

Dummy HubDummy Hub

Team Server(running

daemons)

Team Server(running

daemons)

Laptop formasquerading

Laptop formasquerading

GatewayGateway

Laptop forServer

Laptop forServer

Member’s LaptopsMember’s Laptops

Provided

Must Prepare

Page 114: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Network Setting

In Las Vegas

Advanced Tips

Dummy HubDummy Hub

Team Server(running

daemons)

Team Server(running

daemons)

Laptop formasquerading

Laptop formasquerading

GatewayGateway

Laptop forServer

Laptop forServer

Member’s LaptopsMember’s Laptops

Provided

Must Prepare

Route for AttackConnected toother teams

Connected toother teams

Page 115: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Network Setting

In Las Vegas

Advanced Tips

Dummy HubDummy Hub

Team Server(running

daemons)

Team Server(running

daemons)

Laptop formasquerading

Laptop formasquerading

GatewayGateway

Laptop forServer

Laptop forServer

Member’s LaptopsMember’s Laptops

Provided

Must Prepare

Route for DefendConnected toother teams

Connected toother teams

Page 116: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Network Setting

In Las Vegas

Advanced Tips

Dummy HubDummy Hub

Team Server(running

daemons)

Team Server(running

daemons)

Laptop formasquerading

Laptop formasquerading

GatewayGateway

Laptop forServer

Laptop forServer

Member’s LaptopsMember’s Laptops

Provided

Must Prepare

Connected toother teams

Connected toother teams

Masquerading (Packet capture)Routing (Use both Internet & Intranet)Masquerading (Packet capture)Routing (Use both Internet & Intranet)

VM Server (FreeBSD)Web Server (Share Information)IRC Server (Chat with members)VPN Server (For other members)

VM Server (FreeBSD)Web Server (Share Information)IRC Server (Chat with members)VPN Server (For other members)

Wireless InternetWireless Internet

Page 117: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Masquerading (Packet Capture)

In Las Vegas

Advanced Tips

Capture the incoming attack packet of the other team

Repeat the other team’s payload against enemy

Capture the outgoing packet that includes key

Modify key in the packet or Drop the packet

Team Server(running

daemons)

Team Server(running

daemons)

Laptop formasquerading

Laptop formasquerading

GatewayGateway

Capturing Packet

Page 118: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Disposition for Efficiency

In Las Vegas

Advanced Tips

Server Manager (1), Network Manager (2), Global Hogu Finder (1),

Exploit Manager (1), Reverser & Exploiter (∞)

Global Hogu Finder is very very important :D

Contest Room

Lounge or Anywhere

Position N

Server Manager 1

Network Manager 2

Global Hogu Finder 1

Reverser & Exploiter 3

Exploit Manager 1

Total 8

Position N

Reverser & Exploiter ∞

Total ∞

Page 119: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Positions – Server Manager

In Las Vegas

Advanced Tips

Team Server is only managed by Server Manager

Important position :D

Test daemon’s services

For high SLA (Service Level Availability)

Manage Daemon’s version

Change daemon, set version

Ex. tomato -> tomato.1

Page 120: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Positions – Network Manager

In Las Vegas

Advanced Tips

Capture & Filter incoming packets Team, Share to other members

Very Important :D

Drop or Modify outgoing packet that contains key

Depend !

Manage Web Server, IRC Server, VPN Server, Masquerading Server

Once in a while, Check Server Log

Page 121: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Positions – Global Hogu Finder

In Las Vegas

Advanced Tips

Social Hacking the other team’s member ?

If you can :D

Analyze the other team’s server environments

Hacking other team’s server or labtop

Brute Forcing or Guessing Password for the other team’s daemon server

Get root, then you can read all of the keys.

Page 122: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Positions – Exploit Manager

In Las Vegas

Advanced Tips

Manage exploit codes from other members

Is it works correctly?

Modify exploit codes on the other team’s situations

Different from all the team's defense

Authenticate to Auth-Server

Get Points :D

Page 123: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Positions – Reverser & Exploiter

In Las Vegas

Advanced Tips

Find Vulnerabilities in Daemons

Mostly, BOF or FSB vulnerabilities :D

Patch Vulnerability & Give to Server Manager

As soon as possible

Analyze the other team’s packet and Get their payload

Lovely :D

Programming Exploit Code & Give to Exploit Manager

Pwn! Pwn! Pwn! HolyPwner !

Page 124: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Shellcode

In Las Vegas

Advanced Tips

Reverse Shellcode

Fork process

Open Socket & Connect to listening server

dup2 about stdin, stdout and stderr

execve ‘/bin/sh’

Read Key Shellcode

Open the key file

Read the key

Write the key to socket

Write Key Shellcode

Open the key file

Write auth key to key file

Read & Write Key Shellcode

Open the key file

Read the key

Write auth key to key file

Write the key to socket

Page 125: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Shellcode – Read Key Shellcode

In Las Vegas

Advanced Tips

Read Key Shellcode Example

Should be made shellcode to suit the situation

Page 126: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Shellcode

In Las Vegas

Advanced Tips

If enemy do masquerading

OMG ...?

EnemyEnemyLaptop for

masqueradingLaptop for

masquerading

GatewayGateway

Drop or Modify Packet

My TeamMy Team

Page 127: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Shellcode

In Las Vegas

Advanced Tips

How to avoid Masquerading?

• Shellcode Encryption

• Packing

• Obfuscating

• …

• Key Encryption

• XOR (Very easy and convenient)

• ROT

• …

Page 128: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Shellcode – Read XOR Key Shell Code

In Las Vegas

Advanced Tips

XOR Key Encryption Shellcode Example

Also, should be XOR operation on the server side

Page 129: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Shellcode

In Las Vegas

Advanced Tips

How to avoid Repeating my payload?

• Read Key using UDP Shellcode

• Staged loading Shellcode

• …

Page 130: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Shellcode – Staged Loading Shellcode

In Las Vegas

Advanced Tips

Why use Multi-Stage Loading Shellcode?

• Small buffer for Shellcode

• Avoid Masquerading

• Avoid repeating payload

• Excute Binary File using binary loader

• …

Page 131: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Shellcode – Staged Loading Shellcode (1)

In Las Vegas

Advanced Tips

Stage 1 – minimum shellcode for connection

• must be small

• free of NULLs

• new connection and read additional data

• jumps to the data and execute it

Vulnerable

Daemon

Payload LoaderPayload Loader

Attacker

Page 132: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Shellcode – Staged Loading Shellcode (1)

In Las Vegas

Advanced Tips

Stage 2 – Payload to execute

• Other Shellcodes

• Read Key Shellcode

• Reverse Connection Shellcode

• ...

Vulnerable

Daemon

Payload LoaderPayload Loader

AttackerNew Connection

&Read Payload

New Connection&

Read Payload

PayloadPayload

Page 133: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Shellcode – Staged Loading Shellcode (2)

In Las Vegas

Advanced Tips

Stage 1 – minimum shellcode for connection

• must be small

• free of NULLs

• new connection and read additional data

• jumps to the data and execute it

Vulnerable

DaemonAttacker

Payload LoaderPayload Loader

Page 134: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Shellcode – Staged Loading Shellcode (2)

In Las Vegas

Advanced Tips

Stage 2 – Binary Loader for executing binary

Vulnerable

DaemonAttacker

Payload LoaderPayload Loader

New Connection&

Read Payload

New Connection&

Read Payload

Binary LoaderBinary Loader

Page 135: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Shellcode – Staged Loading Shellcode (2)

In Las Vegas

Advanced Tips

Stage 3 – Executable Binary for executing on Binary Loader

Vulnerable

Daemon

Payload LoaderPayload Loader

Attacker

New Connection&

Read Payload

New Connection&

Read Payload

Binary LoaderBinary Loader

Read DataRead Data

Executable BinaryExecutable Binary

Page 136: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Shellcode

In Las Vegas

Advanced Tips

Shellcode Generator

Page 137: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

In Las Vegas :Conclusions

Page 138: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

Look at the big picture :D

There are many things to cheat other teams

Attack is not only way to be winner

In Las Vegas

Conclusions

Page 139: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

I wanna see the result below :D !!!

Participate Defcon CTF Qualification, and Go to Las Vegas !!

In Las Vegas

Conclusions

Rank Team Score

1 KimchiMan 7900 Qualified!

2 Since1999 7800 Qualified!

3 Unji 7400 Qualified!

4 Little H4ma 7400 Qualified!

5 Phantom: Secret between 0 and 1 7400 Qualified!

6 Be5t of B3st 7400 Qualified!

7 SW M4e5tro 7200 Qualified!

8 H4nGukSaRam 7100 Qualified!

9 H4des 7100 Qualified!

10 RolyPoly 7100 Qualified!

Page 140: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

http://phrack.org/issues.html?issue=66&id=14#article

Binary Mangling with Radare by pancake

Defcon 101 by ramses@PLUS

:D

참고자료

SapHeads’s Write-up for Binary 400

http://x-n2o.com/bin400-dc20

Multi-Stage loading Shellcode by Jarkko Turkulainen

http://www.klake.org/~jt/mstage/

Page 141: [2012 CodeEngn Conference 06] posquit0 - Defcon 20th : The way to go to Las Vegas

If you have questions, contact me :[email protected]

Thank you for listening.

www.CodeEngn.comCodeEngn ReverseEngineering Conference