diff --git a/README.md b/README.md index 63e2efc..7371cea 100644 --- a/README.md +++ b/README.md @@ -163,7 +163,7 @@ I grouped most of the variables you may want to modify in this section ([see Doc Obviously you can also build your own firmware. To build the *standard* one I used: - Arduino IDE `2.2.1` -- `Adafruit TinyUSB Library` version `2.2.3`, Board `Raspberry Pi RP2040 (3.6.0)` setting Tools=>CPU Speed at `120MHz` and Tools=>USB Stack to `Adafruit TinyUSB` +- `Adafruit TinyUSB Library` version `2.2.5`, Board `Raspberry Pi RP2040 (3.6.0)` setting Tools=>CPU Speed at `120MHz` and Tools=>USB Stack to `Adafruit TinyUSB` - `ssd1306` OLED library version `1.8.3` If you want to re-create a new fake filesystem, you may want to have a look to the `utils` folder, where I placed some utilities to build a new one. diff --git a/USBvalve/USBvalve.ino b/USBvalve/USBvalve.ino index 080f518..5f747e4 100644 --- a/USBvalve/USBvalve.ino +++ b/USBvalve/USBvalve.ino @@ -20,7 +20,7 @@ #include "Adafruit_TinyUSB.h" #include "SSD1306AsciiWire.h" #include -#include +#include // // BADUSB detector section @@ -75,11 +75,13 @@ bool activeState = false; // // USBvalve globals // -#define VERSION "USBvalve - 0.13.1" +#define VERSION "USBvalve - 0.14.0" boolean readme = false; boolean autorun = false; boolean written = false; +boolean deleted = false; boolean written_reported = false; +boolean deleted_reported = false; boolean hid_sent = false; boolean hid_reported = false; @@ -211,6 +213,12 @@ void loop() { autorun = false; } + if (deleted == true && deleted_reported == false) { + oled.print("\n[!] DELETING"); + deleted = false; + deleted_reported = true; + } + if (written == true && written_reported == false) { oled.print("\n[!] WRITING"); written = false; @@ -275,14 +283,25 @@ int32_t msc_read_callback(uint32_t lba, void* buffer, uint32_t bufsize) { // This happens only for the "real" size of disk int32_t msc_write_callback(uint32_t lba, uint8_t* buffer, uint32_t bufsize) { + // Check for file deletion at Block 7 + // The first char of filename is replaced with 0xE5, we are going + // to check for it + if (lba == 7) { + if (buffer[32] == 0xE5 || buffer[64] == 0xE5 || buffer[160] == 0xE5) { + deleted = true; + } + } + // This check for writing of space. The LBA > 10 is set to avoid some // false positives, in particular on Windows Systems if (lba > 10) { written = true; } + // We are declaring a bigger size than what is actually allocated, so // this is protecting our memory integrity if (lba < DISK_BLOCK_NUM - 1) { + // Writing buffer to "disk" uint8_t* addr = msc_disk[lba]; memcpy(addr, buffer, bufsize); } @@ -358,10 +377,10 @@ void hexDump(unsigned char* data, size_t size) { } // Reset the Pico -void swreset() -{ - watchdog_enable(1500, 1); - while(1); +void swreset() { + watchdog_enable(1500, 1); + while (1) + ; } // @@ -408,7 +427,7 @@ void tuh_hid_report_received_cb(uint8_t dev_addr, uint8_t instance, uint8_t cons // Used in main loop to write output to OLED hid_sent = true; - + // Read the HID protocol uint8_t const itf_protocol = tuh_hid_interface_protocol(dev_addr, instance); diff --git a/USBvalve/ramdisk.h b/USBvalve/ramdisk.h index 4415f15..85a93ee 100644 --- a/USBvalve/ramdisk.h +++ b/USBvalve/ramdisk.h @@ -37,6 +37,8 @@ // README.TXT // System Volume Information // +// Files information are saved at Block 7 +// // Keep 11 chars #define DISK_LABEL 'M', 'y', 'D', 'r', 'i', 'v', 'e', ' ', ' ', ' ', ' ' diff --git a/firmware/USBvalve-0.13.1-32.uf2 b/firmware/USBvalve-0.14.0-32.uf2 similarity index 81% rename from firmware/USBvalve-0.13.1-32.uf2 rename to firmware/USBvalve-0.14.0-32.uf2 index a391dff..eb05cc5 100644 Binary files a/firmware/USBvalve-0.13.1-32.uf2 and b/firmware/USBvalve-0.14.0-32.uf2 differ diff --git a/firmware/USBvalve-0.13.1-64.uf2 b/firmware/USBvalve-0.14.0-64.uf2 similarity index 81% rename from firmware/USBvalve-0.13.1-64.uf2 rename to firmware/USBvalve-0.14.0-64.uf2 index 222565f..d72ab24 100644 Binary files a/firmware/USBvalve-0.13.1-64.uf2 and b/firmware/USBvalve-0.14.0-64.uf2 differ