Skip to content

Fix BadUSB overflow, Karma OOB, channel compliance, and add Glass2 OLED support - #122

Open
Swissola wants to merge 5 commits into
7h30th3r0n3:mainfrom
Swissola:fix/badusb-overflow-karma-length
Open

Fix BadUSB overflow, Karma OOB, channel compliance, and add Glass2 OLED support#122
Swissola wants to merge 5 commits into
7h30th3r0n3:mainfrom
Swissola:fix/badusb-overflow-karma-length

Conversation

@Swissola

@Swissola Swissola commented May 24, 2026

Copy link
Copy Markdown

Summary

Three fixes and one feature addition for Cardputer ADV.

Fix: BadUSB strcpy overflow

Replace all strcpy() calls with strncpy() + explicit null-terminator for Cmd[15] and OldCmd[15] fixed-size buffers. strcpy() from user-controlled Ducky Script content had no length bound — any command token longer than 14 characters overwrites the stack.

Fix: Karma sniffer OOB frame access

Add sig_len < 27 guard before accessing frame[25] (SSID IE length byte) and frame[26..] (SSID data). Also extends the existing SSID length check to verify sig_len >= 26 + ssid_length_Karma before the memcpy. A malformed or truncated probe request frame previously caused an out-of-bounds read.

Fix: Wi-Fi channel compliance — extend to channels 12–13

Updates all five channel arrays to include channels 12 and 13. Channels 1–13 are legal across ETSI (EU/UK), TELEC (Japan), and most other regulatory domains. The previous 1–11 limit was unnecessarily restrictive outside North America.

Feature: Glass2 secondary OLED display (Cardputer ADV)

Adds support for the M5Stack Glass2 Unit (1.51" transparent OLED, SSD1309 driver, 128×64) as a secondary display on the Grove port.

  • Adds glass2.h using M5UnitGLASS2 from M5GFX — the official M5Stack driver, already a transitive dependency via M5Unified. No additional library required.
  • All calls guarded inside the board_M5CardputerADV detection block — no effect on standard Cardputer or any other board
  • _g2_ready flag means calls are safe no-ops if no Glass2 is physically connected
  • Grove GPIO1/2 are free on ADV: the LoRa/GPS cap uses EXT header (GPIO13/15)
Mode Glass2 display
Startup Evil-M5Project / Cardputer ADV / Glass2 ready
Karma MODE: KARMA / SSID: -- / CLTS: 0 / CRED: 0
Portal (live) MODE: PORTAL / SSID: <name> / CLTS: n / CRED: n
Probe sniff MODE: PROBE / Sniffing...
Spam MODE: SPAM / Beaconing...

Test plan

  • BadUSB: run a Ducky Script with modifier keys to confirm bounded copy path works
  • Karma: capture probe requests, confirm normal SSID capture and no crash on malformed frames
  • Channel scan: confirm channels 12–13 appear in results
  • Glass2 (ADV with unit): splash on boot, mode labels update correctly
  • Standard Cardputer: no behaviour change (ADV detection skips all Glass2 code)

🤖 Generated with Claude Code

Swissola and others added 3 commits May 24, 2026 07:51
Two safety fixes in Evil-Cardputer-v1-5-2.ino:

1. BadUSB parser: replace strcpy() with strncpy() + explicit null-terminator
   for Cmd[15] and OldCmd[15] buffers. strcpy() from user-controlled script
   content had no length bound, allowing stack corruption on commands longer
   than 14 characters.

2. packetSnifferKarma(): add sig_len bounds check before accessing frame[25]
   (SSID IE length byte) and frame[26..] (SSID data). Without this check, a
   malformed or truncated probe request frame caused an out-of-bounds read.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
UK law (Wireless Telegraphy Act 2006 / Ofcom) permits Wi-Fi channels 1-13.
Updated five hardcoded channel arrays across probe sniffing, channel hopper,
beacon spam, beacon_task, and PwnGrid spam to include channels 12 and 13.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds glass2.h helper (SSD1309/Adafruit_SSD1306, I2C on Grove GPIO1/2)
and wires it into the Cardputer ADV detection block. Glass2 shows
active mode on the transparent OLED: KARMA, PORTAL, PROBE, SPAM.

Grove port (GPIO1/2) is free on ADV — GPS cap uses EXT header GPIO13/15.
No-op if Glass2 not connected (_g2_ready guard).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Swissola Swissola changed the title Fix BadUSB strcpy overflow and Karma sniffer OOB frame access Fix BadUSB overflow, Karma OOB, channel compliance, and add Glass2 OLED support May 24, 2026
Swissola and others added 2 commits May 24, 2026 10:22
M5UnitGLASS2.h ships with M5GFX, which is already a transitive
dependency via M5Unified — no extra library required. Gives access
to the full M5GFX drawing API vs the basic Adafruit bitmap renderer.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Update Glass2 on every new probe-request SSID captured: shows the
latest SSID on line 2 and running count on line 3, giving a glanceable
view without looking at the main display.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant