mirror of
https://github.com/dbisu/pico-ducky.git
synced 2025-12-06 02:41:45 +00:00
Add exception handling to file open
This commit is contained in:
@@ -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 (GND) and pin 20 (GPIO15).
|
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.
|
||||||
|
|||||||
@@ -127,19 +127,22 @@ 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')
|
||||||
for line in f:
|
previousLine = ""
|
||||||
line = line.rstrip()
|
for line in f:
|
||||||
if(line[0:6] == "REPEAT"):
|
line = line.rstrip()
|
||||||
for i in range(int(line[7:])):
|
if(line[0:6] == "REPEAT"):
|
||||||
#repeat the last command
|
for i in range(int(line[7:])):
|
||||||
parseLine(previousLine)
|
#repeat the last command
|
||||||
time.sleep(float(defaultDelay)/1000)
|
parseLine(previousLine)
|
||||||
else:
|
time.sleep(float(defaultDelay)/1000)
|
||||||
parseLine(line)
|
else:
|
||||||
previousLine = line
|
parseLine(line)
|
||||||
time.sleep(float(defaultDelay)/1000)
|
previousLine = line
|
||||||
|
time.sleep(float(defaultDelay)/1000)
|
||||||
|
except OSError as e:
|
||||||
|
print("Unable to open file ", file)
|
||||||
|
|
||||||
def selectPayload():
|
def selectPayload():
|
||||||
payload = "payload.dd"
|
payload = "payload.dd"
|
||||||
|
|||||||
Reference in New Issue
Block a user