2017-09-17 2 views
1

나는이 책을 폭력적인 python이라고하며, CH5에서는 스크립트를 작성하여 아이폰 wifi 쪽의 mac 주소를 찾는다. 마지막 바이트를 1 씩 증가시켜 블루투스가 켜져 있는지 확인하십시오. 기본적으로 숨겨진 모드에서 블루투스가있는 아이폰을 찾으십시오.Python scapy prn send rcv error

왜 그런 스크립트 오류가 발생하는지 혼란 스럽습니다. 앞으로이 오류가 발생하지 않도록하려면 어떻게해야합니까?

#!/usr/bin/python 
# -*- coding: utf-8 -*- 

from scapy.all import * 
from bluetooth import * 


def retBtAddr(addr): 
    btAddr=str(hex(int(addr.replace(':', ''), 16) + 1))[2:] 
    btAddr=btAddr[0:2]+":"+btAddr[2:4]+":"+btAddr[4:6]+":"+\ 
    btAddr[6:8]+":"+btAddr[8:10]+":"+btAddr[10:12] 
    return btAddr 

def checkBluetooth(btAddr): 
    btName = lookup_name(btAddr) 
    if btName: 
     print '[+] Detected Bluetooth Device: ' + btName 
    else: 
     print '[-] Failed to Detect Bluetooth Device.' 


def wifiPrint(pkt): 
    iPhone_OUI = 'd0:23:db' 
    if pkt.haslayer(Dot11): 
     wifiMAC = pkt.getlayer(Dot11).addr2 
     if iPhone_OUI == wifiMAC[:8]: 
      print '[*] Detected iPhone MAC: ' + wifiMAC 
      btAddr = retBtAddr(wifiMAC) 
      print '[+] Testing Bluetooth MAC: ' + btAddr 
      checkBluetooth(btAddr) 


conf.iface = 'wlan1mon' 
sniff(prn=wifiPrint) 

에러 메시지 나 수신 : 다음

아래 스크립트

sudo python 10-iphoneFinder.py 
Traceback (most recent call last): 
    File "10-iphoneFinder.py", line 34, in <module> 
    sniff(prn=wifiPrint) 
    File "/home/rb/.local/lib/python2.7/site-packages/scapy/sendrecv.py", line 620, in sniff 
    r = prn(p) 
    File "10-iphoneFinder.py", line 26, in wifiPrint 
    if iPhone_OUI == wifiMAC[:8]: 
TypeError: 'NoneType' object has no attribute '__getitem__' 
Scapy에서

답변

0

에서, Dot11 층의 addr2 필드가 조건부 필드이므로은 할 수도 스니핑 된 패킷에 해당 필드가없는 경우 값은 None입니다. 적어도 말을, 스크립트가 정말 잘 코딩되지 않은 보조 노트로

IPHONE_OUI = 'd0:23:db:' 

def wifiPrint(pkt): 
    if Dot11 in pkt: 
     wifiMAC = pkt[Dot11].addr2 
     if wifiMAC is not None and wifiMAC.startswith(IPHONE_OUI): 
      print '[*] Detected iPhone MAC: ' + wifiMAC 
      btAddr = retBtAddr(wifiMAC) 
      print '[+] Testing Bluetooth MAC: ' + btAddr 
      checkBluetooth(btAddr) 

: 여기

우리가 wifiPrint() 기능을 쓸 수있는 방법이다. 어쩌면 Scapy (또는 파이썬)를 배울 수있는 좋은 아이디어는 아닙니다.