So far, we've focused on "Black Hat" techniques (stealing passwords, destroying hardware). But BadUSB is essentially a keyboard automation tool. This means we can use it for good (Automation) or for fun (Pranks).
In this section, we will write scripts that are harmless but incredibly annoying or useful. These are great for demonstrating the danger of USB drives to your friends without actually hurting them.
29. දුෂ්ට වැඩ විතරක් නෙවෙයි!
අපි මෙච්චර කල් කතා කළේ දත්ත හොරකම් කරන හැටි සහ හාඩ්වෙයාර් පුච්චන හැටි (Black Hat) ගැනනේ. ඒත් මතක තියාගන්න, BadUSB කියන්නේ නිකන්ම "කීබෝඩ් ඔටෝමැේෂන්" ටූල් එකක්. ඒ කියන්නේ අපිට පුළුවන් මේක පාවිච්චි කරලා අපේ වැඩ ලේසි කරගන්න (Automation) හෝ යාළුවෙක්ව බය කරලා ආතල් එකක් ගන්න (Pranks).
මේ කොටසේදී අපි ලියන්නේ හානිකර නැති, හැබැයි පිස්සු හැදෙන ස්ක්රිප්ට්ස් ටිකක්. කාටවත් හානියක් නොවී USB ආරක්ෂාව ගැන කියලා දෙන්න මේවා මරු.
30. වින්ඩෝස් අප්ඩේට් ප්රෑන්ක් එක
මේක තමයි ලෝකේ ප්රසිද්ධම IT Prank එක. අපි කරන්නේ `fakeupdate.net` වගේ සයිට් එකක් ඕපන් කරලා, ඒක `F11` ගහලා Full Screen දාන එක. එතකොට යාළුවා හිතන්නේ එයාගේ මැෂින් එක ඇත්තටම අප්ඩේට් වෙනවා කියලා. එයා පැය ගාණක් බලන් ඉඳියි!
// DIGISPARK PAYLOAD: FAKE UPDATE #include "DigiKeyboard.h" void setup() { DigiKeyboard.delay(2000); DigiKeyboard.sendKeyStroke(0); // 1. Open Run Dialog DigiKeyboard.sendKeyStroke(KEY_R, MOD_GUI_LEFT); DigiKeyboard.delay(500); // 2. Open FakeUpdate.net in Chrome // 'kiosk' mode opens it in full screen immediately DigiKeyboard.print("chrome --kiosk http://fakeupdate.net/win10u"); DigiKeyboard.sendKeyStroke(KEY_ENTER); // If user doesn't have chrome, use 'start msedge' }
Note: The `--kiosk` flag in Chrome forces the browser into Full Screen mode instantly, and disables the "Press F11 to exit" message. The victim won't know how to close it easily (Alt+F4 still works, but they panic first).
31. හොල්මන් මවුස් එක (Mouse Jiggler)
මේ ස්ක්රිප්ට් එකෙන් වෙන්නේ මවුස් කර්සර් (Cursor) එක තත්පර කීපයකට සැරයක් ඉබේම හෙලවෙන එක. මේකේ ප්රයෝජන දෙකක් තියෙනවා:
1. Prank: යාළුවෙක් මොකක් හරි Click කරන්න යද්දිම මවුස් එක පනිනවා. එයාට හිතෙන්නේ මවුස් එක කැඩිලා කියලා.
2. Work from Home: ඔයා ඔන්ලයින් (Teams/Zoom) ඉන්නවා කියලා පෙන්නන්න මේක පාවිච්චි කරන්න පුළුවන්. මැෂින් එක Sleep වෙන්නේ නෑ.
// DIGISPARK PAYLOAD: MOUSE JIGGLER #include "DigiMouse.h" // Note: We use DigiMouse library here void setup() { DigiMouse.begin(); } void loop() { // Move mouse 5 pixels right, 5 pixels down DigiMouse.moveX(5); DigiMouse.moveY(5); DigiMouse.delay(100); // Move it back DigiMouse.moveX(-5); DigiMouse.moveY(-5); // Wait for a random time (5 to 10 seconds) // This makes it look like a "Ghost" touch DigiMouse.delay(random(5000, 10000)); }
Let's do something actually useful. Imagine you formatted a PC and need to install Chrome, VLC, Zoom, and 7-Zip. Instead of downloading them one by one, we can use a service called Ninite and automate it with BadUSB.
32. IT Admin උදව්කරු (Automation)
අපි හිතමු ඔයා අලුතින් මැෂින් එකක් ෆෝමැට් කළා කියලා. දැන් ඉතින් Chrome, VLC, Zoom දාන්න පැය ගාණක් යයි. ඒ වෙනුවට අපිට පුළුවන් BadUSB එක ගැහුව ගමන් මේ ඔක්කොම එකපාර ඉන්ස්ටෝල් වෙන ස්ක්රිප්ට් එකක් හදන්න.
අපි මේකට **Ninite** කියන වෙබ්සයිට් එකේ කමාන්ඩ්ස් පාවිච්චි කරනවා.
// DIGISPARK PAYLOAD: INSTANT INSTALLER #include "DigiKeyboard.h" void setup() { DigiKeyboard.delay(2000); DigiKeyboard.sendKeyStroke(0); DigiKeyboard.sendKeyStroke(KEY_R, MOD_GUI_LEFT); DigiKeyboard.delay(500); // Downloads and installs Chrome & VLC silently DigiKeyboard.print("powershell -c \"Start-Process -FilePath 'https://ninite.com/chrome-vlc/ninite.exe' -ArgumentList '/silent' -Wait\""); DigiKeyboard.sendKeyStroke(KEY_ENTER); // PC is ready in 5 minutes without you touching it! }
33. Rickroll (සම්භාව්ය විහිළුව)
BadUSB එකක් හදලා Rickroll එකක් නොකළොත් වැඩක් නෑනේ. මේකෙන් වෙන්නේ පෙන් එක ගැහුව ගමන් යූටියුබ් ඕපන් වෙලා සින්දුව ප්ලේ වෙන එක. ඒ වගේම අපි වොලියුම් (Volume) එක 100% කරලා දානවා.
// DIGISPARK PAYLOAD: RICKROLL #include "DigiKeyboard.h" void setup() { DigiKeyboard.delay(2000); DigiKeyboard.sendKeyStroke(0); // 1. Max Volume (Press Vol Up 50 times) for(int i=0; i<50; i++){ DigiKeyboard.sendKeyStroke(0, 128); // Media Vol Up Key } // 2. Open YouTube DigiKeyboard.sendKeyStroke(KEY_R, MOD_GUI_LEFT); DigiKeyboard.delay(500); DigiKeyboard.print("cmd /c start https://youtu.be/dQw4w9WgXcQ"); DigiKeyboard.sendKeyStroke(KEY_ENTER); }