本文整理汇总了Python中scapy.layers.dot11.Dot11方法的典型用法代码示例。如果您正苦于以下问题:Python dot11.Dot11方法的具体用法?Python dot11.Dot11怎么用?Python dot11.Dot11使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scapy.layers.dot11
的用法示例。
在下文中一共展示了dot11.Dot11方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: packet_handler
# 需要导入模块: from scapy.layers import dot11 [as 别名]
# 或者: from scapy.layers.dot11 import Dot11 [as 别名]
def packet_handler(packet):
if packet.haslayer(Dot11) and packet.type == 0 and packet.subtype == 8:
try:
ssid = packet.info.decode("utf-8")
mac_address = str(packet.addr2)
channel = int(ord(packet[Dot11Elt:3].info))
if not endpoints.get(mac_address) and not ssid == "":
if CONFIG.print_all:
print_endpoint(ssid, mac_address, channel)
if is_tp_link(ssid):
password = get_password(mac_address)
print_endpoint(ssid, mac_address,
channel, password=password)
add_endpoint(ssid, mac_address, password=password)
else:
add_endpoint(ssid, mac_address)
except (UnicodeDecodeError, AttributeError, TypeError, IndexError, AttributeError):
pass
示例2: enBuilder
# 需要导入模块: from scapy.layers import dot11 [as 别名]
# 或者: from scapy.layers.dot11 import Dot11 [as 别名]
def enBuilder(self, pkt, stream, iVal):
## Remove the LLC layer
del pkt[LLC]
## Add the Dot11WEP layer
encodedPacket = pkt/Dot11WEP(iv = iVal, keyid = 0, wepdata = stream)
## Flip FCField bits accordingly
if encodedPacket[Dot11].FCfield == 1:
encodedPacket[Dot11].FCfield = 65
elif encodedPacket[Dot11].FCfield == 2:
encodedPacket[Dot11].FCfield = 66
## Add the ICV
#encodedPacket[Dot11WEP].icv = int(self.pt.endSwap(hex(crc32(str(encodedPacket[Dot11])[0:-4]) & 0xffffffff)), 16)
encodedPacket[Dot11WEP].icv = int(self.pt.fcsGen(encodedPacket[Dot11], end = -4), 16)
return encodedPacket
示例3: ap_call
# 需要导入模块: from scapy.layers import dot11 [as 别名]
# 或者: from scapy.layers.dot11 import Dot11 [as 别名]
def ap_call(self):
# Main Network Place
for pkt in self.pkts:
if pkt.haslayer(Dot11Beacon):
bssid = pkt.getlayer(Dot11).addr2
essid = pkt.getlayer(Dot11Elt).info
essid = re.sub(r'[^\w]', '', essid)
cap = pkt.sprintf("{Dot11Beacon:%Dot11Beacon.cap%}").split('+')
elem_layers = pkt.getlayer(Dot11Elt)
crypto = set()
if pkt.getlayer(Dot11).addr2 not in self.counter_:
self.counter_.append(bssid)
self.ap_call_[str(bssid)] = [essid, 0, 0, '', 0, '', '', ''] # essid[0], beacon[1], data[2], security[3], channel[4], cipher[5], auth[6]
self.ap_call_[bssid][1] += 1
self.ap_call_[bssid][5] = maccom(bssid)
elif pkt[Dot11].addr2 in self.counter_:
self.ap_call_[bssid][1] += 1
self.ap_call_ext(elem_layers, bssid, crypto, cap)
示例4: ap_data_call
# 需要导入模块: from scapy.layers import dot11 [as 别名]
# 或者: from scapy.layers.dot11 import Dot11 [as 别名]
def ap_data_call(self):
for pkt in self.pkts:
if pkt.haslayer(Dot11) and pkt.getlayer(Dot11).type == 2L:
st = pkt.getlayer(Dot11).addr2
rv = pkt.getlayer(Dot11).addr1
for dev in self.counter_:
if dev == st:
try:
self.ap_call_[st][2] += 1
except KeyError:
pass
elif dev == rv:
try:
self.ap_call_[rv][2] += 1
except KeyError:
pass
return
示例5: ap_call_handshake
# 需要导入模块: from scapy.layers import dot11 [as 别名]
# 或者: from scapy.layers.dot11 import Dot11 [as 别名]
def ap_call_handshake(self):
eapol_list, tabulator__ = [], []
for pkt in self.pkts:
if pkt.haslayer(EAPOL):
sender = pkt.getlayer(Dot11).addr2
receiver = pkt.getlayer(Dot11).addr1
for dev in self.counter_:
if sender == dev and receiver not in eapol_list:
handshake = receiver
ap = sender
eapol_list.append(handshake)
tabulator__.append([ap.upper(), color.YELLOW+handshake.upper()+color.END])
elif receiver == dev and sender not in eapol_list:
handshake = sender
ap = receiver
eapol_list.append(handshake)
tabulator__.append([ap.upper(), color.YELLOW+handshake.upper()+color.END])
else:
pass
if self.has_handshakes():
return "\n"+tabulate(tabulator__, headers=['BSSID', 'HANDSHAKE'], tablefmt="simple")+"\n"
return "\n"
示例6: ap_call_clients
# 需要导入模块: from scapy.layers import dot11 [as 别名]
# 或者: from scapy.layers.dot11 import Dot11 [as 别名]
def ap_call_clients(self):
for pkt in self.pkts:
if pkt.haslayer(Dot11) and pkt.getlayer(Dot11).type == 2L and not pkt.haslayer(EAPOL):
sender = pkt.getlayer(Dot11).addr2
receiver = pkt.getlayer(Dot11).addr3
for dev in self.counter_:
if dev == sender and receiver not in self.cl_counter:
ap = sender
cl = receiver
self.cl_counter.append(cl)
self.ap_call_2[cl] = [ap, str(pwrCall(pkt)), 1, maccom(cl)]
elif dev == sender and receiver in self.cl_counter:
self.ap_call_2[receiver][2] += 1
self.ap_call_2[receiver][1] = pwrCall(pkt)
elif dev == receiver and sender not in self.cl_counter:
ap = receiver
cl = sender
self.cl_counter.append(cl)
self.ap_call_2[cl] = [ap, str(pwrCall(pkt)), 1, maccom(cl)]
elif dev == receiver and sender in self.cl_counter:
self.ap_call_2[sender][2] += 1
self.ap_call_2[sender][1] = pwrCall(pkt)
else:
pass
示例7: call3
# 需要导入模块: from scapy.layers import dot11 [as 别名]
# 或者: from scapy.layers.dot11 import Dot11 [as 别名]
def call3(self, pkt):
eapol_list, tabulator__ = [], []
if pkt.haslayer(EAPOL):
sender = pkt.getlayer(Dot11).addr2
receiver = pkt.getlayer(Dot11).addr1
for dev in self.counter_:
if sender == dev and receiver not in eapol_list:
handshake = receiver
ap = sender
eapol_list.append(handshake)
tabulator__.append(ap)
tabulator__.append(handshake)
self.handshakes += 1
elif receiver == dev and sender not in eapol_list:
handshake = sender
ap = receiver
eapol_list.append(handshake)
tabulator__.append(ap)
tabulator__.append(handshake)
self.handshakes += 1
else:
pass
return tabulator__
示例8: call4
# 需要导入模块: from scapy.layers import dot11 [as 别名]
# 或者: from scapy.layers.dot11 import Dot11 [as 别名]
def call4(self, pkt):
tabulator = []
if pkt.haslayer(Dot11) and pkt.getlayer(Dot11).type == 2L and not pkt.haslayer(EAPOL):
sender = pkt.getlayer(Dot11).addr2
receiver = pkt.getlayer(Dot11).addr3
for dev in self.counter_:
if dev == sender and receiver not in self.cl_counter:
ap = sender
cl = receiver
self.cl_counter.append(cl)
self.ntwk_call_4[cl] = [ap, str(pwrCall(pkt)), 1, maccom(cl)]
elif dev == sender and receiver in self.cl_counter:
self.ntwk_call_4[receiver][2] += 1
self.ntwk_call_4[receiver][1] = pwrCall(pkt)
elif dev == receiver and sender not in self.cl_counter:
ap = receiver
cl = sender
self.cl_counter.append(cl)
self.ntwk_call_4[cl] = [ap, str(pwrCall(pkt)), 1, maccom(cl)]
elif dev == receiver and sender in self.cl_counter:
self.ntwk_call_4[sender][2] += 1
self.ntwk_call_4[sender][1] = pwrCall(pkt)
else:
pass
示例9: organizer
# 需要导入模块: from scapy.layers import dot11 [as 别名]
# 或者: from scapy.layers.dot11 import Dot11 [as 别名]
def organizer(self):
self.ap = binascii.a2b_hex(self.pkt_i.getlayer(Dot11).addr2.replace(':','').lower())
self.cl = binascii.a2b_hex(self.pkt_i.getlayer(Dot11).addr1.replace(':','').lower())
self.aNONCE = binascii.a2b_hex(binascii.hexlify(self.pkt_i.getlayer(Raw).load)[26:90])
self.cNONCE = binascii.a2b_hex(binascii.hexlify(self.pkt_ii.getlayer(Raw).load)[26:90])
self.key_data = min(self.ap, self.cl) + max(self.ap, self.cl) + min(self.aNONCE, self.cNONCE) + max(self.aNONCE, self.cNONCE)
self.version = chr(self.pkt_ii.getlayer(EAPOL).version)
self.type = chr(self.pkt_ii.getlayer(EAPOL).type)
self.len = chr(self.pkt_ii.getlayer(EAPOL).len)
self.payload = binascii.a2b_hex(binascii.hexlify(self.version\
+self.type\
+self.__NULL_\
+self.len\
+binascii.a2b_hex(binascii.hexlify(self.pkt_ii.getlayer(Raw).load)[:154])\
+self.__NULL_*16\
+binascii.a2b_hex(binascii.hexlify(self.pkt_ii.getlayer(Raw).load)[186:])))
self.data = self.version\
+self.type\
+self.__NULL_\
+self.len\
+self.pkt_ii.getlayer(Raw).load
示例10: get_auth_resp
# 需要导入模块: from scapy.layers import dot11 [as 别名]
# 或者: from scapy.layers.dot11 import Dot11 [as 别名]
def get_auth_resp(self, pkt):
if pkt.haslayer(RadioTap):
if pkt.haslayer(Dot11Auth):
sn = pkt.getlayer(Dot11).addr2.replace(':', '')
rc = pkt.getlayer(Dot11).addr1.replace(':', '')
if rc == self.cl.replace(':', '') and sn == self.ap.replace(':', ''):
if self.verbose:
self.pull.info("Received %s (%s) %s<%s %s (%s) %s[Open Authentication]%s" % \
(self.cl.replace(':', '').upper(), self.pull.DARKCYAN+org(self.cl).org+self.pull.END, self.pull.RED, self.pull.END, self.ap.replace(':', '').upper(),\
self.pull.DARKCYAN+org(self.ap).org+self.pull.END, self.pull.YELLOW, self.pull.END))
self.pull.info("Authentication %s (%s) %s>%s %s (%s) %s[SuccessFull]%s" % \
(self.ap.replace(':', '').upper(), self.pull.DARKCYAN+org(self.ap).org+self.pull.END, self.pull.RED, self.pull.END, self.cl.replace(':', '').upper(),\
self.pull.DARKCYAN+org(self.cl).org+self.pull.END, self.pull.GREEN, self.pull.END))
else:
self.pull.info("Received %s %s<%s %s %s[Open Authentication]%s" % (self.cl.replace(':', '').upper(), self.pull.RED, self.pull.END,\
self.ap.replace(':', '').upper(), self.pull.YELLOW, self.pull.END))
self.pull.info("Authentication %s %s>%s %s %s[SuccessFull]%s" % \
(self.ap.replace(':', '').upper(), self.pull.RED, self.pull.END, self.cl.replace(':', '').upper(),\
self.pull.GREEN, self.pull.END))
self.__AUTH_STEP = bool(1)
raise ValueError
示例11: clients_garbage
# 需要导入模块: from scapy.layers import dot11 [as 别名]
# 或者: from scapy.layers.dot11 import Dot11 [as 别名]
def clients_garbage(self, pkt):
if pkt.haslayer(Dot11) and pkt.getlayer(Dot11).type == 2L and not pkt.haslayer(EAPOL):
_sn = pkt.getlayer(Dot11).addr2
_rc = pkt.getlayer(Dot11).addr1
_tgt = None
if _sn in self.bss_counter:
_tgt, _ap = _rc, _sn
elif _rc in self.bss_counter:
_tgt, _ap = _sn, _rc
if _tgt and _tgt not in self.clients:
for cell in self.cells:
for _key, _val in cell.items():
if _key == 'bssid' and _val == _ap:
if not (_tgt.replace(':','').lower() in self.__BLACKLIST):
cell['clients'] += 1; self.clients.append(_tgt)
self.__ALSA_CLIENTS[_val].append( (_tgt, self.dBM_sig(pkt)) )
示例12: is_valid_handshake_frame
# 需要导入模块: from scapy.layers import dot11 [as 别名]
# 或者: from scapy.layers.dot11 import Dot11 [as 别名]
def is_valid_handshake_frame(packet):
"""
Check if the Dot11 packet is a valid EAPOL KEY frame
:param self: Handshakeverify object
:param packet: A scapy.layers.RadioTap object
:type self: Handshakeverify
:type packet: scapy.layers.RadioTap
:return True if this is an EAPOL KEY frame
:rtype: bool
"""
# pkt is Dot11 nad packet is not retried
if packet.haslayer(dot11.Dot11) and not packet.FCfield & (1 << 3):
# check it is key type eapol
if packet.haslayer(EAPOL) and packet[EAPOL].type == 3:
return True
return False
示例13: test_single_extension
# 需要导入模块: from scapy.layers import dot11 [as 别名]
# 或者: from scapy.layers.dot11 import Dot11 [as 别名]
def test_single_extension(self):
# We need a NM to init EM
nm = interfaces.NetworkManager()
# Init an EM and pass some shared data
em = extensions.ExtensionManager(nm)
em.set_extensions(constants.DEFAULT_EXTENSIONS)
shared_data = {"one": 1, "two": 2, "is_freq_hop_allowed": True}
em.init_extensions(shared_data)
# A deauth packet appears in the air
packet = (
dot11.RadioTap() /
dot11.Dot11(
type=0,
subtype=12,
addr1="00:00:00:00:00:00",
addr2="00:00:00:00:00:00",
addr3="00:00:00:00:00:00") /
dot11.Dot11Deauth())
em._process_packet(packet)
# The extension1.py sent packet "1" and returned output
# "one", "two". Validate with get_packet(), send_output()
assert em._packets_to_send["1"] == [1]
assert em._packets_to_send["2"] == []
assert em.get_output() == ["one", "two"]
示例14: wpaEncrypt
# 需要导入模块: from scapy.layers import dot11 [as 别名]
# 或者: from scapy.layers.dot11 import Dot11 [as 别名]
def wpaEncrypt(encKey, origPkt, decodedPkt, PN, genFCS = True):
"""Encompasses the steps needed to encrypt a WPA packet
No structure for TKIP has been done as of yet
"""
## Increment the PN positively per IEEE spec
PN[5] += 1
## Grab the payload of the decoded packet
dEverything = decodedPkt[LLC]
## Remove the FCS from the original packet
newPkt = RadioTap((pt.byteRip(origPkt.copy(),
chop = True,
order = 'last',
output = 'str',
qty = 4)))
del newPkt[Dot11WEP]
## The data is ready for encryption
newPkt = newPkt/dEverything
encodedPkt = ccmpCrypto.encryptCCMP(newPkt, encKey, PN, genFCS)
## Flip FCField bits accordingly
if encodedPkt[Dot11].FCfield == 1:
encodedPkt[Dot11].FCfield = 65
elif encodedPkt[Dot11].FCfield == 2:
encodedPkt[Dot11].FCfield = 66
return encodedPkt
### Instantiations
示例15: decoder
# 需要导入模块: from scapy.layers import dot11 [as 别名]
# 或者: from scapy.layers.dot11 import Dot11 [as 别名]
def decoder(self, pkt, tk):
"""Decrypt the packet"""
## If the packet has FCS, it should be removed and added later on.
if self.hasFCS(pkt):
pload = self.pt.byteRip(pkt[Dot11WEP],
order = 'last',
qty = 4,
chop = True,
output = 'str')
else:
pload = str(pkt[Dot11WEP])
## The minimum valid TKIP packet has 21 bytes
if(len(pload) <= 20):
return
## Address required to calculate RC4 key
addr = bytearray(re.sub(':','', pkt[Dot11].addr2).decode("hex"))
#print bytearray(pload)
#print addr
#print tk
key = self.generateRC4Key(bytearray(pload), addr, tk)
## Decrypt packet
stream = self.rc4(bytearray(str(pload)), key)
## Check if decrypted CRC is correct. If it's not, ignore the packet.
dlen = len(stream)
crc = crc32(str(stream[:-12]))
### This is an issue, work it out later
#if (stream[dlen - 12] != (crc & 0xff) or
#stream[dlen - 11] != ((crc >> 8) & 0xff) or
#stream[dlen - 10] != ((crc >> 16) & 0xff) or
#stream[dlen - 9] != ((crc >> 24) & 0xff)):
#return
return stream