This is a submission for the Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machine
What I Built
When vibe coding with autonomous agents, I keep my MacBook awake with caffeinate so long builds, tests, and model generations don't sleep while I step away. But an unattended, awake laptop in a coffee shop, office, or hackathon invites snooping colleagues or thieves to touch the trackpad or grab the machine.
vibe-trap is a lightweight, escape-proof macOS AFK anti-tamper and anti-theft security utility that turns your laptop into a digital jumpscare trap:
| Capability | What It Does & How It Works |
|---|---|
| πͺ€ Kiosk Jumpscare Lockout | Topmost borderless fullscreen window elevated to .screenSaver level (above Dock, Menu Bar, and Mission Control). Cursor is hidden and clicks are swallowed. |
| π CoreAudio Hardware Override | Bypasses macOS volume sliders, unmuting and forcing system audio to 100% via native CoreAudio HAL (VirtualMainVolume), cleanly restoring original volume upon disarm. |
| ποΈ ElevenLabs AI Audio | High-transient horror audio loops generated with ElevenLabs AI Sound Effects (scream.mp3, smile.mp3, zombie.mp3). |
| β NEW: Anti-Theft Defense Suite | Tri-sensor protection against coffee-shop theft: tracks physical movement via Apple Silicon accelerometer, AC power unplug, and lid closure (--anti-theft). |
| π‘οΈ Anti-Bypass Defense | Intercepts Ctrl+C, Ctrl+\, and POSIX signals, instantly locking the machine behind FileVault using Apple's private SACLockScreenImmediate(). |
| π Silent Password Disarm | Type vibetrap blindly anywhere on the keyboard to disarm. A 50ms timestamp gate deduplicates terminal stdin and Quartz event streams. |
caffeinate -d npx vibe-trap
Demo & Quick Start
Zero setup and no Python dependencies required. Runs instantly on macOS with Node 18+:
# Standard AFK Trap (Keeps screen awake, 5s countdown):
caffeinate -d npx vibe-trap
# β Coffee Shop Anti-Theft Mode (Monitors charger unplug & lid closure):
caffeinate -d npx vibe-trap --anti-theft
# π Full Hardware Anti-Theft (Unlocks Apple Silicon Accelerometer/Gyro with root):
sudo caffeinate -d npx vibe-trap --anti-theft --sensitivity high
# Safe Dry-Run Mode (Safe for headphones, tests window without locking screen):
npx vibe-trap --dry-run --no-max-volume
Permissions Note: Grant your terminal app Accessibility access in System Settings > Privacy & Security > Accessibility so
vibe-trapcan detect global input events.
How The Trap Springs
1. ARMED:
$ caffeinate -d npx vibe-trap --anti-theft
[+] Disarm password: 'vibetrap'
[+] Loaded ElevenLabs procedural audio payloads
[+] Sensors active: AC Charger, Clamshell Lid, Input Tap
[+] β³ Arming in 5s... (step away from workstation)
[+] π‘οΈ [ARMED] Workstation protected!
2. TRIGGERED (Touch / Unplug / Move / Lid Close):
[!] UNAUTHORIZED ACTION DETECTED!
-> System unmuted and volume driven to 100% via CoreAudio
-> Fullscreen window forced to .screenSaver level across all Spaces
-> Continuous ElevenLabs horror audio blasts at maximum volume
-> Mouse cursor hidden; clicks swallowed
3. ESCAPE ATTEMPT (Intruder hits Ctrl+C or kill):
-> Signal caught -> SACLockScreenImmediate() + pmset displaysleepnow
-> Mac locks immediately into macOS login screen
4. OWNER DISARM:
Owner returns, types 'vibetrap' -> Trap disarmed, volume & terminal restored.
Code & Architecture
ntsd
/
vibe-trap
macOS AFK anti-tamper & jumpscare trap utility. Keeps screen awake, locks workstation on unauthorized touch.
πͺ€ vibe-trap
macOS AFK Anti-Tamper & Jumpscare Utility
Keeping your MacBook screen awake, watching for unauthorized hands, and springing the ultimate trap.
Built for the DEV Hacktoberfest 2026 Week 4 Challenge: Ghost in the Machine.
β‘ Overview
When you're vibe coding with autonomous agents, long builds, downloads, and model generations mean you always run caffeinate to keep your MacBook awake while stepping away. But an unattended, awake laptop invites snooping coworkers or friends to touch your trackpad or browse your terminal history.
vibe-trap is a lightweight macOS AFK security trap that:
- Keeps your MacBook screen awake using macOS
caffeinate. - Listens for global system-wide input events (mouse and keyboard).
- If an unauthorized person touches the mouse (any click) or types an incorrect key, it immediately launches a borderless, topmost, fullscreen jumpscare/meme window and blasts an eerie audio payload using native
afplay. - It engages persistent kiosk lockout: loops audioβ¦
- Source Code: github.com/ntsd/vibe-trap (MIT License)
- Engine: 100% native Swift 5.9 binary (172 KB, <10ms boot time).
-
Runner: Zero-dependency Node.js wrapper (
bin/cli.js).
caffeinate -d npx vibe-trap --anti-theft
β
[bin/cli.js] (Runner)
β
βΌ
[bin/vibe_trap] (Swift, 172 KB)
β
βββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββ
βΌ βΌ βΌ
[Input Monitors] [Hardware Sensors] [Lockout Window]
β’ Quartz CGEventTap β’ Apple Silicon IMU β’ Fullscreen NSWindow
β’ Raw stdin stream β’ IOPowerSources (MagSafe)β’ NSWindow (.screenSaver)
β’ Clamshell Lid State β’ CoreAudio HAL 100%
β’ ElevenLabs Audio Loop
βββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββ
βΌ
[Bypass Defense / Disarm]
β’ Ctrl+C / Signals βββΊ SACLockScreenImmediate()
β’ Password Typed βββΊ Clean restore & exit
How I Built It: Key Engineering Breakthroughs
1. Eliminating the 25-Second PyInstaller Cold Start
Our initial prototype used Python with pynput and PyInstaller. On macOS, PyInstaller unpacks dynamic libraries to /var/folders/ on every execution, causing Apple Mobile File Integrity (AMFI) and Gatekeeper verification delays of 20β25 seconds.
We scrapped Python and rebuilt the engine entirely in native Swift (src/main.swift), compiling directly to a 172 KB standalone binary that launches in under 10 milliseconds.
2. Tri-Vector Coffee Shop Anti-Theft Defense
To protect laptops in public cafes, vibe-trap monitors three distinct physical vectors:
-
Apple Silicon Hardware IMU (
AppleSPUHIDDevice): Reads the undocumented 6-axis MEMS accelerometer/gyroscope inside M-series MacBooks via IOKit HID at 800Hz. It auto-calibrates a baseline gravity vector during countdown to ignore minor table vibrations, triggering if someone tilts or lifts the machine. -
AC Power Disconnect (
IOPowerSources): Registers anIOPSNotificationCreateRunLoopSourcecallback to immediately fire the alarm the instant an intruder pulls the MagSafe or USB-C charging cable. -
Lid Closure Guard (
AppleClamshellState): HooksIOPMrootDomainandNSWorkspace.willSleepNotificationto detect grab-and-run attempts where the thief snaps the laptop shut.
3. CoreAudio Hardware HAL Volume Override
Intruders might try muting your laptop beforehand. When triggered, vibe-trap bypasses software volume sliders and directly drives the macOS CoreAudio Hardware Abstraction Layer:
- Queries
kAudioHardwarePropertyDefaultOutputDevice. - Unmutes with
kAudioDevicePropertyMuteand drivesVirtualMainVolumeto1.0in<1ms. - Stores the owner's original volume and mute state on boot, restoring them cleanly upon disarm.
4. Procedural Horror Audio with ElevenLabs
Payload audio (scream.mp3, smile.mp3, zombie.mp3) was synthesized with the ElevenLabs AI Sound Effects API:
- Engineered prompts for high acoustic transients ("Piercing supernatural jumpscare shriek with metallic reverb").
- Deployed as native looping audio with process tracking for instant termination on password verification.
5. Escape-Proof Kiosk Window & Low-Level Event Tap
Standard fullscreen windows leave the Dock and Menu Bar accessible. vibe-trap forces the window to .screenSaver level across all spaces (canJoinAllSpaces), hides the cursor, and uses Quartz CGEvent.tapCreate combined with raw stdin to swallow all mouse input and match the disarm sequence.
6. Anti-Bypass Defense via Apple Private Frameworks
If an intruder attempts Ctrl+C, Ctrl+\, or sends SIGTERM, userland processes normally die. We intercept POSIX signals via DispatchSource.makeSignalSource, dynamically load Apple's private login.framework symbol SACLockScreenImmediate() via dlsym, and invoke pmset displaysleepnow, locking the workstation into FileVault before the process terminates.
Why Open Innovation Matters
-
100% Offline & Air-Gapped: Vibe coding happens on airplanes, in trains, and in basement cafes.
vibe-traprequires zero cloud calls or runtime internet access. -
Open-Source Auditability: Asking for macOS Accessibility and Input Monitoring permissions is sensitive. Because
vibe-trapis 100% open source under the MIT License, developers can verify that keystrokes are evaluated solely in memory and never logged or exfiltrated. - Deep System Freedom: Open-source research allows developers to access hidden hardware capabilitiesβlike the undocumented Apple Silicon IMUβthat closed developer SDKs hide away.
My Agent Session
This entire utilityβfrom diagnosing PyInstaller's Gatekeeper delay to reverse-engineering Apple Silicon's SPU accelerometer and wiring CoreAudio HALβwas pair-programmed in a collaborative agent session:
Direct session link: View on DEV Agent Sessions
Prize Categories
- Overall Winner: Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machine
- Best Use of ElevenLabs: Procedural jumpscare audio generation synthesized with ElevenLabs AI Sound Effects and deployed as native looping assets.
Top comments (0)