首页 > 人工智能『AI』 > Broadlink-e-control-db-dump bug fix

Broadlink-e-control-db-dump bug fix

This script will “parse” the broadlink e-Control Android application **rmt.db database** and dump the IR / RF codes (in HEX format) for selected accessories into a text file which can be later used with broadlink-python to send the codes to the RM PRO hub.

这个东西在处理逻辑上有bug,如果出现查询为空的情况,就挂了。

我修复了一下,修复代码如下:

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
57
58
59
60
61
import sqlite3 as lite
from binascii import hexlify
 
# This script will "parse" the broadlink e-Control Android application database and dump the IR / RF codes for selected accessories into a text file which can be later used with broadlink-python to send the codes to the RM PRO hub
# You need to get the "rmt.db" file from your (rooted) android device or emulator (ARM), the file is located in "/data/data/com.broadlink.rmt/databases/rmt.db" and put it in the same folder as this script.
# adb pull /data/data/com.broadlink.rmt/databases/rmt.db
 
buttonIDS = []
buttonNames = []
 
# e-Control Database file
con = lite.connect('rmt.db')
 
# Get All Accessories
with con:
    cur = con.cursor()
    cur.execute("SELECT id, name FROM subIRTable")
 
    rows = cur.fetchall()
 
    for row in rows:
        print "Accessory ID: " + str(row[0]) + " | Accessory Name: " + row[1]
 
# Choose Accessory
 
accessory = input("Select Accessory ID: ")
 
cur.execute("SELECT name FROM subIRTable where id =" + str(accessory))
 
accessory_name = cur.fetchone()[0]
 
print "[+] You selected: " + accessory_name
print "[+] Dumping codes to " + accessory_name + ".txt"
 
 
# Get Buttons id
with con:
    cur = con.cursor()
    cur.execute("SELECT name, id FROM buttonTable where subIRId=" + str(accessory))
    rows = cur.fetchall()
 
    for row in rows:
        buttonIDS.append(row[1])
        buttonNames.append(row[0])
 
    codesFile = open(accessory_name + '.txt', 'w')
 
    # Get Codes
 
    for i in range(0, len(buttonIDS)):
        cur.execute("SELECT irCode FROM codeTable where buttonId=" + str(buttonIDS[i]))
        #print str((cur.fetchall()[0])[0]).encode('hex')
        code = cur.fetchone()
        if code:
            cod = code[0]
        else:
            continue
        hexlify(cod)
        result = "Button Name: " + buttonNames[i] + "| Button ID: " + str(buttonIDS[i]) + " | Code: " + str(cod).encode('hex') + "\n"
        codesFile.writelines(result.encode('utf-8'))
    codesFile.close()

原创文章,转载请注明: 转载自 火星信息安全研究院

本文标题: 《Broadlink-e-control-db-dump bug fix》

本文链接地址: http://h4ck.org.cn/2017/12/broadlink-e-control-db-dump-bug-fix/

  1. 还没有评论
评论提交中, 请稍候...

留言

可以使用的标签: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>
Trackbacks & Pingbacks ( 0 )
  1. 还没有 trackbacks