mirror of https://github.com/secdev/scapy.git
- added LEIntField and StrFixedLenField
- added partial PrismHeader support
This commit is contained in:
parent
25823bf32a
commit
858833c4e4
44
scapy.py
44
scapy.py
|
@ -22,6 +22,10 @@
|
||||||
|
|
||||||
#
|
#
|
||||||
# $Log: scapy.py,v $
|
# $Log: scapy.py,v $
|
||||||
|
# Revision 0.9.16.7 2004/06/07 09:20:43 pbi
|
||||||
|
# - added LEIntField and StrFixedLenField
|
||||||
|
# - added partial PrismHeader support
|
||||||
|
#
|
||||||
# Revision 0.9.16.6 2004/04/29 15:46:19 pbi
|
# Revision 0.9.16.6 2004/04/29 15:46:19 pbi
|
||||||
# - fixed fragment()
|
# - fixed fragment()
|
||||||
#
|
#
|
||||||
|
@ -363,7 +367,7 @@
|
||||||
|
|
||||||
from __future__ import generators
|
from __future__ import generators
|
||||||
|
|
||||||
RCSID="$Id: scapy.py,v 0.9.16.6 2004/04/29 15:46:19 pbi Exp $"
|
RCSID="$Id: scapy.py,v 0.9.16.7 2004/06/07 09:20:43 pbi Exp $"
|
||||||
|
|
||||||
VERSION = RCSID.split()[2]+"beta"
|
VERSION = RCSID.split()[2]+"beta"
|
||||||
|
|
||||||
|
@ -985,7 +989,10 @@ class Field:
|
||||||
islist=0
|
islist=0
|
||||||
def __init__(self, name, default, fmt="H"):
|
def __init__(self, name, default, fmt="H"):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.fmt = "!"+fmt
|
if fmt[0] in "@=<>!":
|
||||||
|
self.fmt = fmt
|
||||||
|
else:
|
||||||
|
self.fmt = "!"+fmt
|
||||||
self.default = self.any2i(None,default)
|
self.default = self.any2i(None,default)
|
||||||
self.sz = struct.calcsize(self.fmt)
|
self.sz = struct.calcsize(self.fmt)
|
||||||
|
|
||||||
|
@ -1222,6 +1229,10 @@ class IntField(Field):
|
||||||
def __init__(self, name, default):
|
def __init__(self, name, default):
|
||||||
Field.__init__(self, name, default, "I")
|
Field.__init__(self, name, default, "I")
|
||||||
|
|
||||||
|
class LEIntField(Field):
|
||||||
|
def __init__(self, name, default):
|
||||||
|
Field.__init__(self, name, default, "@I")
|
||||||
|
|
||||||
class XIntField(IntField):
|
class XIntField(IntField):
|
||||||
def i2repr(self, pkt, x):
|
def i2repr(self, pkt, x):
|
||||||
if x is None:
|
if x is None:
|
||||||
|
@ -1251,6 +1262,16 @@ class StrField(Field):
|
||||||
def getfield(self, pkt, s):
|
def getfield(self, pkt, s):
|
||||||
return "",s
|
return "",s
|
||||||
|
|
||||||
|
class StrFixedLenField(StrField):
|
||||||
|
def __init__(self, name, default, length):
|
||||||
|
StrField.__init__(self, name, default)
|
||||||
|
self.length = length
|
||||||
|
def getfield(self, pkt, s):
|
||||||
|
return s[self.length:], self.m2i(pkt,s[:self.length])
|
||||||
|
def addfield(self, pkt, s, val):
|
||||||
|
return s+struct.pack("16s",self.i2m(pkt, val))
|
||||||
|
|
||||||
|
|
||||||
class StrLenField(StrField):
|
class StrLenField(StrField):
|
||||||
def __init__(self, name, default, fld):
|
def __init__(self, name, default, fld):
|
||||||
StrField.__init__(self, name, default)
|
StrField.__init__(self, name, default)
|
||||||
|
@ -2773,6 +2794,21 @@ class Dot11Deauth(Packet):
|
||||||
name = "802.11 Deauthentication"
|
name = "802.11 Deauthentication"
|
||||||
fields_desc = [ ShortEnumField("reason", 1, reason_code) ]
|
fields_desc = [ ShortEnumField("reason", 1, reason_code) ]
|
||||||
|
|
||||||
|
|
||||||
|
class PrismHeader(Packet):
|
||||||
|
""" iwpriv wlan0 monitor 3 """
|
||||||
|
fields_desc = [ LEIntField("msgcode",68),
|
||||||
|
LEIntField("len",144),
|
||||||
|
StrFixedLenField("dev","",16),
|
||||||
|
StrFixedLenField("truc","",68),
|
||||||
|
LEIntField("signal",0),
|
||||||
|
LEIntField("toto1",0),
|
||||||
|
LEIntField("toto2",0),
|
||||||
|
LEIntField("noise",0),
|
||||||
|
StrFixedLenField("tit","",36)
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class NTP(Packet):
|
class NTP(Packet):
|
||||||
# RFC 1769
|
# RFC 1769
|
||||||
name = "NTP"
|
name = "NTP"
|
||||||
|
@ -2853,6 +2889,7 @@ def bind_layers(lower, upper, fval):
|
||||||
|
|
||||||
|
|
||||||
layer_bonds = [ ( Dot3, LLC, { } ),
|
layer_bonds = [ ( Dot3, LLC, { } ),
|
||||||
|
( PrismHeader, Dot11, { }),
|
||||||
( Dot11, LLC, { "type" : 2 } ),
|
( Dot11, LLC, { "type" : 2 } ),
|
||||||
( LLPPP, IP, { } ),
|
( LLPPP, IP, { } ),
|
||||||
( Ether, LLC, { "type" : 0x007a } ),
|
( Ether, LLC, { "type" : 0x007a } ),
|
||||||
|
@ -2946,6 +2983,7 @@ LLTypes = { ARPHDR_ETHER : Ether,
|
||||||
ARPHDR_LOOPBACK : Ether,
|
ARPHDR_LOOPBACK : Ether,
|
||||||
101 : IP,
|
101 : IP,
|
||||||
801 : Dot11,
|
801 : Dot11,
|
||||||
|
802 : PrismHeader,
|
||||||
105 : Dot11,
|
105 : Dot11,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3141,7 +3179,7 @@ class L2ListenSocket(SuperSocket):
|
||||||
elif L3Types.has_key(sa_ll[1]):
|
elif L3Types.has_key(sa_ll[1]):
|
||||||
cls = L3Types[sa_ll[1]]
|
cls = L3Types[sa_ll[1]]
|
||||||
else:
|
else:
|
||||||
warning("Unable to guess type (interface=%s protocol=%#x family=%i %i). Using Ethernet" % (sa_ll[0],sa_ll[1],sa_ll[3]))
|
warning("Unable to guess type (interface=%s protocol=%#x family=%i). Using Ethernet" % (sa_ll[0],sa_ll[1],sa_ll[3]))
|
||||||
cls = Ether
|
cls = Ether
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue