Skip to content

Commit

Permalink
feat: add function to run boot script
Browse files Browse the repository at this point in the history
  • Loading branch information
lavafroth committed Jun 12, 2023
1 parent a1f69f5 commit 8793455
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from adafruit_httpserver import POST, FileResponse, Request, Server

from api import handle
from ducky import run_boot_script


async def main():
Expand All @@ -25,6 +26,9 @@ async def main():
pool = socketpool.SocketPool(wifi.radio)
server = Server(pool)

# Run the boot script immediately after spawing the wifi network
asyncio.run(run_boot_script())

@server.route("/")
def base(request: Request):
return FileResponse(request, "index.html", root_path="/static")
Expand Down
13 changes: 12 additions & 1 deletion src/ducky.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Logic to interpret and execute user defined ducky script payloads.
"""
import os
import time

import usb_hid
Expand Down Expand Up @@ -117,4 +118,14 @@ def run_script_file(path: str):
with open(path, "r", encoding="utf-8") as handle:
run_script(handle.read())
except OSError as error:
warn(f"unable to open file {path}: {error}")
warn(f"unable to run script {path}: {error}")


async def run_boot_script():
"""
Try reading and running the boot.dd script if defined by the user
"""
path = "payloads/boot.dd"
if not os.path.exists(path):
return
run_script_file(path)

0 comments on commit 8793455

Please sign in to comment.