bash 从 airodump-ng 读取实时输出
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17776383/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Reading realtime output from airodump-ng
提问by EK_AllDay
When I execute the command airodump-ng mon0 >> output.txt , output.txt is empty. I need to be able to run airodump-ng mon0 and after about 5 seconds stop the command , than have access to its output. Any thoughts where I should begin to look? I was using bash.
当我执行命令 airodump-ng mon0 >> output.txt 时, output.txt 为空。我需要能够运行 airodump-ng mon0 并在大约 5 秒后停止命令,然后才能访问其输出。我应该从哪里开始寻找任何想法?我正在使用 bash。
采纳答案by Ansgar Wiechers
Start the command as a background process, sleep 5 seconds, then kill the background process. You may need to redirect a different stream than STDOUT for capturing the output in a file. This threadmentions STDERR (which would be FD 2). I can't verify this here, but you can check the descriptor number with strace
. The command should show something like this:
将命令作为后台进程启动,休眠 5 秒,然后杀死后台进程。您可能需要重定向与 STDOUT 不同的流以捕获文件中的输出。该线程提到了 STDERR(即 FD 2)。我无法在这里验证这一点,但您可以使用strace
. 该命令应显示如下内容:
$ strace airodump-ng mon0 2>&1 | grep ^write
...
write(2, "...
The number in the write
statement is the file descriptor airodump-ng
writes to.
write
语句中的数字是airodump-ng
写入的文件描述符。
The script might look somewhat like this (assuming that STDERR needs to be redirected):
脚本可能看起来有点像这样(假设需要重定向 STDERR):
#!/bin/bash
{ airodump-ng mon0 2>> output.txt; } &
PID=$!
sleep 5
kill -TERM $PID
cat output.txt
回答by sttaq
You can write the output to a file using the following:
您可以使用以下命令将输出写入文件:
airodump-ng [INTERFACE] -w [OUTPUT-PREFIX] --write-interval 30 -o csv
This will give you a csv file whose name would be prefixed by [OUTPUT-PREFIX]
. This file will be updated after every 30 seconds. If you give a prefix like /var/log/test then the file will go in /var/log/ and would look like test-XX.csv
这将为您提供一个 csv 文件,其名称将以[OUTPUT-PREFIX]
. 此文件将每 30 秒更新一次。如果您提供像 /var/log/test 这样的前缀,那么该文件将进入 /var/log/ 并且看起来像 test-XX.csv
You should then be able to access the output file(s) by any other tool while airodump is running.
然后,您应该能够在 airodump 运行时通过任何其他工具访问输出文件。
回答by SuB
By airodump-ng 1.2 rc4
you should use following command:
通过airodump-ng 1.2 rc4
你应该使用下面的命令:
timeout 5 airodump-ng -w my --output-format csv --write-interval 1 wlan1mon
After this command has compeleted you can access it's output by viewing my-01.csv
. Please not that the output file is in CSV format.
此命令完成后,您可以通过查看来访问它的输出my-01.csv
。请注意输出文件是 CSV 格式。
Your command doen't work because airodump-ng
output to stderr
instead of stdout
!!! So following command is corrected version of yours:
您的命令不起作用,因为airodump-ng
输出到stderr
而不是stdout
!!! 因此,以下命令是您的更正版本:
airodump-ng mon0 &> output.txt
The first method is better in parsing the output using other programs/applications.
第一种方法在使用其他程序/应用程序解析输出时效果更好。