mirror of
https://github.com/dbisu/pico-ducky.git
synced 2026-02-03 21:21:04 +00:00
Add Programming switch (#4)
* Add support for programming switch * Update README.md documentation
This commit is contained in:
@@ -30,3 +30,8 @@ $ cp duckyinpython.py /<path to media device>/code.py
|
|||||||
Copy your Ducky Scipt file as payload.dd
|
Copy your Ducky Scipt file as payload.dd
|
||||||
|
|
||||||
$ cp <duckyscriptfile> /path to media device>/payload.dd
|
$ cp <duckyscriptfile> /path to media device>/payload.dd
|
||||||
|
|
||||||
|
# NEW: added support for a programming switch.
|
||||||
|
Tie pin 0 (GPIO0) to pin 3 (GND) to not automatically run payloads.
|
||||||
|
Easiest way to do this is to add a jumper wire between those pins.
|
||||||
|

|
||||||
|
|||||||
@@ -3,6 +3,8 @@ from adafruit_hid.keyboard import Keyboard
|
|||||||
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
|
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
|
||||||
from adafruit_hid.keycode import Keycode
|
from adafruit_hid.keycode import Keycode
|
||||||
import time
|
import time
|
||||||
|
import digitalio
|
||||||
|
from board import *
|
||||||
|
|
||||||
duckyCommands = ["WINDOWS", "GUI", "APP", "MENU", "SHIFT", "ALT", "CONTROL", "CTRL", "DOWNARROW", "DOWN",
|
duckyCommands = ["WINDOWS", "GUI", "APP", "MENU", "SHIFT", "ALT", "CONTROL", "CTRL", "DOWNARROW", "DOWN",
|
||||||
"LEFTARROW", "LEFT", "RIGHTARROW", "RIGHT", "UPARROW", "UP", "BREAK", "PAUSE", "CAPSLOCK", "DELETE", "END",
|
"LEFTARROW", "LEFT", "RIGHTARROW", "RIGHT", "UPARROW", "UP", "BREAK", "PAUSE", "CAPSLOCK", "DELETE", "END",
|
||||||
@@ -63,22 +65,34 @@ layout = KeyboardLayoutUS(kbd)
|
|||||||
#sleep a the start to allow the device to be recognized by the host computer
|
#sleep a the start to allow the device to be recognized by the host computer
|
||||||
time.sleep(.5)
|
time.sleep(.5)
|
||||||
|
|
||||||
defaultDelay = 0
|
|
||||||
duckyScriptPath = "payload.dd"
|
|
||||||
f = open(duckyScriptPath,"r",encoding='utf-8')
|
|
||||||
print("Running payload.dd")
|
|
||||||
previousLine = ""
|
|
||||||
duckyScript = f.readlines()
|
|
||||||
for line in duckyScript:
|
|
||||||
line = line.rstrip()
|
|
||||||
if(line[0:6] == "REPEAT"):
|
|
||||||
for i in range(int(line[7:])):
|
|
||||||
#repeat the last command
|
|
||||||
parseLine(previousLine)
|
|
||||||
time.sleep(float(defaultDelay)/1000)
|
|
||||||
else:
|
|
||||||
parseLine(line)
|
|
||||||
previousLine = line
|
|
||||||
time.sleep(float(defaultDelay)/1000)
|
|
||||||
|
|
||||||
print("Done...")
|
# check GPIO0 for program switch
|
||||||
|
# easiest way to implement is to run a jumper from pin 0 (GPIO0) to pin3 (GND)
|
||||||
|
progStatus = False
|
||||||
|
progStatusPin = digitalio.DigitalInOut(GP0)
|
||||||
|
progStatusPin.switch_to_input(pull=digitalio.Pull.UP)
|
||||||
|
progStatus = progStatusPin.value
|
||||||
|
|
||||||
|
if(progStatus == True):
|
||||||
|
#not in programming state, run script file
|
||||||
|
defaultDelay = 0
|
||||||
|
duckyScriptPath = "payload.dd"
|
||||||
|
f = open(duckyScriptPath,"r",encoding='utf-8')
|
||||||
|
print("Running payload.dd")
|
||||||
|
previousLine = ""
|
||||||
|
duckyScript = f.readlines()
|
||||||
|
for line in duckyScript:
|
||||||
|
line = line.rstrip()
|
||||||
|
if(line[0:6] == "REPEAT"):
|
||||||
|
for i in range(int(line[7:])):
|
||||||
|
#repeat the last command
|
||||||
|
parseLine(previousLine)
|
||||||
|
time.sleep(float(defaultDelay)/1000)
|
||||||
|
else:
|
||||||
|
parseLine(line)
|
||||||
|
previousLine = line
|
||||||
|
time.sleep(float(defaultDelay)/1000)
|
||||||
|
|
||||||
|
print("Done...")
|
||||||
|
else:
|
||||||
|
print("Update new payload file")
|
||||||
|
|||||||
BIN
pics/jumper.png
Normal file
BIN
pics/jumper.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 864 KiB |
Reference in New Issue
Block a user