Create a USB Mouse Jiggler to Keep a Target Computer from Falling Asleep (& Prank Friends Too) « Null Byte :: WonderHowTo

While obvious, it's a lot more difficult to hack into a locked computer than an unlocked computer. As a white-hat hacker, pentester, cybersecurity specialist, or someone working in digital forensics, there's an easy solution — make it so that the computer won't fall asleep and lock automatically in the first place.One way to stop a laptop or desktop computer from sleeping into a locked state is to use a mouse jiggler. It's a tactic used frequently by law enforcement to avoid having to get a password for the account later when examining the data for evidence. The suspect will likely not give up the credentials, but if the suspect was caught off-guard during a raid, a mouse jiggler could be planted quickly to make sure the computer doesn't doze off, avoiding the need for a password altogether.Don't Miss:How to Run USB Rubber Ducky Scripts on a Digispark BoardA mouse jiggler simply moves the mouse pointer or cursor around just enough to keep the operating system in an active state. There are mouse jigglers that can be purchased online that are ready to go, such as ones fromAFK TECH,CRU,HONKID(it hasmultiple ones),JEDIA,Punkdig,Qualitrusty,Reliabest, andVAYDEER(also withmultipleversions). Still, it's much more fun to build your own.Inpreviousarticles,we'veshownhow to use aDigispark, an ATtiny 85-based microcontroller development board, to mimic a keyboard to input keystrokes on a computer. And we'll be using the same board to create a mouse jiggler. You could also turn it into an auto-clicker, but we'll be showing you how to code it to jiggle the mouse pointer endlessly to avoid the screensaver kicking in.RequirementsAs mentioned already, you'll need a Digispark MCU, which will plug directly into a USB port on the target machine. Here are some options available on Amazon:Digispark - 1 unit for almost $6(4 stars, 8 ratings)Digispark - 1 unit for almost $10(4.7 stars, 5 ratings)Digispark - 2 units for almost $10(5 stars, 1 rating)Digispark - 2 units for about $12(3.7 stars, 7 ratings)Digispark - 3 units for about $8(5 stars, 48 ratings)Digispark - 5 units for about $10(5 stars, 1 rating)Digispark - 5 units for about $11(4.5 stars, 60 ratings)Digispark - 5 units for about $11(4.2 stars, 24 ratings)Digispark - 6 units for about $12(5 stars, 1 rating)You'll also need the Arduino IDE, the software we'll be using to program the Digispark. You can download it for Linux, macOS, and Windows fromArduino's website. Once you've downloaded it, install it, and we're ready to go!The InspirationOur project was inspired bya mouse jiggler developed by James Franklin. It's a really cool example because it shows one way that you can implement it, where the movement is so subtle that the average person would probably never notice it. It would keep the screen unlocked indefinitely, provided you could plug the Digispark in somewhere where it wouldn't be noticed, like at the back of a desktop tower or a monitor connected to the USB grid. With it hidden, it could run forever and keep the computer always unlocked unless the user logs out manually.Here, we'll be using a slightly modified script, one where it's super obvious that the mouse is moving, for demonstration purposes. You could even have some real fun with this, making it so that the mouse moves at random intervals so that whoever is using the computer will wonder why their mouse pointer keeps jumping across the screen and moving erratically. It'd be a fun prank to play on a friend or coworker.Step 1: Get the Modified Mouse Jiggler CodeBefore we configure Arduino IDE to work with the Digispark, we'll need the modified code. In Arduino IDE, click on "File," then "New," if a new sketch isn't already open, and paste the following code into the body. You could alsofind and download the modified code from GitHub.// Digispark Mouse Jiggler
// Written by James Franklin for Air-Gap in 2019
// www.air-gap.com.au

// Modified by Kody Kinzie of Null Byte
// https://github.com/skickar/USBAttackWorkshop/blob/master/MouseJigglerBIG.ino

