- ability to give a WEP key as an argument to unwep()

This commit is contained in:
pbi 2005-05-25 13:15:10 +00:00
parent 79fa9982eb
commit b6ebdce850
1 changed files with 12 additions and 7 deletions

View File

@ -21,6 +21,9 @@
# #
# $Log: scapy.py,v $ # $Log: scapy.py,v $
# Revision 0.9.17.96 2005/05/25 15:15:10 pbi
# - ability to give a WEP key as an argument to unwep()
#
# Revision 0.9.17.95 2005/05/25 15:05:03 pbi # Revision 0.9.17.95 2005/05/25 15:05:03 pbi
# - fixed pcap supersockets warnings # - fixed pcap supersockets warnings
# #
@ -782,7 +785,7 @@
from __future__ import generators from __future__ import generators
RCSID="$Id: scapy.py,v 0.9.17.95 2005/05/25 15:05:03 pbi Exp $" RCSID="$Id: scapy.py,v 0.9.17.96 2005/05/25 15:15:10 pbi Exp $"
VERSION = RCSID.split()[2]+"beta" VERSION = RCSID.split()[2]+"beta"
@ -4499,14 +4502,14 @@ class Dot11(Packet):
return Dot11WEP return Dot11WEP
else: else:
return Packet.guess_payload_class(self) return Packet.guess_payload_class(self)
def unwep(self, warn=1): def unwep(self, key=None, warn=1):
if self.FCfield & 0x40 == 0: if self.FCfield & 0x40 == 0:
if warn: if warn:
warning("No WEP to remove") warning("No WEP to remove")
return return
if isinstance(self.payload.payload, NoPayload): if isinstance(self.payload.payload, NoPayload):
if conf.wepkey: if key or conf.wepkey:
self.payload.decrypt() self.payload.decrypt(key)
if isinstance(self.payload.payload, NoPayload): if isinstance(self.payload.payload, NoPayload):
if warn: if warn:
warning("Dot11 can't be decrypted. Check conf.wepkey.") warning("Dot11 can't be decrypted. Check conf.wepkey.")
@ -4606,9 +4609,11 @@ class Dot11WEP(Packet):
def post_dissect(self, s): def post_dissect(self, s):
self.decrypt() self.decrypt()
def decrypt(self): def decrypt(self,key=None):
if conf.wepkey: if key is None:
c = ARC4.new(self.iv+conf.wepkey) key = conf.wepkey
if key:
c = ARC4.new(self.iv+key)
self.add_payload(LLC(c.decrypt(self.wepdata[:-4]))) self.add_payload(LLC(c.decrypt(self.wepdata[:-4])))