10 Commits

Author SHA1 Message Date
Dave
2876f80140 Update README to clarify non-US keyboard instructions (#70) 2022-04-10 11:51:41 -05:00
Aask
0988524506 making light pwm (#68)
Co-authored-by: unknown <ask.wietting@gmail.com>
2022-04-05 18:23:06 -05:00
dbisu
e11b087b75 Add exception handling to file open 2022-04-03 13:52:40 -05:00
mm12
f79fe2cb48 Update README.md (#65) 2022-03-27 13:27:58 -05:00
Dave
3d101c82d4 Disable auto reload when a new payload or code is deployed. Add blinking LED when board is idle, ready for reload or payload is finished running (#59) 2022-03-18 15:03:35 -05:00
Phil
3fd60760c6 Saving some memory (#55)
* saving some memory

* remove print

* better syntax

* Update duckyinpython.py
2022-03-10 18:11:35 -06:00
Dave
21ffbeb415 Adding support for four position switch to select payloads (#51) 2022-02-24 20:14:02 -06:00
Neradoc
895fc7af58 Removed keyboard_layout.py (#50)
`keyboard_layout.py` is now in adafruit_hid (version 5+) and no longer needed.
2022-02-11 22:03:44 -06:00
Elisha Hollander
11467900c5 remove second DELETE (#46) 2022-01-16 10:05:58 -06:00
dbisu
fc0c2556e0 Fixed typo 2021-12-11 10:57:41 -06:00
2 changed files with 127 additions and 28 deletions

View File

@@ -50,7 +50,7 @@ Enter setup mode.
Copy boot.py to the root of the pico-ducky. Copy boot.py to the root of the pico-ducky.
Copy your payload script to the pico-ducky. Copy your payload script to the pico-ducky.
Disconnect the pico from your host PC. 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. 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. Remove the jumper and reconnect to your PC to reprogram.
The default mode is USB mass storage enabled. 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. **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`
@@ -112,6 +111,22 @@ from keyboard_layout_win_LANG import KeyboardLayout
from keycode_win_LANG import Keycode 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 ## Useful links and resources
### Docs ### Docs

View File

@@ -14,11 +14,30 @@ 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) import pwmio
led.direction = digitalio.Direction.OUTPUT
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 = { duckyCommands = {
'WINDOWS': Keycode.WINDOWS, 'GUI': Keycode.GUI, 'WINDOWS': Keycode.WINDOWS, 'GUI': Keycode.GUI,
@@ -32,7 +51,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,
'BAKCKSPACE': Keycode.BACKSPACE, 'DELETE': Keycode.DELETE, '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,
@@ -101,41 +120,106 @@ 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_pwm_up(led)
# see setup mode for instructions
progStatus = False def getProgrammingStatus():
progStatusPin = digitalio.DigitalInOut(GP0) # check GP0 for setup mode
progStatusPin.switch_to_input(pull=digitalio.Pull.UP) # see setup mode for instructions
progStatus = not progStatusPin.value progStatusPin = digitalio.DigitalInOut(GP0)
progStatusPin.switch_to_input(pull=digitalio.Pull.UP)
progStatus = not progStatusPin.value
return(progStatus)
defaultDelay = 0 defaultDelay = 0
def runScript(file): def runScript(file):
global defaultDelay global defaultDelay
duckyScriptPath = file duckyScriptPath = file
f = open(duckyScriptPath,"r",encoding='utf-8') try:
previousLine = "" f = open(duckyScriptPath,"r",encoding='utf-8')
duckyScript = f.readlines() previousLine = ""
for line in duckyScript: for line in f:
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:])):
#repeat the last command #repeat the last command
parseLine(previousLine) parseLine(previousLine)
time.sleep(float(defaultDelay)/1000) time.sleep(float(defaultDelay)/1000)
else: else:
parseLine(line) parseLine(line)
previousLine = line previousLine = line
time.sleep(float(defaultDelay)/1000) 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): if(progStatus == False):
# not in setup mode, inject the payload # not in setup mode, inject the payload
print("Running payload.dd") payload = selectPayload()
runScript("payload.dd") print("Running ", payload)
runScript(payload)
print("Done") print("Done")
else: else:
print("Update your payload") 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