flipperzero-firmware icon indicating copy to clipboard operation
flipperzero-firmware copied to clipboard

Dummy decoy/bad usb keyboard layout

Open dummy-decoy opened this issue 2 years ago • 9 comments

What's new

  • added a config menu to the badusb application which allows to select the keyboard layout used when emulating a hid and running a badusb script. the selected layout is persisted and reused on subsequent script execution until another layout is selected. some keyboard layouts are provided, layout files can be generated using the tool (here)[https://github.com/dummy-decoy/flipperzero_badusb_kl]
  • reworked directory structure on the sd card to avoid mixing scripts and keyboard layout files. new structure and additional sd card files are in "assets/resources/badusb".

Verification

  • copy the content of the "assets/resources/badusb/" folder into the "badusb/" folder of the sd card. if the sd card does not have the new directory hierarchy, the display may be confusing because the file selector will go straight to the root of the sd-card (but still everything will work)
  • on your computer, select a keyboard input language other than english-us.
  • plug the flipperzero to a computer with an usb cable
  • launch the badusb application, select a simple script
  • press run. the script executes, if your computer keyboard is not set to "en-US", you may see some strange character replacement ('q' instead of 'a', 'z' instead of 'y'...)
  • on the flipper, still on the script execution page, press the left button to enter the "config" menu. select a keyboard layout matching the one on your computer. after selecting a layout, you are back to the config menu, you should press back once again to see the script execution view again.
  • on the flipper, press "run". the script executes, you should see exactly what was intended, without character replacements.
  • when you exit the badusb application, you should see a ".badusb.settings" file appear next to the script and layouts folders. this file persists the last used keyboard layout. application should work even if this file does not exist.

(effect is stronger when the computer is running a dvorak keyboard layout... standard scripts, without specifying a keyboard layout, fail miserably with dvorak configured computers)

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

dummy-decoy avatar Aug 03 '22 12:08 dummy-decoy

Works great ❤️

v1nc avatar Aug 03 '22 15:08 v1nc

Hi. Amazing work. It will be merge after 0.64 release.

skotopes avatar Aug 03 '22 16:08 skotopes

Also tested working well. Kudos!

UberGuidoZ avatar Aug 03 '22 22:08 UberGuidoZ

Nicely done! While it would have been nice to store the keyboard layout files as Flipper Format (Human readable), I understand the complexity in mapping characters to key ID's. I guess the next big step would be support for UTF-16, should anyone have the (in)sanity to attempt that.

djsime1 avatar Aug 04 '22 06:08 djsime1

Works nicely. Would be cool to see the currently selected layout in the main screen too.

rcv4 avatar Aug 05 '22 21:08 rcv4

Will be merged this week and included in next release

skotopes avatar Aug 07 '22 16:08 skotopes

Would be cool to see the currently selected layout in the main screen too.

@rcv4 done.

dummy-decoy avatar Aug 08 '22 08:08 dummy-decoy

Do you have documentation for the users to generate their own keyboard files? @dummy-decoy

RogueMaster avatar Aug 15 '22 18:08 RogueMaster

Do you have documentation for the users to generate their own keyboard files?

@RogueMaster i added the documentation for .kl file format inside the documentation folder right now.

dummy-decoy avatar Aug 15 '22 19:08 dummy-decoy

Hi, is this PR still WIP ? under another PR ?

shelld0n avatar Sep 17 '22 08:09 shelld0n

sorry folks, after resting here for a month without getting attention, i made a mistake 3 days ago and wiped all development for this pull request (thanks GitHub and your confusing web interface), just in time for this PR to be merged and closed...

dummy-decoy avatar Sep 17 '22 09:09 dummy-decoy

Here's the commit from before you wiped it out: https://github.com/flipperdevices/flipperzero-firmware/archive/254484f1234719b36b85f522daa0937a1cb78faa.zip

djsime1 avatar Sep 17 '22 12:09 djsime1

sorry folks, after resting here for a month without getting attention, i made a mistake 3 days ago and wiped all development for this pull request (thanks GitHub and your confusing web interface), just in time for this PR to be merged and closed...

it can be saved i guess, your PR was Amazing i sincerly hope it makes it to the dev branch 👍

shelld0n avatar Sep 17 '22 12:09 shelld0n

If you are still interested in contribution then we are freed enough space and ready for it.

skotopes avatar Oct 08 '22 18:10 skotopes

I've restored the files and updated them to the latest dev, so this should be a good starting point if anyone wants to resume development. https://github.com/djsime1/flipperzero-firmware/tree/badusb-layout Note: There have been numerous changes that broke the code since it was last updated, which I have NOT fixed (at the time of writing) in the branch above.

djsime1 avatar Oct 09 '22 15:10 djsime1

I found a local copy of this branch from where i tested it on Aug 5. I fixed the breaking changes but i somehow messed up ~the icons in the layout selector and~ the embedded layouts But i added a label that shows the keyboard layout again. https://github.com/rcv4/flipperzero-firmware/tree/badusb_keyboardlayout

EDIT: fixed the icons

rcv4 avatar Oct 11 '22 20:10 rcv4

@rcv4 added you on discord. I can't make appear the menu to select a keyboard layout. Could you please help me ? Thanks

OsIrIs29000 avatar Dec 20 '22 17:12 OsIrIs29000

Do you confirm these layouts only work on PC keyboards and not MAC keyboards ?

VxTedxV avatar Dec 20 '22 22:12 VxTedxV

Do you confirm these layouts only work on PC keyboards and not MAC keyboards ?

It should work but you have to modify the code of your badusb program, maybe take an example on the demo_macos, preinstalled on the flipper. Also I've found how to use different layouts like AZERTY but it is with unleashed fw of flipper not the original one as I cant make it works.

OsIrIs29000 avatar Dec 20 '22 23:12 OsIrIs29000

The language option is not shown in the bad usb application

mikeair8 avatar Feb 09 '23 16:02 mikeair8

@mikeair8 this feature will be released in 0.77 which is currently in RC state

skotopes avatar Feb 09 '23 16:02 skotopes