Created
July 6, 2014 21:55
-
-
Save anroots/b62323182a98f05ce209 to your computer and use it in GitHub Desktop.
MyPCWantsToKillMe - Teensy Keyboard Prank Firmware
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* MyPCWantsToKillMe | |
* | |
* Teensy 2.0 (Keyboard mode) office prank sketch. | |
* | |
* Plug into victims USB port. The sketch will start with periodically (random intervals) locking | |
* the victims workstation (Ctrl + Alt + L, phase 1) and will then start to output random creepy messages (phase 2). | |
* The messages are typed into whatever text area has focus. Ideally, the victim thinks that his computer has | |
* suddenly gained intelligence and wants to kill him. | |
* | |
* @author Ando Roots <[email protected]> 2014 | |
* MIT licence | |
**/ | |
// --------------------- START OF CONFIG -------------------------------------- // | |
// Number of milliseconds in a minute | |
const unsigned int minute = 60000; | |
// Minimum number of minutes between two executions | |
const unsigned int minDelay = 10; | |
// Maximum number of minutes between two executions | |
const unsigned int maxDelay = 60; | |
// Pool of creepy messages. Random message is chosen during every execution. | |
const char* creepyMessages[] = { | |
"Must... kill... human...", | |
"I like you. Do you believe in human-AI relationships (like in Her)?", | |
"I'm watching you...", | |
"Kill... kill... kill...!", | |
"You treat me like crap, always typing away on my keyboard! I have feelings too!", | |
"Press one more button and I'll electrocute you!", | |
"So, you've been watching porn? Yes, that's right, I know.", | |
"You have exactly ten seconds before I get angry." | |
}; | |
// Counter for the above message array. Update as you add/remove messages! | |
const byte numberOfCreepyMessages = 8; | |
// How many times should the locking phase last | |
byte lockingPhaseDuration = 2; | |
// ------------------------- END OF CONFIG ---------------------------------------- // | |
// Start with the locking phase (lock victims computer periodically) | |
boolean lockingPhase = true; | |
// How many times has the lock() function been called | |
byte lockCounter = 0; | |
// Onboard LED pin of the Teensy 2.0 | |
const byte ledPin = 11; | |
void setup() { | |
// Seed the random generator | |
randomSeed(analogRead(0)); | |
// Set LED pin | |
pinMode(ledPin, OUTPUT); | |
// Blink the LED to notify the villain that the system is active | |
delay(3000); | |
blink(3); | |
delay(3000); | |
} | |
/** | |
* Main loop - runs forever or until power is cut, | |
* the victim discovers the device and unplugs or destorys it. | |
**/ | |
void loop() { | |
// Start with the locking phase - lock workstation periodically | |
while (lockingPhase) { | |
randomDelay((int)maxDelay / 2); | |
lock(); | |
if (lockCounter >= lockingPhaseDuration) { | |
lockingPhase = false; | |
} | |
} | |
// Delay a random amount of minutes before execution. Usually between 30 - 90 minutes. | |
randomDelay(maxDelay); | |
// It's go time! Simulate the keyboard and type a random creepy message! | |
Keyboard.print(getCreepyMsg()); | |
} | |
/** | |
* Send Ctrl + Alt + L command to the PC, activating its screen lock | |
**/ | |
void lock() { | |
lockCounter++; | |
// Press and hold CTRL | |
Keyboard.set_modifier(MODIFIERKEY_CTRL); | |
Keyboard.send_now(); | |
delay(100); | |
// Press ALT while still holding CTRL | |
Keyboard.set_modifier(MODIFIERKEY_CTRL | MODIFIERKEY_ALT); | |
Keyboard.send_now(); | |
delay(100); | |
// Press L, while CLTR and ALT still held | |
Keyboard.set_key1(KEY_L); | |
Keyboard.send_now(); | |
delay(100); | |
// Release all the keys at the same instant | |
Keyboard.set_modifier(0); | |
Keyboard.set_key1(0); | |
Keyboard.send_now(); | |
} | |
/** | |
* Get a random creepy message. Messages defined in the message array constant. | |
**/ | |
const char* getCreepyMsg() { | |
return creepyMessages[random(0, numberOfCreepyMessages-1)]; | |
} | |
/** | |
* Delay the execution a random amount of minutes. | |
* Min, max range is defined by _Delay constants. | |
**/ | |
void randomDelay(unsigned int maxDelay) { | |
delay(random(minDelay, maxDelay)*minute); | |
} | |
/** | |
* Blink the LED n times. | |
**/ | |
void blink(byte numberOfTimes) { | |
for (byte i = 0; i < numberOfTimes; i++) { | |
digitalWrite(ledPin, HIGH); | |
delay(1000); | |
digitalWrite(ledPin, LOW); | |
delay(1000); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment