How bpluta/pwnground works
Main Components
• Overall division between two high-level modules:
• User Interface Module
• Virtual Machine (Emulation & Simulation Engine)
• Supporting libraries or utilities (e.g., Extensions, Utilities) that provide helper functions and common functionality.
• Within the Virtual Machine module, highlight the following subcomponents:
• Binary Executable (handling Mach-O files, binary assembler, static linker)
• Instruction Set (contains various ARM64 instruction implementations, builders, executors, and string builders)
• Operating System Simulator (includes dynamic linker, syscall handling, process spawning, shell interpreter, and system components)
• Virtual Memory (simulating virtual memory blocks, mapped sections, and pages)
Confirm the Components via the File Structure
• The “UserInterface” directory contains:
• Components: including inspectors, instructions, pickers, and other UI elements.
• Scenes: different views for various playground levels (e.g., BufferOverflowLevelScene, ExploitingLevelScene) and a main PwngroundScene.
• Interactors: managing interactions between UI and underlying simulation logic.
• Setup and ViewHelpers: that initialize the playground and provide utility functions related to UI.
• The “Virtual Machine” directory is subdivided into:
• “Binary Executable” (with files for assembling and parsing Mach-O binaries)
• “Instruction Set” (implementation of various ARM64 instructions and their executors)
• “Operating System” (simulated XNU kernel functions, syscalls, and standard input/output handling)
• “Virtual Memory” (implements simulation of memory management)
• Additional support is provided by “Extensions” (helper functions extending Swift’s standards types) and “Utilities” (common reusable code).
How the Components Interact
• Data Flow and Control:
• The UI (built with SwiftUI and Combine) captures user input and displays debugging visuals.
• Interactors (inside the UI layer) mediate between user actions and underlying simulation logic, triggering changes in the Virtual Machine.
• The Virtual Machine emulates the execution of ARM64 instructions, processing user-built exploits and updating simulated memory/register states.
• Results such as register changes, memory mapping, and debug logs are then passed back to the UI to update visuals.
• User actions → UI Components → Interactors → Virtual Machine Core (subdivided into Instruction Set, Operating System, Virtual Memory)
• Virtual Machine Core → Output (debugger, live visual feedback) → UI Views
Architectural Patterns & Design Principles
• Separation of concerns: Clearly separate interactive UI from the emulation core.
• Modular design: The Virtual Machine is structurally subdivided into focused submodules (Instruction Set, OS, Memory) that mimic real system components.
• Use of SwiftUI’s declarative UI patterns combined with Combine’s reactive programming for event handling.
• The design also simulates real system hierarchy—from bit-level CPU instruction execution to kernel-level system process simulation (even though it is a simplified simulator).