aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaghuram Subramani <raghus2247@gmail.com>2022-06-25 21:19:30 +0530
committerRaghuram Subramani <raghus2247@gmail.com>2022-06-25 21:19:30 +0530
commit158df569bc1efa4fea1272e6c8f232efed194aa7 (patch)
tree3bddbffc549102ef3fabae8bdaf0e1e13360cf7e
parenta7c25f19d9700c008e6d6b5b4f95ea6103bda8ab (diff)
progress
-rw-r--r--.vscode/targets.log49
-rw-r--r--circuitpython/Dockerfile4
-rwxr-xr-xcircuitpython/build.sh10
-rwxr-xr-xcircuitpython/sleep.sh2
-rw-r--r--code.py20
-rw-r--r--raspiducky.py40
6 files changed, 65 insertions, 60 deletions
diff --git a/.vscode/targets.log b/.vscode/targets.log
index 0b43f62..db253cf 100644
--- a/.vscode/targets.log
+++ b/.vscode/targets.log
@@ -1,4 +1,6 @@
make all --print-data-base --no-builtin-variables --no-builtin-rules --question
+make: *** No rule to make target 'all'. Stop.
+
# GNU Make 4.3
# Built for x86_64-pc-linux-gnu
# Copyright (C) 1988-2020 Free Software Foundation, Inc.
@@ -6,7 +8,7 @@ make all --print-data-base --no-builtin-variables --no-builtin-rules --question
# This is free software: you are free to change and redistribute it.
# There is NO WARRANTY, to the extent permitted by law.
-# Make data base, printed on Sat Jun 25 07:41:44 2022
+# Make data base, printed on Sat Jun 25 13:32:08 2022
# Variables
@@ -15,11 +17,15 @@ GDK_BACKEND = x11
# environment
LC_ALL = C
# environment
-VSCODE_IPC_HOOK_EXTHOST = /run/user/1000/vscode-ipc-85ac5635-45b4-4f11-8956-d2618b54573b.sock
+TERMINATOR_DBUS_NAME = net.tenshu.Terminator21a9d5db22c73a993ff0b42f64b396873
+# environment
+VSCODE_IPC_HOOK_EXTHOST = /run/user/1000/vscode-ipc-dc3045c1-3c2b-4120-b1f8-3ab75d172daa.sock
# environment
MANDATORY_PATH = /usr/share/gconf/xubuntu.mandatory.path
# environment
-VSCODE_CWD = /home/raghu
+VSCODE_CWD = /home/raghu/data/laboratory/raspi-ducky
+# environment
+TERMINATOR_UUID = urn:uuid:b2386b56-c3e2-4d2f-b89c-0f4cd02ebbba
# environment
LIBVIRT_DEFAULT_URI = qemu:///system
# environment
@@ -35,11 +41,13 @@ VSCODE_HANDLES_UNCAUGHT_ERRORS = true
# default
.VARIABLES :=
# environment
-PWD = /home/raghu/data/laboratory/raspi-ducky
+PWD = /home/raghu/laboratory/raspi-ducky
# automatic
%D = $(patsubst %/,%,$(dir $%))
# environment
-XDG_DATA_DIRS = /home/raghu/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/share/xubuntu:/usr/share/xfce4:/usr/local/share:/usr/share:/var/lib/snapd/desktop:/usr/share
+XDG_DATA_DIRS = /usr/share/xubuntu:/usr/share/xfce4:/usr/local/share:/usr/share:/var/lib/snapd/desktop:/usr/share
+# environment
+OLDPWD = /home/raghu/laboratory
# automatic
^D = $(patsubst %/,%,$(dir $^))
# environment
@@ -60,6 +68,8 @@ XAUTHORITY = /home/raghu/.Xauthority
.INCLUDE_DIRS = /usr/local/include /usr/include /usr/include
# makefile
MAKEFLAGS = pqrR
+# environment
+TERMINATOR_DBUS_PATH = /net/tenshu/Terminator2
# makefile
CURDIR := /home/raghu/data/laboratory/raspi-ducky
# environment
@@ -89,7 +99,7 @@ MAKEFILE_LIST :=
# environment
VSCODE_VERBOSE_LOGGING = true
# environment
-VSCODE_PID = 716546
+VSCODE_PID = 748039
# environment
XDG_SESSION_TYPE = x11
# automatic
@@ -117,13 +127,13 @@ SHELL = /bin/sh
# default
MAKECMDGOALS := all
# environment
-SHLVL = 0
+SHLVL = 1
# environment
MAKELEVEL := 0
# default
MAKE = $(MAKE_COMMAND)
# environment
-PATH = /home/raghu/.local/bin:/home/raghu/gems/bin:/home/raghu/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
+PATH = /home/raghu/gems/bin:/home/raghu/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
# default
MAKEFILES :=
# environment
@@ -141,7 +151,7 @@ XDG_SEAT = seat0
# environment
XDG_CURRENT_DESKTOP = XFCE
# environment
-LS_COLORS =
+LS_COLORS = rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
# automatic
+F = $(notdir $+)
# environment
@@ -167,7 +177,7 @@ DEFAULTS_PATH = /usr/share/gconf/xubuntu.default.path
# default
MAKE_VERSION := 4.3
# environment
-_ = /usr/share/code/code
+_ = /usr/bin/code
# environment
XDG_RUNTIME_DIR = /run/user/1000
# environment
@@ -175,6 +185,8 @@ GEM_HOME = /home/raghu/gems
# environment
GPG_AGENT_INFO = /run/user/1000/gnupg/S.gpg-agent:0:1
# environment
+COLORTERM = truecolor
+# environment
GTK_OVERLAY_SCROLLING = 0
# environment
XDG_SESSION_CLASS = user
@@ -187,9 +199,9 @@ ELECTRON_RUN_AS_NODE = 1
# environment
VSCODE_IPC_HOOK = /run/user/1000/vscode-023e123c-1.68.1-main.sock
# environment
-XDG_SESSION_ID = c2
+TERM = xterm-256color
# environment
-PANEL_GDK_CORE_DEVICE_EVENTS = 0
+XDG_SESSION_ID = c2
# default
.RECIPEPREFIX :=
# automatic
@@ -197,6 +209,12 @@ PANEL_GDK_CORE_DEVICE_EVENTS = 0
# default
SUFFIXES :=
# environment
+VSCODE_CLI = 1
+# environment
+ELECTRON_NO_ATTACH_CONSOLE = 1
+# environment
+VTE_VERSION = 6800
+# environment
XDG_GREETER_DATA_DIR = /var/lib/lightdm-data/raghu
# default
.FEATURES := target-specific order-only second-expansion else-if shortest-stem undefine oneshell nocomment grouped-target extra-prereqs archives jobserver output-sync check-symlink load
@@ -205,7 +223,7 @@ XDG_MENU_PREFIX = xfce-
# environment
GDMSESSION = xubuntu
# variable set hash-table stats:
-# Load=97/1024=9%, Rehash=0, Collisions=5/124=4%
+# Load=105/1024=10%, Rehash=0, Collisions=6/132=5%
# Pattern-specific Variable Values
@@ -270,9 +288,8 @@ GNUmakefile:
# strcache performance: lookups = 24 / hit rate = 12%
# hash-table stats:
+
# Load=21/8192=0%, Rehash=0, Collisions=0/24=0%
-# Finished Make data base on Sat Jun 25 07:41:44 2022
+# Finished Make data base on Sat Jun 25 13:32:08 2022
-make: *** No rule to make target 'all'. Stop.
-
diff --git a/circuitpython/Dockerfile b/circuitpython/Dockerfile
index 8e115cc..5cbb6c6 100644
--- a/circuitpython/Dockerfile
+++ b/circuitpython/Dockerfile
@@ -6,4 +6,6 @@ WORKDIR /circuitpython
RUN apt-get update
RUN apt-get install python3 python3-pip git gettext build-essential mtools gcc-arm-none-eabi -y
RUN pip3 install --upgrade -r requirements-dev.txt
-RUN make -C mpy-cross \ No newline at end of file
+RUN make -C mpy-cross
+
+ENTRYPOINT [ "bash", "sleep.sh"] \ No newline at end of file
diff --git a/circuitpython/build.sh b/circuitpython/build.sh
index 710b06f..3c3df83 100755
--- a/circuitpython/build.sh
+++ b/circuitpython/build.sh
@@ -1,12 +1,10 @@
#!/bin/bash
-a=$PWD
-a=$PWD
-ls /mounted
+file=$b64file
-cp /mounted/code.py $a/frozen/compromyse/raspiducky.py
+echo $file | base64 -d > frozen/compromyse/raspiducky.py
-cd $a/ports/raspberrypi/
+cd /circuitpython/ports/raspberrypi/
make BOARD=raspberry_pi_pico -j4
-cp $a/ports/raspberrypi/build-raspberry_pi_pico/firmware.uf2 $a
+cp /circuitpython/ports/raspberrypi/build-raspberry_pi_pico/firmware.uf2 /circuitpython \ No newline at end of file
diff --git a/circuitpython/sleep.sh b/circuitpython/sleep.sh
new file mode 100755
index 0000000..52597c5
--- /dev/null
+++ b/circuitpython/sleep.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+while true; do sleep 1000; done \ No newline at end of file
diff --git a/code.py b/code.py
deleted file mode 100644
index 7847789..0000000
--- a/code.py
+++ /dev/null
@@ -1,20 +0,0 @@
-def main(): # Made by compromyse: https://compromyse.tk/
- import usb_hid
- from adafruit_hid.keyboard import Keyboard
- from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS as KeyboardLayout
- import time
- import board
- import digitalio
- led = digitalio.DigitalInOut(board.LED)
- led.direction = digitalio.Direction.OUTPUT
- kbd = Keyboard(usb_hid.devices)
- layout = KeyboardLayout(kbd)
- time.sleep(1)
- led.value = True
- kbd.press(227)
- kbd.release_all()
- time.sleep(1)
- layout.write('subl')
- kbd.press(40)
- kbd.release_all()
- led.value = False \ No newline at end of file
diff --git a/raspiducky.py b/raspiducky.py
index 4974748..c41ed59 100644
--- a/raspiducky.py
+++ b/raspiducky.py
@@ -5,6 +5,7 @@ from termcolor import colored
import sys
import urllib.request
import zipfile
+import base64
# Needed for parser
class Keycode:A=4;B=5;C=6;D=7;E=8;F=9;G=10;H=11;I=12;J=13;K=14;L=15;M=16;N=17;O=18;P=19;Q=20;R=21;S=22;T=23;U=24;V=25;W=26;X=27;Y=28;Z=29;ONE=30;TWO=31;THREE=32;FOUR=33;FIVE=34;SIX=35;SEVEN=36;EIGHT=37;NINE=38;ZERO=39;ENTER=40;RETURN=ENTER;ESCAPE=41;BACKSPACE=42;TAB=43;SPACEBAR=44;SPACE=SPACEBAR;MINUS=45;EQUALS=46;LEFT_BRACKET=47;RIGHT_BRACKET=48;BACKSLASH=49;POUND=50;SEMICOLON=51;QUOTE=52;GRAVE_ACCENT=53;COMMA=54;PERIOD=55;FORWARD_SLASH=56;CAPS_LOCK=57;F1=58;F2=59;F3=60;F4=61;F5=62;F6=63;F7=64;F8=65;F9=66;F10=67;F11=68;F12=69;PRINT_SCREEN=70;SCROLL_LOCK=71;PAUSE=72;INSERT=73;HOME=74;PAGE_UP=75;DELETE=76;END=77;PAGE_DOWN=78;RIGHT_ARROW=79;LEFT_ARROW=80;DOWN_ARROW=81;UP_ARROW=82;KEYPAD_NUMLOCK=83;KEYPAD_FORWARD_SLASH=84;KEYPAD_ASTERISK=85;KEYPAD_MINUS=86;KEYPAD_PLUS=87;KEYPAD_ENTER=88;KEYPAD_ONE=89;KEYPAD_TWO=90;KEYPAD_THREE=91;KEYPAD_FOUR=92;KEYPAD_FIVE=93;KEYPAD_SIX=94;KEYPAD_SEVEN=95;KEYPAD_EIGHT=96;KEYPAD_NINE=97;KEYPAD_ZERO=98;KEYPAD_PERIOD=99;KEYPAD_BACKSLASH=100;APPLICATION=101;POWER=102;KEYPAD_EQUALS=103;F13=104;F14=105;F15=106;F16=107;F17=108;F18=109;F19=110;F20=111;F21=112;F22=113;F23=114;F24=115;LEFT_CONTROL=224;CONTROL=LEFT_CONTROL;LEFT_SHIFT=225;SHIFT=LEFT_SHIFT;LEFT_ALT=226;ALT=LEFT_ALT;OPTION=ALT;LEFT_GUI=227;GUI=LEFT_GUI;WINDOWS=GUI;COMMAND=GUI;RIGHT_CONTROL=228;RIGHT_SHIFT=229;RIGHT_ALT=230;RIGHT_GUI=231
@@ -35,7 +36,8 @@ def buildimage():
# Build the image
print(colored('[+]> Building image, this may take a few minutes.. This will only happen on the first run.', 'green'))
subprocess.call('docker build -t raspiducky .', shell=True)
- print("Done!")
+ print('Done!')
+ os.chdir('../')
# Check if image already exists
def imagecheck():
@@ -54,33 +56,33 @@ def convertLine(line):
elif hasattr(Keycode, key):
newline.append(getattr(Keycode, key))
else:
- print(colored(f"Unknown key: \"{key}\"", 'red'))
+ print(colored(f'Unknown key: "{key}"', 'red'))
sys.exit(1)
return newline
def runScriptLine(line):
for k in line:
- final.append(f"kbd.press({k})")
- final.append("kbd.release_all()")
+ final.append(f'kbd.press({k})')
+ final.append('kbd.release_all()')
def parseLine(line):
global defaultDelay
- if(line[0:3] == "REM"):
+ if(line[0:3] == 'REM'):
# ignore ducky script comments
pass
- elif(line[0:5] == "DELAY"):
+ elif(line[0:5] == 'DELAY'):
final.append(f'time.sleep({int(line[6:])})')
- elif(line[0:6] == "STRING"):
+ elif(line[0:6] == 'STRING'):
final.append(f'layout.write(\'{line[7:]}\')')
else:
newScriptLine = convertLine(line)
runScriptLine(newScriptLine)
# Final docker section
-def dockersection():
+def dockersection(base64_file):
# Build image, skip build if image is already built
if imagecheck():
- print(colored("[+]> Looks like the Docker image is already built, I will skip that step.", 'green'))
+ print(colored('[+]> Looks like the Docker image is already built, I will skip that step.', 'green'))
else:
if os.path.isdir('circuitpython'):
print(colored('[+]> Circuitpython directory is present, build can continue.', 'green'))
@@ -90,18 +92,20 @@ def dockersection():
buildimage()
# Run container and start build
- subprocess.call("docker rm raspiduckyrun >/dev/null 2>/dev/null", shell=True)
+ subprocess.call('docker rm raspiduckyrun >/dev/null 2>/dev/null', shell=True)
print(colored('[+]> Everything went fine, starting firmware build..', 'green'))
# For some reason the firmware has to be built twice for cp to work
- subprocess.call(f'docker run --name raspiduckyrun raspiducky', shell=True)
+ id = subprocess.check_output(f'docker run --rm --detach -e b64file={base64_file} raspiducky', shell=True).decode('UTF-8').strip('\n')
+
+ subprocess.call(f'docker exec {id} bash build.sh', shell=True)
# Copy UF2 file
print(colored('[+]> Looks like the build succeeded, copying the file here...','green'))
- subprocess.call("docker cp raspiduckyrun:/circuitpython/firmware.uf2 firmware.uf2", shell=True)
+ subprocess.call(f'docker cp {id}:/circuitpython/firmware.uf2 firmware.uf2', shell=True)
- # Remove container before exitting
- subprocess.call("docker rm raspiduckyrun", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
+ print(colored('[+]> Stopping the container...','green'))
+ subprocess.call(f'docker stop {id}', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
def duckyscriptsection():
try:
@@ -134,6 +138,9 @@ def duckyscriptsection():
h.write(f'\t{line}\n')
h.write('\tled.value = False')
+ with open('code.py', 'rb') as h:
+ return base64.b64encode(h.read()).decode('UTF-8')
+
def cleanup():
try:
os.remove('code.py')
@@ -142,9 +149,8 @@ def cleanup():
def main():
init()
- duckyscriptsection()
- dockersection()
+ dockersection(duckyscriptsection())
cleanup()
-if __name__ == "__main__":
+if __name__ == '__main__':
main() \ No newline at end of file