#include <DigiMouse.h>
unsigned int LowerCycleTime = 500; //Minimum Time in milli-seconds between each mouse action  Default: 10000 (10 Seconds), Max 65535ms
unsigned int UpperCycleTime = 1000; //Maximum Time in milli-seconds between each mouse action  Default: 30000 (30 Seconds), Max 65535ms
//Random Function will randomly execute a mouse move between these two values
void setup() {
  randomSeed(analogRead(0));  //Random Seed off background noise on analog pin
  pinMode(1, OUTPUT);
  DigiMouse.begin(); //start

}
void loop() {
//Moves mouse 1 pixel in a direction (up/down/left/right) in a square

  digitalWrite(1, HIGH);
  DigiMouse.moveY(1000000);
  DigiMouse.delay(50);
  digitalWrite(1, LOW);
  DigiMouse.delay(random(LowerCycleTime, UpperCycleTime));

  digitalWrite(1, HIGH);
  DigiMouse.moveX(1000000); //
  DigiMouse.delay(50);
  digitalWrite(1, LOW);
  DigiMouse.delay(random(LowerCycleTime, UpperCycleTime));

  digitalWrite(1, HIGH);
  DigiMouse.moveY(-1000000);
  DigiMouse.delay(50);
  digitalWrite(1, LOW);
  DigiMouse.delay(random(LowerCycleTime, UpperCycleTime));

  digitalWrite(1, HIGH);
  DigiMouse.moveX(-1000000);
   DigiMouse.delay(50);
  digitalWrite(1, LOW);
  DigiMouse.delay(random(LowerCycleTime, UpperCycleTime));

}Compared to Franklin's original code, in the beginning, there's a LowerCycleTime of 500 and UpperCycleTime of 1,000, which is milliseconds for 0.5 and 1 seconds. The former sets the shortest amount of time between random mouse movements, while the latter sets the longest time between random mouse movements. Franklin's original has them set to 10,000 (10 seconds) and 300,000 (300 seconds), respectively.The second difference is that we've chosen 1,000,000 for the first DigiMouse.moveY and DigiMouse.moveX instructions, then down to –1,000,000 for the last two. This will make the mouse pointer's location move up, left, down, right in the shape of a square, which should be fairly noticeable.Step 2: Configure Arduino IDETo connect to the Digispark, we'll need to add it to our boards manager in Arduino IDE. First, open up the "Preferences" menu in Arduino IDE. Next, click on the windows button next to the "Additional Boards Manager URLs" field to expand it.https://digistump.com/package_digistump_index.json
https://raw.githubusercontent.com/digistump/arduino-boards-index/master/package_digistump_index.jsonNow, paste in one of the above links onto a new line (you don't need them both, the first one just redirects to the second one). Click "OK," then "OK" again to save. The JSON link basically provides all of the port definitions for the various Digispark variations.Next, go to "Tools," click "Board," then "Boards Manager." Here, you'll search for "digi" and "Install" the Digistump AVR Boards. If you already have it, you could also update it from here if an update is available. Hit "Close," and you're all set.Step 3: Select the Digispark BoardGo back to "Tools," click "Board," and you should see "Digispark AVR Boards" listed. Select that, then choose the first result for "Digispark (Default - 16.5mhz)."Step 4: Push the Code to the DigisparkUnlike many sketches, you'll want to leave the Digispark unplugged from your computer before you start uploading it, however weird that sounds. So in your Mouse Jiggler sketch, click the Upload button (right-facing arrow) or go to "Sketch" –> "Upload" in the menu. Once you do that, it will compile the sketch, then tell you to plug in the Digispark, so do that now. After it says it's completed the upload, you should see the mouse pointer start to jump around the screen in a square motion.If you want to see how the original code worked, you cangrab the INO from GitHubor use the code below. Then, unplug the Digispark, hit "Upload," and plug it back in to load the original sketch on it. Once it's loaded, you shouldn't see your mouse cursor move at all, and you never will, because it's making micro-movements that are impossible to spot but will keep the computer on forever.// Digispark Mouse Jiggler
// Written by James Franklin for Air-Gap in 2019
// www.air-gap.com.au

