قالب وردپرس درنا توس
Home / Tips and Tricks / Create a mouse jiggler with a Digispark and Arduino to prevent a target computer from falling asleep «Null-byte :: WonderHowTo

Create a mouse jiggler with a Digispark and Arduino to prevent a target computer from falling asleep «Null-byte :: WonderHowTo



While it’s obvious, it’s much more difficult to hack a locked computer than an unlocked one. As a white-hat hacker, pen tester, cybersecurity specialist, or someone who works in digital forensics, there’s a simple solution: make sure the computer doesn’t go to sleep and automatically lock in the first place.

One way to prevent a laptop or desktop computer from sleeping in a locked state is to use a mouse jiggler. It’s a tactic often used by law enforcement to avoid having to get a password for the account later when examining the data for evidence. The suspect probably won’t provide the credentials, but if the suspect was caught off guard during a raid, a mouse jiggler could be quickly planted to keep the computer from dozing off, eliminating the need for a password at all.

A mouse jiggler simply moves the mouse pointer or cursor just enough to keep the operating system in an active state. There are mouse jigglers that can be bought online and are ready to use, such as those from AFK TECH, CRU, HONKID (it has several), JEDIA, Punkdig, Qualitrusty, Reliabest and VAYDEER (also with multiple versions). Still, it is much more fun to build one yourself.

In previous articles, we̵

7;ve shown how to use a Digispark, an ATtiny 85-based microcontroller development board, to mimic a keyboard to enter keystrokes on a computer. And we will use the same board to make a mouse jiggler. You could also make it an auto-clicker, but we’ll show you how to code it to move the mouse pointer endlessly to prevent the screen saver from triggering.

Requirements

As already mentioned, you need a Digispark MCU, which plugs directly into a USB port on the target computer. Here are some of the options available on Amazon:

You also need the Arduino IDE, which is the software we will be using to program the Digispark. You can download it for Linux, macOS and Windows from the Arduino website. Install it after you download it and we’re good to go!

The inspiration

Our project was inspired by a mouse jiggler developed by James Franklin. It’s a really cool example because it shows a way you can implement it, where the movement is so subtle that the average person would probably never notice. It would keep the screen unlocked indefinitely, provided you plugged in the Digispark somewhere it wouldn’t be noticed, such as on the back of a desktop tower or a monitor plugged into the USB grid. When hidden, it can run forever and keep the computer unlocked at all times unless the user logs out manually.

Here, for demonstration purposes, we’re using a slightly modified script, one of which it is abundantly clear that the mouse moves. In fact, you could have some real fun with making the mouse move at random intervals, so that the person using the computer will wonder why their mouse pointer keeps jumping around the screen and moving erratically. It would be a fun joke to play with a friend or colleague.

Step 1: Get the modified mouse jiggler code

Before configuring Arduino IDE to work with the Digispark, we need the custom code. In Arduino IDE, click “File” then “New” if no new sketch has been opened yet, and paste the following code into the body. You can also find 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 
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, there is a LowerCycleTime of 500 at the beginning and UpperCycleTime of 1,000, which is milliseconds for 0.5 and 1 second. The former sets the shortest time between random mouse movements, while the latter sets the longest time between random mouse movements. In Franklin’s original they are set to 10,000 (10 seconds) and 300,000 (300 seconds), respectively.

The second difference is that we chose 1,000,000 for the first DigiMouse.moveY and DigiMouse.moveX instructions, then down to –1,000,000 for the last two. This will move the mouse pointer location up, left, down, and right in the shape of a square, which is quite noticeable.

Step 2: Configure Arduino IDE

To connect to the Digispark, we need to add it to our boards manager in Arduino IDE. First, open the “Preferences” menu in Arduino IDE. Then click the Windows button next to the “Extra 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.json

Now paste one of the links above onto a new line (you don’t need them both, the first just redirects to the second). Click “OK” and then “OK” again to save. The JSON link basically provides all port definitions for the different Digispark variations.

Then go to “Tools,” click on “Board,” then “Boards Manager.” Here you search for “digi” and “Install” the Digistump AVR cards. If you already have it, you can also update it here if an update is available. Hit “Close” and you’re all set.

Step 3: Select the Digispark sign

Go back to “Tools”, click on “Board” and you should see “Digispark AVR Boards” listed. Select that and then choose the first result for “Digispark (default – 16.5 MHz).”

Step 4: push the code to the Digispark

Unlike many sketches, you’ll want to leave the Digispark disconnected from your computer before uploading it, as weird as that sounds. So in your Mouse Jiggler sketch click on the Upload button (right pointing arrow) or go to “Sketch” -> “Upload” in the menu. Once you’ve done that, it will compile the sketch and tell you to plug in the Digispark, so do that now. After it says upload is complete, you should see the mouse pointer jump across the screen in a square motion.

If you want to see how the original code worked, you can grab the INO from GitHub or use the code below. Then unplug the Digispark, click “Upload” and plug it back in to load the original sketch onto it. Once it loads, you shouldn’t see your mouse cursor move at all, and you never will, as it makes 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 
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));

}

Be creative with your Digispark sketches

The use of the Digispark as a mouse is an imperfect science. While we made a pretty simple tool today, it’s worth noting that once we need to get this done more precisely – for example, working with an unknown screen resolution – it really starts to get difficult there.

Apart from that, it is possible to use the mouse and inject keystrokes at the same time so you can get really creative with these scripts. Check out our previous Digispark guides to learn more about the keystrokes.

Do you want to start making money as a white hat hacker? Jump-start your hacking career with our 2020 Premium Ethical Hacking Certification Training Bundle from the new Null Byte Shop and get more than 60 hours of training from cybersecurity professionals.

Buy now (90% discount)>

Other valuable deals to check out:

Cover photo and screenshots from Retia / Null byte (original cover photo from Math / Pexels)

Source link