cephurs

evilmaid

Apr 26th, 2018
406
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ## 1. Start this script running in PowerShell
  2. ## 2. Close your laptop lid. The next time the lid opens, the script will send a mail.
  3.  
  4. $lastAwake = Get-Date; while($true) {
  5.     Start-Sleep -Seconds 1
  6.     $now = Get-Date
  7.     if(($now - $lastAwake).TotalSeconds -gt 3) {
  8.         $params = @{
  9.             To = 'user@example.com'
  10.             From = 'user@example.com'
  11.             Subject = 'Evil maid detected!'
  12.             Body = "Detected laptop opened at $now"
  13.             SmtpServer = 'smtp@example.com'
  14.         }
  15.         Send-MailMessage @params
  16.     }
  17.     $lastAwake = $now
  18. }
Add Comment
Please, Sign In to add comment