PoshCode Logo PowerShell Code Repository

Keylogger by greg zakharov 7 months ago
embed code: <script type="text/javascript" src="http://PoshCode.org/embed/4707"></script>download | new post

Example of elementary keylogger.

  1. [String]$buff = ""
  2.  
  3. while($true) {
  4.   [Console]::ReadKey("`r") | % {
  5.     if ($_.Key -eq 'Enter') {break}
  6.     if ([Char]::IsLetterOrDigit($_.KeyChar) -or [Char]::IsWhiteSpace($_.KeyChar) -or`
  7.         [Char]::IsPunctuation($_.KeyChar) -or [Char]::IsSymbol($_.KeyChar)) {
  8.       $buff += $_.KeyChar
  9.       Write-Host $_.KeyChar -no
  10.     }
  11.   }
  12. }
  13. ""
  14.  
  15. if (-not [String]::IsNullOrEmpty($buff)) {
  16.   Out-File ($pwd.Path + '\keylogger.log') -in $buff -enc ASCII -app -for
  17. }

Submit a correction or amendment below (
click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:


Remember me