From 8b11882c5241038dedb2605dd9b5f82204846baf Mon Sep 17 00:00:00 2001 From: Dave Date: Sat, 21 Dec 2024 12:00:23 -0600 Subject: [PATCH] Pico2 support (#299) * Add support for Pico2/2W boards * Update documentation to include Pico2/2W * update language support --- README.md | 22 ++++++++++++++++------ boot.py | 4 ++-- build_scripts/create_release_bundle.py | 3 ++- code.py | 8 ++++---- duckyinpython.py | 8 ++++---- 5 files changed, 28 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index af3cf9e..89ac3d7 100644 --- a/README.md +++ b/README.md @@ -27,11 +27,19 @@ Install and have your USB Rubber Ducky working in less than 5 minutes. If using a Pico board: -Copy the adafruit-circuitpython-raspberry_pi_pico-en_US-8.0.0.uf2 file to the root of the Pico (RPI-RP2). The device will reboot and after a second or so, it will reconnect as CIRCUITPY. +Copy the adafruit-circuitpython-raspberry_pi_pico-en_US-9.2.1.uf2 file to the root of the Pico (RPI-RP2). The device will reboot and after a second or so, it will reconnect as CIRCUITPY. If using a Pico W board: -Copy the adafruit-circuitpython-raspberry_pi_pico_w-en_US-8.0.0.uf2 file to the root of the Pico (RPI-RP2). The device will reboot and after a second or so, it will reconnect as CIRCUITPY. +Copy the adafruit-circuitpython-raspberry_pi_pico_w-en_US-9.2.1.uf2 file to the root of the Pico (RPI-RP2). The device will reboot and after a second or so, it will reconnect as CIRCUITPY. + +If using a Pico 2 board: + +Copy the adafruit-circuitpython-raspberry_pi_pico2-en_US-9.2.1.uf2 file to the root of the Pico (RPI-RP2). The device will reboot and after a second or so, it will reconnect as CIRCUITPY. + +If using a Pico 2W board: + +Copy the adafruit-circuitpython-raspberry_pi_pico2_w-en_US-9.2.1.uf2 file to the root of the Pico (RPI-RP2). The device will reboot and after a second or so, it will reconnect as CIRCUITPY. 4. Copy the lib folder to the root of the CIRCUITPY @@ -76,14 +84,16 @@ Install and have your USB Rubber Ducky working in less than 5 minutes. 1. Clone the repo to get a local copy of the files. `git clone https://github.com/dbisu/pico-ducky.git` -2. Download [CircuitPython for the Raspberry Pi Pico](https://circuitpython.org/board/raspberry_pi_pico/). *Updated to 8.0.0 - Download [CircuitPython for the Raspberry Pi Pico W](https://circuitpython.org/board/raspberry_pi_pico_w/). *Updated to 8.0.0 +2. Download [CircuitPython for the Raspberry Pi Pico](https://circuitpython.org/board/raspberry_pi_pico/). *Updated to 9.2.1 + Download [CircuitPython for the Raspberry Pi Pico W](https://circuitpython.org/board/raspberry_pi_pico_w/). *Updated to 9.2.1 + Download [CircuitPython for the Raspberry Pi Pico 2](https://circuitpython.org/board/raspberry_pi_pico2/). *Updated to 9.2.1 + Download [CircuitPython for the Raspberry Pi Pico 2W](https://circuitpython.org/board/raspberry_pi_pico2_w/). *Updated to 9.2.1 3. Plug the device into a USB port while holding the boot button. It will show up as a removable media device named `RPI-RP2`. 4. Copy the downloaded `.uf2` file to the root of the Pico (`RPI-RP2`). The device will reboot and after a second or so, it will reconnect as `CIRCUITPY`. -5. Download `adafruit-circuitpython-bundle-8.x-mpy-YYYYMMDD.zip` [here](https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases/latest) and extract it outside the device. +5. Download `adafruit-circuitpython-bundle-9.x-mpy-YYYYMMDD.zip` [here](https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases/latest) and extract it outside the device. 6. Navigate to `lib` in the recently extracted folder and copy `adafruit_hid` to the `lib` folder on your Raspberry Pi Pico. @@ -100,7 +110,7 @@ Install and have your USB Rubber Ducky working in less than 5 minutes. 12. *For Pico W Only* Create the file `secrets.py` in the root of the Pico W. This contains the AP name and password to be created by the Pico W. `secrets = { 'ssid' : "BadAPName", 'password' : "badpassword" }` -13. Find a script [here](https://github.com/hak5/usbrubberducky-payloads) or [create your own one using Ducky Script](https://docs.hak5.org/hak5-usb-rubber-ducky/ducky-script-basics/hello-world) and save it as `payload.dd` in the Pico. Currently, pico-ducky only supports DuckyScript 1.0, not 3.0. +13. Find a script [here](https://github.com/hak5/usbrubberducky-payloads) or [create your own one using Ducky Script](https://docs.hak5.org/hak5-usb-rubber-ducky/ducky-script-basics/hello-world) and save it as `payload.dd` in the Pico. Currently, pico-ducky only supports DuckyScript 1.0, and some of 3.0. 14. Be careful, if your device isn't in [setup mode](#setup-mode), the device will reboot and after half a second, the script will run. diff --git a/boot.py b/boot.py index 7e7d434..96358a6 100644 --- a/boot.py +++ b/boot.py @@ -24,10 +24,10 @@ # GP15 not connected == USB NOT visible # GP15 connected to GND == USB visible -if(board.board_id == 'raspberry_pi_pico'): +if(board.board_id == 'raspberry_pi_pico' or board.board_id == 'raspberry_pi_pico2'): # On Pi Pico, default to USB visible noStorage = not noStorageStatus -elif(board.board_id == 'raspberry_pi_pico_w'): +elif(board.board_id == 'raspberry_pi_pico_w' or board.board_id == 'raspberry_pi_pico2_w'): # on Pi Pico W, default to USB hidden by default # so webapp can access storage noStorage = noStorageStatus diff --git a/build_scripts/create_release_bundle.py b/build_scripts/create_release_bundle.py index 2c16e19..b003bef 100644 --- a/build_scripts/create_release_bundle.py +++ b/build_scripts/create_release_bundle.py @@ -17,7 +17,8 @@ "WIN_IT", "WIN_PO", "WIN_SW", - "WIN_TR" ] + "WIN_TR", + "WIN_UK" ] supported_boards = ["raspberry_pi_pico", "raspberry_pi_pico_w", diff --git a/code.py b/code.py index 3d47f85..6091070 100644 --- a/code.py +++ b/code.py @@ -12,7 +12,7 @@ from board import * import board from duckyinpython import * -if(board.board_id == 'raspberry_pi_pico_w'): +if(board.board_id == 'raspberry_pi_pico_w' or board.board_id == 'raspberry_pi_pico2_w'): import wifi from webapp import * @@ -41,9 +41,9 @@ def startWiFi(): #supervisor.disable_autoreload() supervisor.runtime.autoreload = False -if(board.board_id == 'raspberry_pi_pico'): +if(board.board_id == 'raspberry_pi_pico' or board.board_id == 'raspberry_pi_pico2'): led = pwmio.PWMOut(board.LED, frequency=5000, duty_cycle=0) -elif(board.board_id == 'raspberry_pi_pico_w'): +elif(board.board_id == 'raspberry_pi_pico_w' or board.board_id == 'raspberry_pi_pico2_w'): led = digitalio.DigitalInOut(board.LED) led.switch_to_output() @@ -68,7 +68,7 @@ async def main_loop(): global led,button1 button_task = asyncio.create_task(monitor_buttons(button1)) - if(board.board_id == 'raspberry_pi_pico_w'): + if(board.board_id == 'raspberry_pi_pico_w' or board.board_id == 'raspberry_pi_pico2_w'): pico_led_task = asyncio.create_task(blink_pico_w_led(led)) print("Starting Wifi") startWiFi() diff --git a/duckyinpython.py b/duckyinpython.py index 4900266..11fb858 100644 --- a/duckyinpython.py +++ b/duckyinpython.py @@ -202,7 +202,7 @@ def runScript(file): previousLine = "" for line in script_lines: print(f"runScript: {line}") - + if(line[0:6] == "REPEAT"): for i in range(int(line[7:])): #repeat the last command @@ -214,7 +214,7 @@ def runScript(file): time.sleep(float(defaultDelay) / 1000) except OSError as e: print("Unable to open file", file) - + def selectPayload(): global payload1Pin, payload2Pin, payload3Pin, payload4Pin payload = "payload.dd" @@ -249,9 +249,9 @@ def selectPayload(): async def blink_led(led): print("Blink") - if(board.board_id == 'raspberry_pi_pico'): + if(board.board_id == 'raspberry_pi_pico' or board.board_id == 'raspberry_pi_pico2'): blink_pico_led(led) - elif(board.board_id == 'raspberry_pi_pico_w'): + elif(board.board_id == 'raspberry_pi_pico_w' or board.board_id == 'raspberry_pi_pico2_w'): blink_pico_w_led(led) async def blink_pico_led(led):