本文介绍了airodump-ng输出与python子进程.Popen coummunicate方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从 airodump-ng mon0

因此,我试图在使用Popen.communicate一段时间后读取 airodump-ng mon0 的输出,但仍然无法获取任何内容.

For that reason I was trying to read the output of airodump-ng mon0 after certain time with Popen.communicate but still cannot get anything.

import subprocess

airodump = subprocess.Popen(['airodump-ng', 'mon0'],
                        stdin=subprocess.PIPE,
                        stdout=subprocess.PIPE,
                        stderr=subprocess.PIPE)
try:
    o_airodump, unused_stderr = airodump.communicate(timeout=15)
except subprocess.TimeoutExpired as e:
    airodump.kill()
    o_airodump, unused_stderr = airodump.communicate()
    print(o_airodump)
    print(unused_stderr)

当我运行它时,它卡在:

When I run this it gets stuck at:

o_airodump, unused_stderr = airodump.communicate()

我现在完全被困住了.并且无法找到任何其他方式.请帮忙.

I am totally stuck now. And unable to find any other ways. Please help.

推荐答案

60秒后,我使用以下代码检索了可用的wifi网络列表:

I used the following code to retreive the list of avaible wifi networks after 60 seconds:

def find_wifi(interface):
    table = ''
    stdout = []
    timeout = 60
    table_start = re.compile('\sCH')
    start_time = time.time()

    airodump = subprocess.Popen(['airodump-ng', interface], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, bufsize=1)

    while time.time() < start_time + timeout:
        line = airodump.stdout.readline()
        if table_start.match(line):
            table = ''.join(stdout)
            stdout = []
        stdout.append(line)
    airodump.terminate()
    print(table)

这篇关于airodump-ng输出与python子进程.Popen coummunicate方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-18 14:09