Swift playground teaching basics of buffer overflow vulnerability and ARM64 assembly by exploiting vulnerable app on ARM64 emulator (WWDC22 Swift Student Challenge Winner)

Overview

Pwnground

Project overview

Pwnground is a project created as my submission for WWDC22 Swift Student Challenge (winner). It is an interactive Swift Playground guiding through principles of binary exploitation with focus on stack-based buffer overflow vulnerability. The project involves own exploit playground environment created over ARM64 CPU emulator, simple XNU kernel simulator as well as live debugger displaying what each of the executed instructions does and how it affects CPU registers, memory and flags for better understanding of ARM64 assembly language and of what the created exploit actually does.

Description

In the playground user is guided to create an exploit for a vulnerable application displaying WWDC Scholarship results in order to escalate privileges and assign themselves to a group of winners. Tutorial is divided for 5 parts with step-by-step introduction to all the concepts behind exploiting simple stack-based buffer overflow vulnerability.

  1. Buffer overflow - Playing with application input and learning how buffer overflow works using the vulnerable application as an example.
  2. Padding - Redirecting of execution flow. Finding correct padding and overriding return address to cause arbitrary code execution.
  3. Shellpath - Learning basics of ARM64 assembly and CPU registers building shell path string on the CPU level.
  4. Shellcode - Interacting with operating system with assembly using syscalls requesting to spawn system shell through the exploited app.
  5. Exploitation - Using the created exploit to escalate user privileges and assigning user to system group of the winners.

Technical overview

To simulate real behavior of devices during exploitation of buffer overflow vulnerabilieies the project was designed to simulate all the most relevant things that happen from the bit level of executing instructions by the CPU, through kernel subrutines up to standard input / output handling. For the project I have implemented ARM64 emulator covering execution of few dozen of the most commonly used ARM64 CPU instructions alongside the official ARM Instruction Set Reference to emulate behavior of the real Apple Silicon CPU. On the software level, there is simple XNU kernel simulator which is capable of parsing and executing simple Mach-O executables on the emulator keeping compliance with Apple Platforms like Mach-O binary format, dynamic linking handling, syscalls, virtual memory implementation, function call convention etc. It is not full ARM64 emulator nor full XNU simulator but it covers enough for running simple programs and basic experimenting with ARM64 assembly for the purposes of learning basics of buffer overflow vulnerability exploitation.

Whole project has been created with Swift using pure iOS SDK using SwiftUI and Combine with no external libraries / frameworks.

Running project

The project was designed for iPad Pro devices with target of iOS 15.2 and newer. Builds have been tested on following configurations:

  • macOS 12.3 and Xcode 13.3 (when building on a Mac)
  • Swift Playgrounds 4.0.2 (when building directly on an iPad)

Swift Playgrounds on iPad

Project can be run directly on iPad by opening the Pwnground.swiftpm project file in Swift Playgrounds app (4.0.2 or later) and clicking Run button. Please note that building the project on Swift Playground on iPad is significally slower than in Xcode on Mac and it may take some while to build the app.

Xcode on Mac

Other way is to build the project on Mac by opehing the Pwnground.swiftpm project file in the Xcode (13.3 or later) and running by simply clicking Run. Project was designed for iPad Pro devices but it also works well fine as standalone macOS app on Apple Silicon Macs.

You might also like...
 My WWDC 2022 swift student challenge submission - GradientDescend
My WWDC 2022 swift student challenge submission - GradientDescend

GradientDescend Welcome to GradientDescend! This is my submission for the WWDC 2022 Swift Student Challenge. If you'd like, you can check out Gradient

WWDC22 demo: Scanning data with the camera
WWDC22 demo: Scanning data with the camera

Scanning Data with the Camera in SwiftUI WWDC22 brings brilliant Live Text data scanning tools which let users scan text and codes with the camera, si

VT100/Xterm Terminal emulator in Swift
VT100/Xterm Terminal emulator in Swift

SwiftTerm SwiftTerm is a VT100/Xterm terminal emulator library for Swift applications that can be embedded into macOS, iOS applications, text-based, h

