Created
August 10, 2019 20:19
-
-
Save dimiboy/66be40f1632849738a33353e60600c0e to your computer and use it in GitHub Desktop.
Failed logon reporter with a photo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$NewFailedLogin = $null | |
$StartDate = get-date | |
$CamPath = "C:\CommandCam" | |
$SmtpServer = "smtp.mail.ru" | |
$From = "" | |
$to = "" | |
$Cred = Import-CliXml $CamPath\cred.clixml | |
$CurrentAudit = (auditpol /get /subcategory:"Logon")[4] | |
if( -not $CurrentAudit.Contains("Failure")){ | |
auditpol /set /subcategory:"Logon" /failure:enable | |
} | |
while ($true){ | |
$NewFailedLogin = (Get-EventLog -LogName security -Newest 1 -After $StartDate -instanceID 4625) | |
if ($NewFailedLogin -ne $null){ | |
cd $CamPath | |
.\CommandCam.exe | |
sleep 1 | |
Send-MailMessage -SmtpServer $SmtpServer -Body ("Failed Logon Detected at " + $NewFailedLogin.TimeGenerated) -From $from -Subject "Failed Logon Detected" -To $To -Credential $Cred -Verbose -UseSsl -attachment $CamPath\image.bmp | |
} | |
$NewFailedLogin = $null | |
$StartDate = get-date | |
sleep 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment