我想通過藍牙發送擊鍵從我的iPhone4從Ubuntu。 即開發一個非常原始的虛擬鍵盤。HID報告描述符(與iPhone)
問題有我的應用程序的談話到iPhone(即使用報告協議,這是所有iPhone支持)。實際上,我的write(interruptChannelFD)
調用不會返回錯誤,但 iPhone側不會顯示任何文本。 l2cap通道已經使用blueZ庫打開。
問題1:鑑於沒有虛擬鍵盤存在,它有多難?
我在iPhone和我的Linux機器連接並保持連接的階段,沒問題。 此外,所有perror()
調用都告訴我,控制和中斷通道套接字連接正常。 (我所做的是將我的加密狗連接到鍵盤設備類,並使用 Collin Mulliner的着名代碼稍作修改 - 我必須輸入密碼一次,因爲所有智能手機都需要)。
問題2:我應該可以只將write()
插入中斷套接字而不用擔心加密吧?我輸入了密碼,手機信任鍵盤。 (科林琢磨可能HID攻擊,但我連誠實)
而且,我的理解是在HID設備,確切的報告 描述 在SPD specfied的引導協議是沒有什麼關係 - 報表格式無論如何都是固定的。所以...
問題3:我是否錯過關於報告協議的一些主要內容。 我所做的是修改Apple鍵盤報告描述符並將 寫入套接字(請參見下文)。
const uint8_t hid_spec[] = {
0x05, 0x01, // usage page
0x09, 0x06, // keyboard
0xa1, 0x01, // collection (Application)
0x85, 0x01, // report id (0x01)
0x05, 0x07, // usage page(keyboard)
0x19, 0xe0, // usage min
0x29, 0xe7, // usage max
0x15, 0x00, // logical min
0x25, 0x01, // logical max
0x75, 0x01, // report size
0x95, 0x08, // report count
0x81, 0x02, // input (dat var abs)
0x75, 0x08, // report size
0x95, 0x01, // report count
0x81, 0x01, // input (const)
// The following two outputs I don't seem to receive
0x75, 0x01, // report size
0x95, 0x05, // report count
0x05, 0x08, // usage page (LEDs)
0x19, 0x01, // usage min
0x29, 0x05, // usage max
0x91, 0x02, // OUTPUT1 (dat var abs)
0x75, 0x03,
0x95, 0x01,
0x91, 0x01, // OUTPUT2 (arr,const)
0x75, 0x08, // report size
0x95, 0x06, // report count
0x15, 0x00, // logical min
0x26, 0xff, 0x00 // logical max
0x05, 0x07
0x19, 0x00
0x2a, 0xff, 0x00,
0x81, 0x00,
// A total of 9 bits sent by now
// I tried remove the following fields
/********** BEGIN SNIP
0x75, 0x01,
0x95, 0x01,
0x15, 0x00,
0x25, 0x01,
0x05, 0x0c,
0x09, 0xb8,
0x81, 0x06,
0x09, 0xe2,
0x81, 0x06,
0x09, 0xe9,
0x81, 0x02,
0x09, 0xea,
0x81, 0x02,
0x75, 0x01,
0x95, 0x04,
0x81, 0x01,
**** END SNIP/
0xc0 // end coll
};
在此之後,我寫了下面的10個字節爲中斷通道:
pkg[0] = 0xa1; // BT HDR (DATA)
pkg[1] = 0x01; // REPORT ID 0x1 == kbd
pkg[2] = modifiers; // Ctrl, Shift, etc
pkg[3] = 0x00; // constant 0 (see descr)
// pkg[4] = 0x00; // the key code - entered before this point, according to HID usage tables.
pkg[5] = 0x00;
pkg[6] = 0x00;
pkg[7] = 0x00;
pkg[8] = 0x00;
pkg[9] = 0x00;
if (write(is, pkg, 10) <= 0) {
perror("write");
exit(-1);
}
+1,順便說一句,可以通過'org.bluez.Agent'' RequestPinCode'使用BlueZ輸入一個PIN碼(也就是說,您需要通過'org.bluez.Adapter'' RegisterAgent'註冊爲代理商。 )。如果您使用的是2.1藍牙設備,則不必輸入PIN碼(因爲那些設備允許安全簡單配對) – Hasturkun