Applications/Custom (UL, RM)/RogueMaster/Scripts/badusbdemo_jamisonderek.README.md
This script was created for the YouTube video to demonstrate various concepts in JavaScript running on the Flipper Zero, using a real world scenario.
This script uses features that were introduced in the dev branch of Momentum firmware on April 5, 2024. You need to be sure your firmware is updated or else you will get errors running the script.
This script will copy an MP3 file from the Flipper to the computer, play it on the computer, run commands to get information from the computer (like wifi credentials), copy the output back to the Flipper Zero, and display it and append it on a local file on the Flipper. It will also automate switching between keyboard, disk, ejecting devices.
Many of these ideas are from the Momentum Discord server's script-sharing channel. I encourage you to check out the various scripts being shared there.
This script will:
storage APIs to see if a virtual USB disk image exists. If it does, it will delete it. It then creates a new virtual USB disk image using the usbdisk APIs. It will then use storage APIs to mount the virtual USB disk image and then it will use the copy function to copy a file from the SD card onto the virtual USB disk. It will then unmount the virtual USB disk image.badusb APIs to emulate a keyboard with the specified language layout.Waiting for connection message on the screen to indicate that the Flipper Zero is ready to be connected to a computer. It uses badusb APIs to wait for a connection.Windows+x then i).localFileName.badusb APIs will disconnect the Flipper Zero from the computer.usbdisk APIs will then attach the virtual USB disk image.usbdisk APIs will detect the detach the virtual USB disk image.usbdisk APIs will then stop the virtual USB disk image.storage APIs to mount the virtual USB disk image. It will read the output file from the virtual USB disk image and display it on the screen using the textbox APIs. It will also append the output file to the loot.txt file on the SD card.Edit the badusbdemo.js file to customize the script. The following are the settings that should be changed:
layout is set to the correct keyboard layout for the computer (like en-US, en-UK, etc). See your /ext/badusb/assets/layouts for the list of supported latouts.localTempFolder is the temporary folder that will created on the computer. You do not need to change this.localFileName is the name of the output file that will be used by scripts. You do not need to change this.script array is the list of scripts to run.
localFileName.\").copyPayload is true to copy the payload file from the Flipper to the computer (otherwise false).playPayload is true to play the payload file on the computer (otherwise false).payloadName is the name of the payload file to copy and play.payloadSrcName is the path to the file. You do not need to change this. It it expected that the script will also contains a payloads folder with this file.payloadDstName is the name of the file on virtual USB disk. You do not need to change this.lootFile is the name of the file on the SD card to append the output file to. You do not need to change this. This will be saved in the same folder as the script.exfilCapacityMb is the size of the virtual USB disk image in MB. You do not need to change this unless your payload is >4MB.image is the name of the virtual USB disk image. You do not need to change this.flipperStorageName is the name of the virtual USB disk image when it is attached to the Flipper Zero. You should not change this (the driver currently hard-codes this name).resultFolder is the name of the folder on the virtual USB disk image where the output file will be saved. You do not need to change this.resultFileName is the name of the output file on the virtual USB disk image. You do not need to change this.SD Card/apps/Scripts/badusbdemo.js.payloads folder in the same folder as the script (SD Card/apps/Scripts/payload).demo.mp3 file in the payloads folder. This file will be copied to the computer and played. This file should be less than 4MB (your exfilCapacityMb).Apps, then choose Scripts, then choose badusbdemo.js.Waiting for connection.loot.txt file on the SD card in the (SD Card/apps/Scripts/loot.txt)."textbox" module load fail at :23 -- Your firmware is too old. You need to update to the latest dev branch of the firmware."file/dir not exist at :71" -- You need to put demo.mp3 (all lowercase) in SD Card/apps/Scripts/payloads/demo.mp3. The MP3 file I saved in payloads/demo.mp3 for the video was https://www.soundboard.com/track/download/156453"out of memory" -- Reboot the Flipper (BACK+LEFT buttons) before running the script to free up memory.If you have any questions, please ask in my Flipper Zero Discord server. There are also giveaways and other fun things happening there.
Support my work: