Skip to content

Conversation

p4p1
Copy link
Contributor

@p4p1 p4p1 commented May 14, 2025

What's new

A badusb function to take the content of a file and print it.

image

  1. notepad to test badusb script
  2. the badusb script
  3. content of /ext/abc.txt

Verification

Here is a sample script to test the function:

STRING_FROM_FILE /ext/abc.txt

make sure to place a file named abc.txt at the root of an sdcard with text inside of it.

Checklist (For Reviewer)

  • PR has description of feature/bug or link to Confluence/Jira task
  • Description contains actions to verify feature/bugfix
  • I've built this code, uploaded it to the device and verified feature/bugfix

UNUSED(param);
char buffer[254];
size_t read_bytes;
Storage* storage = furi_record_open("storage");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RECORD_STORAGE

Copy link
Member

@hedger hedger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address the comments

char buffer[254];
size_t read_bytes;
Storage* storage = furi_record_open("storage");
File* file = storage_file_alloc(storage);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

file is leaked - never freed


line = &line[ducky_get_command_len(line) + 1];
if (file) {
storage_file_open(file, line, FSAM_READ, FSOM_OPEN_EXISTING);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing check if open was successful


static int32_t ducky_fnc_string_from_file(BadUsbScript* bad_usb, const char* line, int32_t param) {
UNUSED(param);
char buffer[254];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works as a hard limit for file size - I think it should either be documented and checked or much higher

@hedger hedger added USB BadUSB + physical USB interface New Feature Contains an IMPLEMENTATION of a new feature labels Sep 23, 2025
@hedger hedger marked this pull request as draft September 24, 2025 14:53
@hedger
Copy link
Member

hedger commented Sep 24, 2025

Please un-draft when fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

New Feature Contains an IMPLEMENTATION of a new feature USB BadUSB + physical USB interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants