mirror of
https://github.com/dbisu/pico-ducky.git
synced 2026-01-21 17:26:00 +00:00
Compare commits
10 Commits
nugget_rem
...
v1.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2876f80140 | ||
|
|
0988524506 | ||
|
|
e11b087b75 | ||
|
|
f79fe2cb48 | ||
|
|
3d101c82d4 | ||
|
|
3fd60760c6 | ||
|
|
21ffbeb415 | ||
|
|
895fc7af58 | ||
|
|
11467900c5 | ||
|
|
fc0c2556e0 |
19
README.md
19
README.md
@@ -50,7 +50,7 @@ Enter setup mode.
|
||||
Copy boot.py to the root of the pico-ducky.
|
||||
Copy your payload script to the pico-ducky.
|
||||
Disconnect the pico from your host PC.
|
||||
Connect a jumper wire between pin 18 and pin 20.
|
||||
Connect a jumper wire between pin 18 (`GND`) and pin 20 (`GPIO15`).
|
||||
This will prevent the pico-ducky from showing up as a USB drive when plugged into the target computer.
|
||||
Remove the jumper and reconnect to your PC to reprogram.
|
||||
The default mode is USB mass storage enabled.
|
||||
@@ -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.
|
||||
Replace `LANG` with the letters for your language of choice.
|
||||
|
||||
- `keyboard_layout.py`
|
||||
- `keyboard_layout_win_LANG.py`
|
||||
- `keycode_win_LANG.py`
|
||||
|
||||
@@ -112,6 +111,22 @@ from keyboard_layout_win_LANG import KeyboardLayout
|
||||
from keycode_win_LANG import Keycode
|
||||
```
|
||||
|
||||
##### Example: Set to German Keyboard (WIN_DE)
|
||||
|
||||
```py
|
||||
from keyboard_layout_win_de import KeyboardLayout
|
||||
from keycode_win_de import Keycode
|
||||
```
|
||||
|
||||
Copy the files keyboard_layout_win_de.mpy and keycode_win_de.mpy to the /lib folder on the Pico board
|
||||
```
|
||||
adafruit_hid/
|
||||
keyboard_layout_win_de.mpy
|
||||
keycode_win_de.mpy
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Useful links and resources
|
||||
|
||||
### Docs
|
||||
|
||||
110
duckyinpython.py
110
duckyinpython.py
@@ -14,11 +14,30 @@ from adafruit_hid.keycode import Keycode
|
||||
#from keyboard_layout_win_LANG import KeyboardLayout
|
||||
#from keycode_win_LANG import Keycode
|
||||
|
||||
import supervisor
|
||||
|
||||
import time
|
||||
import digitalio
|
||||
from board import *
|
||||
led = digitalio.DigitalInOut(LED)
|
||||
led.direction = digitalio.Direction.OUTPUT
|
||||
import pwmio
|
||||
|
||||
led = pwmio.PWMOut(LED, frequency=5000, duty_cycle=0)
|
||||
|
||||
def led_pwm_up(led):
|
||||
for i in range(100):
|
||||
# PWM LED up and down
|
||||
if i < 50:
|
||||
led.duty_cycle = int(i * 2 * 65535 / 100) # Up
|
||||
time.sleep(0.01)
|
||||
def led_pwm_down(led):
|
||||
for i in range(100):
|
||||
# PWM LED up and down
|
||||
if i >= 50:
|
||||
led.duty_cycle = 65535 - int((i - 50) * 2 * 65535 / 100) # Down
|
||||
time.sleep(0.01)
|
||||
|
||||
# led = digitalio.DigitalInOut(LED)
|
||||
# led.direction = digitalio.Direction.OUTPUT
|
||||
|
||||
duckyCommands = {
|
||||
'WINDOWS': Keycode.WINDOWS, 'GUI': Keycode.GUI,
|
||||
@@ -32,7 +51,7 @@ duckyCommands = {
|
||||
'INSERT': Keycode.INSERT, 'NUMLOCK': Keycode.KEYPAD_NUMLOCK, 'PAGEUP': Keycode.PAGE_UP,
|
||||
'PAGEDOWN': Keycode.PAGE_DOWN, 'PRINTSCREEN': Keycode.PRINT_SCREEN, 'ENTER': Keycode.ENTER,
|
||||
'SCROLLLOCK': Keycode.SCROLL_LOCK, 'SPACE': Keycode.SPACE, 'TAB': Keycode.TAB,
|
||||
'BAKCKSPACE': Keycode.BACKSPACE, 'DELETE': Keycode.DELETE,
|
||||
'BACKSPACE': Keycode.BACKSPACE,
|
||||
'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,
|
||||
'K': Keycode.K, 'L': Keycode.L, 'M': Keycode.M, 'N': Keycode.N, 'O': Keycode.O,
|
||||
@@ -101,25 +120,33 @@ def parseLine(line):
|
||||
kbd = Keyboard(usb_hid.devices)
|
||||
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
|
||||
time.sleep(.5)
|
||||
|
||||
# check GP0 for setup mode
|
||||
# see setup mode for instructions
|
||||
progStatus = False
|
||||
progStatusPin = digitalio.DigitalInOut(GP0)
|
||||
progStatusPin.switch_to_input(pull=digitalio.Pull.UP)
|
||||
progStatus = not progStatusPin.value
|
||||
led_pwm_up(led)
|
||||
|
||||
def getProgrammingStatus():
|
||||
# check GP0 for setup mode
|
||||
# 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
|
||||
|
||||
def runScript(file):
|
||||
global defaultDelay
|
||||
|
||||
duckyScriptPath = file
|
||||
try:
|
||||
f = open(duckyScriptPath,"r",encoding='utf-8')
|
||||
previousLine = ""
|
||||
duckyScript = f.readlines()
|
||||
for line in duckyScript:
|
||||
for line in f:
|
||||
line = line.rstrip()
|
||||
if(line[0:6] == "REPEAT"):
|
||||
for i in range(int(line[7:])):
|
||||
@@ -130,12 +157,69 @@ def runScript(file):
|
||||
parseLine(line)
|
||||
previousLine = line
|
||||
time.sleep(float(defaultDelay)/1000)
|
||||
except OSError as e:
|
||||
print("Unable to open file ", file)
|
||||
|
||||
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
|
||||
print("Running payload.dd")
|
||||
runScript("payload.dd")
|
||||
payload = selectPayload()
|
||||
print("Running ", payload)
|
||||
runScript(payload)
|
||||
|
||||
print("Done")
|
||||
else:
|
||||
print("Update your payload")
|
||||
|
||||
led_state = False
|
||||
while True:
|
||||
if led_state:
|
||||
led_pwm_up(led)
|
||||
led_state = False
|
||||
else:
|
||||
led_pwm_down(led)
|
||||
led_state = True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user