This repository has been archived by the owner on May 29, 2021. It is now read-only.
forked from nn9dev/checkm8-webusb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbad_web_usb.html
56 lines (48 loc) · 2.03 KB
/
bad_web_usb.html
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
<html>
<head>
<title>BadUSB on the Web</title>
</head>
<body>
<form action="#">
<a id="gesture" href="#">Click Me</a>
</form>
<script>
var device = null;
document.getElementById('gesture').onclick = function() {
navigator.usb.requestDevice({ filters: [{ vendorId: 0x05ac, productId: 0x12A8 }] })
.then(theDevice => {
device = theDevice
console.log(device.productName);
console.log(device.manufacturerName);
console.log("SerialNumber: " + device.serialNumber);
device.open().then(function() {
console.log("Device Opened");
let configurationId = 5;
device.selectConfiguration(configurationId).then(function() {
console.log("Set Configuration to " + configurationId);
if (device.configuration != null) {
console.log("Curent Configuration: " + device.configuration.configurationValue);
device.configurations.forEach(configuration => {
console.log("Configuration " + configuration.configurationValue + " : " + (configuration.configurationName || "unnamed"));
configuration.interfaces.forEach(deviceInterface => {
console.log("Interface " + deviceInterface.interfaceNumber + "(" + (deviceInterface.claimed ? "claimed" : "unclaimed") + ") : " + (configuration.configurationName || "unnamed"));
deviceInterface.alternates.forEach(alternate => {
console.log("Alternate " + alternate.alternateSetting + " : Class " + alternate.interfaceClass + " : SubClass " + alternate.interfaceSubclass + " : Protocol " + alternate.interfaceProtocol + " - " + alternate.interfaceName);
});
})
});
device.claimInterface(0).then(function() {
console.log("Interface Claimed");
})
.catch(error => { console.log(error.name + " : " + error.message) });
}
})
.catch(error => { console.log(error.name + " : " + error.message) });
})
.catch(error => { console.log(error.name + " : " + error.message) });
})
.catch(error => { console.log(error.name + " : " + error.message); });
}
</script>
</body>
</html>