aboutsummaryrefslogtreecommitdiff
path: root/Tests
diff options
context:
space:
mode:
authorJesse Davis <jdalton.davis@gmail.com>2016-01-09 17:50:58 -0600
committerJesse Davis <jdalton.davis@gmail.com>2016-01-09 17:50:58 -0600
commitf66e219bd633bfcab96b5f34bfcaf86d3984faaf (patch)
tree7f1eaca85e4b69067b63c94b94bf3fd2d70502b9 /Tests
parent872d4b0eb74072465980567d5cf2cb42fa0283d5 (diff)
downloadPowerSploit-f66e219bd633bfcab96b5f34bfcaf86d3984faaf.tar.gz
PowerSploit-f66e219bd633bfcab96b5f34bfcaf86d3984faaf.zip
new Get-Keystrokes
Diffstat (limited to 'Tests')
-rw-r--r--Tests/Exfiltration.tests.ps155
1 files changed, 55 insertions, 0 deletions
diff --git a/Tests/Exfiltration.tests.ps1 b/Tests/Exfiltration.tests.ps1
new file mode 100644
index 0000000..baeebb8
--- /dev/null
+++ b/Tests/Exfiltration.tests.ps1
@@ -0,0 +1,55 @@
+Set-StrictMode -Version Latest
+
+$TestScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
+$ModuleRoot = Resolve-Path "$TestScriptRoot\.."
+$ModuleManifest = "$ModuleRoot\Exfiltration\Exfiltration.psd1"
+
+Remove-Module [E]xfiltration
+Import-Module $ModuleManifest -Force -ErrorAction Stop
+
+Describe 'Get-Keystrokes' {
+
+ if (Test-Path "$($env:TEMP)\key.log") { Remove-Item -Force "$($env:TEMP)\key.log" }
+ $WindowTitle = (Get-Process -Id $PID).MainWindowTitle
+
+ $Shell = New-Object -ComObject wscript.shell
+ $Shell.AppActivate($WindowTitle)
+
+ $KeyLogger = Get-Keystrokes -Return
+ Start-Sleep -Seconds 1
+
+ $Shell.SendKeys('Pester is SUPER l337!')
+ $KeyLogger.Dispose()
+
+ It 'Should output to file' { Test-Path "$($env:TEMP)\key.log" | Should Be $true }
+
+ $KeyObjects = Get-Content -Path "$($env:TEMP)\key.log" | ConvertFrom-Csv
+
+ It 'Should log all keystrokes' {
+ $Keys = $KeyObjects | % { $_.TypedKey }
+ $String = -join $Keys
+ $String | Should Be '<Shift>Pester< >is< ><Shift>S<Shift>U<Shift>P<Shift>E<Shift>R< >l337<Shift>!'
+ }
+
+ It 'Should get foreground window title' {
+ $KeyObjects[0].WindowTitle | Should Be $WindowTitle
+ }
+
+ It 'Should log time of key press' {
+ $KeyTime = [DateTime]::Parse($KeyObjects[0].Time)
+ $KeyTime.GetType().Name | Should Be 'DateTime'
+ }
+
+ It 'Should stop logging Pester is SUPER l337!after timeout' {
+
+ $Timeout = 0.05
+ $KeyLogger = Get-Keystrokes -Timeout $Timeout -Return
+
+ Start-Sleep -Seconds 4
+
+ $KeyLogger.Runspace.RunspaceAvailability | Should Be 'Available'
+ $KeyLogger.Dispose()
+ }
+
+ Remove-Item -Force "$($env:TEMP)\key.log"
+} \ No newline at end of file