NES - NES emulator, written in Swift

Swift NES NES emulator, written in Swift. NESKit: Emulator core. License GPL v3.

ZX Spectrum emulator for macOs. Retro Virtual Machine

Retro Virtual Machine 1.1.x This is the code for version 1.1.x of my emulator for the ZX Spectrum, Retro Virtual Machine. The current version (v2.0.7)

ActiveGS, Apple 2/2GS emulator for iOS
ActiveGS, Apple 2/2GS emulator for iOS

Activegs IOS Source code for the complete ActiveGS iOS application Installation Process (easier than it sounds!) Download Xcode 7 https://itunes.apple

A Gameboy Emulator for the Apple Watch
A Gameboy Emulator for the Apple Watch

A Gameboy Emulator for the Apple Watch. Interested in how this was made? Check out the write-up here Installation Giovanni uses git submodules for it'

A simple Student Management on an iOS App
A simple Student Management on an iOS App

Student Management XCode Swift App A simple Student Management on an Xcode Swift App Table of Contents About the projects Technologies Features Setup

An unofficial logbook for bouldering at Mandala. Kind of a SwiftUI playground as well.
An unofficial logbook for bouldering at Mandala. Kind of a SwiftUI playground as well.

BoulderLogbook An unofficial boulder logbook for Dresden's boulder gym Mandala. Features When finished it should allow you to: log all your tops for a

Owner
Bartłomiej Pluta
 WWDC22 Swift Student Challenge Winner
Bartłomiej Pluta
This is a project about Swift Student Challenge - WWDC22 [Submitted] Detailed walk through video link below.

Oh My Flag The App Oh My Flag helps students get familiar with flags. It is both educating and entertaining with the design of multi-module and intera

Frank Chu 10 Jun 30, 2022
My WWDC22 Swift Student Challenge submission [Submitted]

WWDC22 Swift Student Challenge Submission An educational iPad app teaching some fundamental rules of typography in a fun and interactive way. Created

null 11 Nov 3, 2022
WWDC22 Challenge: SwiftUI navigation hotdish

Challenge: SwiftUI navigation hotdish See this challenge definition at: Challenge: SwiftUI navigation hotdish Proposed solution The new SwiftUI versio

Zebra 1 Jun 11, 2022
In this mini app covered the concepts like basics of SwiftUI and Navigations and Animations and List with CRUD functions and MVVM and App Launch and App icons adding and also applied persistence using UserDefaults Concept.

TodoList In this application used the concepts from the beginner level project of SwiftUI_Evolve_1 The following concepts covered in this mini app Swi

Sivaram Yadav 2 Dec 4, 2021
Oversecured Vulnerable iOS App

Description OVIA (Oversecured Vulnerable iOS App) is an iOS app that aggregates all the platform's known and popular security vulnerabilities. List of

Oversecured Inc 136 Dec 31, 2022
An open-source SwiftUI Stack Overflow client

StackOv A SwiftUI Stackoverflow client We are currently in the developing process of the next version of StackOv app. The demo version of StackOv is a

Surf 235 Dec 17, 2022
Swift Playgrounds desenvolvido para o Swift Student Challenge da WWDC 21

Pile Up Swift Playgrounds desenvolvido para o Swift Student Challenge da WWDC 21 Descrição Pile Up é um quebra cabeça cujo objetivo é empilhar os bloc

Beatriz Sato 3 Jun 5, 2021
My submission for WWDC'21 Swift Student Challenge which was selected.

Double Spending This is my submission for Swift Student Challenge - WWDC2021. This playgrounds aims to teach you basics of Double Spending Attack. Thi

Garima Bothra 18 Jul 7, 2022
My WWDC21 Swift Student Challenge Submission

Swift3D A 3D framework for everyone. I love SwiftUI. I have been using it constantly since it came out in 2019 and its power and ease of use are what

Christian 191 Sep 23, 2022
My project for WWDC21 Swift Student Challenge!

Art with Times Table An interactive book that shows the figures that are generated when times tables are drawn inside a circle. This project was appro

Lucas Claro 10 Dec 30, 2022