#include <DigiMouse.h>
unsigned int LowerCycleTime = 10000; //Minimum Time in milli-seconds between each mouse action  Default: 10000 (10 Seconds), Max 65535ms
unsigned int UpperCycleTime = 30000; //Maximum Time in milli-seconds between each mouse action  Default: 30000 (30 Seconds), Max 65535ms
//Random Function will randomly execute a mouse move between these two values
void setup() {
  randomSeed(analogRead(0));  //Random Seed off background noise on analog pin
  pinMode(1, OUTPUT);
  DigiMouse.begin(); //start

}
void loop() {
//Moves mouse 1 pixel in a direction (up/down/left/right) in a square

  digitalWrite(1, HIGH);
  DigiMouse.moveY(1);
  DigiMouse.delay(50);
  digitalWrite(1, LOW);
  DigiMouse.delay(random(LowerCycleTime, UpperCycleTime));

  digitalWrite(1, HIGH);
  DigiMouse.moveX(1); //
  DigiMouse.delay(50);
  digitalWrite(1, LOW);
  DigiMouse.delay(random(LowerCycleTime, UpperCycleTime));

  digitalWrite(1, HIGH);
  DigiMouse.moveY(-1);
  DigiMouse.delay(50);
  digitalWrite(1, LOW);
  DigiMouse.delay(random(LowerCycleTime, UpperCycleTime));

  digitalWrite(1, HIGH);
  DigiMouse.moveX(-1);
   DigiMouse.delay(50);
  digitalWrite(1, LOW);
  DigiMouse.delay(random(LowerCycleTime, UpperCycleTime));

}Get Creative with Your Digispark SketchesUsing the Digispark as a mouse is an imperfect science. While we made a pretty simple tool today, it's worth noting that as soon as we need to control this more precisely — for example, working with an unknown screen resolution — that's where things start to get really difficult.Aside from that, it's possible to use the mouseandinject keystrokes simultaneously, so you can really get creative with these scripts. Check outour previous Digispark guidesto learn more about the keystroke side of things.Don't Miss:Use a Digispark to Defeat VPNs & Track a MacOS Computer RemotelyWant to start making money as a white hat hacker?Jump-start your hacking career with our2020 Premium Ethical Hacking Certification Training Bundlefrom the newNull Byte Shopand get over 60 hours of training from cybersecurity professionals.Buy Now (90% off) >Other worthwhile deals to check out:97% off The Ultimate 2021 White Hat Hacker Certification Bundle99% off The 2021 All-in-One Data Scientist Mega Bundle98% off The 2021 Premium Learn To Code Certification Bundle62% off MindMaster Mind Mapping Software: Perpetual LicenseCover photo and screenshots by Retia/Null Byte (original cover photo byMath/Pexels)RelatedHow To:Prank Your Friend's Computer Mouse into a Smelly Smoke MachineHow To:Pull a compilation of computer pranks on a friendNews:Top 10 Pranks for the College Freshman DormSecurity Alert:Your Wireless Mouse or Keyboard Can Be HackedHow To:Hack Your Old Computer Mouse into Retro Wireless Bluetooth Mouse!How To:Connect a Mouse to Your Nexus PlayerHow To:Use a Wireless or USB Mouse on Your iPhone in iOS 13How To:Prank hack a computer mouseHow To:Execute the Impossible Situp PrankHow To:Steal macOS Files with the USB Rubber DuckyHow To:Catch USB Rubber Duckies on Your Computer with USBRipHow To:Inject Keystrokes into Logitech Keyboards with an nRF24LU1+ TransceiverHow To:Take Your Phone Pranks to the Next Level with the Prankowl Caller ID Spoofing DialerHacking Windows 10:How to Break into Somebody's Computer Without a Password (Exploiting the System)How To:Prank Your Friend's Cell Phone by Encasing It in Jello!How To:The Ultimate Guide to Hacking macOSHow To:Make Exploding Targets for Airsoft and BB Guns Using Mousetraps and FireworksAndroid for Hackers:How to Backdoor Windows 10 Using an Android Phone & USB Rubber DuckyHow To:Prank a friend who has fallen asleep in a moving carHow To:Load & Use Keystroke Injection Payloads on the USB Rubber DuckyHacking macOS:How to Spread Trojans & Pivot to Other Mac ComputersHow to Install Remix OS:Android on Your ComputerHow To:12 April Fool's Day Pranks for Your Smartphone-Addicted Family & FriendsHow To:Pull the styrofoam ice-bottom cup prankHow To:Use the USB Rubber Ducky to Disable Antivirus Software & Install RansomwareHow To:Trick someone into thinking their LCD monitor is brokenNews:"Jello-Pool"News:The $25 USB Stick ComputerHow To:Use Google Voice to Prank Your Friends on April Fool's DayHow To:Add an Extra USB Port to Your Wired Computer MouseNews:Million Dollar PrankNews:Bam's Trapdoor BedHow To:Prank an optical mouse by replacing the laser and right-click with a toyNews:Public Bathroom FiascoNews:Snakes in a HotelNews:very hard to do prankHow To:catch a predator (possibly jackass member)News:The Gorilla Tour-GuideNews:old man and the bloody poolNews:The Fart Drink