Bluetooth Rubber Ducky (https://forums.hak5.org/topic/41678-bluetooth-rubber-ducky/)

Dependencies:   BLE_API mbed nRF51822

Fork of microbit_presenter by micro:bit

  • Backspace = x08
  • (F5) = \x86
  • (F11) = \x8A
  • (F12) = \x8B
  • Print Screen = \x8C
  • Application Program Command (CTRL+8) \x9F
  • (‽)RALT LCTRL RSHIFT LSHIFT F1 LCTRL = \u203d + \u2038 (v.similar)
  • Down F1 LCTRL = \u2016
  • F1 F1 LCTRL = \u2000
  • LALT LSHIFT F2 LCTRL = \u206F
  • Insert = \x90
  • Home = \x91
  • Pageup = \x92
  • PageDown = \x93
  • Right Shift + Left Control = \uF8FF
  • Alt Shift + F (File >) = \x99
  • CTRL+B = \x98
  • Right Ctrl = \x9a
  • Escape + stuff, \x9d
  • Test on another PC (rwin) \x9c
  • Scroll = \x8d
  • Capslock = \x8e
  • Numlock = \x8f
  • Left = \x95
  • Right = \x94
  • Up = \x97
  • Down = \x96

Full list of special command characters here.

Committer:
CalvinR
Date:
Mon Aug 21 12:24:51 2017 +0000
Revision:
3:dc7a04d715a2
Parent:
0:cb1939018833
v1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JonnyA 0:cb1939018833 1 /* mbed Microcontroller Library
JonnyA 0:cb1939018833 2 * Copyright (c) 2015 ARM Limited
JonnyA 0:cb1939018833 3 *
JonnyA 0:cb1939018833 4 * Licensed under the Apache License, Version 2.0 (the "License");
JonnyA 0:cb1939018833 5 * you may not use this file except in compliance with the License.
JonnyA 0:cb1939018833 6 * You may obtain a copy of the License at
JonnyA 0:cb1939018833 7 *
JonnyA 0:cb1939018833 8 * http://www.apache.org/licenses/LICENSE-2.0
JonnyA 0:cb1939018833 9 *
JonnyA 0:cb1939018833 10 * Unless required by applicable law or agreed to in writing, software
JonnyA 0:cb1939018833 11 * distributed under the License is distributed on an "AS IS" BASIS,
JonnyA 0:cb1939018833 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
JonnyA 0:cb1939018833 13 * See the License for the specific language governing permissions and
JonnyA 0:cb1939018833 14 * limitations under the License.
JonnyA 0:cb1939018833 15 */
JonnyA 0:cb1939018833 16
JonnyA 0:cb1939018833 17 #include "ble/services/BatteryService.h"
JonnyA 0:cb1939018833 18
JonnyA 0:cb1939018833 19 #include "HIDDeviceInformationService.h"
JonnyA 0:cb1939018833 20
JonnyA 0:cb1939018833 21 #include "examples_common.h"
JonnyA 0:cb1939018833 22
JonnyA 0:cb1939018833 23 static void passkeyDisplayCallback(Gap::Handle_t handle, const SecurityManager::Passkey_t passkey)
JonnyA 0:cb1939018833 24 {
JonnyA 0:cb1939018833 25 printf("Input passKey: ");
JonnyA 0:cb1939018833 26 for (unsigned i = 0; i < Gap::ADDR_LEN; i++) {
JonnyA 0:cb1939018833 27 printf("%c", passkey[i]);
JonnyA 0:cb1939018833 28 }
JonnyA 0:cb1939018833 29 printf("\r\n");
JonnyA 0:cb1939018833 30 }
JonnyA 0:cb1939018833 31
JonnyA 0:cb1939018833 32 static void securitySetupCompletedCallback(Gap::Handle_t handle, SecurityManager::SecurityCompletionStatus_t status)
JonnyA 0:cb1939018833 33 {
JonnyA 0:cb1939018833 34 if (status == SecurityManager::SEC_STATUS_SUCCESS) {
JonnyA 0:cb1939018833 35 printf("Security success %d\r\n", status);
JonnyA 0:cb1939018833 36 } else {
JonnyA 0:cb1939018833 37 printf("Security failed %d\r\n", status);
JonnyA 0:cb1939018833 38 }
JonnyA 0:cb1939018833 39 }
JonnyA 0:cb1939018833 40
JonnyA 0:cb1939018833 41 static void securitySetupInitiatedCallback(Gap::Handle_t, bool allowBonding, bool requireMITM, SecurityManager::SecurityIOCapabilities_t iocaps)
JonnyA 0:cb1939018833 42 {
JonnyA 0:cb1939018833 43 printf("Security setup initiated\r\n");
JonnyA 0:cb1939018833 44 }
JonnyA 0:cb1939018833 45
JonnyA 0:cb1939018833 46 void initializeSecurity(BLE &ble)
JonnyA 0:cb1939018833 47 {
JonnyA 0:cb1939018833 48 bool enableBonding = true;
JonnyA 0:cb1939018833 49 bool requireMITM = HID_SECURITY_REQUIRE_MITM;
JonnyA 0:cb1939018833 50
JonnyA 0:cb1939018833 51 ble.securityManager().onSecuritySetupInitiated(securitySetupInitiatedCallback);
JonnyA 0:cb1939018833 52 ble.securityManager().onPasskeyDisplay(passkeyDisplayCallback);
JonnyA 0:cb1939018833 53 ble.securityManager().onSecuritySetupCompleted(securitySetupCompletedCallback);
JonnyA 0:cb1939018833 54
JonnyA 0:cb1939018833 55 ble.securityManager().init(enableBonding, requireMITM, HID_SECURITY_IOCAPS);
JonnyA 0:cb1939018833 56 }
JonnyA 0:cb1939018833 57
JonnyA 0:cb1939018833 58 void initializeHOGP(BLE &ble)
JonnyA 0:cb1939018833 59 {
JonnyA 0:cb1939018833 60 static const uint16_t uuid16_list[] = {GattService::UUID_HUMAN_INTERFACE_DEVICE_SERVICE,
JonnyA 0:cb1939018833 61 GattService::UUID_DEVICE_INFORMATION_SERVICE,
JonnyA 0:cb1939018833 62 GattService::UUID_BATTERY_SERVICE};
JonnyA 0:cb1939018833 63
JonnyA 0:cb1939018833 64 PnPID_t pnpID;
JonnyA 0:cb1939018833 65 pnpID.vendorID_source = 0x2; // from the USB Implementer's Forum
JonnyA 0:cb1939018833 66 pnpID.vendorID = 0x0D28; // NXP
JonnyA 0:cb1939018833 67 pnpID.productID = 0x0204; // CMSIS-DAP (well, it's a keyboard but oh well)
JonnyA 0:cb1939018833 68 pnpID.productVersion = 0x0100; // v1.0
JonnyA 0:cb1939018833 69 HIDDeviceInformationService deviceInfo(ble, "ARM", "m1", "abc", "def", "ghi", "jkl", &pnpID);
JonnyA 0:cb1939018833 70
JonnyA 0:cb1939018833 71 BatteryService batteryInfo(ble, 80);
JonnyA 0:cb1939018833 72
JonnyA 0:cb1939018833 73 ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED |
JonnyA 0:cb1939018833 74 GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
JonnyA 0:cb1939018833 75 ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS,
JonnyA 0:cb1939018833 76 (uint8_t *)uuid16_list, sizeof(uuid16_list));
JonnyA 0:cb1939018833 77
JonnyA 0:cb1939018833 78 // see 5.1.2: HID over GATT Specification (pg. 25)
JonnyA 0:cb1939018833 79 ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
JonnyA 0:cb1939018833 80 // 30ms to 50ms is recommended (5.1.2)
JonnyA 0:cb1939018833 81 ble.gap().setAdvertisingInterval(50);
JonnyA 0:cb1939018833 82 }
JonnyA 0:cb1939018833 83