Skip to content

Instantly share code, notes, and snippets.

@rickmark
Last active May 19, 2021 12:21
Show Gist options
  • Save rickmark/2eb2177f9d5fe8acd41f226c5aa834c1 to your computer and use it in GitHub Desktop.
Save rickmark/2eb2177f9d5fe8acd41f226c5aa834c1 to your computer and use it in GitHub Desktop.
Oh, god, why WebUSB?
<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>
iPhone
bad_web_usb.html:18 Apple Inc.
bad_web_usb.html:19 SerialNumber: <redacted>
bad_web_usb.html:22 Device Opened
bad_web_usb.html:27 Set Configuration to 5
bad_web_usb.html:29 Curent Configuration: 5
bad_web_usb.html:32 Configuration 1 : unnamed
bad_web_usb.html:34 Interface 0(unclaimed) : unnamed
bad_web_usb.html:36 Alternate 0 : Class 6 : SubClass 1 : Protocol 1 - null
bad_web_usb.html:32 Configuration 2 : unnamed
bad_web_usb.html:34 Interface 0(unclaimed) : unnamed
bad_web_usb.html:36 Alternate 0 : Class 1 : SubClass 1 : Protocol 0 - null
bad_web_usb.html:34 Interface 1(unclaimed) : unnamed
bad_web_usb.html:36 Alternate 0 : Class 1 : SubClass 2 : Protocol 0 - null
bad_web_usb.html:36 Alternate 1 : Class 1 : SubClass 2 : Protocol 0 - null
bad_web_usb.html:34 Interface 2(unclaimed) : unnamed
bad_web_usb.html:36 Alternate 0 : Class 3 : SubClass 0 : Protocol 0 - null
bad_web_usb.html:32 Configuration 3 : unnamed
bad_web_usb.html:34 Interface 0(unclaimed) : unnamed
bad_web_usb.html:36 Alternate 0 : Class 6 : SubClass 1 : Protocol 1 - null
bad_web_usb.html:34 Interface 1(unclaimed) : unnamed
bad_web_usb.html:36 Alternate 0 : Class 255 : SubClass 254 : Protocol 2 - null
bad_web_usb.html:32 Configuration 4 : unnamed
bad_web_usb.html:34 Interface 0(unclaimed) : unnamed
bad_web_usb.html:36 Alternate 0 : Class 6 : SubClass 1 : Protocol 1 - null
bad_web_usb.html:34 Interface 1(unclaimed) : unnamed
bad_web_usb.html:36 Alternate 0 : Class 255 : SubClass 254 : Protocol 2 - null
bad_web_usb.html:34 Interface 2(unclaimed) : unnamed
bad_web_usb.html:36 Alternate 0 : Class 255 : SubClass 253 : Protocol 1 - null
bad_web_usb.html:36 Alternate 1 : Class 255 : SubClass 253 : Protocol 1 - null
bad_web_usb.html:36 Alternate 2 : Class 255 : SubClass 253 : Protocol 1 - null
bad_web_usb.html:32 Configuration 5 : unnamed
bad_web_usb.html:34 Interface 0(unclaimed) : unnamed
bad_web_usb.html:36 Alternate 0 : Class 6 : SubClass 1 : Protocol 1 - null
bad_web_usb.html:34 Interface 1(unclaimed) : unnamed
bad_web_usb.html:36 Alternate 0 : Class 255 : SubClass 254 : Protocol 2 - null
bad_web_usb.html:34 Interface 2(unclaimed) : unnamed
bad_web_usb.html:36 Alternate 0 : Class 2 : SubClass 13 : Protocol 0 - null
bad_web_usb.html:34 Interface 3(unclaimed) : unnamed
bad_web_usb.html:36 Alternate 0 : Class 10 : SubClass 0 : Protocol 1 - null
bad_web_usb.html:36 Alternate 1 : Class 10 : SubClass 0 : Protocol 1 - null
bad_web_usb.html:42 Interface Claimed
| | | +-o iPhone@14400000 <class AppleUSBDevice, id 0x100016812, registered, matched, active, busy 0 (71 ms), retain 29>
| | | +-o IOService <class IOService, id 0x100016817, !registered, !matched, active, busy 0, retain 4>
| | | +-o usbmuxd <class IOUSBDeviceUserClientV2, id 0x10001681a, !registered, !matched, active, busy 0, retain 5>
| | | +-o Google Chrome <class IOUSBDeviceUserClientV2, id 0x10001681b, !registered, !matched, active, busy 0, retain 5>
| | | +-o PTP@0 <class AppleUSBInterface, id 0x100016f7a, registered, matched, active, busy 0 (4 ms), retain 12>
| | | | +-o Google Chrome <class IOUSBInterfaceUserClientV3, id 0x100016fa4, !registered, !matched, active, busy 0, retain 6>
| | | +-o Apple USB Multiplexor@1 <class AppleUSBInterface, id 0x100016f7d, registered, matched, active, busy 0 (3 ms), retain 14>
| | | | +-o usbmuxd <class IOUSBInterfaceUserClientV3, id 0x100016f80, !registered, !matched, active, busy 0, retain 14>
| | | | +-o Google Chrome <class IOUSBInterfaceUserClientV3, id 0x100016f89, !registered, !matched, active, busy 0, retain 6>
| | | +-o NCM Control@2 <class AppleUSBInterface, id 0x100016f7f, registered, matched, active, busy 0 (3 ms), retain 5>
| | | +-o NCM Data@3 <class AppleUSBInterface, id 0x100016f82, registered, matched, active, busy 0 (3 ms), retain 5>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment