Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,14 @@ Install and have your USB Rubber Ducky working in less than 5 minutes.

11. Copy `duckyinpython.py`, `code.py`, `webapp.py`, `wsgiserver.py` to the root folder of the Pico.

12. 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 DuckScript 1.0, not 3.0.
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. 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.
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.

14. **Please note:** by default Pico W will not show as a USB drive
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.

15. **Please note:** by default Pico W will not show as a USB drive

### Pico W Web Service
The Pico W AP defaults to ip address `192.168.4.1`. You should be able to find the webservice at `http://192.168.4.1:80`
Expand Down
39 changes: 34 additions & 5 deletions webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,39 @@ def ducky_main(request):

return(response)

def cleanup_text(buffer):
return_buffer = buffer.replace('+', ' ').replace('%0D%0A', '\n') + '\n'
#print(return_buffer)
return(return_buffer)
_hexdig = '0123456789ABCDEFabcdef'
_hextobyte = None

def cleanup_text(string):
"""unquote('abc%20def') -> b'abc def'."""
global _hextobyte

if not string:
return b''

if isinstance(string, str):
string = string.encode('utf-8')

bits = string.split(b'%')
if len(bits) == 1:
return string

res = [bits[0]]
append = res.append

if _hextobyte is None:
_hextobyte = {(a + b).encode(): bytes([int(a + b, 16)])
for a in _hexdig for b in _hexdig}

for item in bits[1:]:
try:
append(_hextobyte[item[:2]])
append(item[2:])
except KeyError:
append(b'%')
append(item)

return b''.join(res).decode().replace('+',' ')

web_app = WSGIApp()

Expand Down Expand Up @@ -211,4 +240,4 @@ async def startWebService():
wsgiServer.start()
while True:
wsgiServer.update_poll()
await asyncio.sleep(0)
await asyncio.sleep(0)