Skip to content

Instantly share code, notes, and snippets.

@hernandez87v
Created September 14, 2024 21:47
Show Gist options
  • Select an option

  • Save hernandez87v/e801bb96ae2eae1a626e88ecc185ae10 to your computer and use it in GitHub Desktop.

Select an option

Save hernandez87v/e801bb96ae2eae1a626e88ecc185ae10 to your computer and use it in GitHub Desktop.
Flipper Zero Bad USB Script
// 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