Created
September 14, 2024 21:47
-
-
Save hernandez87v/e801bb96ae2eae1a626e88ecc185ae10 to your computer and use it in GitHub Desktop.
Flipper Zero Bad USB Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Flipper Zero Bad USB Script | |
| let badusb = require('badusb'); | |
| let notify = require('notification'); | |
| let dialog = require('dialog'); | |
| // Setup BadUSB | |
| badusb.setup({ | |
| vid: 0xaaaa, | |
| pid: 0xbbbb, | |
| mfr_name: 'Flipper', | |
| prod_name: 'Zero', | |
| }); | |
| dialog.message('RAINCOUVER', 'Press OK to start'); | |
| if (badusb.isConnected()) { | |
| // Minimize all windows (Windows key + D) | |
| badusb.press('GUI', 'd'); | |
| // Wait for all windows to minimize | |
| delay(500); | |
| // Open Run dialog (Windows key + R) | |
| badusb.press('GUI', 'r'); | |
| // Wait for the Run dialog to open | |
| delay(500); | |
| // Type the command to open the default browser with Google search | |
| badusb.print('msedge https://www.google.com/search?q=weather+vancouver'); | |
| // Press Enter to execute the command | |
| badusb.press('ENTER'); | |
| // Wait for the page to load (adjust delay as needed) | |
| delay(5000); | |
| // Open browser's developer console (F12 key) | |
| badusb.press('F12'); | |
| // Wait for console to open | |
| delay(1000); | |
| // Type the JavaScript to replace text | |
| badusb.print( | |
| "(function(){function replaceText(node){if(node.nodeType===Node.TEXT_NODE){node.textContent=node.textContent.replace(/vancouver/gi,'RAINCOUVER');}else{for(let child of node.childNodes){replaceText(child);}}}replaceText(document.body);setInterval(function(){replaceText(document.body);},1000);})();" | |
| ); | |
| delay(500); | |
| // Execute the JavaScript | |
| badusb.press('ENTER'); | |
| delay(1000); | |
| // Close the console (F12 key again) | |
| badusb.press('F12'); | |
| } else { | |
| print('USB not connected'); | |
| notify.error(); | |
| } | |
| // Script execution is complete |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment