mirror of
https://github.com/dbisu/pico-ducky.git
synced 2026-01-21 17:26:00 +00:00
Compare commits
7 Commits
nugget_rem
...
no_mouse
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e6de3e98dc | ||
|
|
018fce3592 | ||
|
|
3fd60760c6 | ||
|
|
21ffbeb415 | ||
|
|
895fc7af58 | ||
|
|
11467900c5 | ||
|
|
fc0c2556e0 |
@@ -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`
|
||||
|
||||
|
||||
4
boot.py
4
boot.py
@@ -1,6 +1,10 @@
|
||||
from board import *
|
||||
import digitalio
|
||||
import storage
|
||||
import usb_hid
|
||||
|
||||
usb_hid.disable()
|
||||
usb_hid.enable((usb_hid.Device.KEYBOARD,))
|
||||
|
||||
noStorageStatus = False
|
||||
noStoragePin = digitalio.DigitalInOut(GP15)
|
||||
|
||||
@@ -14,6 +14,8 @@ 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 *
|
||||
@@ -32,7 +34,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 +103,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.value = True
|
||||
|
||||
|
||||
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
|
||||
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:])):
|
||||
@@ -131,11 +141,62 @@ def runScript(file):
|
||||
previousLine = line
|
||||
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
|
||||
print("Running payload.dd")
|
||||
runScript("payload.dd")
|
||||
payload = selectPayload()
|
||||
print("Running ", payload)
|
||||
runScript(payload)
|
||||
|
||||
print("Done")
|
||||
else:
|
||||
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