Skip to content

Latest commit

 

History

History
157 lines (120 loc) · 4.59 KB

Detect-Mouse-Movement.md

File metadata and controls

157 lines (120 loc) · 4.59 KB

Logo

Table of Contents
  1. Description
  2. The Functions
  3. Examples
  4. Contact
  5. Acknowledgments

Detect-Mouse-Movement

Python
YouTube Tutorial

Description

Detecting the mouse movement of a target could be helpful in 2 different situations. Finding out if they just came back to their PC or finding out if they stepped away from their PC. These functions will pause your script Until one of these conditions are met.

The Functions

[Target-Comes]

In this first function the position of the cursor will be checked every 3 seconds

If the position of the cursor has not changed the capslock button will be pressed every 3 seconds as well

This is to stop the screen from sleeping and use the capslock light as an indicator the function is still waiting

When the position of the cursor is different the function will break out of the loop and resume the script

This is helpful if you are wanting to run a script once they return to their computer

function Target-Comes {
Add-Type -AssemblyName System.Windows.Forms
$originalPOS = [System.Windows.Forms.Cursor]::Position.X
$o=New-Object -ComObject WScript.Shell

    while (1) {
        $pauseTime = 3
        if ([Windows.Forms.Cursor]::Position.X -ne $originalPOS){
            break
        }
        else {
            $o.SendKeys("{CAPSLOCK}");Start-Sleep -Seconds $pauseTime
        }
    }
}

[Target-Leaves]

In the second function the position of the cursor will be checked

Then the script will sleep for the number of seconds defined by the $PauseTime variable

If the cursor is in the same position it will break out of the function and continue the script

This is helpful if you are trying to determine if the target is away to run a script while they are gone

(back to top)

function Target-Leaves {
[CmdletBinding()]
param (	
[Parameter (Position=0, Mandatory = $True)]
[Int]$Seconds
) 
Add-Type -AssemblyName System.Windows.Forms

    while (1) {
	  $originalPOS = [System.Windows.Forms.Cursor]::Position.X
	  Start-Sleep -Seconds $Seconds
        if ([Windows.Forms.Cursor]::Position.X -eq $originalPOS){
            break
        }
        else {
            Start-Sleep -Seconds 1
        }
    }
}

(back to top)

Examples

Listed below are payloads that have used one of these functions:

Acid Burn

JumpScare

(back to top)

Contact

📱 My Socials 📱

C#
YouTube
Python
Twitter
Golang
Instagram
Jsonnet
Discord

(back to top)

Acknowledgments


HOME-PAGE

(back to top)