本文整理汇总了Python中scapy.layers.dot11.Dot11Elt方法的典型用法代码示例。如果您正苦于以下问题:Python dot11.Dot11Elt方法的具体用法?Python dot11.Dot11Elt怎么用?Python dot11.Dot11Elt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scapy.layers.dot11
的用法示例。
在下文中一共展示了dot11.Dot11Elt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: packet_handler
# 需要导入模块: from scapy.layers import dot11 [as 别名]
# 或者: from scapy.layers.dot11 import Dot11Elt [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: ap_call
# 需要导入模块: from scapy.layers import dot11 [as 别名]
# 或者: from scapy.layers.dot11 import Dot11Elt [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)
示例3: call1
# 需要导入模块: from scapy.layers import dot11 [as 别名]
# 或者: from scapy.layers.dot11 import Dot11Elt [as 别名]
def call1(self, pkt):
if pkt.haslayer(Dot11Beacon):
bssid = str(pkt.getlayer(Dot11).addr2)
essid = str(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.ntwk_call_1[str(bssid)] = [essid, 0, 0, '', 0, '', '', '', pwrCall(pkt)] # essid[0], beacon[1], data[2], security[3], channel[4], cipher[5], auth[6]
self.ntwk_call_1[bssid][1] += 1
self.ntwk_call_1[bssid][5] = maccom(bssid)
elif pkt[Dot11].addr2 in self.counter_:
self.ntwk_call_1[bssid][8] = pwrCall(pkt)
self.ntwk_call_1[bssid][1] += 1
self.call1_ext(bssid, crypto, elem_layers, cap)
示例4: beac_shift
# 需要导入模块: from scapy.layers import dot11 [as 别名]
# 或者: from scapy.layers.dot11 import Dot11Elt [as 别名]
def beac_shift(self, pkt):
if pkt.haslayer(Dot11Beacon):
bssid = pkt.getlayer(Dot11).addr2
cap = pkt.sprintf("{Dot11Beacon:%Dot11Beacon.cap%}").split('+')
ELTLAYERS = pkt.getlayer(Dot11Elt)
if bssid not in self.bss_counter:
self.bss_counter.append(bssid)
layer_data__ = self.enc_shift(cap, ELTLAYERS)
s_or_n = self.filtertify(bssid.lower(), layer_data__)
if s_or_n:
self.cells.append({'essid': unicode(layer_data__['essid']), 'bssid': unicode(bssid), 'channel': unicode(layer_data__['channel']), 'auth': unicode(layer_data__['auth']), \
'cipher': unicode(layer_data__['cipher']), 'psk': unicode(layer_data__['psk']), 'pwr': self.dBM_sig(pkt), 'beacon': pkt, 'vendor': unicode(org(bssid).org), 'clients': 0})
self.__ALSA_CLIENTS[bssid] = []
else:
for ap in self.cells:
if ap['bssid'] == bssid:
ap['pwr'] = self.dBM_sig(pkt)
示例5: ap_call_filtered
# 需要导入模块: from scapy.layers import dot11 [as 别名]
# 或者: from scapy.layers.dot11 import Dot11Elt [as 别名]
def ap_call_filtered(self, bool_, tgt):
if bool_ == "YES":
tabulator__ = []
for pkt in self.pkts:
if pkt.haslayer(Dot11Beacon):
essid = pkt.getlayer(Dot11Elt).info
obj = re.search(tgt, essid, re.I)
if obj:
bssid = pkt.getlayer(Dot11).addr2
tabulator__.append([bssid.upper(), color.DARKCYAN+essid.upper()+color.END])
if len(tabulator__) > 0:
return "\n\n"+tabulate(tabulator__, headers=[color.BOLD+'BSSID','ESSID'+color.END], tablefmt="simple")
示例6: enumerate_asso_fields
# 需要导入模块: from scapy.layers import dot11 [as 别名]
# 或者: from scapy.layers.dot11 import Dot11Elt [as 别名]
def enumerate_asso_fields(self, pkt):
elts = pkt.getlayer(Dot11Elt)
__data, count = {}, 0
try:
while isinstance(elts[count], Dot11Elt):
if elts[count].ID == 0 or elts[count].ID == 1 or elts[count].ID == 48 or elts[count].ID == 5 or elts[count].ID == 50 or elts[count].ID == 221: #ESSID #Rates
__data[ elts[count].ID ] = {'ID': elts[count].ID, 'len': elts[count].len, 'info': elts[count].info}
count += 1
except IndexError:
pass
return __data
示例7: form_asso_layers
# 需要导入模块: from scapy.layers import dot11 [as 别名]
# 或者: from scapy.layers.dot11 import Dot11Elt [as 别名]
def form_asso_layers(self, efields, _pkt):
_st_layer = _pkt
for fie, val in efields.items():
if fie == 0 or fie == 1 or fie == 5 or fie == 48 or fie ==50 or fie == 221:
_st_layer = _st_layer / Dot11Elt(ID=val['ID'], len=val['len'], info=val['info'])
return _st_layer
示例8: _is_target
# 需要导入模块: from scapy.layers import dot11 [as 别名]
# 或者: from scapy.layers.dot11 import Dot11Elt [as 别名]
def _is_target(self, packet):
"""
Check if this is the target attacking bssid
:param self: A Deauth object
:param packet: A scapy.layers.RadioTap object
:type self: Deauth
:type packet: scapy.layers.RadioTap
:return: True if this is the target attacking bssid else False
:rtype: bool
"""
if (packet.addr3 != self._data.rogue_ap_mac
and packet.addr3 not in self._deauth_bssids):
try:
essid = packet[dot11.Dot11Elt].info.decode("utf8")
except UnicodeDecodeError:
logger.warning("Unable to decode the essid with with bssid %s",
packet.addr3)
return False
# only compare essid when -dE is given
return ((self._data.args.deauth_essid
and essid == self._data.args.deauth_essid) or
# frenzy deauth
(not self._data.args.deauth_essid
and not self._data.target_ap_bssid) or
# target_ap_bssid without -dE option
(not self._data.args.deauth_essid
and self._data.target_ap_bssid == packet.addr3) or False)
示例9: get_packet
# 需要导入模块: from scapy.layers import dot11 [as 别名]
# 或者: from scapy.layers.dot11 import Dot11Elt [as 别名]
def get_packet(self, pkt):
"""
We start broadcasting the beacons on the first received packet
:param self: A Knownbeacons object
:param packet: A scapy.layers.RadioTap object
:type self: Knownbeacons
:type packet: scapy.layers.RadioTap
:return: A tuple containing ["*"] followed by a list of
the crafted beacon frames
:rtype: tuple(list, list)
.. warning: pkt is not used here but should not be removed since
this prototype is requirement
"""
# If INTERVAL seconds have passed...
if (time.time() - self._starttime > constants.KB_INTERVAL):
# Do a list shift
self._full_pkt_list = self._full_pkt_list[constants.KB_BUCKET_SIZE:] + \
self._full_pkt_list[:constants.KB_BUCKET_SIZE]
self._starttime = time.time()
first_essid = self._full_pkt_list[0][dot11.Dot11Elt].info.decode("utf8")
last_essid = self._full_pkt_list[constants.KB_BUCKET_SIZE-1][dot11.Dot11Elt].info.decode("utf8")
self._msg.append("Sending %s known beacons (%s ... %s)" % \
(str(constants.KB_BUCKET_SIZE), first_essid, \
last_essid))
self._packets_to_send["*"] = self._full_pkt_list[:constants.KB_BUCKET_SIZE]
return self._packets_to_send
示例10: does_have_wpspbc_ie
# 需要导入模块: from scapy.layers import dot11 [as 别名]
# 或者: from scapy.layers.dot11 import Dot11Elt [as 别名]
def does_have_wpspbc_ie(packet):
"""
Check if the pbc button is being pressed
:param self: A Wpspbc object
:param packet: A scapy.layers.RadioTap object
:type self: Wpspbc
:type packet: scapy.layers.RadioTap
:return: None
:rtype: None
"""
elt_section = packet[dot11.Dot11Elt]
while isinstance(elt_section, dot11.Dot11Elt):
# check if WPS IE exists
if elt_section.ID == 221 and\
elt_section.info.startswith("\x00P\xf2\x04"):
# strip the starting 4 bytes
wps_ie_array = [ord(val) for val in elt_section.info[4:]]
pos = 0
# start looping to find the WPS PBC IE
while pos < len(wps_ie_array):
if wps_ie_array[pos] == 0x10 and wps_ie_array[pos
+ 1] == 0x12:
return True
else:
data_len = (
wps_ie_array[pos + 2] << 8) + wps_ie_array[pos + 3]
# jump to the next data element by adding
# the len of type/length/data
pos += (2 + 2 + data_len)
break
elt_section = elt_section.payload
return False
示例11: setUp
# 需要导入模块: from scapy.layers import dot11 [as 别名]
# 或者: from scapy.layers.dot11 import Dot11Elt [as 别名]
def setUp(self):
""" Set up the tests """
essid = dot11.Dot11Elt(ID='SSID', info="")
rates = dot11.Dot11Elt(ID='Rates', info="\x03\x12\x96\x18\x24\x30\x48\x60")
dsset = dot11.Dot11Elt(ID='DSset', info='\x06')
self.packet = dot11.RadioTap() / dot11.Dot11() / essid / rates / dsset
custom_tuple = collections.namedtuple("test",
("target_ap_bssid target_ap_channel rogue_ap_mac args "
"target_ap_essid is_freq_hop_allowed"))
self.target_channel = "6"
self.target_bssid = "BB:BB:BB:BB:BB:BB"
self.rogue_mac = "CC:CC:CC:CC:CC:CC"
self.target_essid = "Evil"
self.args = mock.Mock()
self.args.deauth_essid = False
self.args.channel_monitor = False
self.args.deauth_channels = []
data0 = custom_tuple(self.target_bssid, self.target_channel, self.rogue_mac,
self.args, self.target_essid, True)
data1 = custom_tuple(None, self.target_channel, self.rogue_mac,
self.args, self.target_essid, True)
self.deauth_obj0 = deauth.Deauth(data0)
self.deauth_obj1 = deauth.Deauth(data1)
# test for --deauth-essid
self.deauth_obj0._deauth_bssids = dict()
self.deauth_obj1._deauth_bssids = dict()
示例12: test_get_packet_broadcast
# 需要导入模块: from scapy.layers import dot11 [as 别名]
# 或者: from scapy.layers.dot11 import Dot11Elt [as 别名]
def test_get_packet_broadcast(self):
"""
Test get_packet method for crafting the broadcast frame
"""
# setup the packet
sender = "00:00:00:00:00:00"
receiver = "11:11:11:11:11:11"
essid = dot11.Dot11Elt(ID='SSID', info="")
rates = dot11.Dot11Elt(ID='Rates', info="\x03\x12\x96\x18\x24\x30\x48\x60")
dsset = dot11.Dot11Elt(ID='DSset', info='\x06')
packet = dot11.RadioTap() / dot11.Dot11() / dot11.Dot11Beacon() / essid / rates / dsset
packet.addr1 = receiver
packet.addr2 = sender
packet.addr3 = self.target_bssid
packet.FCfield = 0x0
# run the method
pkts_to_send = self.deauth_obj0.get_packet(packet)
message0 = "Failed to return an correct channel"
message1 = "Failed to return an correct packets"
# check channel: target channel should be one key of
# the result
self.assertEqual(self.target_channel in pkts_to_send, True,
message0)
# check the packets
# check the disassoction packet
result = pkts_to_send[self.target_channel]
self.assertEqual(result[0].subtype, 10, message1)
self.assertEqual(result[0].addr1, constants.WIFI_BROADCAST, message1)
self.assertEqual(result[0].addr2, self.target_bssid, message1)
self.assertEqual(result[0].addr3, self.target_bssid, message1)
# check the deauthentication packet
self.assertEqual(result[1].subtype, 12, message1)
self.assertEqual(result[1].addr1, constants.WIFI_BROADCAST, message1)
self.assertEqual(result[1].addr2, self.target_bssid, message1)
self.assertEqual(result[1].addr3, self.target_bssid, message1)
示例13: test_is_target_target_ap_bssid_true
# 需要导入模块: from scapy.layers import dot11 [as 别名]
# 或者: from scapy.layers.dot11 import Dot11Elt [as 别名]
def test_is_target_target_ap_bssid_true(self):
"""
Get the target attacking bssid for the speficic ESSID
when --essid is not used
"""
essid = dot11.Dot11Elt(ID='SSID', info="Evil")
packet = dot11.RadioTap() / dot11.Dot11() / dot11.Dot11Beacon() / essid
packet.addr3 = "99:99:99:99:99:99"
self.deauth_obj0._data.args.deauth_essid = "Evil"
result = self.deauth_obj0._is_target(packet)
expected = True
message = "Fail to check the attacking essid: " + self.target_essid
self.assertEqual(result, expected, message)
示例14: test_is_target_essid_non_decodable_error
# 需要导入模块: from scapy.layers import dot11 [as 别名]
# 或者: from scapy.layers.dot11 import Dot11Elt [as 别名]
def test_is_target_essid_non_decodable_error(self):
"""
Assign essid to a constant when it is utf-8 non-decodable
"""
essid = dot11.Dot11Elt(ID='SSID', info='\x99\x87\x33')
packet = dot11.RadioTap() / dot11.Dot11() / dot11.Dot11Beacon() / essid
packet.addr3 = "99:99:99:99:99:99"
result = self.deauth_obj0._is_target(packet)
expected = False
message = 'Fail to raise the UnicodeDecodeError for non-printable essid'
self.assertEqual(result, expected, message)
示例15: set_privacy
# 需要导入模块: from scapy.layers import dot11 [as 别名]
# 或者: from scapy.layers.dot11 import Dot11Elt [as 别名]
def set_privacy(self, value):
"""
Configure the privacy settings for None, WEP, and WPA
"""
if value == PRIVACY_NONE:
self.beacon = (
RadioTap()/
Dot11(addr1="ff:ff:ff:ff:ff:ff", addr2=self.bssid, addr3=self.bssid)/
Dot11Beacon(cap='ESS+short-preamble+short-slot')/
Dot11Elt(ID="SSID", info=self.essid)/
Dot11Elt(ID="Rates", info='\x82\x84\x8b\x96\x0c\x12\x18\x24')/
Dot11Elt(ID="DSset", info=self.channel)/
Dot11Elt(ID=42, info="\x04")/
Dot11Elt(ID=47, info="\x04")/
Dot11Elt(ID=50, info="\x0c\x12\x18\x60")
)
elif value == PRIVACY_WEP:
self.beacon = (
RadioTap()/
Dot11(addr1="ff:ff:ff:ff:ff:ff", addr2=self.bssid, addr3=self.bssid)/
Dot11Beacon(cap='ESS+privacy+short-preamble+short-slot')/
Dot11Elt(ID="SSID", info=self.essid)/
Dot11Elt(ID="Rates", info='\x82\x84\x8b\x96\x0c\x12\x18\x24')/
Dot11Elt(ID="DSset", info=self.channel)/
Dot11Elt(ID=42, info="\x04")/
Dot11Elt(ID=47, info="\x04")/
Dot11Elt(ID=50, info="\x0c\x12\x18\x60")
)
elif value == PRIVACY_WPA:
self.beacon = (
RadioTap()/
Dot11(addr1="ff:ff:ff:ff:ff:ff", addr2=self.bssid, addr3=self.bssid)/
Dot11Beacon(cap='ESS+privacy+short-preamble+short-slot')/
Dot11Elt(ID="SSID", info=self.essid)/
Dot11Elt(ID="Rates", info='\x82\x84\x8b\x96\x0c\x12\x18\x24')/
Dot11Elt(ID="DSset", info=self.channel)/
Dot11Elt(ID=221, info="\x00\x50\xf2\x01\x01\x00" + "\x00\x50\xf2\x02" + "\x01\x00" + "\x00\x50\xf2\x02" + "\x01\x00" + "\x00\x50\xf2\x01")/
Dot11Elt(ID=42, info="\x00")/
Dot11Elt(ID=50, info="\x30\x48\x60\x6c")/
Dot11Elt(ID=221, info="\x00\x50\xf2\x02\x01\x01\x84\x00\x03\xa4\x00\x00\x27\xa4\x00\x00\x42\x43\x5e\x00\x62\x32\x2f\x00")
)