gpt4 book ai didi

python - 探针.py : error: argument -f/--mac-info: Ignored explicit argument '-s-r-l'

转载 作者:太空宇宙 更新时间:2023-11-03 14:31:52 24 4
gpt4 key购买 nike

import time
import datetime
import argparse
import netaddr
import sys
import logging
from scapy.all import *
from pprint import pprint
from logging.handlers import RotatingFileHandler


NAME = 'probemon'
DESCRIPTION = "a command line tool for logging 802.11 probe request frames"

DEBUG = False

def build_packet_callback(time_fmt, logger, delimiter, mac_info, ssid, rssi):
def packet_callback(packet):

if not packet.haslayer(Dot11):
return

# we are looking for management frames with a probe subtype
# if neither match we are done here
if packet.type != 0 or packet.subtype != 0x04:
return

# list of output fields
fields = []

# determine preferred time format
log_time = str(int(time.time()))
if time_fmt == 'iso':
log_time = datetime.datetime.now().isoformat()

fields.append(log_time)

# append the mac address itself
fields.append(packet.addr2)

# parse mac address and look up the organization from the vendor octets
if mac_info:
try:
parsed_mac = netaddr.EUI(packet.addr2)
fields.append(parsed_mac.oui.registration().org)
except netaddr.core.NotRegisteredError, e:
fields.append('UNKNOWN')

# include the SSID in the probe frame
if ssid:
fields.append(packet.info)

if rssi:
rssi_val = -(256-ord(packet.notdecoded[-4:-3]))
fields.append(str(rssi_val))

logger.info(delimiter.join(fields))

return packet_callback

def main():
parser = argparse.ArgumentParser(description=DESCRIPTION)
parser.add_argument('-i', '--interface', help="capture interface")
parser.add_argument('-t', '--time', default='iso', help="output time
format (unix, iso)")
parser.add_argument('-o', '--output', default='probemon.log',
help="logging output location")
parser.add_argument('-b', '--max-bytes', default=5000000, help="maximum log size in bytes before rotating")
parser.add_argument('-c', '--max-backups', default=99999, help="maximum number of log files to keep")
parser.add_argument('-d', '--delimiter', default='\t', help="output field delimiter")
parser.add_argument('-f', '--mac-info', action='store_true', help="include MAC address manufacturer")
parser.add_argument('-s', '--ssid', action='store_true', help="include probe SSID in output")
parser.add_argument('-r', '--rssi', action='store_true', help="include rssi in output")
parser.add_argument('-D', '--debug', action='store_true', help="enable debug output")
parser.add_argument('-l', '--log', action='store_true', help="enable scrolling live view of the logfile")
args = parser.parse_args()

if not args.interface:
print "error: capture interface not given, try --help"
sys.exit(-1)

DEBUG = args.debug

# setup our rotating logger
logger = logging.getLogger(NAME)
logger.setLevel(logging.INFO)
handler = RotatingFileHandler(args.output, maxBytes=args.max_bytes,
backupCount=args.max_backups)
logger.addHandler(handler)
if args.log:
logger.addHandler(logging.StreamHandler(sys.stdout))
built_packet_cb = build_packet_callback(args.time, logger,
args.delimiter, args.mac_info, args.ssid, args.rssi)
sniff(iface=args.interface, prn=built_packet_cb, store=0)

if __name__ == '__main__':
main()

运行命令“pythonprobemon.py -i wlan1mon -t unix -”后,我收到错误“probemon.py:错误:参数-f/--mac-info:忽略显式参数'-s-r-l'” o ~/WonderHowTo -f -s -r -l"。任何帮助将非常感激。提前谢谢大家。这是一个 wifi 探针记录器程序。链接 https://null-byte.wonderhowto.com/how-to/log-wi-fi-probe-requests-from-smartphones-laptops-with-probemon-0176303/有助于理解。

最佳答案

从错误消息来看,您似乎没有用空格分隔参数(即使您的命令在这里看起来很好),例如:

pythonprobemon.py -i wlan1mon -t unix -o ~/WonderHowTo -f-s-r-l

这就是“忽略显式参数”错误的来源。您可以尝试:

pythonprobemon.py -i wlan1mon -t unix -o ~/WonderHowTo -fsrl

您还应该为这些参数添加 default=True 并尝试一下。

您可以做的最后一件事是尝试使用扩展别名设置参数:

pythonprobemon.py -i wlan1mon -t unix -o ~/WonderHowTo --mac-info --ssid --rssi --log

关于python - 探针.py : error: argument -f/--mac-info: Ignored explicit argument '-s-r-l' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47217673/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com