【问题标题】:Using Python to brute force my Infrared remote control for a projector使用 Python 暴力破解我的投影仪红外遥控器
【发布时间】:2020-09-12 14:28:46
【问题描述】:

编辑:我想我的一切都差不多了。这只是我的第二个循环不断出现索引失败......任何想法为什么我的 coms 循环失败?


我目前正在尝试获取我的 HD180x optomoa 投影仪的 IR 代码。它正在变成一个非常困难的问题。

我只需要能够打开电源,没有别的。

我没有红外传感器来直接捕获代码,因此尝试在没有红外传感器的情况下进行操作是一种挑战。

到目前为止,这是不可能的。我尝试了几种不同的方法来使用 Raspberry Pi 直接从遥控器获取 IR 代码,但没有成功。

我的下一个想法是使用 IR 发射器,然后循环查看所有可能的 IR Power ON 代码。

LIRC,这是唯一的 Pi IR 软件,有很多遥控器的列表:http://lirc.sourceforge.net/remotes/

我想尝试并做的是制作一个 python 脚本,它只从该列表中获取所有文件,然后尝试所有这些文件。目标只是打开投影仪,所以我可以让它运行多久,如果它打开了,我可以找出是哪个打开的。

所以我的伪代码如下:

  1. 下载整个远程列表。
  2. 索引整个远程列表。 = RLISTINDEX[] 2a。停止 LIRCD 服务。
  3. 将 /etc/lirc/lircd.conf 替换为 RLISTINDEX[](一次移动一个文件) 3a。启动LIRCD服务(这样就可以了
  4. 从远程代码文件中获取“名称”字段。 = RNAME
  5. 获取远程代码文件中所有可能代码的列表 = IRCODE_ARRAY
  6. 运行 irsend SEND_ONCE RNAME IRCODE_ARRAY[](循环遍历代码数组)
  7. 返回步骤 3。

我不知道该怎么做的问题是从配置文件中获取“名称”字段和“代码”字段。

另外,不知道如何通过python发送终端命令。

有什么想法吗?

我能够获取开始发送的代码,现在我只需要了解如何从 conf 文件中获取“IR 代码”...

我是如此接近...我只需要能够执行“发送列表”““”>> /home/pi/list.ist”,这样我就可以找到当前处于活动状态的遥控器的名称。 ......我似乎无法弄清楚如何使该命令正确运行。我认为引号把它搞砸了.....


import os
import shutil
import subprocess
import time
# Using readline() 
count = 0
#os.remove("list.list")
os.system("touch /home/pi/com.list")
os.system("touch /home/pi/list.list")
os.system("systemctl start lircd")
for filename in os.listdir('confs'):
    currconf = "/home/pi/confs/" + filename
    print "**********start*******"
    print "1. ", filename
    #print "2. ", currconf
    #os.system("systemctl stop lircd")
    #subprocess.call('systemctl stop lircd', shell=True)
    shutil.move(currconf, "/etc/lirc/lircd.conf")


    subprocess.call('systemctl reset-failed lircd', shell=True)
    subprocess.call('systemctl restart lircd', shell=True)
    time.sleep(1)
    subprocess.call('systemctl status lircd | tail -3', shell=True)
   # os.system("systemctl start lircd")
   # irlist  = ""
    #print "3. ", irlist
    os.remove("/home/pi/list.list")
    os.remove("/home/pi/com.list")
    os.system('irsend list \"\" \"\" >> /home/pi/list.list')



    qbfile = open("/home/pi/list.list", "r")

    for aline in qbfile:
        values = aline.split()  
        print(values[0])

        rname = values[0].strip('\n')
        print "2. rname", rname
        comlist = 'irsend list ' + rname + ' \"\" >> /home/pi/com.list'
        print "3. comlist", comlist
        os.system(comlist)
        comfile = open("/home/pi/com.list", "r")
        for coms in comfile:
            comvalues = coms.split()  
            comand = comvalues[1]#.strip('\n')
            cmd =  "irsend SEND_ONCE " + rname + " " + comand
            print "4. cmd ", cmd
            time.sleep(.001)
            os.system(cmd)
    print "**********end*******"

【问题讨论】:

    标签: python python-2.7 configuration brute-force


    【解决方案1】:

    一切正常……这是代码

    import os
    import shutil
    import subprocess
    import time
    
    #removes files to start fresh
    os.system("touch /home/pi/com.list")
    os.system("touch /home/pi/list.list")
    os.system("systemctl start lircd")
    
    #gets a sorted list of all the configuration files from LIRC remote storage
    for filename in sorted(os.listdir('/home/pi/confs')):
        #gets the first file
        currconf = "/home/pi/confs/" + filename
        print "**********start*******"
        print "1. ", filename
    
     #moves the first config file to lircd.conf so restart can make it show up
        shutil.move(currconf, "/etc/lirc/lircd.conf")
    
    #restarts lircd (the reset-failed is to make sure there are no time outs
        subprocess.call('systemctl reset-failed lircd', shell=True)
        subprocess.call('systemctl restart lircd', shell=True)
        time.sleep(1)
    #shows the status of lircd
        subprocess.call('systemctl status lircd | tail -3', shell=True)
    
    #removes files again to make sure it is fresh
        os.remove("/home/pi/list.list")
        os.remove("/home/pi/com.list")
    # sends an iresend to get list of all remotes in the remote configuration file that was used and pits it in list.list to be used for configuration later
        os.system('irsend list \"\" \"\" >> /home/pi/list.list')
    
    
    #opens list.list
        qbfile = open("/home/pi/list.list", "r")
    #for all remotes in list.list
        for aline in qbfile:
    #this gets the remote names        
            values = aline.split()  
            if values:
                print(values[0])
    #removes end of file from remote names
                rname = values[0].strip('\n')
                print "2. rname", rname
    #creates command that is going to list all commands of given remote names
                comlist = 'irsend list ' + rname + ' \"\" >> /home/pi/com.list'
                print "3. comlist", comlist
    #runs command            
                os.system(comlist)
    #opens command list file            
                comfile = open("/home/pi/com.list", "r")
                for coms in comfile:
    #gets command name, and not command hex                
                    comvalues = coms.split()  
    
                    #makes sure if there is a null value it does not hang the loop
                    if comvalues:
                        comand = comvalues[1]#.strip('\n')
                        print "4. cmd ", comand
                        time.sleep(.1)
    
                        command2 = 'irsend SEND_ONCE ' + rname + " " + comand
                        print "5. command2", command2
                        ppp = subprocess.Popen(command2, universal_newlines=True, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
                        text = ppp.stdout.read()
                        retcode = ppp.wait()
                        print text
    
    
        print "**********end*******"
    

    【讨论】:

      猜你喜欢
      • 2022-01-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-05
      • 2023-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多