-
-
Save crpietschmann/eed4467834998ff161c6bea58c675342 to your computer and use it in GitHub Desktop.
| ## KeepAwake.ps1 | |
| ## Use SendKeys to toggle the Scroll Lock key | |
| ## | |
| ## This will keep the PC awake and prevent | |
| ## it from going to sleep. | |
| ## | |
| ## Author: Chris Pietschmann (https://build5nines.com) | |
| $timerseconds = 60 * 4 ## Every 4 minutes | |
| $myshell = New-Object -com "Wscript.Shell" | |
| while ($True -eq $True) { | |
| $myshell.sendkeys("{SCROLLLOCK 2}") | |
| Write-Output "Keeping Awake... $(Get-Date)" | |
| Start-Sleep -Seconds $timerseconds | |
| } |
I present to you the ultimate oneliner, StealthCoffee:
- Creates a hidden window to run the new process
- Autoexits the original window we paste this into
- Stops running at 18:15 +/- 5 localtime of the same day
- Sends scroll lock twice (random ms range 103-153) in random intervals between 33 seconds and 183 seconds
Repo to open in incognito and copy the oneliner from: StealthCoffee
Here is the snippet also, you can just copy paste it in a Powershell terminal:
Start-Process powershell -WindowStyle Hidden -ArgumentList '-Command "$wshell = New-Object -ComObject wscript.shell; $end = (Get-Date).Date.AddHours(18).AddMinutes(15).AddMinutes((Get-Random -Minimum -5 -Maximum 5)); while((Get-Date) -lt $end){$wshell.SendKeys(''{SCROLLLOCK}'' ); Start-Sleep -Milliseconds (Get-Random -Minimum 103 -Maximum 153); $wshell.SendKeys(''{SCROLLLOCK}''); Start-Sleep -Seconds (Get-Random -Minimum 33 -Maximum 183)}"'; exit
ProTip: Don't save it as a file locally. I don't have this script anywhere on my local machine to avoid any detection, i just open an incognito window in Google Chrome, navigate to the public repository i listed above and just copy paste the raw text from the file in a Powershell terminal.
simpler in a profile function, sleeps for 4 mins and scrollLock on/off
cat function:myAlive
$WShell = New-Object -com "Wscript.Shell"
while ($true) {
$WShell.sendkeys("{SCROLLLOCK}")
Start-Sleep -Milliseconds 100
$WShell.sendkeys("{SCROLLLOCK}")
Start-Sleep -Seconds 240
}