repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
secdev/scapy
scapy/layers/inet.py
TracerouteResult.graph
def graph(self, ASres=conf.AS_resolver, padding=0, **kargs): """x.graph(ASres=conf.AS_resolver, other args): ASres=None : no AS resolver => no clustering ASres=AS_resolver() : default whois AS resolver (riswhois.ripe.net) ASres=AS_resolver_cymru(): use whois.cymru.com whois data...
python
def graph(self, ASres=conf.AS_resolver, padding=0, **kargs): """x.graph(ASres=conf.AS_resolver, other args): ASres=None : no AS resolver => no clustering ASres=AS_resolver() : default whois AS resolver (riswhois.ripe.net) ASres=AS_resolver_cymru(): use whois.cymru.com whois data...
[ "def", "graph", "(", "self", ",", "ASres", "=", "conf", ".", "AS_resolver", ",", "padding", "=", "0", ",", "*", "*", "kargs", ")", ":", "if", "(", "self", ".", "graphdef", "is", "None", "or", "self", ".", "graphASres", "!=", "ASres", "or", "self", ...
x.graph(ASres=conf.AS_resolver, other args): ASres=None : no AS resolver => no clustering ASres=AS_resolver() : default whois AS resolver (riswhois.ripe.net) ASres=AS_resolver_cymru(): use whois.cymru.com whois database ASres=AS_resolver(server="whois.ra.net") type: outp...
[ "x", ".", "graph", "(", "ASres", "=", "conf", ".", "AS_resolver", "other", "args", ")", ":", "ASres", "=", "None", ":", "no", "AS", "resolver", "=", ">", "no", "clustering", "ASres", "=", "AS_resolver", "()", ":", "default", "whois", "AS", "resolver", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet.py#L1625-L1639
train
secdev/scapy
scapy/asn1fields.py
ASN1F_field.m2i
def m2i(self, pkt, s): """ The good thing about safedec is that it may still decode ASN1 even if there is a mismatch between the expected tag (self.ASN1_tag) and the actual tag; the decoded ASN1 object will simply be put into an ASN1_BADTAG object. However, safedec prevents the r...
python
def m2i(self, pkt, s): """ The good thing about safedec is that it may still decode ASN1 even if there is a mismatch between the expected tag (self.ASN1_tag) and the actual tag; the decoded ASN1 object will simply be put into an ASN1_BADTAG object. However, safedec prevents the r...
[ "def", "m2i", "(", "self", ",", "pkt", ",", "s", ")", ":", "diff_tag", ",", "s", "=", "BER_tagging_dec", "(", "s", ",", "hidden_tag", "=", "self", ".", "ASN1_tag", ",", "implicit_tag", "=", "self", ".", "implicit_tag", ",", "explicit_tag", "=", "self",...
The good thing about safedec is that it may still decode ASN1 even if there is a mismatch between the expected tag (self.ASN1_tag) and the actual tag; the decoded ASN1 object will simply be put into an ASN1_BADTAG object. However, safedec prevents the raising of exceptions needed for ASN...
[ "The", "good", "thing", "about", "safedec", "is", "that", "it", "may", "still", "decode", "ASN1", "even", "if", "there", "is", "a", "mismatch", "between", "the", "expected", "tag", "(", "self", ".", "ASN1_tag", ")", "and", "the", "actual", "tag", ";", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/asn1fields.py#L74-L101
train
secdev/scapy
scapy/asn1fields.py
ASN1F_SEQUENCE.m2i
def m2i(self, pkt, s): """ ASN1F_SEQUENCE behaves transparently, with nested ASN1_objects being dissected one by one. Because we use obj.dissect (see loop below) instead of obj.m2i (as we trust dissect to do the appropriate set_vals) we do not directly retrieve the list of nested...
python
def m2i(self, pkt, s): """ ASN1F_SEQUENCE behaves transparently, with nested ASN1_objects being dissected one by one. Because we use obj.dissect (see loop below) instead of obj.m2i (as we trust dissect to do the appropriate set_vals) we do not directly retrieve the list of nested...
[ "def", "m2i", "(", "self", ",", "pkt", ",", "s", ")", ":", "diff_tag", ",", "s", "=", "BER_tagging_dec", "(", "s", ",", "hidden_tag", "=", "self", ".", "ASN1_tag", ",", "implicit_tag", "=", "self", ".", "implicit_tag", ",", "explicit_tag", "=", "self",...
ASN1F_SEQUENCE behaves transparently, with nested ASN1_objects being dissected one by one. Because we use obj.dissect (see loop below) instead of obj.m2i (as we trust dissect to do the appropriate set_vals) we do not directly retrieve the list of nested objects. Thus m2i returns an empty...
[ "ASN1F_SEQUENCE", "behaves", "transparently", "with", "nested", "ASN1_objects", "being", "dissected", "one", "by", "one", ".", "Because", "we", "use", "obj", ".", "dissect", "(", "see", "loop", "below", ")", "instead", "of", "obj", ".", "m2i", "(", "as", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/asn1fields.py#L344-L375
train
secdev/scapy
scapy/asn1fields.py
ASN1F_CHOICE.m2i
def m2i(self, pkt, s): """ First we have to retrieve the appropriate choice. Then we extract the field/packet, according to this choice. """ if len(s) == 0: raise ASN1_Error("ASN1F_CHOICE: got empty string") _, s = BER_tagging_dec(s, hidden_tag=self.ASN1_tag, ...
python
def m2i(self, pkt, s): """ First we have to retrieve the appropriate choice. Then we extract the field/packet, according to this choice. """ if len(s) == 0: raise ASN1_Error("ASN1F_CHOICE: got empty string") _, s = BER_tagging_dec(s, hidden_tag=self.ASN1_tag, ...
[ "def", "m2i", "(", "self", ",", "pkt", ",", "s", ")", ":", "if", "len", "(", "s", ")", "==", "0", ":", "raise", "ASN1_Error", "(", "\"ASN1F_CHOICE: got empty string\"", ")", "_", ",", "s", "=", "BER_tagging_dec", "(", "s", ",", "hidden_tag", "=", "se...
First we have to retrieve the appropriate choice. Then we extract the field/packet, according to this choice.
[ "First", "we", "have", "to", "retrieve", "the", "appropriate", "choice", ".", "Then", "we", "extract", "the", "field", "/", "packet", "according", "to", "this", "choice", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/asn1fields.py#L530-L555
train
secdev/scapy
scapy/contrib/igmp.py
IGMP.igmpize
def igmpize(self): """Called to explicitly fixup the packet according to the IGMP RFC The rules are: General: 1. the Max Response time is meaningful only in Membership Queries and should be zero IP: 1. Send General Group Query to 224.0.0.1 (all systems) ...
python
def igmpize(self): """Called to explicitly fixup the packet according to the IGMP RFC The rules are: General: 1. the Max Response time is meaningful only in Membership Queries and should be zero IP: 1. Send General Group Query to 224.0.0.1 (all systems) ...
[ "def", "igmpize", "(", "self", ")", ":", "gaddr", "=", "self", ".", "gaddr", "if", "hasattr", "(", "self", ",", "\"gaddr\"", ")", "and", "self", ".", "gaddr", "else", "\"0.0.0.0\"", "# noqa: E501", "underlayer", "=", "self", ".", "underlayer", "if", "sel...
Called to explicitly fixup the packet according to the IGMP RFC The rules are: General: 1. the Max Response time is meaningful only in Membership Queries and should be zero IP: 1. Send General Group Query to 224.0.0.1 (all systems) 2. Send Leave Group to 224...
[ "Called", "to", "explicitly", "fixup", "the", "packet", "according", "to", "the", "IGMP", "RFC" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/igmp.py#L95-L152
train
secdev/scapy
scapy/contrib/bgp.py
_bgp_dispatcher
def _bgp_dispatcher(payload): """ Returns the right class for a given BGP message. """ cls = conf.raw_layer # By default, calling BGP() will build a BGPHeader. if payload is None: cls = _get_cls("BGPHeader", conf.raw_layer) else: if len(payload) >= _BGP_HEADER_SIZE and\ ...
python
def _bgp_dispatcher(payload): """ Returns the right class for a given BGP message. """ cls = conf.raw_layer # By default, calling BGP() will build a BGPHeader. if payload is None: cls = _get_cls("BGPHeader", conf.raw_layer) else: if len(payload) >= _BGP_HEADER_SIZE and\ ...
[ "def", "_bgp_dispatcher", "(", "payload", ")", ":", "cls", "=", "conf", ".", "raw_layer", "# By default, calling BGP() will build a BGPHeader.", "if", "payload", "is", "None", ":", "cls", "=", "_get_cls", "(", "\"BGPHeader\"", ",", "conf", ".", "raw_layer", ")", ...
Returns the right class for a given BGP message.
[ "Returns", "the", "right", "class", "for", "a", "given", "BGP", "message", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/bgp.py#L423-L445
train
secdev/scapy
scapy/contrib/bgp.py
_bgp_capability_dispatcher
def _bgp_capability_dispatcher(payload): """ Returns the right class for a given BGP capability. """ cls = _capabilities_registry["BGPCapGeneric"] # By default, calling BGPCapability() will build a "generic" capability. if payload is None: cls = _capabilities_registry["BGPCapGeneric"] ...
python
def _bgp_capability_dispatcher(payload): """ Returns the right class for a given BGP capability. """ cls = _capabilities_registry["BGPCapGeneric"] # By default, calling BGPCapability() will build a "generic" capability. if payload is None: cls = _capabilities_registry["BGPCapGeneric"] ...
[ "def", "_bgp_capability_dispatcher", "(", "payload", ")", ":", "cls", "=", "_capabilities_registry", "[", "\"BGPCapGeneric\"", "]", "# By default, calling BGPCapability() will build a \"generic\" capability.", "if", "payload", "is", "None", ":", "cls", "=", "_capabilities_reg...
Returns the right class for a given BGP capability.
[ "Returns", "the", "right", "class", "for", "a", "given", "BGP", "capability", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/bgp.py#L551-L568
train
secdev/scapy
scapy/contrib/bgp.py
BGPFieldIPv4.i2m
def i2m(self, pkt, i): """"Internal" (IP as bytes, mask as int) to "machine" representation.""" mask, ip = i ip = socket.inet_aton(ip) return struct.pack(">B", mask) + ip[:self.mask2iplen(mask)]
python
def i2m(self, pkt, i): """"Internal" (IP as bytes, mask as int) to "machine" representation.""" mask, ip = i ip = socket.inet_aton(ip) return struct.pack(">B", mask) + ip[:self.mask2iplen(mask)]
[ "def", "i2m", "(", "self", ",", "pkt", ",", "i", ")", ":", "mask", ",", "ip", "=", "i", "ip", "=", "socket", ".", "inet_aton", "(", "ip", ")", "return", "struct", ".", "pack", "(", "\">B\"", ",", "mask", ")", "+", "ip", "[", ":", "self", ".",...
Internal" (IP as bytes, mask as int) to "machine" representation.
[ "Internal", "(", "IP", "as", "bytes", "mask", "as", "int", ")", "to", "machine", "representation", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/bgp.py#L129-L134
train
secdev/scapy
scapy/contrib/bgp.py
BGPFieldIPv6.i2m
def i2m(self, pkt, i): """"Internal" (IP as bytes, mask as int) to "machine" representation.""" # noqa: E501 mask, ip = i ip = pton_ntop.inet_pton(socket.AF_INET6, ip) return struct.pack(">B", mask) + ip[:self.mask2iplen(mask)]
python
def i2m(self, pkt, i): """"Internal" (IP as bytes, mask as int) to "machine" representation.""" # noqa: E501 mask, ip = i ip = pton_ntop.inet_pton(socket.AF_INET6, ip) return struct.pack(">B", mask) + ip[:self.mask2iplen(mask)]
[ "def", "i2m", "(", "self", ",", "pkt", ",", "i", ")", ":", "# noqa: E501", "mask", ",", "ip", "=", "i", "ip", "=", "pton_ntop", ".", "inet_pton", "(", "socket", ".", "AF_INET6", ",", "ip", ")", "return", "struct", ".", "pack", "(", "\">B\"", ",", ...
Internal" (IP as bytes, mask as int) to "machine" representation.
[ "Internal", "(", "IP", "as", "bytes", "mask", "as", "int", ")", "to", "machine", "representation", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/bgp.py#L174-L178
train
secdev/scapy
scapy/contrib/bgp.py
BGPCapability.pre_dissect
def pre_dissect(self, s): """ Check that the payload is long enough (at least 2 bytes). """ length = len(s) if length < _BGP_CAPABILITY_MIN_SIZE: err = " ({}".format(length) + " is < _BGP_CAPABILITY_MIN_SIZE " err += "({})).".format(_BGP_CAPABILITY_MIN_SIZ...
python
def pre_dissect(self, s): """ Check that the payload is long enough (at least 2 bytes). """ length = len(s) if length < _BGP_CAPABILITY_MIN_SIZE: err = " ({}".format(length) + " is < _BGP_CAPABILITY_MIN_SIZE " err += "({})).".format(_BGP_CAPABILITY_MIN_SIZ...
[ "def", "pre_dissect", "(", "self", ",", "s", ")", ":", "length", "=", "len", "(", "s", ")", "if", "length", "<", "_BGP_CAPABILITY_MIN_SIZE", ":", "err", "=", "\" ({}\"", ".", "format", "(", "length", ")", "+", "\" is < _BGP_CAPABILITY_MIN_SIZE \"", "err", ...
Check that the payload is long enough (at least 2 bytes).
[ "Check", "that", "the", "payload", "is", "long", "enough", "(", "at", "least", "2", "bytes", ")", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/bgp.py#L596-L605
train
secdev/scapy
scapy/contrib/isotp.py
ISOTPHeader.post_build
def post_build(self, pkt, pay): """ This will set the ByteField 'length' to the correct value. """ if self.length is None: pkt = pkt[:4] + chb(len(pay)) + pkt[5:] return pkt + pay
python
def post_build(self, pkt, pay): """ This will set the ByteField 'length' to the correct value. """ if self.length is None: pkt = pkt[:4] + chb(len(pay)) + pkt[5:] return pkt + pay
[ "def", "post_build", "(", "self", ",", "pkt", ",", "pay", ")", ":", "if", "self", ".", "length", "is", "None", ":", "pkt", "=", "pkt", "[", ":", "4", "]", "+", "chb", "(", "len", "(", "pay", ")", ")", "+", "pkt", "[", "5", ":", "]", "return...
This will set the ByteField 'length' to the correct value.
[ "This", "will", "set", "the", "ByteField", "length", "to", "the", "correct", "value", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L200-L206
train
secdev/scapy
scapy/contrib/isotp.py
ISOTPHeader.guess_payload_class
def guess_payload_class(self, payload): """ ISOTP encodes the frame type in the first nibble of a frame. """ t = (orb(payload[0]) & 0xf0) >> 4 if t == 0: return ISOTP_SF elif t == 1: return ISOTP_FF elif t == 2: return ISOTP_CF ...
python
def guess_payload_class(self, payload): """ ISOTP encodes the frame type in the first nibble of a frame. """ t = (orb(payload[0]) & 0xf0) >> 4 if t == 0: return ISOTP_SF elif t == 1: return ISOTP_FF elif t == 2: return ISOTP_CF ...
[ "def", "guess_payload_class", "(", "self", ",", "payload", ")", ":", "t", "=", "(", "orb", "(", "payload", "[", "0", "]", ")", "&", "0xf0", ")", ">>", "4", "if", "t", "==", "0", ":", "return", "ISOTP_SF", "elif", "t", "==", "1", ":", "return", ...
ISOTP encodes the frame type in the first nibble of a frame.
[ "ISOTP", "encodes", "the", "frame", "type", "in", "the", "first", "nibble", "of", "a", "frame", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L208-L220
train
secdev/scapy
scapy/contrib/isotp.py
ISOTPMessageBuilder.feed
def feed(self, can): """Attempt to feed an incoming CAN frame into the state machine""" if not isinstance(can, CAN): raise Scapy_Exception("argument is not a CAN frame") identifier = can.identifier data = bytes(can.data) if len(data) > 1 and self.use_ext_addr is not ...
python
def feed(self, can): """Attempt to feed an incoming CAN frame into the state machine""" if not isinstance(can, CAN): raise Scapy_Exception("argument is not a CAN frame") identifier = can.identifier data = bytes(can.data) if len(data) > 1 and self.use_ext_addr is not ...
[ "def", "feed", "(", "self", ",", "can", ")", ":", "if", "not", "isinstance", "(", "can", ",", "CAN", ")", ":", "raise", "Scapy_Exception", "(", "\"argument is not a CAN frame\"", ")", "identifier", "=", "can", ".", "identifier", "data", "=", "bytes", "(", ...
Attempt to feed an incoming CAN frame into the state machine
[ "Attempt", "to", "feed", "an", "incoming", "CAN", "frame", "into", "the", "state", "machine" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L329-L340
train
secdev/scapy
scapy/contrib/isotp.py
ISOTPMessageBuilder.pop
def pop(self, identifier=None, ext_addr=None, basecls=ISOTP): """ Returns a built ISOTP message :param identifier: if not None, only return isotp messages with this destination :param ext_addr: if identifier is not None, only return isotp messages ...
python
def pop(self, identifier=None, ext_addr=None, basecls=ISOTP): """ Returns a built ISOTP message :param identifier: if not None, only return isotp messages with this destination :param ext_addr: if identifier is not None, only return isotp messages ...
[ "def", "pop", "(", "self", ",", "identifier", "=", "None", ",", "ext_addr", "=", "None", ",", "basecls", "=", "ISOTP", ")", ":", "if", "identifier", "is", "not", "None", ":", "for", "i", "in", "range", "(", "len", "(", "self", ".", "ready", ")", ...
Returns a built ISOTP message :param identifier: if not None, only return isotp messages with this destination :param ext_addr: if identifier is not None, only return isotp messages with this extended address for destination :param basecls: the...
[ "Returns", "a", "built", "ISOTP", "message", ":", "param", "identifier", ":", "if", "not", "None", "only", "return", "isotp", "messages", "with", "this", "destination", ":", "param", "ext_addr", ":", "if", "identifier", "is", "not", "None", "only", "return",...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L347-L370
train
secdev/scapy
scapy/contrib/isotp.py
ISOTPSoftSocket.begin_send
def begin_send(self, p): """Begin the transmission of message p. This method returns after sending the first frame. If multiple frames are necessary to send the message, this socket will unable to send other messages until either the transmission of this frame succeeds or it fails.""" ...
python
def begin_send(self, p): """Begin the transmission of message p. This method returns after sending the first frame. If multiple frames are necessary to send the message, this socket will unable to send other messages until either the transmission of this frame succeeds or it fails.""" ...
[ "def", "begin_send", "(", "self", ",", "p", ")", ":", "if", "hasattr", "(", "p", ",", "\"sent_time\"", ")", ":", "p", ".", "sent_time", "=", "time", ".", "time", "(", ")", "return", "self", ".", "outs", ".", "begin_send", "(", "bytes", "(", "p", ...
Begin the transmission of message p. This method returns after sending the first frame. If multiple frames are necessary to send the message, this socket will unable to send other messages until either the transmission of this frame succeeds or it fails.
[ "Begin", "the", "transmission", "of", "message", "p", ".", "This", "method", "returns", "after", "sending", "the", "first", "frame", ".", "If", "multiple", "frames", "are", "necessary", "to", "send", "the", "message", "this", "socket", "will", "unable", "to"...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L602-L610
train
secdev/scapy
scapy/contrib/isotp.py
ISOTPSoftSocket.recv_with_timeout
def recv_with_timeout(self, timeout=1): """Receive a complete ISOTP message, blocking until a message is received or the specified timeout is reached. If timeout is 0, then this function doesn't block and returns the first frame in the receive buffer or None if there isn't any.""" ...
python
def recv_with_timeout(self, timeout=1): """Receive a complete ISOTP message, blocking until a message is received or the specified timeout is reached. If timeout is 0, then this function doesn't block and returns the first frame in the receive buffer or None if there isn't any.""" ...
[ "def", "recv_with_timeout", "(", "self", ",", "timeout", "=", "1", ")", ":", "msg", "=", "self", ".", "ins", ".", "recv", "(", "timeout", ")", "t", "=", "time", ".", "time", "(", ")", "if", "msg", "is", "None", ":", "raise", "Scapy_Exception", "(",...
Receive a complete ISOTP message, blocking until a message is received or the specified timeout is reached. If timeout is 0, then this function doesn't block and returns the first frame in the receive buffer or None if there isn't any.
[ "Receive", "a", "complete", "ISOTP", "message", "blocking", "until", "a", "message", "is", "received", "or", "the", "specified", "timeout", "is", "reached", ".", "If", "timeout", "is", "0", "then", "this", "function", "doesn", "t", "block", "and", "returns",...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L612-L621
train
secdev/scapy
scapy/contrib/isotp.py
ISOTPSoftSocket.recv_raw
def recv_raw(self, x=0xffff): """Receive a complete ISOTP message, blocking until a message is received or the specified timeout is reached. If self.timeout is 0, then this function doesn't block and returns the first frame in the receive buffer or None if there isn't any.""" msg...
python
def recv_raw(self, x=0xffff): """Receive a complete ISOTP message, blocking until a message is received or the specified timeout is reached. If self.timeout is 0, then this function doesn't block and returns the first frame in the receive buffer or None if there isn't any.""" msg...
[ "def", "recv_raw", "(", "self", ",", "x", "=", "0xffff", ")", ":", "msg", "=", "self", ".", "ins", ".", "recv", "(", ")", "t", "=", "time", ".", "time", "(", ")", "return", "self", ".", "basecls", ",", "msg", ",", "t" ]
Receive a complete ISOTP message, blocking until a message is received or the specified timeout is reached. If self.timeout is 0, then this function doesn't block and returns the first frame in the receive buffer or None if there isn't any.
[ "Receive", "a", "complete", "ISOTP", "message", "blocking", "until", "a", "message", "is", "received", "or", "the", "specified", "timeout", "is", "reached", ".", "If", "self", ".", "timeout", "is", "0", "then", "this", "function", "doesn", "t", "block", "a...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L623-L630
train
secdev/scapy
scapy/contrib/isotp.py
ISOTPSoftSocket.select
def select(sockets, remain=None): """This function is called during sendrecv() routine to wait for sockets to be ready to receive """ blocking = remain is None or remain > 0 def find_ready_sockets(): return list(filter(lambda x: not x.ins.rx_queue.empty(), sockets)) ...
python
def select(sockets, remain=None): """This function is called during sendrecv() routine to wait for sockets to be ready to receive """ blocking = remain is None or remain > 0 def find_ready_sockets(): return list(filter(lambda x: not x.ins.rx_queue.empty(), sockets)) ...
[ "def", "select", "(", "sockets", ",", "remain", "=", "None", ")", ":", "blocking", "=", "remain", "is", "None", "or", "remain", ">", "0", "def", "find_ready_sockets", "(", ")", ":", "return", "list", "(", "filter", "(", "lambda", "x", ":", "not", "x"...
This function is called during sendrecv() routine to wait for sockets to be ready to receive
[ "This", "function", "is", "called", "during", "sendrecv", "()", "routine", "to", "wait", "for", "sockets", "to", "be", "ready", "to", "receive" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L646-L678
train
secdev/scapy
scapy/contrib/isotp.py
TimeoutThread.set_timeout
def set_timeout(self, timeout, callback): """Call 'callback' in 'timeout' seconds, unless cancelled.""" if not self._ready_sem.acquire(False): raise Scapy_Exception("Timer was already started") self._callback = callback self._timeout = timeout self._cancelled.clear()...
python
def set_timeout(self, timeout, callback): """Call 'callback' in 'timeout' seconds, unless cancelled.""" if not self._ready_sem.acquire(False): raise Scapy_Exception("Timer was already started") self._callback = callback self._timeout = timeout self._cancelled.clear()...
[ "def", "set_timeout", "(", "self", ",", "timeout", ",", "callback", ")", ":", "if", "not", "self", ".", "_ready_sem", ".", "acquire", "(", "False", ")", ":", "raise", "Scapy_Exception", "(", "\"Timer was already started\"", ")", "self", ".", "_callback", "="...
Call 'callback' in 'timeout' seconds, unless cancelled.
[ "Call", "callback", "in", "timeout", "seconds", "unless", "cancelled", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L791-L799
train
secdev/scapy
scapy/contrib/isotp.py
TimeoutThread.cancel
def cancel(self): """Stop the timer without executing the callback.""" self._cancelled.set() if not self._dead: self._ready_sem.acquire() self._ready_sem.release()
python
def cancel(self): """Stop the timer without executing the callback.""" self._cancelled.set() if not self._dead: self._ready_sem.acquire() self._ready_sem.release()
[ "def", "cancel", "(", "self", ")", ":", "self", ".", "_cancelled", ".", "set", "(", ")", "if", "not", "self", ".", "_dead", ":", "self", ".", "_ready_sem", ".", "acquire", "(", ")", "self", ".", "_ready_sem", ".", "release", "(", ")" ]
Stop the timer without executing the callback.
[ "Stop", "the", "timer", "without", "executing", "the", "callback", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L801-L806
train
secdev/scapy
scapy/contrib/isotp.py
TimeoutThread.stop
def stop(self): """Stop the thread, making this object unusable.""" if not self._dead: self._killed = True self._cancelled.set() self._busy_sem.release() self.join() if not self._ready_sem.acquire(False): warning("ISOTP Timer th...
python
def stop(self): """Stop the thread, making this object unusable.""" if not self._dead: self._killed = True self._cancelled.set() self._busy_sem.release() self.join() if not self._ready_sem.acquire(False): warning("ISOTP Timer th...
[ "def", "stop", "(", "self", ")", ":", "if", "not", "self", ".", "_dead", ":", "self", ".", "_killed", "=", "True", "self", ".", "_cancelled", ".", "set", "(", ")", "self", ".", "_busy_sem", ".", "release", "(", ")", "self", ".", "join", "(", ")",...
Stop the thread, making this object unusable.
[ "Stop", "the", "thread", "making", "this", "object", "unusable", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L808-L817
train
secdev/scapy
scapy/contrib/isotp.py
ISOTPSocketImplementation._rx_timer_handler
def _rx_timer_handler(self): """Method called every time the rx_timer times out, due to the peer not sending a consecutive frame within the expected time window""" with self.rx_mutex: if self.rx_state == ISOTP_WAIT_DATA: # we did not get new data frames in time. ...
python
def _rx_timer_handler(self): """Method called every time the rx_timer times out, due to the peer not sending a consecutive frame within the expected time window""" with self.rx_mutex: if self.rx_state == ISOTP_WAIT_DATA: # we did not get new data frames in time. ...
[ "def", "_rx_timer_handler", "(", "self", ")", ":", "with", "self", ".", "rx_mutex", ":", "if", "self", ".", "rx_state", "==", "ISOTP_WAIT_DATA", ":", "# we did not get new data frames in time.", "# reset rx state", "self", ".", "rx_state", "=", "ISOTP_IDLE", "warnin...
Method called every time the rx_timer times out, due to the peer not sending a consecutive frame within the expected time window
[ "Method", "called", "every", "time", "the", "rx_timer", "times", "out", "due", "to", "the", "peer", "not", "sending", "a", "consecutive", "frame", "within", "the", "expected", "time", "window" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L959-L968
train
secdev/scapy
scapy/contrib/isotp.py
ISOTPSocketImplementation._tx_timer_handler
def _tx_timer_handler(self): """Method called every time the tx_timer times out, which can happen in two situations: either a Flow Control frame was not received in time, or the Separation Time Min is expired and a new frame must be sent.""" with self.tx_mutex: if (self.tx_s...
python
def _tx_timer_handler(self): """Method called every time the tx_timer times out, which can happen in two situations: either a Flow Control frame was not received in time, or the Separation Time Min is expired and a new frame must be sent.""" with self.tx_mutex: if (self.tx_s...
[ "def", "_tx_timer_handler", "(", "self", ")", ":", "with", "self", ".", "tx_mutex", ":", "if", "(", "self", ".", "tx_state", "==", "ISOTP_WAIT_FC", "or", "self", ".", "tx_state", "==", "ISOTP_WAIT_FIRST_FC", ")", ":", "# we did not get any flow control frame in ti...
Method called every time the tx_timer times out, which can happen in two situations: either a Flow Control frame was not received in time, or the Separation Time Min is expired and a new frame must be sent.
[ "Method", "called", "every", "time", "the", "tx_timer", "times", "out", "which", "can", "happen", "in", "two", "situations", ":", "either", "a", "Flow", "Control", "frame", "was", "not", "received", "in", "time", "or", "the", "Separation", "Time", "Min", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L970-L1018
train
secdev/scapy
scapy/contrib/isotp.py
ISOTPSocketImplementation.on_recv
def on_recv(self, cf): """Function that must be called every time a CAN frame is received, to advance the state machine.""" data = bytes(cf.data) if len(data) < 2: return ae = 0 if self.extended_rx_addr is not None: ae = 1 if len(dat...
python
def on_recv(self, cf): """Function that must be called every time a CAN frame is received, to advance the state machine.""" data = bytes(cf.data) if len(data) < 2: return ae = 0 if self.extended_rx_addr is not None: ae = 1 if len(dat...
[ "def", "on_recv", "(", "self", ",", "cf", ")", ":", "data", "=", "bytes", "(", "cf", ".", "data", ")", "if", "len", "(", "data", ")", "<", "2", ":", "return", "ae", "=", "0", "if", "self", ".", "extended_rx_addr", "is", "not", "None", ":", "ae"...
Function that must be called every time a CAN frame is received, to advance the state machine.
[ "Function", "that", "must", "be", "called", "every", "time", "a", "CAN", "frame", "is", "received", "to", "advance", "the", "state", "machine", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L1020-L1050
train
secdev/scapy
scapy/contrib/isotp.py
ISOTPSocketImplementation._recv_fc
def _recv_fc(self, data): """Process a received 'Flow Control' frame""" if (self.tx_state != ISOTP_WAIT_FC and self.tx_state != ISOTP_WAIT_FIRST_FC): return 0 self.tx_timer.cancel() if len(data) < 3: self.tx_state = ISOTP_IDLE self.tx...
python
def _recv_fc(self, data): """Process a received 'Flow Control' frame""" if (self.tx_state != ISOTP_WAIT_FC and self.tx_state != ISOTP_WAIT_FIRST_FC): return 0 self.tx_timer.cancel() if len(data) < 3: self.tx_state = ISOTP_IDLE self.tx...
[ "def", "_recv_fc", "(", "self", ",", "data", ")", ":", "if", "(", "self", ".", "tx_state", "!=", "ISOTP_WAIT_FC", "and", "self", ".", "tx_state", "!=", "ISOTP_WAIT_FIRST_FC", ")", ":", "return", "0", "self", ".", "tx_timer", ".", "cancel", "(", ")", "i...
Process a received 'Flow Control' frame
[ "Process", "a", "received", "Flow", "Control", "frame" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L1052-L1108
train
secdev/scapy
scapy/contrib/isotp.py
ISOTPSocketImplementation._recv_sf
def _recv_sf(self, data): """Process a received 'Single Frame' frame""" self.rx_timer.cancel() if self.rx_state != ISOTP_IDLE: warning("RX state was reset because single frame was received") self.rx_state = ISOTP_IDLE length = six.indexbytes(data, 0) & 0xf ...
python
def _recv_sf(self, data): """Process a received 'Single Frame' frame""" self.rx_timer.cancel() if self.rx_state != ISOTP_IDLE: warning("RX state was reset because single frame was received") self.rx_state = ISOTP_IDLE length = six.indexbytes(data, 0) & 0xf ...
[ "def", "_recv_sf", "(", "self", ",", "data", ")", ":", "self", ".", "rx_timer", ".", "cancel", "(", ")", "if", "self", ".", "rx_state", "!=", "ISOTP_IDLE", ":", "warning", "(", "\"RX state was reset because single frame was received\"", ")", "self", ".", "rx_s...
Process a received 'Single Frame' frame
[ "Process", "a", "received", "Single", "Frame", "frame" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L1110-L1126
train
secdev/scapy
scapy/contrib/isotp.py
ISOTPSocketImplementation._recv_ff
def _recv_ff(self, data): """Process a received 'First Frame' frame""" self.rx_timer.cancel() if self.rx_state != ISOTP_IDLE: warning("RX state was reset because first frame was received") self.rx_state = ISOTP_IDLE if len(data) < 7: return 1 ...
python
def _recv_ff(self, data): """Process a received 'First Frame' frame""" self.rx_timer.cancel() if self.rx_state != ISOTP_IDLE: warning("RX state was reset because first frame was received") self.rx_state = ISOTP_IDLE if len(data) < 7: return 1 ...
[ "def", "_recv_ff", "(", "self", ",", "data", ")", ":", "self", ".", "rx_timer", ".", "cancel", "(", ")", "if", "self", ".", "rx_state", "!=", "ISOTP_IDLE", ":", "warning", "(", "\"RX state was reset because first frame was received\"", ")", "self", ".", "rx_st...
Process a received 'First Frame' frame
[ "Process", "a", "received", "First", "Frame", "frame" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L1128-L1173
train
secdev/scapy
scapy/contrib/isotp.py
ISOTPSocketImplementation._recv_cf
def _recv_cf(self, data): """Process a received 'Consecutive Frame' frame""" if self.rx_state != ISOTP_WAIT_DATA: return 0 self.rx_timer.cancel() # CFs are never longer than the FF if len(data) > self.rx_ll_dl: return 1 # CFs have usually the LL...
python
def _recv_cf(self, data): """Process a received 'Consecutive Frame' frame""" if self.rx_state != ISOTP_WAIT_DATA: return 0 self.rx_timer.cancel() # CFs are never longer than the FF if len(data) > self.rx_ll_dl: return 1 # CFs have usually the LL...
[ "def", "_recv_cf", "(", "self", ",", "data", ")", ":", "if", "self", ".", "rx_state", "!=", "ISOTP_WAIT_DATA", ":", "return", "0", "self", ".", "rx_timer", ".", "cancel", "(", ")", "# CFs are never longer than the FF", "if", "len", "(", "data", ")", ">", ...
Process a received 'Consecutive Frame' frame
[ "Process", "a", "received", "Consecutive", "Frame", "frame" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L1175-L1229
train
secdev/scapy
scapy/contrib/isotp.py
ISOTPSocketImplementation.begin_send
def begin_send(self, x): """Begins sending an ISOTP message. This method does not block.""" with self.tx_mutex: if self.tx_state != ISOTP_IDLE: raise Scapy_Exception("Socket is already sending, retry later") self.tx_done.clear() self.tx_exception = No...
python
def begin_send(self, x): """Begins sending an ISOTP message. This method does not block.""" with self.tx_mutex: if self.tx_state != ISOTP_IDLE: raise Scapy_Exception("Socket is already sending, retry later") self.tx_done.clear() self.tx_exception = No...
[ "def", "begin_send", "(", "self", ",", "x", ")", ":", "with", "self", ".", "tx_mutex", ":", "if", "self", ".", "tx_state", "!=", "ISOTP_IDLE", ":", "raise", "Scapy_Exception", "(", "\"Socket is already sending, retry later\"", ")", "self", ".", "tx_done", ".",...
Begins sending an ISOTP message. This method does not block.
[ "Begins", "sending", "an", "ISOTP", "message", ".", "This", "method", "does", "not", "block", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L1231-L1273
train
secdev/scapy
scapy/contrib/isotp.py
ISOTPSocketImplementation.send
def send(self, p): """Send an ISOTP frame and block until the message is sent or an error happens.""" with self.send_mutex: self.begin_send(p) # Wait until the tx callback is called self.tx_done.wait() if self.tx_exception is not None: ...
python
def send(self, p): """Send an ISOTP frame and block until the message is sent or an error happens.""" with self.send_mutex: self.begin_send(p) # Wait until the tx callback is called self.tx_done.wait() if self.tx_exception is not None: ...
[ "def", "send", "(", "self", ",", "p", ")", ":", "with", "self", ".", "send_mutex", ":", "self", ".", "begin_send", "(", "p", ")", "# Wait until the tx callback is called", "self", ".", "tx_done", ".", "wait", "(", ")", "if", "self", ".", "tx_exception", ...
Send an ISOTP frame and block until the message is sent or an error happens.
[ "Send", "an", "ISOTP", "frame", "and", "block", "until", "the", "message", "is", "sent", "or", "an", "error", "happens", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L1275-L1285
train
secdev/scapy
scapy/contrib/isotp.py
ISOTPSocketImplementation.recv
def recv(self, timeout=None): """Receive an ISOTP frame, blocking if none is available in the buffer for at most 'timeout' seconds.""" try: return self.rx_queue.get(timeout is None or timeout > 0, timeout) except queue.Empty: return None
python
def recv(self, timeout=None): """Receive an ISOTP frame, blocking if none is available in the buffer for at most 'timeout' seconds.""" try: return self.rx_queue.get(timeout is None or timeout > 0, timeout) except queue.Empty: return None
[ "def", "recv", "(", "self", ",", "timeout", "=", "None", ")", ":", "try", ":", "return", "self", ".", "rx_queue", ".", "get", "(", "timeout", "is", "None", "or", "timeout", ">", "0", ",", "timeout", ")", "except", "queue", ".", "Empty", ":", "retur...
Receive an ISOTP frame, blocking if none is available in the buffer for at most 'timeout' seconds.
[ "Receive", "an", "ISOTP", "frame", "blocking", "if", "none", "is", "available", "in", "the", "buffer", "for", "at", "most", "timeout", "seconds", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L1287-L1294
train
secdev/scapy
scapy/layers/tls/automaton_cli.py
TLSClientAutomaton.should_add_ClientCertificate
def should_add_ClientCertificate(self): """ If the server sent a CertificateRequest, we send a Certificate message. If no certificate is available, an empty Certificate message is sent: - this is a SHOULD in RFC 4346 (Section 7.4.6) - this is a MUST in RFC 5246 (Section 7.4.6) ...
python
def should_add_ClientCertificate(self): """ If the server sent a CertificateRequest, we send a Certificate message. If no certificate is available, an empty Certificate message is sent: - this is a SHOULD in RFC 4346 (Section 7.4.6) - this is a MUST in RFC 5246 (Section 7.4.6) ...
[ "def", "should_add_ClientCertificate", "(", "self", ")", ":", "hs_msg", "=", "[", "type", "(", "m", ")", "for", "m", "in", "self", ".", "cur_session", ".", "handshake_messages_parsed", "]", "if", "TLSCertificateRequest", "not", "in", "hs_msg", ":", "return", ...
If the server sent a CertificateRequest, we send a Certificate message. If no certificate is available, an empty Certificate message is sent: - this is a SHOULD in RFC 4346 (Section 7.4.6) - this is a MUST in RFC 5246 (Section 7.4.6) XXX We may want to add a complete chain.
[ "If", "the", "server", "sent", "a", "CertificateRequest", "we", "send", "a", "Certificate", "message", ".", "If", "no", "certificate", "is", "available", "an", "empty", "Certificate", "message", "is", "sent", ":", "-", "this", "is", "a", "SHOULD", "in", "R...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/automaton_cli.py#L312-L328
train
secdev/scapy
scapy/layers/tls/automaton_cli.py
TLSClientAutomaton.should_add_ClientVerify
def should_add_ClientVerify(self): """ XXX Section 7.4.7.1 of RFC 5246 states that the CertificateVerify message is only sent following a client certificate that has signing capability (i.e. not those containing fixed DH params). We should verify that before adding the message. W...
python
def should_add_ClientVerify(self): """ XXX Section 7.4.7.1 of RFC 5246 states that the CertificateVerify message is only sent following a client certificate that has signing capability (i.e. not those containing fixed DH params). We should verify that before adding the message. W...
[ "def", "should_add_ClientVerify", "(", "self", ")", ":", "hs_msg", "=", "[", "type", "(", "m", ")", "for", "m", "in", "self", ".", "cur_session", ".", "handshake_messages_parsed", "]", "if", "(", "TLSCertificateRequest", "not", "in", "hs_msg", "or", "self", ...
XXX Section 7.4.7.1 of RFC 5246 states that the CertificateVerify message is only sent following a client certificate that has signing capability (i.e. not those containing fixed DH params). We should verify that before adding the message. We should also handle the case when the Certific...
[ "XXX", "Section", "7", ".", "4", ".", "7", ".", "1", "of", "RFC", "5246", "states", "that", "the", "CertificateVerify", "message", "is", "only", "sent", "following", "a", "client", "certificate", "that", "has", "signing", "capability", "(", "i", ".", "e"...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/automaton_cli.py#L351-L365
train
secdev/scapy
scapy/layers/tls/automaton_cli.py
TLSClientAutomaton.add_ClientData
def add_ClientData(self): """ The user may type in: GET / HTTP/1.1\r\nHost: testserver.com\r\n\r\n Special characters are handled so that it becomes a valid HTTP request. """ if not self.data_to_send: data = six.moves.input().replace('\\r', '\r').replace('\\n'...
python
def add_ClientData(self): """ The user may type in: GET / HTTP/1.1\r\nHost: testserver.com\r\n\r\n Special characters are handled so that it becomes a valid HTTP request. """ if not self.data_to_send: data = six.moves.input().replace('\\r', '\r').replace('\\n'...
[ "def", "add_ClientData", "(", "self", ")", ":", "if", "not", "self", ".", "data_to_send", ":", "data", "=", "six", ".", "moves", ".", "input", "(", ")", ".", "replace", "(", "'\\\\r'", ",", "'\\r'", ")", ".", "replace", "(", "'\\\\n'", ",", "'\\n'", ...
The user may type in: GET / HTTP/1.1\r\nHost: testserver.com\r\n\r\n Special characters are handled so that it becomes a valid HTTP request.
[ "The", "user", "may", "type", "in", ":", "GET", "/", "HTTP", "/", "1", ".", "1", "\\", "r", "\\", "nHost", ":", "testserver", ".", "com", "\\", "r", "\\", "n", "\\", "r", "\\", "n", "Special", "characters", "are", "handled", "so", "that", "it", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/automaton_cli.py#L446-L462
train
secdev/scapy
scapy/layers/eap.py
MKAParamSet.dispatch_hook
def dispatch_hook(cls, _pkt=None, *args, **kargs): """ Returns the right parameter set class. """ cls = conf.raw_layer if _pkt is not None: ptype = orb(_pkt[0]) return globals().get(_param_set_cls.get(ptype), conf.raw_layer) return cls
python
def dispatch_hook(cls, _pkt=None, *args, **kargs): """ Returns the right parameter set class. """ cls = conf.raw_layer if _pkt is not None: ptype = orb(_pkt[0]) return globals().get(_param_set_cls.get(ptype), conf.raw_layer) return cls
[ "def", "dispatch_hook", "(", "cls", ",", "_pkt", "=", "None", ",", "*", "args", ",", "*", "*", "kargs", ")", ":", "cls", "=", "conf", ".", "raw_layer", "if", "_pkt", "is", "not", "None", ":", "ptype", "=", "orb", "(", "_pkt", "[", "0", "]", ")"...
Returns the right parameter set class.
[ "Returns", "the", "right", "parameter", "set", "class", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/eap.py#L485-L495
train
secdev/scapy
scapy/layers/sixlowpan.py
source_addr_mode2
def source_addr_mode2(pkt): """source_addr_mode This function depending on the arguments returns the amount of bits to be used by the source address. Keyword arguments: pkt -- packet object instance """ if pkt.sac == 0x0: if pkt.sam == 0x0: return 16 elif pkt.sa...
python
def source_addr_mode2(pkt): """source_addr_mode This function depending on the arguments returns the amount of bits to be used by the source address. Keyword arguments: pkt -- packet object instance """ if pkt.sac == 0x0: if pkt.sam == 0x0: return 16 elif pkt.sa...
[ "def", "source_addr_mode2", "(", "pkt", ")", ":", "if", "pkt", ".", "sac", "==", "0x0", ":", "if", "pkt", ".", "sam", "==", "0x0", ":", "return", "16", "elif", "pkt", ".", "sam", "==", "0x1", ":", "return", "8", "elif", "pkt", ".", "sam", "==", ...
source_addr_mode This function depending on the arguments returns the amount of bits to be used by the source address. Keyword arguments: pkt -- packet object instance
[ "source_addr_mode" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/sixlowpan.py#L213-L239
train
secdev/scapy
scapy/layers/sixlowpan.py
destiny_addr_mode
def destiny_addr_mode(pkt): """destiny_addr_mode This function depending on the arguments returns the amount of bits to be used by the destiny address. Keyword arguments: pkt -- packet object instance """ if pkt.m == 0 and pkt.dac == 0: if pkt.dam == 0x0: return 16 ...
python
def destiny_addr_mode(pkt): """destiny_addr_mode This function depending on the arguments returns the amount of bits to be used by the destiny address. Keyword arguments: pkt -- packet object instance """ if pkt.m == 0 and pkt.dac == 0: if pkt.dam == 0x0: return 16 ...
[ "def", "destiny_addr_mode", "(", "pkt", ")", ":", "if", "pkt", ".", "m", "==", "0", "and", "pkt", ".", "dac", "==", "0", ":", "if", "pkt", ".", "dam", "==", "0x0", ":", "return", "16", "elif", "pkt", ".", "dam", "==", "0x1", ":", "return", "8",...
destiny_addr_mode This function depending on the arguments returns the amount of bits to be used by the destiny address. Keyword arguments: pkt -- packet object instance
[ "destiny_addr_mode" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/sixlowpan.py#L242-L286
train
secdev/scapy
scapy/layers/sixlowpan.py
_extract_dot15d4address
def _extract_dot15d4address(pkt, source=True): """This function extracts the source/destination address of a 6LoWPAN from its upper Dot15d4Data (802.15.4 data) layer. params: - source: if True, the address is the source one. Otherwise, it is the destination. returns: the packed & pr...
python
def _extract_dot15d4address(pkt, source=True): """This function extracts the source/destination address of a 6LoWPAN from its upper Dot15d4Data (802.15.4 data) layer. params: - source: if True, the address is the source one. Otherwise, it is the destination. returns: the packed & pr...
[ "def", "_extract_dot15d4address", "(", "pkt", ",", "source", "=", "True", ")", ":", "underlayer", "=", "pkt", ".", "underlayer", "while", "underlayer", "is", "not", "None", "and", "not", "isinstance", "(", "underlayer", ",", "Dot15d4Data", ")", ":", "# noqa:...
This function extracts the source/destination address of a 6LoWPAN from its upper Dot15d4Data (802.15.4 data) layer. params: - source: if True, the address is the source one. Otherwise, it is the destination. returns: the packed & processed address
[ "This", "function", "extracts", "the", "source", "/", "destination", "address", "of", "a", "6LoWPAN", "from", "its", "upper", "Dot15d4Data", "(", "802", ".", "15", ".", "4", "data", ")", "layer", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/sixlowpan.py#L358-L383
train
secdev/scapy
scapy/layers/sixlowpan.py
sixlowpan_fragment
def sixlowpan_fragment(packet, datagram_tag=1): """Split a packet into different links to transmit as 6lowpan packets. Usage example: >>> ipv6 = ..... (very big packet) >>> pkts = sixlowpan_fragment(ipv6, datagram_tag=0x17) >>> send = [Dot15d4()/Dot15d4Data()/x for x in pkts] ...
python
def sixlowpan_fragment(packet, datagram_tag=1): """Split a packet into different links to transmit as 6lowpan packets. Usage example: >>> ipv6 = ..... (very big packet) >>> pkts = sixlowpan_fragment(ipv6, datagram_tag=0x17) >>> send = [Dot15d4()/Dot15d4Data()/x for x in pkts] ...
[ "def", "sixlowpan_fragment", "(", "packet", ",", "datagram_tag", "=", "1", ")", ":", "if", "not", "packet", ".", "haslayer", "(", "IPv6", ")", ":", "raise", "Exception", "(", "\"SixLoWPAN only fragments IPv6 packets !\"", ")", "str_packet", "=", "raw", "(", "p...
Split a packet into different links to transmit as 6lowpan packets. Usage example: >>> ipv6 = ..... (very big packet) >>> pkts = sixlowpan_fragment(ipv6, datagram_tag=0x17) >>> send = [Dot15d4()/Dot15d4Data()/x for x in pkts] >>> wireshark(send)
[ "Split", "a", "packet", "into", "different", "links", "to", "transmit", "as", "6lowpan", "packets", ".", "Usage", "example", ":", ">>>", "ipv6", "=", ".....", "(", "very", "big", "packet", ")", ">>>", "pkts", "=", "sixlowpan_fragment", "(", "ipv6", "datagr...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/sixlowpan.py#L751-L778
train
secdev/scapy
scapy/layers/sixlowpan.py
IP6FieldLenField.addfield
def addfield(self, pkt, s, val): """Add an internal value to a string""" tmp_len = self.length_of(pkt) if tmp_len == 0: return s internal = self.i2m(pkt, val)[-tmp_len:] return s + struct.pack("!%ds" % tmp_len, internal)
python
def addfield(self, pkt, s, val): """Add an internal value to a string""" tmp_len = self.length_of(pkt) if tmp_len == 0: return s internal = self.i2m(pkt, val)[-tmp_len:] return s + struct.pack("!%ds" % tmp_len, internal)
[ "def", "addfield", "(", "self", ",", "pkt", ",", "s", ",", "val", ")", ":", "tmp_len", "=", "self", ".", "length_of", "(", "pkt", ")", "if", "tmp_len", "==", "0", ":", "return", "s", "internal", "=", "self", ".", "i2m", "(", "pkt", ",", "val", ...
Add an internal value to a string
[ "Add", "an", "internal", "value", "to", "a", "string" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/sixlowpan.py#L80-L86
train
secdev/scapy
scapy/layers/sixlowpan.py
SixLoWPANAddrField.addfield
def addfield(self, pkt, s, val): """Add an internal value to a string""" if self.length_of(pkt) == 8: return s + struct.pack(self.fmt[0] + "B", val) if self.length_of(pkt) == 16: return s + struct.pack(self.fmt[0] + "H", val) if self.length_of(pkt) == 32: ...
python
def addfield(self, pkt, s, val): """Add an internal value to a string""" if self.length_of(pkt) == 8: return s + struct.pack(self.fmt[0] + "B", val) if self.length_of(pkt) == 16: return s + struct.pack(self.fmt[0] + "H", val) if self.length_of(pkt) == 32: ...
[ "def", "addfield", "(", "self", ",", "pkt", ",", "s", ",", "val", ")", ":", "if", "self", ".", "length_of", "(", "pkt", ")", "==", "8", ":", "return", "s", "+", "struct", ".", "pack", "(", "self", ".", "fmt", "[", "0", "]", "+", "\"B\"", ",",...
Add an internal value to a string
[ "Add", "an", "internal", "value", "to", "a", "string" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/sixlowpan.py#L124-L140
train
secdev/scapy
scapy/layers/sixlowpan.py
LoWPAN_IPHC.post_dissect
def post_dissect(self, data): """dissect the IPv6 package compressed into this IPHC packet. The packet payload needs to be decompressed and depending on the arguments, several conversions should be done. """ # uncompress payload packet = IPv6() packet.version = ...
python
def post_dissect(self, data): """dissect the IPv6 package compressed into this IPHC packet. The packet payload needs to be decompressed and depending on the arguments, several conversions should be done. """ # uncompress payload packet = IPv6() packet.version = ...
[ "def", "post_dissect", "(", "self", ",", "data", ")", ":", "# uncompress payload", "packet", "=", "IPv6", "(", ")", "packet", ".", "version", "=", "IPHC_DEFAULT_VERSION", "packet", ".", "tc", ",", "packet", ".", "fl", "=", "self", ".", "_getTrafficClassAndFl...
dissect the IPv6 package compressed into this IPHC packet. The packet payload needs to be decompressed and depending on the arguments, several conversions should be done.
[ "dissect", "the", "IPv6", "package", "compressed", "into", "this", "IPHC", "packet", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/sixlowpan.py#L452-L515
train
secdev/scapy
scapy/layers/sixlowpan.py
LoWPAN_IPHC._getTrafficClassAndFlowLabel
def _getTrafficClassAndFlowLabel(self): """Page 6, draft feb 2011 """ if self.tf == 0x0: return (self.tc_ecn << 6) + self.tc_dscp, self.flowlabel elif self.tf == 0x1: return (self.tc_ecn << 6), self.flowlabel elif self.tf == 0x2: return (self.tc_ecn <<...
python
def _getTrafficClassAndFlowLabel(self): """Page 6, draft feb 2011 """ if self.tf == 0x0: return (self.tc_ecn << 6) + self.tc_dscp, self.flowlabel elif self.tf == 0x1: return (self.tc_ecn << 6), self.flowlabel elif self.tf == 0x2: return (self.tc_ecn <<...
[ "def", "_getTrafficClassAndFlowLabel", "(", "self", ")", ":", "if", "self", ".", "tf", "==", "0x0", ":", "return", "(", "self", ".", "tc_ecn", "<<", "6", ")", "+", "self", ".", "tc_dscp", ",", "self", ".", "flowlabel", "elif", "self", ".", "tf", "=="...
Page 6, draft feb 2011
[ "Page", "6", "draft", "feb", "2011" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/sixlowpan.py#L707-L716
train
secdev/scapy
scapy/layers/sixlowpan.py
SixLoWPAN.dispatch_hook
def dispatch_hook(cls, _pkt=b"", *args, **kargs): """Depending on the payload content, the frame type we should interpretate""" # noqa: E501 if _pkt and len(_pkt) >= 1: if orb(_pkt[0]) == 0x41: return LoWPANUncompressedIPv6 if orb(_pkt[0]) == 0x42: ...
python
def dispatch_hook(cls, _pkt=b"", *args, **kargs): """Depending on the payload content, the frame type we should interpretate""" # noqa: E501 if _pkt and len(_pkt) >= 1: if orb(_pkt[0]) == 0x41: return LoWPANUncompressedIPv6 if orb(_pkt[0]) == 0x42: ...
[ "def", "dispatch_hook", "(", "cls", ",", "_pkt", "=", "b\"\"", ",", "*", "args", ",", "*", "*", "kargs", ")", ":", "# noqa: E501", "if", "_pkt", "and", "len", "(", "_pkt", ")", ">=", "1", ":", "if", "orb", "(", "_pkt", "[", "0", "]", ")", "==",...
Depending on the payload content, the frame type we should interpretate
[ "Depending", "on", "the", "payload", "content", "the", "frame", "type", "we", "should", "interpretate" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/sixlowpan.py#L729-L744
train
secdev/scapy
scapy/layers/x509.py
X509_TBSCertificate.get_issuer_str
def get_issuer_str(self): """ Returns a one-line string containing every type/value in a rather specific order. sorted() built-in ensures unicity. """ name_str = "" attrsDict = self.get_issuer() for attrType, attrSymbol in _attrName_mapping: if attrTyp...
python
def get_issuer_str(self): """ Returns a one-line string containing every type/value in a rather specific order. sorted() built-in ensures unicity. """ name_str = "" attrsDict = self.get_issuer() for attrType, attrSymbol in _attrName_mapping: if attrTyp...
[ "def", "get_issuer_str", "(", "self", ")", ":", "name_str", "=", "\"\"", "attrsDict", "=", "self", ".", "get_issuer", "(", ")", "for", "attrType", ",", "attrSymbol", "in", "_attrName_mapping", ":", "if", "attrType", "in", "attrsDict", ":", "name_str", "+=", ...
Returns a one-line string containing every type/value in a rather specific order. sorted() built-in ensures unicity.
[ "Returns", "a", "one", "-", "line", "string", "containing", "every", "type", "/", "value", "in", "a", "rather", "specific", "order", ".", "sorted", "()", "built", "-", "in", "ensures", "unicity", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/x509.py#L966-L981
train
secdev/scapy
scapy/sessions.py
DefaultSession.on_packet_received
def on_packet_received(self, pkt): """DEV: entry point. Will be called by sniff() for each received packet (that passes the filters). """ if not pkt: return if self.store: self.lst.append(pkt) if self.prn: result = self.prn(pkt) ...
python
def on_packet_received(self, pkt): """DEV: entry point. Will be called by sniff() for each received packet (that passes the filters). """ if not pkt: return if self.store: self.lst.append(pkt) if self.prn: result = self.prn(pkt) ...
[ "def", "on_packet_received", "(", "self", ",", "pkt", ")", ":", "if", "not", "pkt", ":", "return", "if", "self", ".", "store", ":", "self", ".", "lst", ".", "append", "(", "pkt", ")", "if", "self", ".", "prn", ":", "result", "=", "self", ".", "pr...
DEV: entry point. Will be called by sniff() for each received packet (that passes the filters).
[ "DEV", ":", "entry", "point", ".", "Will", "be", "called", "by", "sniff", "()", "for", "each", "received", "packet", "(", "that", "passes", "the", "filters", ")", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sessions.py#L26-L37
train
secdev/scapy
scapy/packet.py
bind_bottom_up
def bind_bottom_up(lower, upper, __fval=None, **fval): """Bind 2 layers for dissection. The upper layer will be chosen for dissection on top of the lower layer, if ALL the passed arguments are validated. If multiple calls are made with the same # noqa: E501 layers, the last one will be used as default....
python
def bind_bottom_up(lower, upper, __fval=None, **fval): """Bind 2 layers for dissection. The upper layer will be chosen for dissection on top of the lower layer, if ALL the passed arguments are validated. If multiple calls are made with the same # noqa: E501 layers, the last one will be used as default....
[ "def", "bind_bottom_up", "(", "lower", ",", "upper", ",", "__fval", "=", "None", ",", "*", "*", "fval", ")", ":", "if", "__fval", "is", "not", "None", ":", "fval", ".", "update", "(", "__fval", ")", "lower", ".", "payload_guess", "=", "lower", ".", ...
Bind 2 layers for dissection. The upper layer will be chosen for dissection on top of the lower layer, if ALL the passed arguments are validated. If multiple calls are made with the same # noqa: E501 layers, the last one will be used as default. ex: >>> bind_bottom_up(Ether, SNAP, type=0x1234)...
[ "Bind", "2", "layers", "for", "dissection", ".", "The", "upper", "layer", "will", "be", "chosen", "for", "dissection", "on", "top", "of", "the", "lower", "layer", "if", "ALL", "the", "passed", "arguments", "are", "validated", ".", "If", "multiple", "calls"...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L1539-L1553
train
secdev/scapy
scapy/packet.py
bind_top_down
def bind_top_down(lower, upper, __fval=None, **fval): """Bind 2 layers for building. When the upper layer is added as a payload of the lower layer, all the arguments # noqa: E501 will be applied to them. ex: >>> bind_top_down(Ether, SNAP, type=0x1234) >>> Ether()/SNAP() <Ether ...
python
def bind_top_down(lower, upper, __fval=None, **fval): """Bind 2 layers for building. When the upper layer is added as a payload of the lower layer, all the arguments # noqa: E501 will be applied to them. ex: >>> bind_top_down(Ether, SNAP, type=0x1234) >>> Ether()/SNAP() <Ether ...
[ "def", "bind_top_down", "(", "lower", ",", "upper", ",", "__fval", "=", "None", ",", "*", "*", "fval", ")", ":", "if", "__fval", "is", "not", "None", ":", "fval", ".", "update", "(", "__fval", ")", "upper", ".", "_overload_fields", "=", "upper", ".",...
Bind 2 layers for building. When the upper layer is added as a payload of the lower layer, all the arguments # noqa: E501 will be applied to them. ex: >>> bind_top_down(Ether, SNAP, type=0x1234) >>> Ether()/SNAP() <Ether type=0x1234 |<SNAP |>>
[ "Bind", "2", "layers", "for", "building", ".", "When", "the", "upper", "layer", "is", "added", "as", "a", "payload", "of", "the", "lower", "layer", "all", "the", "arguments", "#", "noqa", ":", "E501", "will", "be", "applied", "to", "them", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L1556-L1569
train
secdev/scapy
scapy/packet.py
bind_layers
def bind_layers(lower, upper, __fval=None, **fval): """Bind 2 layers on some specific fields' values. It makes the packet being built # noqa: E501 and dissected when the arguments are present. This functions calls both bind_bottom_up and bind_top_down, with all passed arguments. # noqa: E501 Please h...
python
def bind_layers(lower, upper, __fval=None, **fval): """Bind 2 layers on some specific fields' values. It makes the packet being built # noqa: E501 and dissected when the arguments are present. This functions calls both bind_bottom_up and bind_top_down, with all passed arguments. # noqa: E501 Please h...
[ "def", "bind_layers", "(", "lower", ",", "upper", ",", "__fval", "=", "None", ",", "*", "*", "fval", ")", ":", "if", "__fval", "is", "not", "None", ":", "fval", ".", "update", "(", "__fval", ")", "bind_top_down", "(", "lower", ",", "upper", ",", "*...
Bind 2 layers on some specific fields' values. It makes the packet being built # noqa: E501 and dissected when the arguments are present. This functions calls both bind_bottom_up and bind_top_down, with all passed arguments. # noqa: E501 Please have a look at their docs: - help(bind_bottom_up) ...
[ "Bind", "2", "layers", "on", "some", "specific", "fields", "values", ".", "It", "makes", "the", "packet", "being", "built", "#", "noqa", ":", "E501", "and", "dissected", "when", "the", "arguments", "are", "present", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L1573-L1585
train
secdev/scapy
scapy/packet.py
split_bottom_up
def split_bottom_up(lower, upper, __fval=None, **fval): """This call un-links an association that was made using bind_bottom_up. Have a look at help(bind_bottom_up) """ if __fval is not None: fval.update(__fval) def do_filter(params, cls): params_is_invalid = any( k not ...
python
def split_bottom_up(lower, upper, __fval=None, **fval): """This call un-links an association that was made using bind_bottom_up. Have a look at help(bind_bottom_up) """ if __fval is not None: fval.update(__fval) def do_filter(params, cls): params_is_invalid = any( k not ...
[ "def", "split_bottom_up", "(", "lower", ",", "upper", ",", "__fval", "=", "None", ",", "*", "*", "fval", ")", ":", "if", "__fval", "is", "not", "None", ":", "fval", ".", "update", "(", "__fval", ")", "def", "do_filter", "(", "params", ",", "cls", "...
This call un-links an association that was made using bind_bottom_up. Have a look at help(bind_bottom_up)
[ "This", "call", "un", "-", "links", "an", "association", "that", "was", "made", "using", "bind_bottom_up", ".", "Have", "a", "look", "at", "help", "(", "bind_bottom_up", ")" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L1588-L1600
train
secdev/scapy
scapy/packet.py
split_top_down
def split_top_down(lower, upper, __fval=None, **fval): """This call un-links an association that was made using bind_top_down. Have a look at help(bind_top_down) """ if __fval is not None: fval.update(__fval) if lower in upper._overload_fields: ofval = upper._overload_fields[lower] ...
python
def split_top_down(lower, upper, __fval=None, **fval): """This call un-links an association that was made using bind_top_down. Have a look at help(bind_top_down) """ if __fval is not None: fval.update(__fval) if lower in upper._overload_fields: ofval = upper._overload_fields[lower] ...
[ "def", "split_top_down", "(", "lower", ",", "upper", ",", "__fval", "=", "None", ",", "*", "*", "fval", ")", ":", "if", "__fval", "is", "not", "None", ":", "fval", ".", "update", "(", "__fval", ")", "if", "lower", "in", "upper", ".", "_overload_field...
This call un-links an association that was made using bind_top_down. Have a look at help(bind_top_down)
[ "This", "call", "un", "-", "links", "an", "association", "that", "was", "made", "using", "bind_top_down", ".", "Have", "a", "look", "at", "help", "(", "bind_top_down", ")" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L1603-L1614
train
secdev/scapy
scapy/packet.py
split_layers
def split_layers(lower, upper, __fval=None, **fval): """Split 2 layers previously bound. This call un-links calls bind_top_down and bind_bottom_up. It is the opposite of # noqa: E501 bind_layers. Please have a look at their docs: - help(split_bottom_up) - help(split_top_down) """ if ...
python
def split_layers(lower, upper, __fval=None, **fval): """Split 2 layers previously bound. This call un-links calls bind_top_down and bind_bottom_up. It is the opposite of # noqa: E501 bind_layers. Please have a look at their docs: - help(split_bottom_up) - help(split_top_down) """ if ...
[ "def", "split_layers", "(", "lower", ",", "upper", ",", "__fval", "=", "None", ",", "*", "*", "fval", ")", ":", "if", "__fval", "is", "not", "None", ":", "fval", ".", "update", "(", "__fval", ")", "split_bottom_up", "(", "lower", ",", "upper", ",", ...
Split 2 layers previously bound. This call un-links calls bind_top_down and bind_bottom_up. It is the opposite of # noqa: E501 bind_layers. Please have a look at their docs: - help(split_bottom_up) - help(split_top_down)
[ "Split", "2", "layers", "previously", "bound", ".", "This", "call", "un", "-", "links", "calls", "bind_top_down", "and", "bind_bottom_up", ".", "It", "is", "the", "opposite", "of", "#", "noqa", ":", "E501", "bind_layers", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L1618-L1630
train
secdev/scapy
scapy/packet.py
explore
def explore(layer=None): """Function used to discover the Scapy layers and protocols. It helps to see which packets exists in contrib or layer files. params: - layer: If specified, the function will explore the layer. If not, the GUI mode will be activated, to browse the available layers...
python
def explore(layer=None): """Function used to discover the Scapy layers and protocols. It helps to see which packets exists in contrib or layer files. params: - layer: If specified, the function will explore the layer. If not, the GUI mode will be activated, to browse the available layers...
[ "def", "explore", "(", "layer", "=", "None", ")", ":", "if", "layer", "is", "None", ":", "# GUI MODE", "if", "not", "conf", ".", "interactive", ":", "raise", "Scapy_Exception", "(", "\"explore() GUI-mode cannot be run in \"", "\"interactive mode. Please provide a \"",...
Function used to discover the Scapy layers and protocols. It helps to see which packets exists in contrib or layer files. params: - layer: If specified, the function will explore the layer. If not, the GUI mode will be activated, to browse the available layers examples: >>> explor...
[ "Function", "used", "to", "discover", "the", "Scapy", "layers", "and", "protocols", ".", "It", "helps", "to", "see", "which", "packets", "exists", "in", "contrib", "or", "layer", "files", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L1634-L1757
train
secdev/scapy
scapy/packet.py
ls
def ls(obj=None, case_sensitive=False, verbose=False): """List available layers, or infos on a given layer class or name. params: - obj: Packet / packet name to use - case_sensitive: if obj is a string, is it case sensitive? - verbose """ is_string = isinstance(obj, six.string_types) ...
python
def ls(obj=None, case_sensitive=False, verbose=False): """List available layers, or infos on a given layer class or name. params: - obj: Packet / packet name to use - case_sensitive: if obj is a string, is it case sensitive? - verbose """ is_string = isinstance(obj, six.string_types) ...
[ "def", "ls", "(", "obj", "=", "None", ",", "case_sensitive", "=", "False", ",", "verbose", "=", "False", ")", ":", "is_string", "=", "isinstance", "(", "obj", ",", "six", ".", "string_types", ")", "if", "obj", "is", "None", "or", "is_string", ":", "t...
List available layers, or infos on a given layer class or name. params: - obj: Packet / packet name to use - case_sensitive: if obj is a string, is it case sensitive? - verbose
[ "List", "available", "layers", "or", "infos", "on", "a", "given", "layer", "class", "or", "name", ".", "params", ":", "-", "obj", ":", "Packet", "/", "packet", "name", "to", "use", "-", "case_sensitive", ":", "if", "obj", "is", "a", "string", "is", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L1761-L1849
train
secdev/scapy
scapy/packet.py
fuzz
def fuzz(p, _inplace=0): """Transform a layer into a fuzzy layer by replacing some default values by random objects""" # noqa: E501 if not _inplace: p = p.copy() q = p while not isinstance(q, NoPayload): for f in q.fields_desc: if isinstance(f, PacketListField): ...
python
def fuzz(p, _inplace=0): """Transform a layer into a fuzzy layer by replacing some default values by random objects""" # noqa: E501 if not _inplace: p = p.copy() q = p while not isinstance(q, NoPayload): for f in q.fields_desc: if isinstance(f, PacketListField): ...
[ "def", "fuzz", "(", "p", ",", "_inplace", "=", "0", ")", ":", "# noqa: E501", "if", "not", "_inplace", ":", "p", "=", "p", ".", "copy", "(", ")", "q", "=", "p", "while", "not", "isinstance", "(", "q", ",", "NoPayload", ")", ":", "for", "f", "in...
Transform a layer into a fuzzy layer by replacing some default values by random objects
[ "Transform", "a", "layer", "into", "a", "fuzzy", "layer", "by", "replacing", "some", "default", "values", "by", "random", "objects" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L1857-L1874
train
secdev/scapy
scapy/packet.py
Packet.init_fields
def init_fields(self): """ Initialize each fields of the fields_desc dict """ if self.class_dont_cache.get(self.__class__, False): self.do_init_fields(self.fields_desc) else: self.do_init_cached_fields()
python
def init_fields(self): """ Initialize each fields of the fields_desc dict """ if self.class_dont_cache.get(self.__class__, False): self.do_init_fields(self.fields_desc) else: self.do_init_cached_fields()
[ "def", "init_fields", "(", "self", ")", ":", "if", "self", ".", "class_dont_cache", ".", "get", "(", "self", ".", "__class__", ",", "False", ")", ":", "self", ".", "do_init_fields", "(", "self", ".", "fields_desc", ")", "else", ":", "self", ".", "do_in...
Initialize each fields of the fields_desc dict
[ "Initialize", "each", "fields", "of", "the", "fields_desc", "dict" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L167-L175
train
secdev/scapy
scapy/packet.py
Packet.do_init_fields
def do_init_fields(self, flist): """ Initialize each fields of the fields_desc dict """ for f in flist: self.default_fields[f.name] = copy.deepcopy(f.default) self.fieldtype[f.name] = f if f.holds_packets: self.packetfields.append(f)
python
def do_init_fields(self, flist): """ Initialize each fields of the fields_desc dict """ for f in flist: self.default_fields[f.name] = copy.deepcopy(f.default) self.fieldtype[f.name] = f if f.holds_packets: self.packetfields.append(f)
[ "def", "do_init_fields", "(", "self", ",", "flist", ")", ":", "for", "f", "in", "flist", ":", "self", ".", "default_fields", "[", "f", ".", "name", "]", "=", "copy", ".", "deepcopy", "(", "f", ".", "default", ")", "self", ".", "fieldtype", "[", "f"...
Initialize each fields of the fields_desc dict
[ "Initialize", "each", "fields", "of", "the", "fields_desc", "dict" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L177-L185
train
secdev/scapy
scapy/packet.py
Packet.do_init_cached_fields
def do_init_cached_fields(self): """ Initialize each fields of the fields_desc dict, or use the cached fields information """ cls_name = self.__class__ # Build the fields information if Packet.class_default_fields.get(cls_name, None) is None: self.pr...
python
def do_init_cached_fields(self): """ Initialize each fields of the fields_desc dict, or use the cached fields information """ cls_name = self.__class__ # Build the fields information if Packet.class_default_fields.get(cls_name, None) is None: self.pr...
[ "def", "do_init_cached_fields", "(", "self", ")", ":", "cls_name", "=", "self", ".", "__class__", "# Build the fields information", "if", "Packet", ".", "class_default_fields", ".", "get", "(", "cls_name", ",", "None", ")", "is", "None", ":", "self", ".", "pre...
Initialize each fields of the fields_desc dict, or use the cached fields information
[ "Initialize", "each", "fields", "of", "the", "fields_desc", "dict", "or", "use", "the", "cached", "fields", "information" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L187-L208
train
secdev/scapy
scapy/packet.py
Packet.prepare_cached_fields
def prepare_cached_fields(self, flist): """ Prepare the cached fields of the fields_desc dict """ cls_name = self.__class__ # Fields cache initialization if flist: Packet.class_default_fields[cls_name] = dict() Packet.class_default_fields_ref[cls...
python
def prepare_cached_fields(self, flist): """ Prepare the cached fields of the fields_desc dict """ cls_name = self.__class__ # Fields cache initialization if flist: Packet.class_default_fields[cls_name] = dict() Packet.class_default_fields_ref[cls...
[ "def", "prepare_cached_fields", "(", "self", ",", "flist", ")", ":", "cls_name", "=", "self", ".", "__class__", "# Fields cache initialization", "if", "flist", ":", "Packet", ".", "class_default_fields", "[", "cls_name", "]", "=", "dict", "(", ")", "Packet", "...
Prepare the cached fields of the fields_desc dict
[ "Prepare", "the", "cached", "fields", "of", "the", "fields_desc", "dict" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L210-L243
train
secdev/scapy
scapy/packet.py
Packet.dissection_done
def dissection_done(self, pkt): """DEV: will be called after a dissection is completed""" self.post_dissection(pkt) self.payload.dissection_done(pkt)
python
def dissection_done(self, pkt): """DEV: will be called after a dissection is completed""" self.post_dissection(pkt) self.payload.dissection_done(pkt)
[ "def", "dissection_done", "(", "self", ",", "pkt", ")", ":", "self", ".", "post_dissection", "(", "pkt", ")", "self", ".", "payload", ".", "dissection_done", "(", "pkt", ")" ]
DEV: will be called after a dissection is completed
[ "DEV", ":", "will", "be", "called", "after", "a", "dissection", "is", "completed" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L245-L248
train
secdev/scapy
scapy/packet.py
Packet.copy
def copy(self): """Returns a deep copy of the instance.""" clone = self.__class__() clone.fields = self.copy_fields_dict(self.fields) clone.default_fields = self.copy_fields_dict(self.default_fields) clone.overloaded_fields = self.overloaded_fields.copy() clone.underlayer...
python
def copy(self): """Returns a deep copy of the instance.""" clone = self.__class__() clone.fields = self.copy_fields_dict(self.fields) clone.default_fields = self.copy_fields_dict(self.default_fields) clone.overloaded_fields = self.overloaded_fields.copy() clone.underlayer...
[ "def", "copy", "(", "self", ")", ":", "clone", "=", "self", ".", "__class__", "(", ")", "clone", ".", "fields", "=", "self", ".", "copy_fields_dict", "(", "self", ".", "fields", ")", "clone", ".", "default_fields", "=", "self", ".", "copy_fields_dict", ...
Returns a deep copy of the instance.
[ "Returns", "a", "deep", "copy", "of", "the", "instance", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L287-L304
train
secdev/scapy
scapy/packet.py
Packet._superdir
def _superdir(self): """ Return a list of slots and methods, including those from subclasses. """ attrs = set() cls = self.__class__ if hasattr(cls, '__all_slots__'): attrs.update(cls.__all_slots__) for bcls in cls.__mro__: if hasattr(bcls,...
python
def _superdir(self): """ Return a list of slots and methods, including those from subclasses. """ attrs = set() cls = self.__class__ if hasattr(cls, '__all_slots__'): attrs.update(cls.__all_slots__) for bcls in cls.__mro__: if hasattr(bcls,...
[ "def", "_superdir", "(", "self", ")", ":", "attrs", "=", "set", "(", ")", "cls", "=", "self", ".", "__class__", "if", "hasattr", "(", "cls", ",", "'__all_slots__'", ")", ":", "attrs", ".", "update", "(", "cls", ".", "__all_slots__", ")", "for", "bcls...
Return a list of slots and methods, including those from subclasses.
[ "Return", "a", "list", "of", "slots", "and", "methods", "including", "those", "from", "subclasses", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L384-L395
train
secdev/scapy
scapy/packet.py
Packet.clear_cache
def clear_cache(self): """Clear the raw packet cache for the field and all its subfields""" self.raw_packet_cache = None for _, fval in six.iteritems(self.fields): if isinstance(fval, Packet): fval.clear_cache() self.payload.clear_cache()
python
def clear_cache(self): """Clear the raw packet cache for the field and all its subfields""" self.raw_packet_cache = None for _, fval in six.iteritems(self.fields): if isinstance(fval, Packet): fval.clear_cache() self.payload.clear_cache()
[ "def", "clear_cache", "(", "self", ")", ":", "self", ".", "raw_packet_cache", "=", "None", "for", "_", ",", "fval", "in", "six", ".", "iteritems", "(", "self", ".", "fields", ")", ":", "if", "isinstance", "(", "fval", ",", "Packet", ")", ":", "fval",...
Clear the raw packet cache for the field and all its subfields
[ "Clear", "the", "raw", "packet", "cache", "for", "the", "field", "and", "all", "its", "subfields" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L488-L494
train
secdev/scapy
scapy/packet.py
Packet.self_build
def self_build(self, field_pos_list=None): """ Create the default layer regarding fields_desc dict :param field_pos_list: """ if self.raw_packet_cache is not None: for fname, fval in six.iteritems(self.raw_packet_cache_fields): if self.getfieldval(fna...
python
def self_build(self, field_pos_list=None): """ Create the default layer regarding fields_desc dict :param field_pos_list: """ if self.raw_packet_cache is not None: for fname, fval in six.iteritems(self.raw_packet_cache_fields): if self.getfieldval(fna...
[ "def", "self_build", "(", "self", ",", "field_pos_list", "=", "None", ")", ":", "if", "self", ".", "raw_packet_cache", "is", "not", "None", ":", "for", "fname", ",", "fval", "in", "six", ".", "iteritems", "(", "self", ".", "raw_packet_cache_fields", ")", ...
Create the default layer regarding fields_desc dict :param field_pos_list:
[ "Create", "the", "default", "layer", "regarding", "fields_desc", "dict" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L496-L521
train
secdev/scapy
scapy/packet.py
Packet.do_build
def do_build(self): """ Create the default version of the layer :return: a string of the packet with the payload """ if not self.explicit: self = next(iter(self)) pkt = self.self_build() for t in self.post_transforms: pkt = t(pkt) ...
python
def do_build(self): """ Create the default version of the layer :return: a string of the packet with the payload """ if not self.explicit: self = next(iter(self)) pkt = self.self_build() for t in self.post_transforms: pkt = t(pkt) ...
[ "def", "do_build", "(", "self", ")", ":", "if", "not", "self", ".", "explicit", ":", "self", "=", "next", "(", "iter", "(", "self", ")", ")", "pkt", "=", "self", ".", "self_build", "(", ")", "for", "t", "in", "self", ".", "post_transforms", ":", ...
Create the default version of the layer :return: a string of the packet with the payload
[ "Create", "the", "default", "version", "of", "the", "layer" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L531-L546
train
secdev/scapy
scapy/packet.py
Packet.build
def build(self): """ Create the current layer :return: string of the packet with the payload """ p = self.do_build() p += self.build_padding() p = self.build_done(p) return p
python
def build(self): """ Create the current layer :return: string of the packet with the payload """ p = self.do_build() p += self.build_padding() p = self.build_done(p) return p
[ "def", "build", "(", "self", ")", ":", "p", "=", "self", ".", "do_build", "(", ")", "p", "+=", "self", ".", "build_padding", "(", ")", "p", "=", "self", ".", "build_done", "(", "p", ")", "return", "p" ]
Create the current layer :return: string of the packet with the payload
[ "Create", "the", "current", "layer" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L551-L560
train
secdev/scapy
scapy/packet.py
Packet.do_dissect_payload
def do_dissect_payload(self, s): """ Perform the dissection of the layer's payload :param str s: the raw layer """ if s: cls = self.guess_payload_class(s) try: p = cls(s, _internal=1, _underlayer=self) except KeyboardInterrupt:...
python
def do_dissect_payload(self, s): """ Perform the dissection of the layer's payload :param str s: the raw layer """ if s: cls = self.guess_payload_class(s) try: p = cls(s, _internal=1, _underlayer=self) except KeyboardInterrupt:...
[ "def", "do_dissect_payload", "(", "self", ",", "s", ")", ":", "if", "s", ":", "cls", "=", "self", ".", "guess_payload_class", "(", "s", ")", "try", ":", "p", "=", "cls", "(", "s", ",", "_internal", "=", "1", ",", "_underlayer", "=", "self", ")", ...
Perform the dissection of the layer's payload :param str s: the raw layer
[ "Perform", "the", "dissection", "of", "the", "layer", "s", "payload" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L796-L817
train
secdev/scapy
scapy/packet.py
Packet.guess_payload_class
def guess_payload_class(self, payload): """ DEV: Guesses the next payload class from layer bonds. Can be overloaded to use a different mechanism. :param str payload: the layer's payload :return: the payload class """ for t in self.aliastypes: for fval...
python
def guess_payload_class(self, payload): """ DEV: Guesses the next payload class from layer bonds. Can be overloaded to use a different mechanism. :param str payload: the layer's payload :return: the payload class """ for t in self.aliastypes: for fval...
[ "def", "guess_payload_class", "(", "self", ",", "payload", ")", ":", "for", "t", "in", "self", ".", "aliastypes", ":", "for", "fval", ",", "cls", "in", "t", ".", "payload_guess", ":", "if", "all", "(", "hasattr", "(", "self", ",", "k", ")", "and", ...
DEV: Guesses the next payload class from layer bonds. Can be overloaded to use a different mechanism. :param str payload: the layer's payload :return: the payload class
[ "DEV", ":", "Guesses", "the", "next", "payload", "class", "from", "layer", "bonds", ".", "Can", "be", "overloaded", "to", "use", "a", "different", "mechanism", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L831-L844
train
secdev/scapy
scapy/packet.py
Packet.hide_defaults
def hide_defaults(self): """Removes fields' values that are the same as default values.""" # use list(): self.fields is modified in the loop for k, v in list(six.iteritems(self.fields)): v = self.fields[k] if k in self.default_fields: if self.default_field...
python
def hide_defaults(self): """Removes fields' values that are the same as default values.""" # use list(): self.fields is modified in the loop for k, v in list(six.iteritems(self.fields)): v = self.fields[k] if k in self.default_fields: if self.default_field...
[ "def", "hide_defaults", "(", "self", ")", ":", "# use list(): self.fields is modified in the loop", "for", "k", ",", "v", "in", "list", "(", "six", ".", "iteritems", "(", "self", ".", "fields", ")", ")", ":", "v", "=", "self", ".", "fields", "[", "k", "]...
Removes fields' values that are the same as default values.
[ "Removes", "fields", "values", "that", "are", "the", "same", "as", "default", "values", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L856-L864
train
secdev/scapy
scapy/packet.py
Packet.layers
def layers(self): """returns a list of layer classes (including subclasses) in this packet""" # noqa: E501 layers = [] lyr = self while lyr: layers.append(lyr.__class__) lyr = lyr.payload.getlayer(0, _subclass=True) return layers
python
def layers(self): """returns a list of layer classes (including subclasses) in this packet""" # noqa: E501 layers = [] lyr = self while lyr: layers.append(lyr.__class__) lyr = lyr.payload.getlayer(0, _subclass=True) return layers
[ "def", "layers", "(", "self", ")", ":", "# noqa: E501", "layers", "=", "[", "]", "lyr", "=", "self", "while", "lyr", ":", "layers", ".", "append", "(", "lyr", ".", "__class__", ")", "lyr", "=", "lyr", ".", "payload", ".", "getlayer", "(", "0", ",",...
returns a list of layer classes (including subclasses) in this packet
[ "returns", "a", "list", "of", "layer", "classes", "(", "including", "subclasses", ")", "in", "this", "packet" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L990-L997
train
secdev/scapy
scapy/packet.py
Packet.getlayer
def getlayer(self, cls, nb=1, _track=None, _subclass=None, **flt): """Return the nb^th layer that is an instance of cls, matching flt values. """ if _subclass is None: _subclass = self.match_subclass or None if _subclass: match = lambda cls1, cls2: issubclass(cls1...
python
def getlayer(self, cls, nb=1, _track=None, _subclass=None, **flt): """Return the nb^th layer that is an instance of cls, matching flt values. """ if _subclass is None: _subclass = self.match_subclass or None if _subclass: match = lambda cls1, cls2: issubclass(cls1...
[ "def", "getlayer", "(", "self", ",", "cls", ",", "nb", "=", "1", ",", "_track", "=", "None", ",", "_subclass", "=", "None", ",", "*", "*", "flt", ")", ":", "if", "_subclass", "is", "None", ":", "_subclass", "=", "self", ".", "match_subclass", "or",...
Return the nb^th layer that is an instance of cls, matching flt values.
[ "Return", "the", "nb^th", "layer", "that", "is", "an", "instance", "of", "cls", "matching", "flt", "values", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L1017-L1060
train
secdev/scapy
scapy/packet.py
Packet._show_or_dump
def _show_or_dump(self, dump=False, indent=3, lvl="", label_lvl="", first_call=True): # noqa: E501 """ Internal method that shows or dumps a hierarchical view of a packet. Called by show. :param dump: determine if it prints or returns the string value :param int indent: the siz...
python
def _show_or_dump(self, dump=False, indent=3, lvl="", label_lvl="", first_call=True): # noqa: E501 """ Internal method that shows or dumps a hierarchical view of a packet. Called by show. :param dump: determine if it prints or returns the string value :param int indent: the siz...
[ "def", "_show_or_dump", "(", "self", ",", "dump", "=", "False", ",", "indent", "=", "3", ",", "lvl", "=", "\"\"", ",", "label_lvl", "=", "\"\"", ",", "first_call", "=", "True", ")", ":", "# noqa: E501", "if", "dump", ":", "from", "scapy", ".", "theme...
Internal method that shows or dumps a hierarchical view of a packet. Called by show. :param dump: determine if it prints or returns the string value :param int indent: the size of indentation for each layer :param str lvl: additional information about the layer lvl :param str la...
[ "Internal", "method", "that", "shows", "or", "dumps", "a", "hierarchical", "view", "of", "a", "packet", ".", "Called", "by", "show", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L1106-L1160
train
secdev/scapy
scapy/packet.py
Packet.show
def show(self, dump=False, indent=3, lvl="", label_lvl=""): """ Prints or returns (when "dump" is true) a hierarchical view of the packet. :param dump: determine if it prints or returns the string value :param int indent: the size of indentation for each layer :param str...
python
def show(self, dump=False, indent=3, lvl="", label_lvl=""): """ Prints or returns (when "dump" is true) a hierarchical view of the packet. :param dump: determine if it prints or returns the string value :param int indent: the size of indentation for each layer :param str...
[ "def", "show", "(", "self", ",", "dump", "=", "False", ",", "indent", "=", "3", ",", "lvl", "=", "\"\"", ",", "label_lvl", "=", "\"\"", ")", ":", "return", "self", ".", "_show_or_dump", "(", "dump", ",", "indent", ",", "lvl", ",", "label_lvl", ")" ...
Prints or returns (when "dump" is true) a hierarchical view of the packet. :param dump: determine if it prints or returns the string value :param int indent: the size of indentation for each layer :param str lvl: additional information about the layer lvl :param str label_lvl: a...
[ "Prints", "or", "returns", "(", "when", "dump", "is", "true", ")", "a", "hierarchical", "view", "of", "the", "packet", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L1162-L1173
train
secdev/scapy
scapy/packet.py
Packet.show2
def show2(self, dump=False, indent=3, lvl="", label_lvl=""): """ Prints or returns (when "dump" is true) a hierarchical view of an assembled version of the packet, so that automatic fields are calculated (checksums, etc.) :param dump: determine if it prints or returns the string...
python
def show2(self, dump=False, indent=3, lvl="", label_lvl=""): """ Prints or returns (when "dump" is true) a hierarchical view of an assembled version of the packet, so that automatic fields are calculated (checksums, etc.) :param dump: determine if it prints or returns the string...
[ "def", "show2", "(", "self", ",", "dump", "=", "False", ",", "indent", "=", "3", ",", "lvl", "=", "\"\"", ",", "label_lvl", "=", "\"\"", ")", ":", "return", "self", ".", "__class__", "(", "raw", "(", "self", ")", ")", ".", "show", "(", "dump", ...
Prints or returns (when "dump" is true) a hierarchical view of an assembled version of the packet, so that automatic fields are calculated (checksums, etc.) :param dump: determine if it prints or returns the string value :param int indent: the size of indentation for each layer ...
[ "Prints", "or", "returns", "(", "when", "dump", "is", "true", ")", "a", "hierarchical", "view", "of", "an", "assembled", "version", "of", "the", "packet", "so", "that", "automatic", "fields", "are", "calculated", "(", "checksums", "etc", ".", ")" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L1175-L1187
train
secdev/scapy
scapy/packet.py
Packet.sprintf
def sprintf(self, fmt, relax=1): """sprintf(format, [relax=1]) -> str where format is a string that can include directives. A directive begins and ends by % and has the following format %[fmt[r],][cls[:nb].]field%. fmt is a classic printf directive, "r" can be appended for raw substitution (ex: IP.flags=0x18 i...
python
def sprintf(self, fmt, relax=1): """sprintf(format, [relax=1]) -> str where format is a string that can include directives. A directive begins and ends by % and has the following format %[fmt[r],][cls[:nb].]field%. fmt is a classic printf directive, "r" can be appended for raw substitution (ex: IP.flags=0x18 i...
[ "def", "sprintf", "(", "self", ",", "fmt", ",", "relax", "=", "1", ")", ":", "escape", "=", "{", "\"%\"", ":", "\"%\"", ",", "\"(\"", ":", "\"{\"", ",", "\")\"", ":", "\"}\"", "}", "# Evaluate conditions", "while", "\"{\"", "in", "fmt", ":", "i", "...
sprintf(format, [relax=1]) -> str where format is a string that can include directives. A directive begins and ends by % and has the following format %[fmt[r],][cls[:nb].]field%. fmt is a classic printf directive, "r" can be appended for raw substitution (ex: IP.flags=0x18 instead of SA), nb is the number of the layer...
[ "sprintf", "(", "format", "[", "relax", "=", "1", "]", ")", "-", ">", "str", "where", "format", "is", "a", "string", "that", "can", "include", "directives", ".", "A", "directive", "begins", "and", "ends", "by", "%", "and", "has", "the", "following", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L1189-L1291
train
secdev/scapy
scapy/packet.py
Packet.command
def command(self): """ Returns a string representing the command you have to type to obtain the same packet """ f = [] for fn, fv in six.iteritems(self.fields): fld = self.get_field(fn) if isinstance(fv, (list, dict, set)) and len(fv) == 0: ...
python
def command(self): """ Returns a string representing the command you have to type to obtain the same packet """ f = [] for fn, fv in six.iteritems(self.fields): fld = self.get_field(fn) if isinstance(fv, (list, dict, set)) and len(fv) == 0: ...
[ "def", "command", "(", "self", ")", ":", "f", "=", "[", "]", "for", "fn", ",", "fv", "in", "six", ".", "iteritems", "(", "self", ".", "fields", ")", ":", "fld", "=", "self", ".", "get_field", "(", "fn", ")", "if", "isinstance", "(", "fv", ",", ...
Returns a string representing the command you have to type to obtain the same packet
[ "Returns", "a", "string", "representing", "the", "command", "you", "have", "to", "type", "to", "obtain", "the", "same", "packet" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L1341-L1364
train
secdev/scapy
scapy/layers/tls/automaton_srv.py
TLSServerAutomaton.INIT_TLS_SESSION
def INIT_TLS_SESSION(self): """ XXX We should offer the right key according to the client's suites. For now server_rsa_key is only used for RSAkx, but we should try to replace every server_key with both server_rsa_key and server_ecdsa_key. """ self.cur_session = tlsSessio...
python
def INIT_TLS_SESSION(self): """ XXX We should offer the right key according to the client's suites. For now server_rsa_key is only used for RSAkx, but we should try to replace every server_key with both server_rsa_key and server_ecdsa_key. """ self.cur_session = tlsSessio...
[ "def", "INIT_TLS_SESSION", "(", "self", ")", ":", "self", ".", "cur_session", "=", "tlsSession", "(", "connection_end", "=", "\"server\"", ")", "self", ".", "cur_session", ".", "server_certs", "=", "[", "self", ".", "mycert", "]", "self", ".", "cur_session",...
XXX We should offer the right key according to the client's suites. For now server_rsa_key is only used for RSAkx, but we should try to replace every server_key with both server_rsa_key and server_ecdsa_key.
[ "XXX", "We", "should", "offer", "the", "right", "key", "according", "to", "the", "client", "s", "suites", ".", "For", "now", "server_rsa_key", "is", "only", "used", "for", "RSAkx", "but", "we", "should", "try", "to", "replace", "every", "server_key", "with...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/automaton_srv.py#L176-L189
train
secdev/scapy
scapy/layers/tls/automaton_srv.py
TLSServerAutomaton.should_check_ciphersuites
def should_check_ciphersuites(self): """ We extract cipher suites candidates from the client's proposition. """ if isinstance(self.mykey, PrivKeyRSA): kx = "RSA" elif isinstance(self.mykey, PrivKeyECDSA): kx = "ECDSA" if get_usable_ciphersuites(sel...
python
def should_check_ciphersuites(self): """ We extract cipher suites candidates from the client's proposition. """ if isinstance(self.mykey, PrivKeyRSA): kx = "RSA" elif isinstance(self.mykey, PrivKeyECDSA): kx = "ECDSA" if get_usable_ciphersuites(sel...
[ "def", "should_check_ciphersuites", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "mykey", ",", "PrivKeyRSA", ")", ":", "kx", "=", "\"RSA\"", "elif", "isinstance", "(", "self", ".", "mykey", ",", "PrivKeyECDSA", ")", ":", "kx", "=", "\"ECD...
We extract cipher suites candidates from the client's proposition.
[ "We", "extract", "cipher", "suites", "candidates", "from", "the", "client", "s", "proposition", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/automaton_srv.py#L212-L222
train
secdev/scapy
scapy/layers/tls/automaton_srv.py
TLSServerAutomaton.should_add_ServerHello
def should_add_ServerHello(self): """ Selecting a cipher suite should be no trouble as we already caught the None case previously. Also, we do not manage extensions at all. """ if isinstance(self.mykey, PrivKeyRSA): kx = "RSA" elif isinstance(self.myk...
python
def should_add_ServerHello(self): """ Selecting a cipher suite should be no trouble as we already caught the None case previously. Also, we do not manage extensions at all. """ if isinstance(self.mykey, PrivKeyRSA): kx = "RSA" elif isinstance(self.myk...
[ "def", "should_add_ServerHello", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "mykey", ",", "PrivKeyRSA", ")", ":", "kx", "=", "\"RSA\"", "elif", "isinstance", "(", "self", ".", "mykey", ",", "PrivKeyECDSA", ")", ":", "kx", "=", "\"ECDSA\...
Selecting a cipher suite should be no trouble as we already caught the None case previously. Also, we do not manage extensions at all.
[ "Selecting", "a", "cipher", "suite", "should", "be", "no", "trouble", "as", "we", "already", "caught", "the", "None", "case", "previously", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/automaton_srv.py#L243-L259
train
secdev/scapy
scapy/modules/krack/automaton.py
KrackAP.parse_args
def parse_args(self, ap_mac, ssid, passphrase, channel=None, # KRACK attack options double_3handshake=True, encrypt_3handshake=True, wait_3handshake=0, double_gtk_refresh=True, arp_target...
python
def parse_args(self, ap_mac, ssid, passphrase, channel=None, # KRACK attack options double_3handshake=True, encrypt_3handshake=True, wait_3handshake=0, double_gtk_refresh=True, arp_target...
[ "def", "parse_args", "(", "self", ",", "ap_mac", ",", "ssid", ",", "passphrase", ",", "channel", "=", "None", ",", "# KRACK attack options", "double_3handshake", "=", "True", ",", "encrypt_3handshake", "=", "True", ",", "wait_3handshake", "=", "0", ",", "doubl...
Mandatory arguments: @iface: interface to use (must be in monitor mode) @ap_mac: AP's MAC @ssid: AP's SSID @passphrase: AP's Passphrase (min 8 char.) Optional arguments: @channel: used by the interface. Default 6, autodetected on windows Krack attacks options: ...
[ "Mandatory", "arguments", ":", "@iface", ":", "interface", "to", "use", "(", "must", "be", "in", "monitor", "mode", ")", "@ap_mac", ":", "AP", "s", "MAC", "@ssid", ":", "AP", "s", "SSID", "@passphrase", ":", "AP", "s", "Passphrase", "(", "min", "8", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/modules/krack/automaton.py#L72-L155
train
secdev/scapy
scapy/modules/krack/automaton.py
KrackAP.install_PMK
def install_PMK(self): """Compute and install the PMK""" self.pmk = PBKDF2HMAC( algorithm=hashes.SHA1(), length=32, salt=self.ssid.encode(), iterations=4096, backend=default_backend(), ).derive(self.passphrase.encode())
python
def install_PMK(self): """Compute and install the PMK""" self.pmk = PBKDF2HMAC( algorithm=hashes.SHA1(), length=32, salt=self.ssid.encode(), iterations=4096, backend=default_backend(), ).derive(self.passphrase.encode())
[ "def", "install_PMK", "(", "self", ")", ":", "self", ".", "pmk", "=", "PBKDF2HMAC", "(", "algorithm", "=", "hashes", ".", "SHA1", "(", ")", ",", "length", "=", "32", ",", "salt", "=", "self", ".", "ssid", ".", "encode", "(", ")", ",", "iterations",...
Compute and install the PMK
[ "Compute", "and", "install", "the", "PMK" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/modules/krack/automaton.py#L169-L177
train
secdev/scapy
scapy/modules/krack/automaton.py
KrackAP.install_unicast_keys
def install_unicast_keys(self, client_nonce): """Use the client nonce @client_nonce to compute and install PTK, KCK, KEK, TK, MIC (AP -> STA), MIC (STA -> AP) """ pmk = self.pmk anonce = self.anonce snonce = client_nonce amac = mac2str(self.mac) smac = mac...
python
def install_unicast_keys(self, client_nonce): """Use the client nonce @client_nonce to compute and install PTK, KCK, KEK, TK, MIC (AP -> STA), MIC (STA -> AP) """ pmk = self.pmk anonce = self.anonce snonce = client_nonce amac = mac2str(self.mac) smac = mac...
[ "def", "install_unicast_keys", "(", "self", ",", "client_nonce", ")", ":", "pmk", "=", "self", ".", "pmk", "anonce", "=", "self", ".", "anonce", "snonce", "=", "client_nonce", "amac", "=", "mac2str", "(", "self", ".", "mac", ")", "smac", "=", "mac2str", ...
Use the client nonce @client_nonce to compute and install PTK, KCK, KEK, TK, MIC (AP -> STA), MIC (STA -> AP)
[ "Use", "the", "client", "nonce" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/modules/krack/automaton.py#L179-L200
train
secdev/scapy
scapy/modules/krack/automaton.py
KrackAP.install_GTK
def install_GTK(self): """Compute a new GTK and install it alongs MIC (AP -> Group = broadcast + multicast) """ # Compute GTK self.gtk_full = self.gen_nonce(32) self.gtk = self.gtk_full[:16] # Extract derivated keys self.mic_ap_to_group = self.gtk_full[1...
python
def install_GTK(self): """Compute a new GTK and install it alongs MIC (AP -> Group = broadcast + multicast) """ # Compute GTK self.gtk_full = self.gen_nonce(32) self.gtk = self.gtk_full[:16] # Extract derivated keys self.mic_ap_to_group = self.gtk_full[1...
[ "def", "install_GTK", "(", "self", ")", ":", "# Compute GTK", "self", ".", "gtk_full", "=", "self", ".", "gen_nonce", "(", "32", ")", "self", ".", "gtk", "=", "self", ".", "gtk_full", "[", ":", "16", "]", "# Extract derivated keys", "self", ".", "mic_ap_...
Compute a new GTK and install it alongs MIC (AP -> Group = broadcast + multicast)
[ "Compute", "a", "new", "GTK", "and", "install", "it", "alongs", "MIC", "(", "AP", "-", ">", "Group", "=", "broadcast", "+", "multicast", ")" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/modules/krack/automaton.py#L202-L215
train
secdev/scapy
scapy/modules/krack/automaton.py
KrackAP.build_ap_info_pkt
def build_ap_info_pkt(self, layer_cls, dest): """Build a packet with info describing the current AP For beacon / proberesp use """ return RadioTap() \ / Dot11(addr1=dest, addr2=self.mac, addr3=self.mac) \ / layer_cls(timestamp=0, beacon_interval=100, ...
python
def build_ap_info_pkt(self, layer_cls, dest): """Build a packet with info describing the current AP For beacon / proberesp use """ return RadioTap() \ / Dot11(addr1=dest, addr2=self.mac, addr3=self.mac) \ / layer_cls(timestamp=0, beacon_interval=100, ...
[ "def", "build_ap_info_pkt", "(", "self", ",", "layer_cls", ",", "dest", ")", ":", "return", "RadioTap", "(", ")", "/", "Dot11", "(", "addr1", "=", "dest", ",", "addr2", "=", "self", ".", "mac", ",", "addr3", "=", "self", ".", "mac", ")", "/", "laye...
Build a packet with info describing the current AP For beacon / proberesp use
[ "Build", "a", "packet", "with", "info", "describing", "the", "current", "AP", "For", "beacon", "/", "proberesp", "use" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/modules/krack/automaton.py#L219-L232
train
secdev/scapy
scapy/modules/krack/automaton.py
KrackAP.build_GTK_KDE
def build_GTK_KDE(self): """Build the Key Data Encapsulation for GTK KeyID: 0 Ref: 802.11i p81 """ return b''.join([ b'\xdd', # Type KDE chb(len(self.gtk_full) + 6), b'\x00\x0f\xac', # OUI b'\x01', # GTK KDE b'\x00\x0...
python
def build_GTK_KDE(self): """Build the Key Data Encapsulation for GTK KeyID: 0 Ref: 802.11i p81 """ return b''.join([ b'\xdd', # Type KDE chb(len(self.gtk_full) + 6), b'\x00\x0f\xac', # OUI b'\x01', # GTK KDE b'\x00\x0...
[ "def", "build_GTK_KDE", "(", "self", ")", ":", "return", "b''", ".", "join", "(", "[", "b'\\xdd'", ",", "# Type KDE", "chb", "(", "len", "(", "self", ".", "gtk_full", ")", "+", "6", ")", ",", "b'\\x00\\x0f\\xac'", ",", "# OUI", "b'\\x01'", ",", "# GTK ...
Build the Key Data Encapsulation for GTK KeyID: 0 Ref: 802.11i p81
[ "Build", "the", "Key", "Data", "Encapsulation", "for", "GTK", "KeyID", ":", "0", "Ref", ":", "802", ".", "11i", "p81" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/modules/krack/automaton.py#L301-L313
train
secdev/scapy
scapy/modules/krack/automaton.py
KrackAP.send_wpa_enc
def send_wpa_enc(self, data, iv, seqnum, dest, mic_key, key_idx=0, additionnal_flag=["from-DS"], encrypt_key=None): """Send an encrypted packet with content @data, using IV @iv, sequence number @seqnum, MIC key @mic_key """ if encrypt_key is Non...
python
def send_wpa_enc(self, data, iv, seqnum, dest, mic_key, key_idx=0, additionnal_flag=["from-DS"], encrypt_key=None): """Send an encrypted packet with content @data, using IV @iv, sequence number @seqnum, MIC key @mic_key """ if encrypt_key is Non...
[ "def", "send_wpa_enc", "(", "self", ",", "data", ",", "iv", ",", "seqnum", ",", "dest", ",", "mic_key", ",", "key_idx", "=", "0", ",", "additionnal_flag", "=", "[", "\"from-DS\"", "]", ",", "encrypt_key", "=", "None", ")", ":", "if", "encrypt_key", "is...
Send an encrypted packet with content @data, using IV @iv, sequence number @seqnum, MIC key @mic_key
[ "Send", "an", "encrypted", "packet", "with", "content" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/modules/krack/automaton.py#L315-L345
train
secdev/scapy
scapy/modules/krack/automaton.py
KrackAP.send_ether_over_wpa
def send_ether_over_wpa(self, pkt, **kwargs): """Send an Ethernet packet using the WPA channel Extra arguments will be ignored, and are just left for compatibility """ payload = LLC() / SNAP() / pkt[Ether].payload dest = pkt.dst if dest == "ff:ff:ff:ff:ff:ff": ...
python
def send_ether_over_wpa(self, pkt, **kwargs): """Send an Ethernet packet using the WPA channel Extra arguments will be ignored, and are just left for compatibility """ payload = LLC() / SNAP() / pkt[Ether].payload dest = pkt.dst if dest == "ff:ff:ff:ff:ff:ff": ...
[ "def", "send_ether_over_wpa", "(", "self", ",", "pkt", ",", "*", "*", "kwargs", ")", ":", "payload", "=", "LLC", "(", ")", "/", "SNAP", "(", ")", "/", "pkt", "[", "Ether", "]", ".", "payload", "dest", "=", "pkt", ".", "dst", "if", "dest", "==", ...
Send an Ethernet packet using the WPA channel Extra arguments will be ignored, and are just left for compatibility
[ "Send", "an", "Ethernet", "packet", "using", "the", "WPA", "channel", "Extra", "arguments", "will", "be", "ignored", "and", "are", "just", "left", "for", "compatibility" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/modules/krack/automaton.py#L359-L370
train
secdev/scapy
scapy/layers/tls/automaton.py
_TLSAutomaton.get_next_msg
def get_next_msg(self, socket_timeout=2, retry=2): """ The purpose of the function is to make next message(s) available in self.buffer_in. If the list is not empty, nothing is done. If not, in order to fill it, the function uses the data already available in self.remain_in from a...
python
def get_next_msg(self, socket_timeout=2, retry=2): """ The purpose of the function is to make next message(s) available in self.buffer_in. If the list is not empty, nothing is done. If not, in order to fill it, the function uses the data already available in self.remain_in from a...
[ "def", "get_next_msg", "(", "self", ",", "socket_timeout", "=", "2", ",", "retry", "=", "2", ")", ":", "if", "self", ".", "buffer_in", ":", "# A message is already available.", "return", "self", ".", "socket", ".", "settimeout", "(", "socket_timeout", ")", "...
The purpose of the function is to make next message(s) available in self.buffer_in. If the list is not empty, nothing is done. If not, in order to fill it, the function uses the data already available in self.remain_in from a previous call and waits till there are enough to dissect a TLS...
[ "The", "purpose", "of", "the", "function", "is", "to", "make", "next", "message", "(", "s", ")", "available", "in", "self", ".", "buffer_in", ".", "If", "the", "list", "is", "not", "empty", "nothing", "is", "done", ".", "If", "not", "in", "order", "t...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/automaton.py#L78-L166
train
secdev/scapy
scapy/layers/tls/automaton.py
_TLSAutomaton.raise_on_packet
def raise_on_packet(self, pkt_cls, state, get_next_msg=True): """ If the next message to be processed has type 'pkt_cls', raise 'state'. If there is no message waiting to be processed, we try to get one with the default 'get_next_msg' parameters. """ # Maybe we already pa...
python
def raise_on_packet(self, pkt_cls, state, get_next_msg=True): """ If the next message to be processed has type 'pkt_cls', raise 'state'. If there is no message waiting to be processed, we try to get one with the default 'get_next_msg' parameters. """ # Maybe we already pa...
[ "def", "raise_on_packet", "(", "self", ",", "pkt_cls", ",", "state", ",", "get_next_msg", "=", "True", ")", ":", "# Maybe we already parsed the expected packet, maybe not.", "if", "get_next_msg", ":", "self", ".", "get_next_msg", "(", ")", "if", "(", "not", "self"...
If the next message to be processed has type 'pkt_cls', raise 'state'. If there is no message waiting to be processed, we try to get one with the default 'get_next_msg' parameters.
[ "If", "the", "next", "message", "to", "be", "processed", "has", "type", "pkt_cls", "raise", "state", ".", "If", "there", "is", "no", "message", "waiting", "to", "be", "processed", "we", "try", "to", "get", "one", "with", "the", "default", "get_next_msg", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/automaton.py#L168-L182
train
secdev/scapy
scapy/layers/tls/automaton.py
_TLSAutomaton.add_record
def add_record(self, is_sslv2=None, is_tls13=None): """ Add a new TLS or SSLv2 or TLS 1.3 record to the packets buffered out. """ if is_sslv2 is None and is_tls13 is None: v = (self.cur_session.tls_version or self.cur_session.advertised_tls_version) ...
python
def add_record(self, is_sslv2=None, is_tls13=None): """ Add a new TLS or SSLv2 or TLS 1.3 record to the packets buffered out. """ if is_sslv2 is None and is_tls13 is None: v = (self.cur_session.tls_version or self.cur_session.advertised_tls_version) ...
[ "def", "add_record", "(", "self", ",", "is_sslv2", "=", "None", ",", "is_tls13", "=", "None", ")", ":", "if", "is_sslv2", "is", "None", "and", "is_tls13", "is", "None", ":", "v", "=", "(", "self", ".", "cur_session", ".", "tls_version", "or", "self", ...
Add a new TLS or SSLv2 or TLS 1.3 record to the packets buffered out.
[ "Add", "a", "new", "TLS", "or", "SSLv2", "or", "TLS", "1", ".", "3", "record", "to", "the", "packets", "buffered", "out", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/automaton.py#L184-L200
train
secdev/scapy
scapy/layers/tls/automaton.py
_TLSAutomaton.add_msg
def add_msg(self, pkt): """ Add a TLS message (e.g. TLSClientHello or TLSApplicationData) inside the latest record to be sent through the socket. We believe a good automaton should not use the first test. """ if not self.buffer_out: self.add_record() r...
python
def add_msg(self, pkt): """ Add a TLS message (e.g. TLSClientHello or TLSApplicationData) inside the latest record to be sent through the socket. We believe a good automaton should not use the first test. """ if not self.buffer_out: self.add_record() r...
[ "def", "add_msg", "(", "self", ",", "pkt", ")", ":", "if", "not", "self", ".", "buffer_out", ":", "self", ".", "add_record", "(", ")", "r", "=", "self", ".", "buffer_out", "[", "-", "1", "]", "if", "isinstance", "(", "r", ",", "TLS13", ")", ":", ...
Add a TLS message (e.g. TLSClientHello or TLSApplicationData) inside the latest record to be sent through the socket. We believe a good automaton should not use the first test.
[ "Add", "a", "TLS", "message", "(", "e", ".", "g", ".", "TLSClientHello", "or", "TLSApplicationData", ")", "inside", "the", "latest", "record", "to", "be", "sent", "through", "the", "socket", ".", "We", "believe", "a", "good", "automaton", "should", "not", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/automaton.py#L202-L214
train
secdev/scapy
scapy/layers/tls/automaton.py
_TLSAutomaton.flush_records
def flush_records(self): """ Send all buffered records and update the session accordingly. """ s = b"".join(p.raw_stateful() for p in self.buffer_out) self.socket.send(s) self.buffer_out = []
python
def flush_records(self): """ Send all buffered records and update the session accordingly. """ s = b"".join(p.raw_stateful() for p in self.buffer_out) self.socket.send(s) self.buffer_out = []
[ "def", "flush_records", "(", "self", ")", ":", "s", "=", "b\"\"", ".", "join", "(", "p", ".", "raw_stateful", "(", ")", "for", "p", "in", "self", ".", "buffer_out", ")", "self", ".", "socket", ".", "send", "(", "s", ")", "self", ".", "buffer_out", ...
Send all buffered records and update the session accordingly.
[ "Send", "all", "buffered", "records", "and", "update", "the", "session", "accordingly", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/automaton.py#L216-L222
train
secdev/scapy
scapy/layers/dot15d4.py
util_srcpanid_present
def util_srcpanid_present(pkt): '''A source PAN ID is included if and only if both src addr mode != 0 and PAN ID Compression in FCF == 0''' # noqa: E501 if (pkt.underlayer.getfieldval("fcf_srcaddrmode") != 0) and (pkt.underlayer.getfieldval("fcf_panidcompress") == 0): # noqa: E501 return True else...
python
def util_srcpanid_present(pkt): '''A source PAN ID is included if and only if both src addr mode != 0 and PAN ID Compression in FCF == 0''' # noqa: E501 if (pkt.underlayer.getfieldval("fcf_srcaddrmode") != 0) and (pkt.underlayer.getfieldval("fcf_panidcompress") == 0): # noqa: E501 return True else...
[ "def", "util_srcpanid_present", "(", "pkt", ")", ":", "# noqa: E501", "if", "(", "pkt", ".", "underlayer", ".", "getfieldval", "(", "\"fcf_srcaddrmode\"", ")", "!=", "0", ")", "and", "(", "pkt", ".", "underlayer", ".", "getfieldval", "(", "\"fcf_panidcompress\...
A source PAN ID is included if and only if both src addr mode != 0 and PAN ID Compression in FCF == 0
[ "A", "source", "PAN", "ID", "is", "included", "if", "and", "only", "if", "both", "src", "addr", "mode", "!", "=", "0", "and", "PAN", "ID", "Compression", "in", "FCF", "==", "0" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/dot15d4.py#L362-L367
train
secdev/scapy
scapy/layers/dot15d4.py
dot15d4AddressField.i2repr
def i2repr(self, pkt, x): """Convert internal value to a nice representation""" if len(hex(self.i2m(pkt, x))) < 7: # short address return hex(self.i2m(pkt, x)) else: # long address x = "%016x" % self.i2m(pkt, x) return ":".join(["%s%s" % (x[i], x[i + 1]) for...
python
def i2repr(self, pkt, x): """Convert internal value to a nice representation""" if len(hex(self.i2m(pkt, x))) < 7: # short address return hex(self.i2m(pkt, x)) else: # long address x = "%016x" % self.i2m(pkt, x) return ":".join(["%s%s" % (x[i], x[i + 1]) for...
[ "def", "i2repr", "(", "self", ",", "pkt", ",", "x", ")", ":", "if", "len", "(", "hex", "(", "self", ".", "i2m", "(", "pkt", ",", "x", ")", ")", ")", "<", "7", ":", "# short address", "return", "hex", "(", "self", ".", "i2m", "(", "pkt", ",", ...
Convert internal value to a nice representation
[ "Convert", "internal", "value", "to", "a", "nice", "representation" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/dot15d4.py#L40-L46
train
secdev/scapy
scapy/layers/dot15d4.py
dot15d4AddressField.addfield
def addfield(self, pkt, s, val): """Add an internal value to a string""" if self.adjust(pkt, self.length_of) == 2: return s + struct.pack(self.fmt[0] + "H", val) elif self.adjust(pkt, self.length_of) == 8: return s + struct.pack(self.fmt[0] + "Q", val) else: ...
python
def addfield(self, pkt, s, val): """Add an internal value to a string""" if self.adjust(pkt, self.length_of) == 2: return s + struct.pack(self.fmt[0] + "H", val) elif self.adjust(pkt, self.length_of) == 8: return s + struct.pack(self.fmt[0] + "Q", val) else: ...
[ "def", "addfield", "(", "self", ",", "pkt", ",", "s", ",", "val", ")", ":", "if", "self", ".", "adjust", "(", "pkt", ",", "self", ".", "length_of", ")", "==", "2", ":", "return", "s", "+", "struct", ".", "pack", "(", "self", ".", "fmt", "[", ...
Add an internal value to a string
[ "Add", "an", "internal", "value", "to", "a", "string" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/dot15d4.py#L48-L55
train
secdev/scapy
scapy/layers/tls/crypto/prf.py
_tls_P_hash
def _tls_P_hash(secret, seed, req_len, hm): """ Provides the implementation of P_hash function defined in section 5 of RFC 4346 (and section 5 of RFC 5246). Two parameters have been added (hm and req_len): - secret : the key to be used. If RFC 4868 is to be believed, the length must ...
python
def _tls_P_hash(secret, seed, req_len, hm): """ Provides the implementation of P_hash function defined in section 5 of RFC 4346 (and section 5 of RFC 5246). Two parameters have been added (hm and req_len): - secret : the key to be used. If RFC 4868 is to be believed, the length must ...
[ "def", "_tls_P_hash", "(", "secret", ",", "seed", ",", "req_len", ",", "hm", ")", ":", "hash_len", "=", "hm", ".", "hash_alg", ".", "hash_len", "n", "=", "(", "req_len", "+", "hash_len", "-", "1", ")", "//", "hash_len", "seed", "=", "bytes_encode", "...
Provides the implementation of P_hash function defined in section 5 of RFC 4346 (and section 5 of RFC 5246). Two parameters have been added (hm and req_len): - secret : the key to be used. If RFC 4868 is to be believed, the length must match hm.key_len. Actually, python hmac t...
[ "Provides", "the", "implementation", "of", "P_hash", "function", "defined", "in", "section", "5", "of", "RFC", "4346", "(", "and", "section", "5", "of", "RFC", "5246", ")", ".", "Two", "parameters", "have", "been", "added", "(", "hm", "and", "req_len", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/crypto/prf.py#L22-L51
train
secdev/scapy
scapy/layers/tls/crypto/prf.py
_ssl_PRF
def _ssl_PRF(secret, seed, req_len): """ Provides the implementation of SSLv3 PRF function: SSLv3-PRF(secret, seed) = MD5(secret || SHA-1("A" || secret || seed)) || MD5(secret || SHA-1("BB" || secret || seed)) || MD5(secret || SHA-1("CCC" || secret || seed)) || ... req_len sho...
python
def _ssl_PRF(secret, seed, req_len): """ Provides the implementation of SSLv3 PRF function: SSLv3-PRF(secret, seed) = MD5(secret || SHA-1("A" || secret || seed)) || MD5(secret || SHA-1("BB" || secret || seed)) || MD5(secret || SHA-1("CCC" || secret || seed)) || ... req_len sho...
[ "def", "_ssl_PRF", "(", "secret", ",", "seed", ",", "req_len", ")", ":", "if", "req_len", ">", "416", ":", "warning", "(", "\"_ssl_PRF() is not expected to provide more than 416 bytes\"", ")", "return", "\"\"", "d", "=", "[", "b\"A\"", ",", "b\"B\"", ",", "b\"...
Provides the implementation of SSLv3 PRF function: SSLv3-PRF(secret, seed) = MD5(secret || SHA-1("A" || secret || seed)) || MD5(secret || SHA-1("BB" || secret || seed)) || MD5(secret || SHA-1("CCC" || secret || seed)) || ... req_len should not be more than 26 x 16 = 416.
[ "Provides", "the", "implementation", "of", "SSLv3", "PRF", "function", ":" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/crypto/prf.py#L93-L121
train
secdev/scapy
scapy/layers/tls/crypto/prf.py
_tls_PRF
def _tls_PRF(secret, label, seed, req_len): """ Provides the implementation of TLS PRF function as defined in section 5 of RFC 4346: PRF(secret, label, seed) = P_MD5(S1, label + seed) XOR P_SHA-1(S2, label + seed) Parameters are: - secret: the secret used by the...
python
def _tls_PRF(secret, label, seed, req_len): """ Provides the implementation of TLS PRF function as defined in section 5 of RFC 4346: PRF(secret, label, seed) = P_MD5(S1, label + seed) XOR P_SHA-1(S2, label + seed) Parameters are: - secret: the secret used by the...
[ "def", "_tls_PRF", "(", "secret", ",", "label", ",", "seed", ",", "req_len", ")", ":", "tmp_len", "=", "(", "len", "(", "secret", ")", "+", "1", ")", "//", "2", "S1", "=", "secret", "[", ":", "tmp_len", "]", "S2", "=", "secret", "[", "-", "tmp_...
Provides the implementation of TLS PRF function as defined in section 5 of RFC 4346: PRF(secret, label, seed) = P_MD5(S1, label + seed) XOR P_SHA-1(S2, label + seed) Parameters are: - secret: the secret used by the HMAC in the 2 expansion functions (S1 and...
[ "Provides", "the", "implementation", "of", "TLS", "PRF", "function", "as", "defined", "in", "section", "5", "of", "RFC", "4346", ":" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/crypto/prf.py#L124-L148
train
secdev/scapy
scapy/layers/tls/crypto/prf.py
_tls12_SHA256PRF
def _tls12_SHA256PRF(secret, label, seed, req_len): """ Provides the implementation of TLS 1.2 PRF function as defined in section 5 of RFC 5246: PRF(secret, label, seed) = P_SHA256(secret, label + seed) Parameters are: - secret: the secret used by the HMAC in the 2 expansion fun...
python
def _tls12_SHA256PRF(secret, label, seed, req_len): """ Provides the implementation of TLS 1.2 PRF function as defined in section 5 of RFC 5246: PRF(secret, label, seed) = P_SHA256(secret, label + seed) Parameters are: - secret: the secret used by the HMAC in the 2 expansion fun...
[ "def", "_tls12_SHA256PRF", "(", "secret", ",", "label", ",", "seed", ",", "req_len", ")", ":", "return", "_tls_P_SHA256", "(", "secret", ",", "label", "+", "seed", ",", "req_len", ")" ]
Provides the implementation of TLS 1.2 PRF function as defined in section 5 of RFC 5246: PRF(secret, label, seed) = P_SHA256(secret, label + seed) Parameters are: - secret: the secret used by the HMAC in the 2 expansion functions (S1 and S2 are the halves of this secret). - label: s...
[ "Provides", "the", "implementation", "of", "TLS", "1", ".", "2", "PRF", "function", "as", "defined", "in", "section", "5", "of", "RFC", "5246", ":" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/crypto/prf.py#L151-L167
train
secdev/scapy
scapy/layers/tls/crypto/prf.py
PRF.compute_master_secret
def compute_master_secret(self, pre_master_secret, client_random, server_random): """ Return the 48-byte master_secret, computed from pre_master_secret, client_random and server_random. See RFC 5246, section 6.3. """ seed = client_random + server_ran...
python
def compute_master_secret(self, pre_master_secret, client_random, server_random): """ Return the 48-byte master_secret, computed from pre_master_secret, client_random and server_random. See RFC 5246, section 6.3. """ seed = client_random + server_ran...
[ "def", "compute_master_secret", "(", "self", ",", "pre_master_secret", ",", "client_random", ",", "server_random", ")", ":", "seed", "=", "client_random", "+", "server_random", "if", "self", ".", "tls_version", "<", "0x0300", ":", "return", "None", "elif", "self...
Return the 48-byte master_secret, computed from pre_master_secret, client_random and server_random. See RFC 5246, section 6.3.
[ "Return", "the", "48", "-", "byte", "master_secret", "computed", "from", "pre_master_secret", "client_random", "and", "server_random", ".", "See", "RFC", "5246", "section", "6", ".", "3", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/crypto/prf.py#L210-L222
train