<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>Hacking on Admantium</title>
        <link>https://admantium.com/tags/hacking/</link>
        <description>Recent content in Hacking on Admantium</description>
        <generator>Hugo -- gohugo.io</generator>
        <language>en-us</language>
        <lastBuildDate>Thu, 07 May 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://admantium.com/tags/hacking/index.xml" rel="self" type="application/rss+xml" /><item>
            <title>Physical Hacking: An introduction to Ducky Script</title>
            <link>https://admantium.com/blog/micro25_raspberry_pico_ducky_script/</link>
            <pubDate>Thu, 07 May 2026 00:00:00 +0000</pubDate>
            <guid>https://admantium.com/blog/micro25_raspberry_pico_ducky_script/</guid>
            <description>&lt;!-- META&#xA;  STARTED 2024-10-03&#xA;  FINISHED 2024-10-19&#xA;--&gt;&#xA;&lt;p&gt;&lt;em&gt;Image source: &lt;a class=&#34;link&#34; href=&#34;https://shop.hak5.org/products/usb-rubber-ducky&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;hak5&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;Physical hacking of a computer encompasses injection of commands with the target to grab files, install programs, create custom users or gain control. With the programmable Ducky Script USB stick, these exploits can be crafted to target any host system. When inserted, a preprogramed script is executed, written in the Ducky Script language.&lt;/p&gt;&#xA;&lt;p&gt;This article is a concise introduction to the DuckyScript programming language. Based on the &lt;a class=&#34;link&#34; href=&#34;https://docs.hak5.org/hak5-usb-rubber-ducky/duckyscript-tm-quick-reference&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;official DuckyScript documentation&lt;/a&gt;, it covers the essential commands and overall syntax, from keystrokes to host state management and function definition.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;This article is for educational purposes only. Only use computers and devices that you own, and be mindful that they can be damaged.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;The technical context for this article is &lt;code&gt;CircuitPython v9.1.4&lt;/code&gt; and &lt;code&gt;Adafruit CircuitPython Bundle v9.x&lt;/code&gt;. The examples should work with newer releases too, but might require some code changes.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;h2 id=&#34;duckyscript-program&#34;&gt;DuckyScript Program&#xA;&lt;/h2&gt;&lt;p&gt;A DuckyScript program is a line terminated sequence of commands that executes keystrokes on a target computer. The goal of these keystrokes is typically to infiltrate or compromise a system, for example by running commands that start a reverse shell, creating user accounts with root privileges, or downloading and installing malware. Therefore, a DuckyScript program can be thought of the vehicle, and the actual, os-specific exploit, as the transport.&lt;/p&gt;&#xA;&lt;p&gt;The original DuckyScript programs are compiled into a binary using the &lt;a class=&#34;link&#34; href=&#34;https://payloadstudio.hak5.org/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;Hak5 Payload Studio&lt;/a&gt; program. This binary is then uploaded to an USB stick, and executed when the USB stick is connected to a host device&lt;/p&gt;&#xA;&lt;p&gt;The original hardware is not the only option to run DuckyScripts - several interpreters for different hardware are available in the open source community, including  these:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://github.com/dbisu/pico-ducky&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;pico ducky&lt;/a&gt;: A library for running DuckyScript on the Raspberry Pico microcontroller, using a CircuitPython interpreter.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://github.com/YariKartoshe4ka/PotatoParser&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;Potato Parser&lt;/a&gt;: A library for running DuckyScript on ESP32 Devices. This Arduino project creates a custom binary with all included libraries.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://github.com/flipperdevices/flipperzero-firmware/blob/dev/documentation/file_formats/BadUsbScriptFormat.md&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;Flipper BadUSB&lt;/a&gt;: A DuckyScript 2.x compatible language that runs on the flipper hacking device.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://github.com/PrettyBoyCosmo/DucKey-Logger&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;DucKey-Logger&lt;/a&gt;: A special PowerShell based exploit that completely logs all keystrokes and sends them to an online address.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;ducky-script-commands&#34;&gt;Ducky Script Commands&#xA;&lt;/h2&gt;&lt;p&gt;The DuckyScript commands can be separated into these categories:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Keystrokes: Most commands initiate a single or sequence of keystrokes, including control keys.&lt;/li&gt;&#xA;&lt;li&gt;Host State Management: Some commands read the systems keyboard state, and can be used as triggers to continue program flow, e.g. waiting for the user to start the screensaver, from which the exploit than resumes&lt;/li&gt;&#xA;&lt;li&gt;Device State Management: The original rubber duck USB stick features an LED and a button. Commands for these features can turn the LED on or await the press of a button as a trigger&lt;/li&gt;&#xA;&lt;li&gt;Program Structure &amp;amp; Control: DuckyScript allow the definition of variables and functions, lopping, branches and functions. For integer and boolean values, several operators exist. Finally, the global program state can be reflected and modified.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;keystrokes&#34;&gt;Keystrokes&#xA;&lt;/h2&gt;&lt;h3 id=&#34;character-keys&#34;&gt;Character Keys&#xA;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;STRING&lt;/code&gt;, &lt;code&gt;STRINGLN&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Execute character keypresses one after the other. The &lt;code&gt;STRINGLN&lt;/code&gt; command automatically adds a newline character. Both commands can also be used in a block notation, and indented form.&lt;/p&gt;&#xA;&lt;p&gt;To enter the string &amp;ldquo;hello&amp;rdquo; on a target system, both of the following commands can be used.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;STRING&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  h&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  e&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  l&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  l&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  o&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;STRING hello&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;cursor-keys&#34;&gt;cursor keys&#xA;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;UP&lt;/code&gt; &lt;code&gt;DOWN&lt;/code&gt; &lt;code&gt;LEFT&lt;/code&gt; &lt;code&gt;RIGHT&lt;/code&gt;&#xA;&lt;code&gt;UPARROW&lt;/code&gt; &lt;code&gt;DOWNARROW&lt;/code&gt; &lt;code&gt;LEFTARROW&lt;/code&gt; &lt;code&gt;RIGHTARROW&lt;/code&gt;&#xA;&lt;code&gt;PAGEUP&lt;/code&gt; &lt;code&gt;PAGEDOWN&lt;/code&gt; &lt;code&gt;HOME&lt;/code&gt; &lt;code&gt;END&lt;/code&gt;&#xA;&lt;code&gt;INSERT&lt;/code&gt; &lt;code&gt;DELETE&lt;/code&gt; &lt;code&gt;DEL&lt;/code&gt; &lt;code&gt;BACKSPACE&lt;/code&gt;&#xA;&lt;code&gt;TAB&lt;/code&gt; &lt;code&gt;SPACE&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;These commands execute a cursor key press. As such, they are helpful to navigate inside a specific program, such as a text editor.&lt;/p&gt;&#xA;&lt;h3 id=&#34;system-keys&#34;&gt;System Keys&#xA;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;ENTER&lt;/code&gt; &lt;code&gt;ESCAPE&lt;/code&gt; &lt;code&gt;PAUSE&lt;/code&gt; &lt;code&gt;BREAK&lt;/code&gt; &lt;code&gt;PRINTSCREEN&lt;/code&gt; &lt;code&gt;MENU&lt;/code&gt; &lt;code&gt;APP&lt;/code&gt; &lt;code&gt;F1&lt;/code&gt; &lt;code&gt;F2&lt;/code&gt; &lt;code&gt;F3&lt;/code&gt; &lt;code&gt;F4&lt;/code&gt; &lt;code&gt;F5&lt;/code&gt; &lt;code&gt;F6&lt;/code&gt; &lt;code&gt;F7&lt;/code&gt; &lt;code&gt;F8&lt;/code&gt; &lt;code&gt;F9&lt;/code&gt; &lt;code&gt;F0&lt;/code&gt; &lt;code&gt;F11&lt;/code&gt; &lt;code&gt;F12&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;SHIFT&lt;/code&gt; &lt;code&gt;ALT&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;CONTROL&lt;/code&gt; or &lt;code&gt;CTRL&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;COMMAND&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;WINDOWS&lt;/code&gt; or &lt;code&gt;GUI&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;CTRL SHIFT&lt;/code&gt;&#xA;&lt;code&gt;ALT SHIFT&lt;/code&gt;&#xA;&lt;code&gt;COMMAND CTRL&lt;/code&gt;&#xA;&lt;code&gt;COMMAND CTRL SHIFT&lt;/code&gt;&#xA;&lt;code&gt;COMMAND OPTION&lt;/code&gt;&#xA;&lt;code&gt;COMMAND OPTION SHIFT&lt;/code&gt;&#xA;&lt;code&gt;CONTROL ALT DELETE&lt;/code&gt;&#xA;&lt;code&gt;CAPSLOCK&lt;/code&gt;&#xA;&lt;code&gt;NUMLOCK&lt;/code&gt;&#xA;&lt;code&gt;SCROLLOCK&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;System keys and key combinations can be used to target OS-specific shortcuts, such as to quickly open a program.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;INJECT_MOD&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;This special command needs to be used when a single modifier key should be pressed. See the following example.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-py&#34; data-lang=&#34;py&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;INJECT_MOD GUI&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;control-keystroke-duration&#34;&gt;Control Keystroke Duration&#xA;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;HOLD&lt;/code&gt; &lt;code&gt;RELEASE&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;All keystroke commands are executed immediately, but with the help of these special commands, the duration can be controlled.&lt;/p&gt;&#xA;&lt;p&gt;The following example shows how to keep two keys pressed for 4 seconds.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-py&#34; data-lang=&#34;py&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;HOLD ALT F4&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;DELAY &lt;span style=&#34;color:#ae81ff&#34;&gt;4000&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;RELEASE ALT F4&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;host-state-management&#34;&gt;Host State Management&#xA;&lt;/h2&gt;&lt;p&gt;With these commands, the hosts currently pressed keys can be determined.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;WAIT_FOR_CAPS_ON&lt;/code&gt;&#xA;&lt;code&gt;WAIT_FOR_CAPS_OFF&lt;/code&gt;&#xA;&lt;code&gt;WAIT_FOR_CAPS_CHANGE&lt;/code&gt;&#xA;&lt;code&gt;WAIT_FOR_NUM_ON&lt;/code&gt;&#xA;&lt;code&gt;WAIT_FOR_NUM_OFF&lt;/code&gt;&#xA;&lt;code&gt;WAIT_FOR_NUM_CHANGE&lt;/code&gt;&#xA;&lt;code&gt;WAIT_FOR_SCROLL_ON&lt;/code&gt;&#xA;&lt;code&gt;WAIT_FOR_SCROLL_OFF&lt;/code&gt;&#xA;&lt;code&gt;WAIT_FOR_SCROLL_CHANGE&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;On a keyboard, the cap, num and scroll keys can be locked. Their absolute state is reflected by the &lt;code&gt;ON&lt;/code&gt; and &lt;code&gt;OFF&lt;/code&gt; variants, and any state change with the &lt;code&gt;CHANGE&lt;/code&gt; suffix. These commands act as triggers - the program execution stops until the desired state of a key is detected.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;$_CAPSLOCK_ON&lt;/code&gt;&#xA;&lt;code&gt;$_NUMLOCK_ON&lt;/code&gt;&#xA;&lt;code&gt;$_SCROLLLOCK_ON&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;These commands return boolean values depending on the current state of the lock keys.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;SAVE_HOST_KEYBOARD_LOCK_STATE&lt;/code&gt;&#xA;&lt;code&gt;RESTORE_HOST_KEYBOARD_LOCK_STATE&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;This command saves the current state of all lock keys and then restores this state. It could be used to detect a certain user behavior, then switching to a desired state to execute a program, and then to return to the previous state without alarming the user.&lt;/p&gt;&#xA;&lt;h2 id=&#34;device-state-management&#34;&gt;Device State Management&#xA;&lt;/h2&gt;&lt;h3 id=&#34;device-type&#34;&gt;Device Type&#xA;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;ATTACKMODE&lt;/code&gt; {&lt;code&gt;HID&lt;/code&gt; &lt;code&gt;STORAGE&lt;/code&gt; &lt;code&gt;HID STORAGE&lt;/code&gt; &lt;code&gt;OFF&lt;/code&gt;}&lt;/p&gt;&#xA;&lt;p&gt;A command that puts the USB stick into a different device type that the host system discovers, such as HID, storage, or HID and storage. When set to off, the device will disconnect.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;ATTACKMODE&lt;/code&gt; {&lt;code&gt;VID_&lt;/code&gt; &lt;code&gt;PID_&lt;/code&gt; &lt;code&gt;MAN_&lt;/code&gt; &lt;code&gt;PROD_&lt;/code&gt; &lt;code&gt;SERIAL_&lt;/code&gt;}&lt;/p&gt;&#xA;&lt;p&gt;Each USB device has several identifiers. These can be configured during setup.  Here is a concrete example how to combine these two commands into one.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-py&#34; data-lang=&#34;py&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;ATTACKMODE HID VID_033A PID_C3C4 MAN_DUCK PROD_DUCK SERIAL_42&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;code&gt;ATTACKMODE&lt;/code&gt; {&lt;code&gt;VID_RANDOM&lt;/code&gt; &lt;code&gt;PID_RANDOM&lt;/code&gt; &lt;code&gt;MAN_RANDOM&lt;/code&gt; &lt;code&gt;PROD_RANDOM&lt;/code&gt; &lt;code&gt;SERIAL_RANDOM&lt;/code&gt;}&lt;/p&gt;&#xA;&lt;p&gt;Randomize the vendor and product information.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;SAVE_ATTACKMODE&lt;/code&gt; &lt;code&gt;RESTORE_ATTACKMODE&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;For dynamically changing the programs behavior, its attack mode configuration can be saved as a state. The state also stores the current ID values - enabling the device to mimic itself as a keyboard now, an USB stick later, and so on.&lt;/p&gt;&#xA;&lt;h3 id=&#34;device-files&#34;&gt;Device Files&#xA;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;HIDE_PAYLOAD&lt;/code&gt;, &lt;code&gt;RESTORE_PAYLOAD&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;A DuckyScript program will be compiled to a binary file and placed on the device. This file is called &lt;code&gt;inject.bin&lt;/code&gt;, and an accompanying &lt;code&gt;seed.bin&lt;/code&gt; to generate random values. Both files are shown when the device is connected in HID mode to the host. Executing &lt;code&gt;HIDE_PAYLOAD&lt;/code&gt; hides both files, and &lt;code&gt;RESTORE_PAYLOAD&lt;/code&gt; shows them.&lt;/p&gt;&#xA;&lt;p&gt;A third file is called &lt;code&gt;loot.bin&lt;/code&gt;, which will be filled with content extracted from the host using the special command &lt;code&gt;EXFIL&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;h3 id=&#34;hardware-components&#34;&gt;Hardware Components&#xA;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;WAIT_FOR_BUTTON_PRESS&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;The Ducky Script USB device features a button which can be used for two purposes inside a program. With this command, program execution is blocked until the hardware button is pressed.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;BUTTON_DEF&lt;/code&gt; &amp;amp; &lt;code&gt;END_BUTTON&lt;/code&gt;, &lt;code&gt;ENABLE_BUTTON&lt;/code&gt;, &lt;code&gt;DISABLE_BUTTON&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;This command encapsulates a separate block of code that executes when the button is pressed. (a simple form of a function, but without parameter passing or other). The other two commands control whether such defined blocks will or will not be executed when a button is pressed.&lt;/p&gt;&#xA;&lt;p&gt;Here is an example to print a message when the button is pressed.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-py&#34; data-lang=&#34;py&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;BUTTON_DEF&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  STRING Magic button was pressed&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;END_BUTTON&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;ENABLE_BUTTON&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;code&gt;LED_OFF&lt;/code&gt;, &lt;code&gt;LED_R&lt;/code&gt; &lt;code&gt;LED_G&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;These commands control the onboard LED - it can be illuminated as red, green or turned off.&lt;/p&gt;&#xA;&lt;h2 id=&#34;program-structure--control&#34;&gt;Program Structure &amp;amp; Control&#xA;&lt;/h2&gt;&lt;p&gt;Ducky Script programs are executed top-down. Some commands alter this control flow, including function definition, loops, and several commands delaying the execution until a trigger occurs.&lt;/p&gt;&#xA;&lt;h3 id=&#34;variables&#34;&gt;Variables&#xA;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;DEFINE&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Constants declared with &lt;code&gt;#&lt;/code&gt;, they can contain any string. When called, their value will be inserted. The documentation is not clear about if you can also nest Ducky script commands inside a constant.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;VAR&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Variables are declared with a &lt;code&gt;$&lt;/code&gt;, they can hold unsigned 8bit integer values in decimal and hex notation, as well as the boolean values (represented as strings) of &lt;code&gt;TRUE&lt;/code&gt; and &lt;code&gt;FALSE&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Assignments can be augmented, e.g. increasing numerical values as shown in the following example.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-py&#34; data-lang=&#34;py&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;VAR &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;COUNTER &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; ( &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;COUNTER &lt;span style=&#34;color:#f92672&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt; )&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;code&gt;RANDOM_LOWERCASE_LETTER&lt;/code&gt; &lt;code&gt;RANDOM_UPPERCASE_LETTER&lt;/code&gt; &lt;code&gt;RANDOM_LETTER&lt;/code&gt; &lt;code&gt;RANDOM_NUMBER&lt;/code&gt; &lt;code&gt;RANDOM_SPECIAL&lt;/code&gt; &lt;code&gt;RANDOM_CHAR&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;With these commands, random strings can be created, including letters, numbers, and special characters. See the following code for the full rule set.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-py&#34; data-lang=&#34;py&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;RANDOM_LOWERCASE_LETTER &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;abcdefghijklmnopqrstuvwxyz&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;RANDOM_UPPERCASE_LETTER &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;ABCDEFGHIJKLMNOPQRSTUVWXYZ&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;RANDOM_LETTER &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&amp;#34;&amp;#34;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;  abcdefghijklmnopqrstuvwxyz&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;  ABCDEFGHIJKLMNOPQRSTUVWXYZ&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;  &amp;#34;&amp;#34;&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;RANDOM_NUMBER &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;0123456789&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;RANDOM_SPECIAL &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;!@#$%^&amp;amp;*()&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;RANDOM_CHAR &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&amp;#34;&amp;#34;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;  abcdefghijklmnopqrstuvwxyz&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;  ABCDEFGHIJKLMNOPQRSTUVWXYZ&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;  0123456789&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;  !@#$%^&amp;amp;*()&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;  &amp;#34;&amp;#34;&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;code&gt;$_RANDOM_INT&lt;/code&gt; &lt;code&gt;$_RANDOM_MIN&lt;/code&gt; &lt;code&gt;$_RANDOM_MAX&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;These commands can be used instead of concrete numerical values, resulting in a random integer with the default range of &lt;code&gt;0...65535&lt;/code&gt;, or within the defined min and max values.&lt;/p&gt;&#xA;&lt;h3 id=&#34;programming-operators&#34;&gt;Programming Operators&#xA;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;+&lt;/code&gt;, &lt;code&gt;-&lt;/code&gt;, &lt;code&gt;*&lt;/code&gt;, &lt;code&gt;/&lt;/code&gt;, &lt;code&gt;%&lt;/code&gt;, &lt;code&gt;^&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Perform mathematic operations on numbers. The documentation does not detail how overflows of the integer value range are handled.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;==&lt;/code&gt;, &lt;code&gt;!=&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;These comparison operator work on pairs of integers and boolean values, for example checking the state of a certain key press.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;&lt;/code&gt;, &lt;code&gt;&amp;gt;=&lt;/code&gt;, &lt;code&gt;&amp;lt;=&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;These comparison operators only work on integer values.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt;, &lt;code&gt;||&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;These commands enable chaining multiple boolean expressions together.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;&amp;amp;&lt;/code&gt;, &lt;code&gt;|&lt;/code&gt;, &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Bitwise operators that work on numerical values.&lt;/p&gt;&#xA;&lt;h3 id=&#34;loops-and-conditions&#34;&gt;Loops and Conditions&#xA;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;WHILE&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;The while statement continuously executes a code block until its termination definition evaluates to true. The following example prints and increases an integer value until it reaches the value of 10.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-py&#34; data-lang=&#34;py&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;VAR &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;NUM &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;WHILE (&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;NUM &lt;span style=&#34;color:#f92672&#34;&gt;&amp;lt;=&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;10&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    STRING &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;NUM&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;NUM &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; (&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;NUM &lt;span style=&#34;color:#f92672&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;END_WHILE&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;code&gt;IF&lt;/code&gt;, &lt;code&gt;ELSE&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;These commands enable branching of program logic. The given term is evaluated to a boolean value, and when evaluated to true, the given code is executed. From the documentation, it is unclear whether multiple &lt;code&gt;ELSE&lt;/code&gt; blocks can be used, and also if other program structure commands can be nested, such as function definitions.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-py&#34; data-lang=&#34;py&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;VAR &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;NUM &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;42&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;IF ( &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;NUM &lt;span style=&#34;color:#f92672&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;42&lt;/span&gt; ) THEN&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  STRING Magic number&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;ELSE IF ( &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;NUM &lt;span style=&#34;color:#f92672&#34;&gt;!=&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;42&lt;/span&gt; ) THEN&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  STRING Just an ordinary number&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;END_IF&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;function-definition&#34;&gt;Function Definition&#xA;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;FUNCTION&lt;/code&gt; &lt;code&gt;RETURN&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Functions define blocks of code that are executed when called. They cannot receive parameters, but any variable referenced from within a function will be searched in the global scope. Functions can return numerical and boolean values that can used in other expression (for example a comparison operator).&lt;/p&gt;&#xA;&lt;p&gt;Here is an example how to increment a numerical value by 10.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-py&#34; data-lang=&#34;py&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;FUNCTION INCR()&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  VAR &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;RES &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;NUM &lt;span style=&#34;color:#f92672&#34;&gt;+&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;10&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  RETURN &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;RES&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;END_FUNCTION&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;VAR &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;NUM &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;10&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;VAR &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;$&lt;/span&gt;NUM2 &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; INCR()&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;global-program-flow&#34;&gt;Global Program Flow&#xA;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;DELAY&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Fixed time in milliseconds that needs to pass before running the next step.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;RESTART_PAYLOAD&lt;/code&gt;, &lt;code&gt;STOP_PAYLOAD&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Stop and restart the programmed payload&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;RESET&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Completely clears the keystroke buffers, including all LED states.&lt;/p&gt;&#xA;&lt;h3 id=&#34;global-program-configuration&#34;&gt;Global Program Configuration&#xA;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;$_JITTER_ENABLED&lt;/code&gt;, &lt;code&gt;$_JITTER_MAX&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Define a maximum value of millisecond delay to keystrokes, where each value will be computed individually.&lt;/p&gt;&#xA;&lt;h3 id=&#34;internal-variables&#34;&gt;Internal Variables&#xA;&lt;/h3&gt;&lt;p&gt;Ducky Script programs define several internal variables - the &lt;a class=&#34;link&#34; href=&#34;https://docs.hak5.org/hak5-usb-rubber-ducky/duckyscript-tm-quick-reference#internal-variables&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;complete list&lt;/a&gt; encompassed around 40 entries. The variables provide access to the global device, program, and host state, including the hardware buttons and LED, the lock keys, and on the host, whether read/write activity to the USB device is detected or the OS type.&lt;/p&gt;&#xA;&lt;h2 id=&#34;conclusion&#34;&gt;Conclusion&#xA;&lt;/h2&gt;&lt;p&gt;DuckyScript is a programming language to initiate keystrokes on a target computer. Essentially, these commands serve as a vehicle to transport an exploit onto a target system. This article provided a compact introduction to the DuckyScript language. You learned about all commands structured into four categories: a) keystrokes, a single or sequence of keys that are executed, b) host state management, commands that check the state of control keys, c) device management, to control the rubber ducks USB stick button and LED , d) program structure &amp;amp; control, defining variables, functions, and using various expressions to compare and modify numbers, strings and boolean values. Reflecting the language design, a striking feature is that the linear, continuous execution can be controlled by waiting for a specific condition on the target system. And with this, an exploit can be applied at the best moment to fulfill its goal.&lt;/p&gt;&#xA;</description>
        </item><item>
            <title>Raspberry Pico: USB Hacking Device Programming</title>
            <link>https://admantium.com/blog/micro24_raspberry_pico_usb_hacking/</link>
            <pubDate>Sun, 26 Apr 2026 00:00:00 +0000</pubDate>
            <guid>https://admantium.com/blog/micro24_raspberry_pico_usb_hacking/</guid>
            <description>&lt;!-- META&#xA;  STARTED 2024-09-22&#xA;  FINISHED 2024-09-29&#xA;--&gt;&#xA;&lt;p&gt;Small form-factor single board computers and microcontroller are an ubiquitous stack in electronic projects. An interesting application area for these devices is physical hacking, e.g. using an USB connection to a host system to inject commands, gain system access, or steal files. To my surprise, an entry level microcontroller, the Raspberry Pico, can be used for these nefarious tasks.&lt;/p&gt;&#xA;&lt;p&gt;This article shows how to turn a Raspberry Pico into a USB hacking device, also called bad USB in hacker jargon. The Pico is programmed to execute a set of steps on the target computer once its USB connection is established. You will learn how to setup the Pico with the required Python version and libraries and see a simple example program that runs on a Linux host: Opening a text file, writing a text, and storing the file.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;This article is for educational purposes only. Only use computers and devices that you own, and be mindful that they can be damaged.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;The technical context for this article is &lt;code&gt;CircuitPython v9.1.4&lt;/code&gt; and &lt;code&gt;Adafruit CircuitPython Bundle v9.x&lt;/code&gt;. The examples should work with newer releases too, but might require some code changes.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;h2 id=&#34;required-hardware--software&#34;&gt;Required Hardware &amp;amp; Software&#xA;&lt;/h2&gt;&lt;p&gt;For this article, you need a delightfully simple bill-of-materials:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Raspberry Pico or Raspberry Pico W&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;And for the software:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://circuitpython.org/board/raspberry_pi_pico/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;CircuitPython Raspberry Pico&lt;/a&gt; or &lt;a class=&#34;link&#34; href=&#34;https://circuitpython.org/board/raspberry_pi_pico_w/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;CircuitPython Raspberry Pico W&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://circuitpython.org/libraries&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;Adafruit CircuitPython Bundle&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://github.com/dbisu/pico-ducky&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;Pico Ducky&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Connect the Pico to your computer and continue with the setup steps.&lt;/p&gt;&#xA;&lt;h2 id=&#34;installing-circuit-python-and-required-libraries&#34;&gt;Installing Circuit Python and Required Libraries&#xA;&lt;/h2&gt;&lt;p&gt;To turn the Pico into a USB hacking gadget, you first need to install the Circuit Python distribution.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Download the latest version of Circuit Python for the &lt;a class=&#34;link&#34; href=&#34;https://circuitpython.org/board/raspberry_pi_pico/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;Raspberry Pico&lt;/a&gt; or &lt;a class=&#34;link&#34; href=&#34;https://circuitpython.org/board/raspberry_pi_pico_w/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;Raspberry Pico W&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Hold down the Pico’s BOOTSEL button and connect the Pico to your computer&lt;/li&gt;&#xA;&lt;li&gt;Drag and drop the Circuit Python firmware to the Pico&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;With Circuit Python installed, open the Thonny IDE, configure the interpreter as &amp;ldquo;CircuitPython (generic)&amp;rdquo; and select the connected Raspberry Pico. This should look like this:&lt;/p&gt;&#xA;&lt;p&gt;&#xA;    &lt;img src=&#34;https://admantium.com/images/blog/micro24_circuit_python_setup.png&#34;&#xA;        loading=&#34;lazy&#34;&#xA;        &#xA;        &#xA;    &gt;&lt;/p&gt;&#xA;&lt;p&gt;Now you can access the Pico’s filesystem and add the required libraries:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Download the &lt;a class=&#34;link&#34; href=&#34;https://circuitpython.org/libraries&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;Adafruit Circuit Python bundle&lt;/a&gt; for the same major release of Circuit Python that you used before&lt;/li&gt;&#xA;&lt;li&gt;From the Zip file, copy the following files to the Raspberry Pico with the very same path:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-c&#34; data-lang=&#34;c&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;lib&lt;span style=&#34;color:#f92672&#34;&gt;/&lt;/span&gt;adafruit_hid&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;lib&lt;span style=&#34;color:#f92672&#34;&gt;/&lt;/span&gt;adafruit_wsgi&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;lib&lt;span style=&#34;color:#f92672&#34;&gt;/&lt;/span&gt;asyncio&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;adafruit_debouncer.mpy&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;adafruit_ticks.mpy&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The last part is to copy selected files from &lt;a class=&#34;link&#34; href=&#34;https://github.com/dbisu/pico-ducky&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;Pico Ducky&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Download a Zip file of the project, or use &lt;code&gt;git clone&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Copy the following files to the Pico’s root directory:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;boot.py&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;code.py&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;duckyinpython.py&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;&#xA;&lt;li&gt;And if you are using a Pico W, additionally copy these files:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;secrets.py&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;webapp.py&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;wsgiserver.py&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The final file layout should like this in the Thonny IDE:&lt;/p&gt;&#xA;&lt;p&gt;&#xA;    &lt;img src=&#34;https://admantium.com/images/blog/micro24_libraries_on_pico.png&#34;&#xA;        loading=&#34;lazy&#34;&#xA;        &#xA;        &#xA;    &gt;&lt;/p&gt;&#xA;&lt;p&gt;Now you are ready to write your first exploit.&lt;/p&gt;&#xA;&lt;h2 id=&#34;writing-an-exploit&#34;&gt;Writing an Exploit&#xA;&lt;/h2&gt;&lt;p&gt;In hacking jargon, an exploit is the execution of intended commands and functions on a computer for a specific goal. The spearhead of bad USB exploits is the scripting language &lt;a class=&#34;link&#34; href=&#34;https://docs.hak5.org/hak5-usb-rubber-ducky/duckyscript-tm-quick-reference&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;DuckyScript&lt;/a&gt;, which is used on special programmable USB sticks.&lt;/p&gt;&#xA;&lt;p&gt;But thanks to Pico Ducky, these scripts can be run on the Raspberry Pico instead. This libraries code contains an interpreter for DuckyScript, executing Python code instead. According to its develop, you should be able to run any Duck scripts, such as those from the official &lt;a class=&#34;link&#34; href=&#34;https://github.com/hak5/usbrubberducky-payloads/tree/master/payloads&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;DuckyScript Payloads GitHub repository&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;A coverage of the complete Ducky script language, its syntax and features, is not the scope of this article. But two points need to be mentioned. First, each exploit is specific to an operating system. Second, real world exploits target specific known vulnerabilities of the host for the purpose if infiltration, privilege escalation or malware installation (which is out of scope too). Third, only execute exploits on your own computers, and be aware that you can damage them in the process.&lt;/p&gt;&#xA;&lt;p&gt;With all this being said, lets stick to an entry level example. Targeting a Linux host system, the script opens the application shortcut menu, opens a text editor, and types a message. The script is as follows:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-shell&#34; data-lang=&#34;shell&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;REM Target: Linux Ubuntu&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;REM Exploit: open text editor and write a message&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;ALT F2&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;STRING gedit&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;DELAY &lt;span style=&#34;color:#ae81ff&#34;&gt;1500&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;ENTER&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;DELAY &lt;span style=&#34;color:#ae81ff&#34;&gt;1500&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;STRING Hello World!&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;DELAY &lt;span style=&#34;color:#ae81ff&#34;&gt;3000&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;As you can infer, these commands correspond to concrete keystrokes (&lt;code&gt;ALT&lt;/code&gt;, &lt;code&gt;F4&lt;/code&gt;, &lt;code&gt;ENTER&lt;/code&gt;), consecutive typing of arbitrary text (&lt;code&gt;STRING&lt;/code&gt;), waiting between commands with &lt;code&gt;DELAY&lt;/code&gt; and making commands with REM. This script does not have any triggers, so it will run continuously once started.&lt;/p&gt;&#xA;&lt;h2 id=&#34;running-an-exploit&#34;&gt;Running an Exploit&#xA;&lt;/h2&gt;&lt;p&gt;The copied file &lt;code&gt;code.py&lt;/code&gt; contains all instructions to run a Pico Duck exploit. It will search and load a file called &lt;code&gt;payload.dd&lt;/code&gt; and execute it. Therefore, to run the test exploit, you just need to upload it to the Pico. But be advised again: Only run exploits on your own computers, and be mindful that you can damage the computer in the process.&lt;/p&gt;&#xA;&lt;p&gt;For testing purposes, you can run the script from the Thonny IDE on your setup computer. To have an additional fallback: Connect the &lt;code&gt;GP0 0&lt;/code&gt; with any &lt;code&gt;GND&lt;/code&gt; pin on the Pico to put it into setup mode and disable automatic program execution. Then, selects the &lt;code&gt;code.py&lt;/code&gt; file, and click on the run button. The Thonny terminal shows the program execution like this:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;progStatus False&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Finding payload&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Running  payload.dd&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Done&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;For the concrete deployment of the exploit, simply unplug the Pico and connect it to its target system. Once the USB drive is mounted, the script will run automatically.&lt;/p&gt;&#xA;&lt;h2 id=&#34;pico-w-bonus-interactive-web-server&#34;&gt;Pico W Bonus: Interactive Web Server&#xA;&lt;/h2&gt;&lt;p&gt;When you use a Pico W Board, the Pico Duck library will create a local Wifi hotspot with SSID and PSK defined in the &lt;code&gt;secrets.py&lt;/code&gt; file. Starting the program via Thonny, you should see the following messages:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Starting Wifi&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Connect wifi&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;192.168.4.1 &lt;span style=&#34;color:#ae81ff&#34;&gt;80&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Starting Web Service&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;starting monitor_buttons&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;starting blink_pico_w_led&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;192.168.4.1 &lt;span style=&#34;color:#ae81ff&#34;&gt;80&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;open this IP in your browser: http://192.168.4.1:80/&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Connect to the WiFi hotspot, open the given URL, and you will see a simple web GUI that allows you to add, edit and run exploits.&lt;/p&gt;&#xA;&lt;p&gt;&#xA;    &lt;img src=&#34;https://admantium.com/images/blog/micro24_web_gui.png&#34;&#xA;        loading=&#34;lazy&#34;&#xA;        &#xA;        &#xA;    &gt;&lt;/p&gt;&#xA;&lt;h2 id=&#34;outlook&#34;&gt;Outlook&#xA;&lt;/h2&gt;&lt;p&gt;Using USB devices to automatically execute commands can compromise systems. This article only showed a very simple exploit, and it has clear limitations. First, it only works on the intended target system and relies on the specific graphical text editor program to be present. Second, the script will run continuously, without interpretation.&lt;/p&gt;&#xA;&lt;p&gt;Comparing the DuckyScript with HID script from my &lt;a class=&#34;link&#34; href=&#34;https://admantium.com/blog/micro23_rasperry_zero_hacking_device/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;earlier article&lt;/a&gt; leads me to several observations. HID is based on JavaScript, giving access to full programming language concepts with functions, loops and conditions. Also, HID scripts includes commands to randomize the typing speed of long texts to that of humans Another difference are triggers. HID scripts can be started when a specific event happens, for example when other keystrokes on the host system are detected or when no keystrokes are detected for an amount of time. This makes HID script more stealthy. But there is one big difference: For DuckyScript, a &lt;a class=&#34;link&#34; href=&#34;https://docs.hak5.org/hak5-usb-rubber-ducky/duckyscript-tm-quick-reference&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;complete language documentation&lt;/a&gt; is available. I&amp;rsquo;m sure that a better understanding of its features will change my viewpoints.&lt;/p&gt;&#xA;&lt;p&gt;Finally, the USB HID library provides many additional features that can be used. The &lt;a class=&#34;link&#34; href=&#34;https://docs.circuitpython.org/projects/hid/en/latest/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;official documentation&lt;/a&gt; lists examples how to control the mouse as well as other generic input like changing the sound volume of the targeted computer. It would be interesting to see how these commands could be incorporated or integrated with Pico Duck.&lt;/p&gt;&#xA;&lt;h2 id=&#34;conclusion&#34;&gt;Conclusion&#xA;&lt;/h2&gt;&lt;p&gt;In this article, you learned how to convert the Raspberry Pico microcontroller into a USB hacking device. Essentially you program the Pico with a custom scripting language, called DuckyScript, with which USB keyboard commands can be executed. Mounted to a target system, the script is executed on the host, and can be used to input complex command sequences. The article showed you how to get started. Besides the Pico itself, you just need a recent Circuit Python version, a USB HID library, and the Pico Duck library which interprets DuckyScript exploits to run with Micro Python. You also saw a very simple exploit for a Linux system: Opening the text editor and type an automated message. But be advised: Only run exploits on systems that you own, and mind that you can damage your computer too.&lt;/p&gt;&#xA;</description>
        </item><item>
            <title>Turning the Raspberry Pi Zero into a Hacking Gadget</title>
            <link>https://admantium.com/blog/micro23_rasperry_zero_hacking_device/</link>
            <pubDate>Thu, 16 Apr 2026 00:00:00 +0000</pubDate>
            <guid>https://admantium.com/blog/micro23_rasperry_zero_hacking_device/</guid>
            <description>&lt;!-- META&#xA;  STARTED 2024-09-19&#xA;  FINISHED 2024-09-28&#xA;--&gt;&#xA;&lt;p&gt;Single Board Computers with the ability to run a full-fledged Linux distribution can be used as portable devices for a wide variety of use cases. To my surprise, one of them is computer hacking. I was astonished about the creativity and ease-of-use how a Raspberry Pi, Raspberry Pi Zero or Pico can be used for potentially nefarious activities. And after a long deliberation, I decided to start writing blog posts about this subject.&lt;/p&gt;&#xA;&lt;p&gt;The article completely covers the installation, setup, and configuration to convert a Raspberry Pi Zero into a portable hacking device. Once powered, the device will start a custom WiFi endpoint and can be connected to via SSH or HTTP. It offers a CLI and a full-fledged GUI to configure the device behavior when connected to USB. And it can run shell or a custom JavaScript compatible language to initiate keyboard stokes, move the mouse, and access files of the device it is connected too. You will also learn how to combine triggers, startup templates, and HID script for an entry level exploit: When connected via USB to a host system, a text editor will be opened and a message written into it.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;This article is for educational purposes only. Only use computers and devices that you own, and be mindful that they can be damaged.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;The initial idea for this topic was sparked by an excellent article in the German computer magazine CT 2023/27 titled &amp;ldquo;Bad USB: Raspi Zero&amp;rdquo;. The articles itself cannot be accessed, but only its &lt;a class=&#34;link&#34; href=&#34;https://www.heise.de/select/ct/2023/27/softlinks/yhhf&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;link collection&lt;/a&gt; is available on the public internet.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;h2 id=&#34;writing-about-hacking&#34;&gt;Writing about Hacking?&#xA;&lt;/h2&gt;&lt;p&gt;For a long time, I have been thinking about the aspect of writing about hacking. My specific concern is about how knowledge in this area, the concrete concepts and processes, can be used for nefarious activities. On the other hand, knowledge gathered by first-hand experience, and transparent communication about it, can raise the awareness about essential dangers. Ultimately, this is tied to the question of knowledge itself: For which purpose do you use it?&lt;/p&gt;&#xA;&lt;p&gt;Physical hacking is the process of connecting an external device to a target computer and starting an exploit. The goals of hacking are manifold, starting from recording interactions that happen at the computer, reading and copying computer files or the computer memory, running user interactions like keystrokes or mouse movements, executing scripts to modify the system or install new applications. An exploit is the concrete process to achieve a goal, and it can be a combination of intended computer behavior (e.g. registering a USB device) with known or new vulnerabilities in a computer system.&lt;/p&gt;&#xA;&lt;p&gt;I&amp;rsquo;m no security consultant, but working in IT, I&amp;rsquo;m exposed to security topics on a daily basis. Bridging the gap from theoretical knowledge to hands-on experiences while further exploring the amazing Raspberry Pi use cases provided the final nudge to start this blog series. And with this realization, I also feel the need to formulate a disclaimer: This blog content is presented as-is for educational purposes. Only use them on computer systems that you own, and be aware that you can damage the systems.&lt;/p&gt;&#xA;&lt;p&gt;Finally, bear in mind that explored concepts in this article are written from a beginner’s mind.&lt;/p&gt;&#xA;&lt;h2 id=&#34;hardware-requirements-and-assembly&#34;&gt;Hardware Requirements and Assembly&#xA;&lt;/h2&gt;&lt;p&gt;The required hardware for this article is as follows:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Raspberry Pi Zero W (specifically not a Pi Zero W)&lt;/li&gt;&#xA;&lt;li&gt;USB Dongle (for example the &lt;a class=&#34;link&#34; href=&#34;https://wiki.52pi.com/index.php?title=EP-0097&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;EP-0097&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The USB dongle needs to be assembled to turn the Zero into a USB hacking device. The particular dongle that I acquired did not include a construction manual, but its components seemed manageable.&lt;/p&gt;&#xA;&lt;p&gt;&#xA;    &lt;img src=&#34;https://admantium.com/images/blog/micro23_usb_dongle_components.jpg&#34;&#xA;        loading=&#34;lazy&#34;&#xA;        &#xA;        &#xA;    &gt;&lt;/p&gt;&#xA;&lt;p&gt;However, trying to assemble it manually surfaced an embarrassing knowledge gap. Specifically, I thought that the connection pins of the USB dongle need to be connected to the Zeros GPI pins. But no, right next to the Zeros USB ports, external circuit &amp;ldquo;touchpoints&amp;rdquo; are exposed - the dongle pins merely need to touch them too.&lt;/p&gt;&#xA;&lt;p&gt;To assemble the USB dongle correctly, follow these steps:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Remove the protection layer from the acryl board&lt;/li&gt;&#xA;&lt;li&gt;Put the thinner acryl board to the bottom&lt;/li&gt;&#xA;&lt;li&gt;Put the dongle board on top so that the backside of the extruding pins aligns&lt;/li&gt;&#xA;&lt;li&gt;Put the thicker acryl board on top, aligning with the pins outward facing direction&lt;/li&gt;&#xA;&lt;li&gt;Put the RPI Zero with the bottom side down and align the connector pins with the touchpoints&lt;/li&gt;&#xA;&lt;li&gt;Carefully tighten the screws&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The resulting device should look like this:&lt;/p&gt;&#xA;&lt;p&gt;&#xA;    &lt;img src=&#34;https://admantium.com/images/blog/micro23_usb_dongle_assembled.jpg&#34;&#xA;        loading=&#34;lazy&#34;&#xA;        &#xA;        &#xA;    &gt;&lt;/p&gt;&#xA;&lt;h2 id=&#34;software-installation--first-boot&#34;&gt;Software Installation &amp;amp; First Boot&#xA;&lt;/h2&gt;&lt;p&gt;To turn the RPI Zero into a hacking device, the Linux Distribution &lt;a class=&#34;link&#34; href=&#34;https://github.com/RoganDawes/P4wnP1_aloa&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;P4wnP1 ALOA&lt;/a&gt; - called PPA from here -  will be used. This is a custom Linux distribution, build on top of Kali Linux and specifically modified to run on the RPI Zero. As any other OS, the installation encompasses downloading the image, flashing it onto a SD Card, and booting the device.&lt;/p&gt;&#xA;&lt;p&gt;The specific steps in detail:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Go to the &lt;a class=&#34;link&#34; href=&#34;https://github.com/RoganDawes/P4wnP1_aloa&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;P4wnP1 ALOA release page&lt;/a&gt; and download the latest version (Note: Don&amp;rsquo;t be discouraged by the release date of February 2020 - the project works very well!)&lt;/li&gt;&#xA;&lt;li&gt;Open an image software of your choice, then flash the image (my recommendation is &lt;a class=&#34;link&#34; href=&#34;https://www.balena.io/etcher/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;Balena Etcher&lt;/a&gt;)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;After this, put the SD Card into the device, and power it via the USB mini port.&lt;/p&gt;&#xA;&lt;p&gt;Shortly after booting, PPA creates a custom WiFi with an awkward, UTF8 icon encoded named: &amp;ldquo;💥 🖥️ 💥&amp;rdquo;. Connect to it with the password &lt;code&gt;MaMe82-P4wnP1&lt;/code&gt;, and once the connection is established, you start exploring the many configuration options.&lt;/p&gt;&#xA;&lt;h2 id=&#34;tool-overview&#34;&gt;Tool Overview&#xA;&lt;/h2&gt;&lt;p&gt;PPA is a special Linux distribution with flexible and run-time configurable hardware features of the Raspberry Pi Zero. It provides access to this configuration both via the Web GUI and a CLI. After reading the projects extensive documentation and using the tool for some time, the Web GUI provides more features and will be used exclusively in the remainder of this article.&lt;/p&gt;&#xA;&lt;p&gt;With an active connection to the hotspot, open &lt;code&gt;http://172.24.0.1:8000&lt;/code&gt; in a browser to access the configuration screen:&lt;/p&gt;&#xA;&lt;p&gt;&#xA;    &lt;img src=&#34;https://admantium.com/images/blog/micro23_ppa_web_gui.png&#34;&#xA;        loading=&#34;lazy&#34;&#xA;        &#xA;        &#xA;    &gt;&lt;/p&gt;&#xA;&lt;p&gt;Each section in this GUI is a configurable building block of the complete functionality. By learning one section at a time, the overall number of available features becomes clearer.&lt;/p&gt;&#xA;&lt;h3 id=&#34;hardware-settings&#34;&gt;Hardware Settings&#xA;&lt;/h3&gt;&lt;p&gt;Most sections in the tool menu directly modify the hardware features.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;USB: In this section, you define the USB properties when the Zero is connected to the targets. Available options start with the ID, serial number and vendor name, and continue with which USB functions the device offers. It can serve as an ethernet adapter, an HID device (keyboard, mouse, custom HID like pointer), as a serial interface, and as USB storage.&lt;/li&gt;&#xA;&lt;li&gt;WiFi: You can enable or disable the WiFi, change its SSID and PSK, and define its channel and visibility.&lt;/li&gt;&#xA;&lt;li&gt;Bluetooth: The Bluetooth stack provides several configuration options. The basic ones: availability, discoverability, and connectivity. Furthermore, you can configure if other devices are pairable with/without a key. BLE and Blue Toot High Speed are also supported. Lastly, different Bluetooth network encapsulation protocol services are provided: Network Access Point, Portable Area Network, and Group Ad-hoc network.&lt;/li&gt;&#xA;&lt;li&gt;Network: In this category, you can configure the concrete network interface settings for the &lt;code&gt;bteth&lt;/code&gt;, &lt;code&gt;usbeth&lt;/code&gt; and &lt;code&gt;wlan0&lt;/code&gt;. For an DHCP server, the IPv4 gateway address, client addresses and netmask, and static hosts. Alternatively, you can also configure interfaces with just static addresses or as clients.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3 id=&#34;behavior-programming&#34;&gt;Behavior Programming&#xA;&lt;/h3&gt;&lt;p&gt;To create and manage scripts that are executed when the USB stick is connected to a host, you can use the following:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Trigger Actions: A combination of an event and a concrete action. For an event, several options exist: system checkpoints during startup (Wifi AP, core services), when an USB gadget connects or disconnects, when an external WiFi AP is joined, values on group channel, and even when a GPIO input is detection. The actions can be to write a log entry, send a value to a group channel, set an output to a GPIO, as well as starting a HID script or bash script. Each trigger action can be set to run only and exactly once, or continuously every time it occurs.&lt;/li&gt;&#xA;&lt;li&gt;HID Script: The heart of exploitation scripting. PPA provides a JavaScript compatible language to program complex behavior that runs on the target machines. As provided in the documentation, special attention was given to robust and OS-agnostic keyboard interactions, including keyboard layout, timing of keystrokes, and waiting for keyboard input. Also, the mouse cursor can be controlled, and combining it with the concrete physical dimensions of the target screen, pixel perfect controls can be achieved. Finally, all JavaScript concepts can be used, giving access to functions, loops, complex conditions and much more.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3 id=&#34;log-and-settings&#34;&gt;Log and Settings&#xA;&lt;/h3&gt;&lt;p&gt;Two more sections complete the configurability of the PPA device.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Event Log: Shows all on-device stored log messages that PPA created during its usage. Messages are retained and persisted between boots, giving a complete picture how and when it was used.&lt;/li&gt;&#xA;&lt;li&gt;Generic Settings: The very last menu item appears a bit misleadingly named - it does not control the overall GUI, but the concrete run- and boot time behavior of PPA. Essentially, the Master Template Editor allows you to select and combine any defined USB, WiFi, Bluetooth, and Network setting, as well as the Trigger actions. With this, you specify the concrete behavior of the PPA, essentially arming the device for its intend purpose. The other options are to restart or shutdown the system, and to create or restore a backup of all user-define settings and modifications.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;writing-and-activating-an-hid-exploit&#34;&gt;Writing and activating an HID Exploit&#xA;&lt;/h2&gt;&lt;p&gt;The feature of PPA is extensive, and for a beginner exploring the device features, it might seem daunting to find a good start point. Following the project documentation closely, let’s start with a script that opens a text editor on the host and writes a message. The target OS is Linux Ubuntu.&lt;/p&gt;&#xA;&lt;p&gt;In the GUI, open the HID Script tab. The editor features syntax highlighting and remote execution for testing purposes. Paste the following code into the editor:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-js&#34; data-lang=&#34;js&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;layout&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;de&amp;#39;&lt;/span&gt;);   &lt;span style=&#34;color:#75715e&#34;&gt;// US keyboard layout&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;typingSpeed&lt;/span&gt;(&lt;span style=&#34;color:#ae81ff&#34;&gt;100&lt;/span&gt;,&lt;span style=&#34;color:#ae81ff&#34;&gt;150&lt;/span&gt;) &lt;span style=&#34;color:#75715e&#34;&gt;// Wait 100ms between key strokes + an additional random value between 0ms and 150ms (natural)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;//waitLED(ANY_OR_NONE);  // Wait till NUM LED of target changes frequently multiple times (doesn&amp;#39;t work on OSX)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;delay&lt;/span&gt;(&lt;span style=&#34;color:#ae81ff&#34;&gt;5000&lt;/span&gt;);&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;press&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;CTRL ALT t&amp;#34;&lt;/span&gt;);&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;delay&lt;/span&gt;(&lt;span style=&#34;color:#ae81ff&#34;&gt;1000&lt;/span&gt;);&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;type&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;gedit\n&amp;#34;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;delay&lt;/span&gt;(&lt;span style=&#34;color:#ae81ff&#34;&gt;1000&lt;/span&gt;);&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;type&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Hello from Raspberry Pi Zero&amp;#34;&lt;/span&gt;);&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;As you see, the commands relate directly to executing keystrokes on the target machines, enriched by meta-arguments to influence the typing process. The function &lt;code&gt;layout&lt;/code&gt; sets the target keyboard, and the &lt;code&gt;delay&lt;/code&gt; function defines a random time range for each keystroke, making interactions more natural. With &lt;code&gt;waitForLed&lt;/code&gt;, a specific trigger can be added, deferring the script execution until keyboard interaction is detected. This prevents executing the script when e.g. the screen is still locked by the user.&lt;/p&gt;&#xA;&lt;p&gt;Now, to run this script, two options exist. If you connected the Raspberry Zero directly to a host system, you could click on &amp;ldquo;Run&amp;rdquo;. The other option is to actually program this script to be executed when the Raspberry Zero is connected to a computer. For this:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Click on &amp;ldquo;Store&amp;rdquo; and define a suitable name for the script.&lt;/li&gt;&#xA;&lt;li&gt;Select the tab &amp;ldquo;Trigger Action&amp;rdquo; and click on &amp;ldquo;Add one&amp;rdquo;&lt;/li&gt;&#xA;&lt;li&gt;In the dialog, activate the &amp;ldquo;Enabled&amp;rdquo; slider, then fill out the trigger &amp;ldquo;USB gadget connected to host&amp;rdquo;, and in the action field the option &amp;ldquo;start a HID script&amp;rdquo; as well as the given script name file (also see the next picture)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&#xA;    &lt;img src=&#34;https://admantium.com/images/blog/micro23_trigger_programming.png&#34;&#xA;        loading=&#34;lazy&#34;&#xA;        &#xA;        &#xA;    &gt;&lt;/p&gt;&#xA;&lt;p&gt;The final step is to store and activate this trigger definition:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Still on the &amp;ldquo;Trigger Action&amp;rdquo; tab, click on &amp;ldquo;Store&amp;rdquo; to save all active triggers as a configuration&lt;/li&gt;&#xA;&lt;li&gt;Go to on &amp;ldquo;Generic Settings&amp;rdquo;, and in the &amp;ldquo;Master Template Editor&amp;rdquo;, select the Trigger Action template that you just stored&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;That’s it. Now you can connect the stick to a Linux host computer and see the script happening.&lt;/p&gt;&#xA;&lt;h2 id=&#34;where-to-continue&#34;&gt;Where to Continue&#xA;&lt;/h2&gt;&lt;p&gt;Exploring the depth of HID script to write advanced exploits is not the focus of this article. However, I explored some ideas and give my summary here:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://github.com/RoganDawes/P4wnP1&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;P4wnP1&lt;/a&gt;: The ancestor project. It includes links to videos and presentations showing particular exploits.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://github.com/whatotter/pwnhyve&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;pwnhyve&lt;/a&gt;: Naming itself as a sibling project, it focuses on bad USB capabilities and the injection of shellcode into target computers.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://github.com/lgeekjopt/P4wnP1_aloa/releases/tag/pi_zero2w&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;pi_zero2w&lt;/a&gt; Another developer forked the project and created a version that runs on a Raspberry Pi Zero 2 W, but it with fewer Kali Linux tools and no Bluetooth support&lt;/li&gt;&#xA;&lt;li&gt;Explore HID Script language: Unfortunately, there is no written document of the language, and digging into the project source code did not reveal an approachable form to me. Considering related rubber duck scripts, the general attack vector is to use HID commands to deploy a base64 decoded scripts for the shell language of the target system (PowerShell for Windows, Bash for Linux), which is then executed to install additional malware or a backdoor.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://github.com/V0lk3n/HIDScripts&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;HID Script collection&lt;/a&gt;: This repository is the only other source of examples. It contains script that target Windows Systems to steal credentials and password and provides examples both in HID and in Rubber Duck script.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;conclusion&#34;&gt;Conclusion&#xA;&lt;/h2&gt;&lt;p&gt;Small form-size single board computer can be used as hacking gadgets. This article showed how to turn a Raspberry Pi Zero into a bad USB device, a specific form of physical hacking in which an inserted USB stick executes command on the host. You only need a Raspberry Pi Zero, an USB dongle to expose the Zeros USB ports, and the PPA Linux Image. Once the initial setup is completed, the Zero turns into a WiFi and SSH accessible device with complex configuration options for all hardware features. To write a bad USB exploit, the HID language, based on JavaScript, can be used to instruct a sequence of keystrokes. This article showed only a simple exploit: Opening the systems text editor to write a message. Yet the potential for serious exploits becomes visible: By executing shell scripts on the targets, access to the system can be achieved, stealing credentials or installing malware and backdoors.&lt;/p&gt;&#xA;</description>
        </item></channel>
</rss>
