mirror of
https://github.com/dbisu/pico-ducky.git
synced 2026-01-21 17:26:00 +00:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e6de3e98dc | ||
|
|
018fce3592 | ||
|
|
3fd60760c6 | ||
|
|
21ffbeb415 | ||
|
|
895fc7af58 | ||
|
|
11467900c5 | ||
|
|
fc0c2556e0 | ||
|
|
bb5c33f068 | ||
|
|
39537f4802 | ||
|
|
ca5c012d8d | ||
|
|
21cf5ffdf2 |
@@ -22,7 +22,7 @@ Install and have your USB Rubber Ducky working in less than 5 minutes.
|
|||||||
|
|
||||||
1. Download [CircuitPython for the Raspberry Pi Pico](https://circuitpython.org/board/raspberry_pi_pico/). *Updated to 7.0.0
|
1. Download [CircuitPython for the Raspberry Pi Pico](https://circuitpython.org/board/raspberry_pi_pico/). *Updated to 7.0.0
|
||||||
|
|
||||||
2. Plug the device into a USB port. It will show up as a removable media device named `RPI-RP2`.
|
2. Plug the device into a USB port while holding the boot button. It will show up as a removable media device named `RPI-RP2`.
|
||||||
|
|
||||||
3. Copy the downloaded `.uf2` file to the root of the Pico (`RPI-RP2`). The device will reboot and after a second or so, it will reconnect as `CIRCUITPY`.
|
3. Copy the downloaded `.uf2` file to the root of the Pico (`RPI-RP2`). The device will reboot and after a second or so, it will reconnect as `CIRCUITPY`.
|
||||||
|
|
||||||
@@ -86,7 +86,6 @@ For a language `LANG`, copy the following files from the zip's `lib` folder to t
|
|||||||
**DO NOT** change the names or extensions of the files. Just pick the right ones.
|
**DO NOT** change the names or extensions of the files. Just pick the right ones.
|
||||||
Replace `LANG` with the letters for your language of choice.
|
Replace `LANG` with the letters for your language of choice.
|
||||||
|
|
||||||
- `keyboard_layout.py`
|
|
||||||
- `keyboard_layout_win_LANG.py`
|
- `keyboard_layout_win_LANG.py`
|
||||||
- `keycode_win_LANG.py`
|
- `keycode_win_LANG.py`
|
||||||
|
|
||||||
|
|||||||
4
boot.py
4
boot.py
@@ -1,6 +1,10 @@
|
|||||||
from board import *
|
from board import *
|
||||||
import digitalio
|
import digitalio
|
||||||
import storage
|
import storage
|
||||||
|
import usb_hid
|
||||||
|
|
||||||
|
usb_hid.disable()
|
||||||
|
usb_hid.enable((usb_hid.Device.KEYBOARD,))
|
||||||
|
|
||||||
noStorageStatus = False
|
noStorageStatus = False
|
||||||
noStoragePin = digitalio.DigitalInOut(GP15)
|
noStoragePin = digitalio.DigitalInOut(GP15)
|
||||||
|
|||||||
114
duckyinpython.py
114
duckyinpython.py
@@ -1,3 +1,7 @@
|
|||||||
|
# License : GPLv2.0
|
||||||
|
# copyright (c) 2021 Dave Bailey
|
||||||
|
# Author: Dave Bailey (dbisu, @daveisu)
|
||||||
|
|
||||||
import usb_hid
|
import usb_hid
|
||||||
from adafruit_hid.keyboard import Keyboard
|
from adafruit_hid.keyboard import Keyboard
|
||||||
|
|
||||||
@@ -10,9 +14,13 @@ from adafruit_hid.keycode import Keycode
|
|||||||
#from keyboard_layout_win_LANG import KeyboardLayout
|
#from keyboard_layout_win_LANG import KeyboardLayout
|
||||||
#from keycode_win_LANG import Keycode
|
#from keycode_win_LANG import Keycode
|
||||||
|
|
||||||
|
import supervisor
|
||||||
|
|
||||||
import time
|
import time
|
||||||
import digitalio
|
import digitalio
|
||||||
from board import *
|
from board import *
|
||||||
|
led = digitalio.DigitalInOut(LED)
|
||||||
|
led.direction = digitalio.Direction.OUTPUT
|
||||||
|
|
||||||
duckyCommands = {
|
duckyCommands = {
|
||||||
'WINDOWS': Keycode.WINDOWS, 'GUI': Keycode.GUI,
|
'WINDOWS': Keycode.WINDOWS, 'GUI': Keycode.GUI,
|
||||||
@@ -26,6 +34,7 @@ duckyCommands = {
|
|||||||
'INSERT': Keycode.INSERT, 'NUMLOCK': Keycode.KEYPAD_NUMLOCK, 'PAGEUP': Keycode.PAGE_UP,
|
'INSERT': Keycode.INSERT, 'NUMLOCK': Keycode.KEYPAD_NUMLOCK, 'PAGEUP': Keycode.PAGE_UP,
|
||||||
'PAGEDOWN': Keycode.PAGE_DOWN, 'PRINTSCREEN': Keycode.PRINT_SCREEN, 'ENTER': Keycode.ENTER,
|
'PAGEDOWN': Keycode.PAGE_DOWN, 'PRINTSCREEN': Keycode.PRINT_SCREEN, 'ENTER': Keycode.ENTER,
|
||||||
'SCROLLLOCK': Keycode.SCROLL_LOCK, 'SPACE': Keycode.SPACE, 'TAB': Keycode.TAB,
|
'SCROLLLOCK': Keycode.SCROLL_LOCK, 'SPACE': Keycode.SPACE, 'TAB': Keycode.TAB,
|
||||||
|
'BACKSPACE': Keycode.BACKSPACE,
|
||||||
'A': Keycode.A, 'B': Keycode.B, 'C': Keycode.C, 'D': Keycode.D, 'E': Keycode.E,
|
'A': Keycode.A, 'B': Keycode.B, 'C': Keycode.C, 'D': Keycode.D, 'E': Keycode.E,
|
||||||
'F': Keycode.F, 'G': Keycode.G, 'H': Keycode.H, 'I': Keycode.I, 'J': Keycode.J,
|
'F': Keycode.F, 'G': Keycode.G, 'H': Keycode.H, 'I': Keycode.I, 'J': Keycode.J,
|
||||||
'K': Keycode.K, 'L': Keycode.L, 'M': Keycode.M, 'N': Keycode.N, 'O': Keycode.O,
|
'K': Keycode.K, 'L': Keycode.L, 'M': Keycode.M, 'N': Keycode.N, 'O': Keycode.O,
|
||||||
@@ -35,11 +44,11 @@ duckyCommands = {
|
|||||||
'F4': Keycode.F4, 'F5': Keycode.F5, 'F6': Keycode.F6, 'F7': Keycode.F7,
|
'F4': Keycode.F4, 'F5': Keycode.F5, 'F6': Keycode.F6, 'F7': Keycode.F7,
|
||||||
'F8': Keycode.F8, 'F9': Keycode.F9, 'F10': Keycode.F10, 'F11': Keycode.F11,
|
'F8': Keycode.F8, 'F9': Keycode.F9, 'F10': Keycode.F10, 'F11': Keycode.F11,
|
||||||
'F12': Keycode.F12,
|
'F12': Keycode.F12,
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
def convertLine(line):
|
def convertLine(line):
|
||||||
newline = []
|
newline = []
|
||||||
print(line)
|
# print(line)
|
||||||
# loop on each key - the filter removes empty values
|
# loop on each key - the filter removes empty values
|
||||||
for key in filter(None, line.split(" ")):
|
for key in filter(None, line.split(" ")):
|
||||||
key = key.upper()
|
key = key.upper()
|
||||||
@@ -54,7 +63,7 @@ def convertLine(line):
|
|||||||
else:
|
else:
|
||||||
# if it's not a known key name, show the error for diagnosis
|
# if it's not a known key name, show the error for diagnosis
|
||||||
print(f"Unknown key: <{key}>")
|
print(f"Unknown key: <{key}>")
|
||||||
print(newline)
|
# print(newline)
|
||||||
return newline
|
return newline
|
||||||
|
|
||||||
def runScriptLine(line):
|
def runScriptLine(line):
|
||||||
@@ -66,6 +75,7 @@ def sendString(line):
|
|||||||
layout.write(line)
|
layout.write(line)
|
||||||
|
|
||||||
def parseLine(line):
|
def parseLine(line):
|
||||||
|
global defaultDelay
|
||||||
if(line[0:3] == "REM"):
|
if(line[0:3] == "REM"):
|
||||||
# ignore ducky script comments
|
# ignore ducky script comments
|
||||||
pass
|
pass
|
||||||
@@ -73,10 +83,19 @@ def parseLine(line):
|
|||||||
time.sleep(float(line[6:])/1000)
|
time.sleep(float(line[6:])/1000)
|
||||||
elif(line[0:6] == "STRING"):
|
elif(line[0:6] == "STRING"):
|
||||||
sendString(line[7:])
|
sendString(line[7:])
|
||||||
|
elif(line[0:5] == "PRINT"):
|
||||||
|
print("[SCRIPT]: " + line[6:])
|
||||||
|
elif(line[0:6] == "IMPORT"):
|
||||||
|
runScript(line[7:])
|
||||||
elif(line[0:13] == "DEFAULT_DELAY"):
|
elif(line[0:13] == "DEFAULT_DELAY"):
|
||||||
defaultDelay = int(line[14:]) * 10
|
defaultDelay = int(line[14:]) * 10
|
||||||
elif(line[0:12] == "DEFAULTDELAY"):
|
elif(line[0:12] == "DEFAULTDELAY"):
|
||||||
defaultDelay = int(line[13:]) * 10
|
defaultDelay = int(line[13:]) * 10
|
||||||
|
elif(line[0:3] == "LED"):
|
||||||
|
if(led.value == True):
|
||||||
|
led.value = False
|
||||||
|
else:
|
||||||
|
led.value = True
|
||||||
else:
|
else:
|
||||||
newScriptLine = convertLine(line)
|
newScriptLine = convertLine(line)
|
||||||
runScriptLine(newScriptLine)
|
runScriptLine(newScriptLine)
|
||||||
@@ -84,24 +103,33 @@ def parseLine(line):
|
|||||||
kbd = Keyboard(usb_hid.devices)
|
kbd = Keyboard(usb_hid.devices)
|
||||||
layout = KeyboardLayout(kbd)
|
layout = KeyboardLayout(kbd)
|
||||||
|
|
||||||
|
# turn off automatically reloading when files are written to the pico
|
||||||
|
supervisor.disable_autoreload()
|
||||||
|
|
||||||
# sleep at the start to allow the device to be recognized by the host computer
|
# sleep at the start to allow the device to be recognized by the host computer
|
||||||
time.sleep(.5)
|
time.sleep(.5)
|
||||||
|
|
||||||
# check GP0 for setup mode
|
led.value = True
|
||||||
# see setup mode for instructions
|
|
||||||
progStatus = False
|
|
||||||
progStatusPin = digitalio.DigitalInOut(GP0)
|
def getProgrammingStatus():
|
||||||
progStatusPin.switch_to_input(pull=digitalio.Pull.UP)
|
# check GP0 for setup mode
|
||||||
progStatus = not progStatusPin.value
|
# see setup mode for instructions
|
||||||
|
progStatusPin = digitalio.DigitalInOut(GP0)
|
||||||
|
progStatusPin.switch_to_input(pull=digitalio.Pull.UP)
|
||||||
|
progStatus = not progStatusPin.value
|
||||||
|
return(progStatus)
|
||||||
|
|
||||||
|
|
||||||
defaultDelay = 0
|
defaultDelay = 0
|
||||||
if(progStatus == False):
|
|
||||||
# not in setup mode, inject the payload
|
def runScript(file):
|
||||||
duckyScriptPath = "payload.dd"
|
global defaultDelay
|
||||||
|
|
||||||
|
duckyScriptPath = file
|
||||||
f = open(duckyScriptPath,"r",encoding='utf-8')
|
f = open(duckyScriptPath,"r",encoding='utf-8')
|
||||||
print("Running payload.dd")
|
|
||||||
previousLine = ""
|
previousLine = ""
|
||||||
duckyScript = f.readlines()
|
for line in f:
|
||||||
for line in duckyScript:
|
|
||||||
line = line.rstrip()
|
line = line.rstrip()
|
||||||
if(line[0:6] == "REPEAT"):
|
if(line[0:6] == "REPEAT"):
|
||||||
for i in range(int(line[7:])):
|
for i in range(int(line[7:])):
|
||||||
@@ -113,6 +141,62 @@ if(progStatus == False):
|
|||||||
previousLine = line
|
previousLine = line
|
||||||
time.sleep(float(defaultDelay)/1000)
|
time.sleep(float(defaultDelay)/1000)
|
||||||
|
|
||||||
|
def selectPayload():
|
||||||
|
payload = "payload.dd"
|
||||||
|
# check switch status
|
||||||
|
# payload1 = GPIO4 to GND
|
||||||
|
# payload2 = GPIO5 to GND
|
||||||
|
# payload3 = GPIO10 to GND
|
||||||
|
# payload4 = GPIO11 to GND
|
||||||
|
payload1Pin = digitalio.DigitalInOut(GP4)
|
||||||
|
payload1Pin.switch_to_input(pull=digitalio.Pull.UP)
|
||||||
|
payload1State = not payload1Pin.value
|
||||||
|
payload2Pin = digitalio.DigitalInOut(GP5)
|
||||||
|
payload2Pin.switch_to_input(pull=digitalio.Pull.UP)
|
||||||
|
payload2State = not payload2Pin.value
|
||||||
|
payload3Pin = digitalio.DigitalInOut(GP10)
|
||||||
|
payload3Pin.switch_to_input(pull=digitalio.Pull.UP)
|
||||||
|
payload3State = not payload3Pin.value
|
||||||
|
payload4Pin = digitalio.DigitalInOut(GP11)
|
||||||
|
payload4Pin.switch_to_input(pull=digitalio.Pull.UP)
|
||||||
|
payload4State = not payload4Pin.value
|
||||||
|
|
||||||
|
|
||||||
|
if(payload1State == True):
|
||||||
|
payload = "payload.dd"
|
||||||
|
|
||||||
|
elif(payload2State == True):
|
||||||
|
payload = "payload2.dd"
|
||||||
|
|
||||||
|
elif(payload3State == True):
|
||||||
|
payload = "payload3.dd"
|
||||||
|
|
||||||
|
elif(payload4State == True):
|
||||||
|
payload = "payload4.dd"
|
||||||
|
|
||||||
|
else:
|
||||||
|
# if all pins are high, then no switch is present
|
||||||
|
# default to payload1
|
||||||
|
payload = "payload.dd"
|
||||||
|
|
||||||
|
|
||||||
|
return payload
|
||||||
|
|
||||||
|
progStatus = False
|
||||||
|
progStatus = getProgrammingStatus()
|
||||||
|
|
||||||
|
if(progStatus == False):
|
||||||
|
# not in setup mode, inject the payload
|
||||||
|
payload = selectPayload()
|
||||||
|
print("Running ", payload)
|
||||||
|
runScript(payload)
|
||||||
|
|
||||||
print("Done")
|
print("Done")
|
||||||
else:
|
else:
|
||||||
print("Update your payload")
|
print("Update your payload")
|
||||||
|
|
||||||
|
while True:
|
||||||
|
time.sleep(1.0)
|
||||||
|
led.value = False
|
||||||
|
time.sleep(1.0)
|
||||||
|
led.value = True
|
||||||
|
|||||||
Reference in New Issue
Block a user