7 Commits

Author SHA1 Message Date
dbisu
e6de3e98dc Only present as a keyboard and not both keyboard and mouse 2022-03-18 15:58:47 -05:00
dbisu
018fce3592 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 2022-03-18 15:00:06 -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
3 changed files with 77 additions and 13 deletions

View File

@@ -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`

View File

@@ -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)

View File

@@ -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