partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
ISOTPSocketImplementation._recv_fc
Process a received 'Flow Control' frame
scapy/contrib/isotp.py
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): """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...
[ "Process", "a", "received", "Flow", "Control", "frame" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L1052-L1108
[ "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...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
ISOTPSocketImplementation._recv_sf
Process a received 'Single Frame' frame
scapy/contrib/isotp.py
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): """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 ...
[ "Process", "a", "received", "Single", "Frame", "frame" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L1110-L1126
[ "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...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
ISOTPSocketImplementation._recv_ff
Process a received 'First Frame' frame
scapy/contrib/isotp.py
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): """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 ...
[ "Process", "a", "received", "First", "Frame", "frame" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L1128-L1173
[ "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...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
ISOTPSocketImplementation._recv_cf
Process a received 'Consecutive Frame' frame
scapy/contrib/isotp.py
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): """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...
[ "Process", "a", "received", "Consecutive", "Frame", "frame" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L1175-L1229
[ "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", ")", ">", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
ISOTPSocketImplementation.begin_send
Begins sending an ISOTP message. This method does not block.
scapy/contrib/isotp.py
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): """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...
[ "Begins", "sending", "an", "ISOTP", "message", ".", "This", "method", "does", "not", "block", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L1231-L1273
[ "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", ".",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
ISOTPSocketImplementation.send
Send an ISOTP frame and block until the message is sent or an error happens.
scapy/contrib/isotp.py
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): """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: ...
[ "Send", "an", "ISOTP", "frame", "and", "block", "until", "the", "message", "is", "sent", "or", "an", "error", "happens", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L1275-L1285
[ "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", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
ISOTPSocketImplementation.recv
Receive an ISOTP frame, blocking if none is available in the buffer for at most 'timeout' seconds.
scapy/contrib/isotp.py
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): """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
[ "Receive", "an", "ISOTP", "frame", "blocking", "if", "none", "is", "available", "in", "the", "buffer", "for", "at", "most", "timeout", "seconds", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/isotp.py#L1287-L1294
[ "def", "recv", "(", "self", ",", "timeout", "=", "None", ")", ":", "try", ":", "return", "self", ".", "rx_queue", ".", "get", "(", "timeout", "is", "None", "or", "timeout", ">", "0", ",", "timeout", ")", "except", "queue", ".", "Empty", ":", "retur...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
TLSClientAutomaton.should_add_ClientCertificate
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.
scapy/layers/tls/automaton_cli.py
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): """ 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) ...
[ "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...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/automaton_cli.py#L312-L328
[ "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", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
TLSClientAutomaton.should_add_ClientVerify
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...
scapy/layers/tls/automaton_cli.py
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): """ 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...
[ "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"...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/automaton_cli.py#L351-L365
[ "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", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
TLSClientAutomaton.add_ClientData
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.
scapy/layers/tls/automaton_cli.py
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): """ 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'...
[ "The", "user", "may", "type", "in", ":", "GET", "/", "HTTP", "/", "1", ".", "1", "\\", "r", "\\", "nHost", ":", "testserver", ".", "com", "\\", "r", "\\", "n", "\\", "r", "\\", "n", "Special", "characters", "are", "handled", "so", "that", "it", ...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/automaton_cli.py#L446-L462
[ "def", "add_ClientData", "(", "self", ")", ":", "if", "not", "self", ".", "data_to_send", ":", "data", "=", "six", ".", "moves", ".", "input", "(", ")", ".", "replace", "(", "'\\\\r'", ",", "'\\r'", ")", ".", "replace", "(", "'\\\\n'", ",", "'\\n'", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
MKAParamSet.dispatch_hook
Returns the right parameter set class.
scapy/layers/eap.py
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): """ 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
[ "Returns", "the", "right", "parameter", "set", "class", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/eap.py#L485-L495
[ "def", "dispatch_hook", "(", "cls", ",", "_pkt", "=", "None", ",", "*", "args", ",", "*", "*", "kargs", ")", ":", "cls", "=", "conf", ".", "raw_layer", "if", "_pkt", "is", "not", "None", ":", "ptype", "=", "orb", "(", "_pkt", "[", "0", "]", ")"...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
source_addr_mode2
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
scapy/layers/sixlowpan.py
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): """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...
[ "source_addr_mode" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/sixlowpan.py#L213-L239
[ "def", "source_addr_mode2", "(", "pkt", ")", ":", "if", "pkt", ".", "sac", "==", "0x0", ":", "if", "pkt", ".", "sam", "==", "0x0", ":", "return", "16", "elif", "pkt", ".", "sam", "==", "0x1", ":", "return", "8", "elif", "pkt", ".", "sam", "==", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
destiny_addr_mode
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
scapy/layers/sixlowpan.py
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): """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 ...
[ "destiny_addr_mode" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/sixlowpan.py#L242-L286
[ "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",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_extract_dot15d4address
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
scapy/layers/sixlowpan.py
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): """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...
[ "This", "function", "extracts", "the", "source", "/", "destination", "address", "of", "a", "6LoWPAN", "from", "its", "upper", "Dot15d4Data", "(", "802", ".", "15", ".", "4", "data", ")", "layer", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/sixlowpan.py#L358-L383
[ "def", "_extract_dot15d4address", "(", "pkt", ",", "source", "=", "True", ")", ":", "underlayer", "=", "pkt", ".", "underlayer", "while", "underlayer", "is", "not", "None", "and", "not", "isinstance", "(", "underlayer", ",", "Dot15d4Data", ")", ":", "# noqa:...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
sixlowpan_fragment
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)
scapy/layers/sixlowpan.py
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): """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] ...
[ "Split", "a", "packet", "into", "different", "links", "to", "transmit", "as", "6lowpan", "packets", ".", "Usage", "example", ":", ">>>", "ipv6", "=", ".....", "(", "very", "big", "packet", ")", ">>>", "pkts", "=", "sixlowpan_fragment", "(", "ipv6", "datagr...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/sixlowpan.py#L751-L778
[ "def", "sixlowpan_fragment", "(", "packet", ",", "datagram_tag", "=", "1", ")", ":", "if", "not", "packet", ".", "haslayer", "(", "IPv6", ")", ":", "raise", "Exception", "(", "\"SixLoWPAN only fragments IPv6 packets !\"", ")", "str_packet", "=", "raw", "(", "p...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
IP6FieldLenField.addfield
Add an internal value to a string
scapy/layers/sixlowpan.py
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): """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)
[ "Add", "an", "internal", "value", "to", "a", "string" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/sixlowpan.py#L80-L86
[ "def", "addfield", "(", "self", ",", "pkt", ",", "s", ",", "val", ")", ":", "tmp_len", "=", "self", ".", "length_of", "(", "pkt", ")", "if", "tmp_len", "==", "0", ":", "return", "s", "internal", "=", "self", ".", "i2m", "(", "pkt", ",", "val", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
SixLoWPANAddrField.addfield
Add an internal value to a string
scapy/layers/sixlowpan.py
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): """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: ...
[ "Add", "an", "internal", "value", "to", "a", "string" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/sixlowpan.py#L124-L140
[ "def", "addfield", "(", "self", ",", "pkt", ",", "s", ",", "val", ")", ":", "if", "self", ".", "length_of", "(", "pkt", ")", "==", "8", ":", "return", "s", "+", "struct", ".", "pack", "(", "self", ".", "fmt", "[", "0", "]", "+", "\"B\"", ",",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
LoWPAN_IPHC.post_dissect
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.
scapy/layers/sixlowpan.py
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): """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 = ...
[ "dissect", "the", "IPv6", "package", "compressed", "into", "this", "IPHC", "packet", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/sixlowpan.py#L452-L515
[ "def", "post_dissect", "(", "self", ",", "data", ")", ":", "# uncompress payload", "packet", "=", "IPv6", "(", ")", "packet", ".", "version", "=", "IPHC_DEFAULT_VERSION", "packet", ".", "tc", ",", "packet", ".", "fl", "=", "self", ".", "_getTrafficClassAndFl...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
LoWPAN_IPHC._getTrafficClassAndFlowLabel
Page 6, draft feb 2011
scapy/layers/sixlowpan.py
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): """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 <<...
[ "Page", "6", "draft", "feb", "2011" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/sixlowpan.py#L707-L716
[ "def", "_getTrafficClassAndFlowLabel", "(", "self", ")", ":", "if", "self", ".", "tf", "==", "0x0", ":", "return", "(", "self", ".", "tc_ecn", "<<", "6", ")", "+", "self", ".", "tc_dscp", ",", "self", ".", "flowlabel", "elif", "self", ".", "tf", "=="...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
SixLoWPAN.dispatch_hook
Depending on the payload content, the frame type we should interpretate
scapy/layers/sixlowpan.py
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): """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: ...
[ "Depending", "on", "the", "payload", "content", "the", "frame", "type", "we", "should", "interpretate" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/sixlowpan.py#L729-L744
[ "def", "dispatch_hook", "(", "cls", ",", "_pkt", "=", "b\"\"", ",", "*", "args", ",", "*", "*", "kargs", ")", ":", "# noqa: E501", "if", "_pkt", "and", "len", "(", "_pkt", ")", ">=", "1", ":", "if", "orb", "(", "_pkt", "[", "0", "]", ")", "==",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
X509_TBSCertificate.get_issuer_str
Returns a one-line string containing every type/value in a rather specific order. sorted() built-in ensures unicity.
scapy/layers/x509.py
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): """ 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...
[ "Returns", "a", "one", "-", "line", "string", "containing", "every", "type", "/", "value", "in", "a", "rather", "specific", "order", ".", "sorted", "()", "built", "-", "in", "ensures", "unicity", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/x509.py#L966-L981
[ "def", "get_issuer_str", "(", "self", ")", ":", "name_str", "=", "\"\"", "attrsDict", "=", "self", ".", "get_issuer", "(", ")", "for", "attrType", ",", "attrSymbol", "in", "_attrName_mapping", ":", "if", "attrType", "in", "attrsDict", ":", "name_str", "+=", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
DefaultSession.on_packet_received
DEV: entry point. Will be called by sniff() for each received packet (that passes the filters).
scapy/sessions.py
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): """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) ...
[ "DEV", ":", "entry", "point", ".", "Will", "be", "called", "by", "sniff", "()", "for", "each", "received", "packet", "(", "that", "passes", "the", "filters", ")", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/sessions.py#L26-L37
[ "def", "on_packet_received", "(", "self", ",", "pkt", ")", ":", "if", "not", "pkt", ":", "return", "if", "self", ".", "store", ":", "self", ".", "lst", ".", "append", "(", "pkt", ")", "if", "self", ".", "prn", ":", "result", "=", "self", ".", "pr...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
bind_bottom_up
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)...
scapy/packet.py
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): """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....
[ "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"...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L1539-L1553
[ "def", "bind_bottom_up", "(", "lower", ",", "upper", ",", "__fval", "=", "None", ",", "*", "*", "fval", ")", ":", "if", "__fval", "is", "not", "None", ":", "fval", ".", "update", "(", "__fval", ")", "lower", ".", "payload_guess", "=", "lower", ".", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
bind_top_down
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 |>>
scapy/packet.py
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): """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 ...
[ "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", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L1556-L1569
[ "def", "bind_top_down", "(", "lower", ",", "upper", ",", "__fval", "=", "None", ",", "*", "*", "fval", ")", ":", "if", "__fval", "is", "not", "None", ":", "fval", ".", "update", "(", "__fval", ")", "upper", ".", "_overload_fields", "=", "upper", ".",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
bind_layers
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) ...
scapy/packet.py
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): """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...
[ "Bind", "2", "layers", "on", "some", "specific", "fields", "values", ".", "It", "makes", "the", "packet", "being", "built", "#", "noqa", ":", "E501", "and", "dissected", "when", "the", "arguments", "are", "present", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L1573-L1585
[ "def", "bind_layers", "(", "lower", ",", "upper", ",", "__fval", "=", "None", ",", "*", "*", "fval", ")", ":", "if", "__fval", "is", "not", "None", ":", "fval", ".", "update", "(", "__fval", ")", "bind_top_down", "(", "lower", ",", "upper", ",", "*...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
split_bottom_up
This call un-links an association that was made using bind_bottom_up. Have a look at help(bind_bottom_up)
scapy/packet.py
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): """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 ...
[ "This", "call", "un", "-", "links", "an", "association", "that", "was", "made", "using", "bind_bottom_up", ".", "Have", "a", "look", "at", "help", "(", "bind_bottom_up", ")" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L1588-L1600
[ "def", "split_bottom_up", "(", "lower", ",", "upper", ",", "__fval", "=", "None", ",", "*", "*", "fval", ")", ":", "if", "__fval", "is", "not", "None", ":", "fval", ".", "update", "(", "__fval", ")", "def", "do_filter", "(", "params", ",", "cls", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
split_top_down
This call un-links an association that was made using bind_top_down. Have a look at help(bind_top_down)
scapy/packet.py
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): """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] ...
[ "This", "call", "un", "-", "links", "an", "association", "that", "was", "made", "using", "bind_top_down", ".", "Have", "a", "look", "at", "help", "(", "bind_top_down", ")" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L1603-L1614
[ "def", "split_top_down", "(", "lower", ",", "upper", ",", "__fval", "=", "None", ",", "*", "*", "fval", ")", ":", "if", "__fval", "is", "not", "None", ":", "fval", ".", "update", "(", "__fval", ")", "if", "lower", "in", "upper", ".", "_overload_field...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
split_layers
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)
scapy/packet.py
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): """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 ...
[ "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", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L1618-L1630
[ "def", "split_layers", "(", "lower", ",", "upper", ",", "__fval", "=", "None", ",", "*", "*", "fval", ")", ":", "if", "__fval", "is", "not", "None", ":", "fval", ".", "update", "(", "__fval", ")", "split_bottom_up", "(", "lower", ",", "upper", ",", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
explore
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...
scapy/packet.py
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): """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...
[ "Function", "used", "to", "discover", "the", "Scapy", "layers", "and", "protocols", ".", "It", "helps", "to", "see", "which", "packets", "exists", "in", "contrib", "or", "layer", "files", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L1634-L1757
[ "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 \"",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
ls
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
scapy/packet.py
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): """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) ...
[ "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", "...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L1761-L1849
[ "def", "ls", "(", "obj", "=", "None", ",", "case_sensitive", "=", "False", ",", "verbose", "=", "False", ")", ":", "is_string", "=", "isinstance", "(", "obj", ",", "six", ".", "string_types", ")", "if", "obj", "is", "None", "or", "is_string", ":", "t...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
fuzz
Transform a layer into a fuzzy layer by replacing some default values by random objects
scapy/packet.py
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): """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): ...
[ "Transform", "a", "layer", "into", "a", "fuzzy", "layer", "by", "replacing", "some", "default", "values", "by", "random", "objects" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L1857-L1874
[ "def", "fuzz", "(", "p", ",", "_inplace", "=", "0", ")", ":", "# noqa: E501", "if", "not", "_inplace", ":", "p", "=", "p", ".", "copy", "(", ")", "q", "=", "p", "while", "not", "isinstance", "(", "q", ",", "NoPayload", ")", ":", "for", "f", "in...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
Packet.init_fields
Initialize each fields of the fields_desc dict
scapy/packet.py
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): """ 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()
[ "Initialize", "each", "fields", "of", "the", "fields_desc", "dict" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L167-L175
[ "def", "init_fields", "(", "self", ")", ":", "if", "self", ".", "class_dont_cache", ".", "get", "(", "self", ".", "__class__", ",", "False", ")", ":", "self", ".", "do_init_fields", "(", "self", ".", "fields_desc", ")", "else", ":", "self", ".", "do_in...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
Packet.do_init_fields
Initialize each fields of the fields_desc dict
scapy/packet.py
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): """ 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)
[ "Initialize", "each", "fields", "of", "the", "fields_desc", "dict" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L177-L185
[ "def", "do_init_fields", "(", "self", ",", "flist", ")", ":", "for", "f", "in", "flist", ":", "self", ".", "default_fields", "[", "f", ".", "name", "]", "=", "copy", ".", "deepcopy", "(", "f", ".", "default", ")", "self", ".", "fieldtype", "[", "f"...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
Packet.do_init_cached_fields
Initialize each fields of the fields_desc dict, or use the cached fields information
scapy/packet.py
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): """ 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...
[ "Initialize", "each", "fields", "of", "the", "fields_desc", "dict", "or", "use", "the", "cached", "fields", "information" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L187-L208
[ "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...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
Packet.prepare_cached_fields
Prepare the cached fields of the fields_desc dict
scapy/packet.py
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): """ 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...
[ "Prepare", "the", "cached", "fields", "of", "the", "fields_desc", "dict" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L210-L243
[ "def", "prepare_cached_fields", "(", "self", ",", "flist", ")", ":", "cls_name", "=", "self", ".", "__class__", "# Fields cache initialization", "if", "flist", ":", "Packet", ".", "class_default_fields", "[", "cls_name", "]", "=", "dict", "(", ")", "Packet", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
Packet.dissection_done
DEV: will be called after a dissection is completed
scapy/packet.py
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): """DEV: will be called after a dissection is completed""" self.post_dissection(pkt) self.payload.dissection_done(pkt)
[ "DEV", ":", "will", "be", "called", "after", "a", "dissection", "is", "completed" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L245-L248
[ "def", "dissection_done", "(", "self", ",", "pkt", ")", ":", "self", ".", "post_dissection", "(", "pkt", ")", "self", ".", "payload", ".", "dissection_done", "(", "pkt", ")" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
train
Packet.copy
Returns a deep copy of the instance.
scapy/packet.py
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): """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...
[ "Returns", "a", "deep", "copy", "of", "the", "instance", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L287-L304
[ "def", "copy", "(", "self", ")", ":", "clone", "=", "self", ".", "__class__", "(", ")", "clone", ".", "fields", "=", "self", ".", "copy_fields_dict", "(", "self", ".", "fields", ")", "clone", ".", "default_fields", "=", "self", ".", "copy_fields_dict", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
Packet._superdir
Return a list of slots and methods, including those from subclasses.
scapy/packet.py
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): """ 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,...
[ "Return", "a", "list", "of", "slots", "and", "methods", "including", "those", "from", "subclasses", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L384-L395
[ "def", "_superdir", "(", "self", ")", ":", "attrs", "=", "set", "(", ")", "cls", "=", "self", ".", "__class__", "if", "hasattr", "(", "cls", ",", "'__all_slots__'", ")", ":", "attrs", ".", "update", "(", "cls", ".", "__all_slots__", ")", "for", "bcls...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
Packet.clear_cache
Clear the raw packet cache for the field and all its subfields
scapy/packet.py
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): """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()
[ "Clear", "the", "raw", "packet", "cache", "for", "the", "field", "and", "all", "its", "subfields" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L488-L494
[ "def", "clear_cache", "(", "self", ")", ":", "self", ".", "raw_packet_cache", "=", "None", "for", "_", ",", "fval", "in", "six", ".", "iteritems", "(", "self", ".", "fields", ")", ":", "if", "isinstance", "(", "fval", ",", "Packet", ")", ":", "fval",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
Packet.self_build
Create the default layer regarding fields_desc dict :param field_pos_list:
scapy/packet.py
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): """ 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...
[ "Create", "the", "default", "layer", "regarding", "fields_desc", "dict" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L496-L521
[ "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", ")", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
Packet.do_build
Create the default version of the layer :return: a string of the packet with the payload
scapy/packet.py
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): """ 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) ...
[ "Create", "the", "default", "version", "of", "the", "layer" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L531-L546
[ "def", "do_build", "(", "self", ")", ":", "if", "not", "self", ".", "explicit", ":", "self", "=", "next", "(", "iter", "(", "self", ")", ")", "pkt", "=", "self", ".", "self_build", "(", ")", "for", "t", "in", "self", ".", "post_transforms", ":", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
Packet.build
Create the current layer :return: string of the packet with the payload
scapy/packet.py
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): """ 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
[ "Create", "the", "current", "layer" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L551-L560
[ "def", "build", "(", "self", ")", ":", "p", "=", "self", ".", "do_build", "(", ")", "p", "+=", "self", ".", "build_padding", "(", ")", "p", "=", "self", ".", "build_done", "(", "p", ")", "return", "p" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
train
Packet.do_dissect_payload
Perform the dissection of the layer's payload :param str s: the raw layer
scapy/packet.py
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): """ 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:...
[ "Perform", "the", "dissection", "of", "the", "layer", "s", "payload" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L796-L817
[ "def", "do_dissect_payload", "(", "self", ",", "s", ")", ":", "if", "s", ":", "cls", "=", "self", ".", "guess_payload_class", "(", "s", ")", "try", ":", "p", "=", "cls", "(", "s", ",", "_internal", "=", "1", ",", "_underlayer", "=", "self", ")", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
Packet.guess_payload_class
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
scapy/packet.py
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): """ 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...
[ "DEV", ":", "Guesses", "the", "next", "payload", "class", "from", "layer", "bonds", ".", "Can", "be", "overloaded", "to", "use", "a", "different", "mechanism", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L831-L844
[ "def", "guess_payload_class", "(", "self", ",", "payload", ")", ":", "for", "t", "in", "self", ".", "aliastypes", ":", "for", "fval", ",", "cls", "in", "t", ".", "payload_guess", ":", "if", "all", "(", "hasattr", "(", "self", ",", "k", ")", "and", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
Packet.hide_defaults
Removes fields' values that are the same as default values.
scapy/packet.py
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): """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...
[ "Removes", "fields", "values", "that", "are", "the", "same", "as", "default", "values", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L856-L864
[ "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", "]...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
Packet.layers
returns a list of layer classes (including subclasses) in this packet
scapy/packet.py
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): """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
[ "returns", "a", "list", "of", "layer", "classes", "(", "including", "subclasses", ")", "in", "this", "packet" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L990-L997
[ "def", "layers", "(", "self", ")", ":", "# noqa: E501", "layers", "=", "[", "]", "lyr", "=", "self", "while", "lyr", ":", "layers", ".", "append", "(", "lyr", ".", "__class__", ")", "lyr", "=", "lyr", ".", "payload", ".", "getlayer", "(", "0", ",",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
Packet.getlayer
Return the nb^th layer that is an instance of cls, matching flt values.
scapy/packet.py
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): """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...
[ "Return", "the", "nb^th", "layer", "that", "is", "an", "instance", "of", "cls", "matching", "flt", "values", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L1017-L1060
[ "def", "getlayer", "(", "self", ",", "cls", ",", "nb", "=", "1", ",", "_track", "=", "None", ",", "_subclass", "=", "None", ",", "*", "*", "flt", ")", ":", "if", "_subclass", "is", "None", ":", "_subclass", "=", "self", ".", "match_subclass", "or",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
Packet._show_or_dump
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...
scapy/packet.py
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 """ 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...
[ "Internal", "method", "that", "shows", "or", "dumps", "a", "hierarchical", "view", "of", "a", "packet", ".", "Called", "by", "show", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L1106-L1160
[ "def", "_show_or_dump", "(", "self", ",", "dump", "=", "False", ",", "indent", "=", "3", ",", "lvl", "=", "\"\"", ",", "label_lvl", "=", "\"\"", ",", "first_call", "=", "True", ")", ":", "# noqa: E501", "if", "dump", ":", "from", "scapy", ".", "theme...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
Packet.show
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...
scapy/packet.py
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=""): """ 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...
[ "Prints", "or", "returns", "(", "when", "dump", "is", "true", ")", "a", "hierarchical", "view", "of", "the", "packet", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L1162-L1173
[ "def", "show", "(", "self", ",", "dump", "=", "False", ",", "indent", "=", "3", ",", "lvl", "=", "\"\"", ",", "label_lvl", "=", "\"\"", ")", ":", "return", "self", ".", "_show_or_dump", "(", "dump", ",", "indent", ",", "lvl", ",", "label_lvl", ")" ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
Packet.show2
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 ...
scapy/packet.py
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=""): """ 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...
[ "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", ".", ")" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L1175-L1187
[ "def", "show2", "(", "self", ",", "dump", "=", "False", ",", "indent", "=", "3", ",", "lvl", "=", "\"\"", ",", "label_lvl", "=", "\"\"", ")", ":", "return", "self", ".", "__class__", "(", "raw", "(", "self", ")", ")", ".", "show", "(", "dump", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
Packet.sprintf
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...
scapy/packet.py
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): """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...
[ "sprintf", "(", "format", "[", "relax", "=", "1", "]", ")", "-", ">", "str", "where", "format", "is", "a", "string", "that", "can", "include", "directives", ".", "A", "directive", "begins", "and", "ends", "by", "%", "and", "has", "the", "following", ...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L1189-L1291
[ "def", "sprintf", "(", "self", ",", "fmt", ",", "relax", "=", "1", ")", ":", "escape", "=", "{", "\"%\"", ":", "\"%\"", ",", "\"(\"", ":", "\"{\"", ",", "\")\"", ":", "\"}\"", "}", "# Evaluate conditions", "while", "\"{\"", "in", "fmt", ":", "i", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
Packet.command
Returns a string representing the command you have to type to obtain the same packet
scapy/packet.py
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): """ 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: ...
[ "Returns", "a", "string", "representing", "the", "command", "you", "have", "to", "type", "to", "obtain", "the", "same", "packet" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L1341-L1364
[ "def", "command", "(", "self", ")", ":", "f", "=", "[", "]", "for", "fn", ",", "fv", "in", "six", ".", "iteritems", "(", "self", ".", "fields", ")", ":", "fld", "=", "self", ".", "get_field", "(", "fn", ")", "if", "isinstance", "(", "fv", ",", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
TLSServerAutomaton.INIT_TLS_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.
scapy/layers/tls/automaton_srv.py
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): """ 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...
[ "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...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/automaton_srv.py#L176-L189
[ "def", "INIT_TLS_SESSION", "(", "self", ")", ":", "self", ".", "cur_session", "=", "tlsSession", "(", "connection_end", "=", "\"server\"", ")", "self", ".", "cur_session", ".", "server_certs", "=", "[", "self", ".", "mycert", "]", "self", ".", "cur_session",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
TLSServerAutomaton.should_check_ciphersuites
We extract cipher suites candidates from the client's proposition.
scapy/layers/tls/automaton_srv.py
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): """ 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...
[ "We", "extract", "cipher", "suites", "candidates", "from", "the", "client", "s", "proposition", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/automaton_srv.py#L212-L222
[ "def", "should_check_ciphersuites", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "mykey", ",", "PrivKeyRSA", ")", ":", "kx", "=", "\"RSA\"", "elif", "isinstance", "(", "self", ".", "mykey", ",", "PrivKeyECDSA", ")", ":", "kx", "=", "\"ECD...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
TLSServerAutomaton.should_add_ServerHello
Selecting a cipher suite should be no trouble as we already caught the None case previously. Also, we do not manage extensions at all.
scapy/layers/tls/automaton_srv.py
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): """ 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...
[ "Selecting", "a", "cipher", "suite", "should", "be", "no", "trouble", "as", "we", "already", "caught", "the", "None", "case", "previously", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/automaton_srv.py#L243-L259
[ "def", "should_add_ServerHello", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "mykey", ",", "PrivKeyRSA", ")", ":", "kx", "=", "\"RSA\"", "elif", "isinstance", "(", "self", ".", "mykey", ",", "PrivKeyECDSA", ")", ":", "kx", "=", "\"ECDSA\...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
KrackAP.parse_args
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: ...
scapy/modules/krack/automaton.py
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, double_gtk_refresh=True, arp_target...
[ "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", ...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/modules/krack/automaton.py#L72-L155
[ "def", "parse_args", "(", "self", ",", "ap_mac", ",", "ssid", ",", "passphrase", ",", "channel", "=", "None", ",", "# KRACK attack options", "double_3handshake", "=", "True", ",", "encrypt_3handshake", "=", "True", ",", "wait_3handshake", "=", "0", ",", "doubl...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
KrackAP.install_PMK
Compute and install the PMK
scapy/modules/krack/automaton.py
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): """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())
[ "Compute", "and", "install", "the", "PMK" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/modules/krack/automaton.py#L169-L177
[ "def", "install_PMK", "(", "self", ")", ":", "self", ".", "pmk", "=", "PBKDF2HMAC", "(", "algorithm", "=", "hashes", ".", "SHA1", "(", ")", ",", "length", "=", "32", ",", "salt", "=", "self", ".", "ssid", ".", "encode", "(", ")", ",", "iterations",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
KrackAP.install_unicast_keys
Use the client nonce @client_nonce to compute and install PTK, KCK, KEK, TK, MIC (AP -> STA), MIC (STA -> AP)
scapy/modules/krack/automaton.py
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): """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...
[ "Use", "the", "client", "nonce" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/modules/krack/automaton.py#L179-L200
[ "def", "install_unicast_keys", "(", "self", ",", "client_nonce", ")", ":", "pmk", "=", "self", ".", "pmk", "anonce", "=", "self", ".", "anonce", "snonce", "=", "client_nonce", "amac", "=", "mac2str", "(", "self", ".", "mac", ")", "smac", "=", "mac2str", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
KrackAP.install_GTK
Compute a new GTK and install it alongs MIC (AP -> Group = broadcast + multicast)
scapy/modules/krack/automaton.py
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 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...
[ "Compute", "a", "new", "GTK", "and", "install", "it", "alongs", "MIC", "(", "AP", "-", ">", "Group", "=", "broadcast", "+", "multicast", ")" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/modules/krack/automaton.py#L202-L215
[ "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_...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
KrackAP.build_ap_info_pkt
Build a packet with info describing the current AP For beacon / proberesp use
scapy/modules/krack/automaton.py
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): """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, ...
[ "Build", "a", "packet", "with", "info", "describing", "the", "current", "AP", "For", "beacon", "/", "proberesp", "use" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/modules/krack/automaton.py#L219-L232
[ "def", "build_ap_info_pkt", "(", "self", ",", "layer_cls", ",", "dest", ")", ":", "return", "RadioTap", "(", ")", "/", "Dot11", "(", "addr1", "=", "dest", ",", "addr2", "=", "self", ".", "mac", ",", "addr3", "=", "self", ".", "mac", ")", "/", "laye...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
KrackAP.build_GTK_KDE
Build the Key Data Encapsulation for GTK KeyID: 0 Ref: 802.11i p81
scapy/modules/krack/automaton.py
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): """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...
[ "Build", "the", "Key", "Data", "Encapsulation", "for", "GTK", "KeyID", ":", "0", "Ref", ":", "802", ".", "11i", "p81" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/modules/krack/automaton.py#L301-L313
[ "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 ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
KrackAP.send_wpa_enc
Send an encrypted packet with content @data, using IV @iv, sequence number @seqnum, MIC key @mic_key
scapy/modules/krack/automaton.py
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): """Send an encrypted packet with content @data, using IV @iv, sequence number @seqnum, MIC key @mic_key """ if encrypt_key is Non...
[ "Send", "an", "encrypted", "packet", "with", "content" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/modules/krack/automaton.py#L315-L345
[ "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...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
KrackAP.send_ether_over_wpa
Send an Ethernet packet using the WPA channel Extra arguments will be ignored, and are just left for compatibility
scapy/modules/krack/automaton.py
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): """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": ...
[ "Send", "an", "Ethernet", "packet", "using", "the", "WPA", "channel", "Extra", "arguments", "will", "be", "ignored", "and", "are", "just", "left", "for", "compatibility" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/modules/krack/automaton.py#L359-L370
[ "def", "send_ether_over_wpa", "(", "self", ",", "pkt", ",", "*", "*", "kwargs", ")", ":", "payload", "=", "LLC", "(", ")", "/", "SNAP", "(", ")", "/", "pkt", "[", "Ether", "]", ".", "payload", "dest", "=", "pkt", ".", "dst", "if", "dest", "==", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_TLSAutomaton.get_next_msg
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...
scapy/layers/tls/automaton.py
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): """ 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...
[ "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...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/automaton.py#L78-L166
[ "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", ")", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_TLSAutomaton.raise_on_packet
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.
scapy/layers/tls/automaton.py
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): """ 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...
[ "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", ...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/automaton.py#L168-L182
[ "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"...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_TLSAutomaton.add_record
Add a new TLS or SSLv2 or TLS 1.3 record to the packets buffered out.
scapy/layers/tls/automaton.py
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): """ 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) ...
[ "Add", "a", "new", "TLS", "or", "SSLv2", "or", "TLS", "1", ".", "3", "record", "to", "the", "packets", "buffered", "out", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/automaton.py#L184-L200
[ "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", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_TLSAutomaton.add_msg
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.
scapy/layers/tls/automaton.py
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): """ 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...
[ "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", ...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/automaton.py#L202-L214
[ "def", "add_msg", "(", "self", ",", "pkt", ")", ":", "if", "not", "self", ".", "buffer_out", ":", "self", ".", "add_record", "(", ")", "r", "=", "self", ".", "buffer_out", "[", "-", "1", "]", "if", "isinstance", "(", "r", ",", "TLS13", ")", ":", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_TLSAutomaton.flush_records
Send all buffered records and update the session accordingly.
scapy/layers/tls/automaton.py
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): """ 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 = []
[ "Send", "all", "buffered", "records", "and", "update", "the", "session", "accordingly", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/automaton.py#L216-L222
[ "def", "flush_records", "(", "self", ")", ":", "s", "=", "b\"\"", ".", "join", "(", "p", ".", "raw_stateful", "(", ")", "for", "p", "in", "self", ".", "buffer_out", ")", "self", ".", "socket", ".", "send", "(", "s", ")", "self", ".", "buffer_out", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
util_srcpanid_present
A source PAN ID is included if and only if both src addr mode != 0 and PAN ID Compression in FCF == 0
scapy/layers/dot15d4.py
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): '''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...
[ "A", "source", "PAN", "ID", "is", "included", "if", "and", "only", "if", "both", "src", "addr", "mode", "!", "=", "0", "and", "PAN", "ID", "Compression", "in", "FCF", "==", "0" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/dot15d4.py#L362-L367
[ "def", "util_srcpanid_present", "(", "pkt", ")", ":", "# noqa: E501", "if", "(", "pkt", ".", "underlayer", ".", "getfieldval", "(", "\"fcf_srcaddrmode\"", ")", "!=", "0", ")", "and", "(", "pkt", ".", "underlayer", ".", "getfieldval", "(", "\"fcf_panidcompress\...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
dot15d4AddressField.i2repr
Convert internal value to a nice representation
scapy/layers/dot15d4.py
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): """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...
[ "Convert", "internal", "value", "to", "a", "nice", "representation" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/dot15d4.py#L40-L46
[ "def", "i2repr", "(", "self", ",", "pkt", ",", "x", ")", ":", "if", "len", "(", "hex", "(", "self", ".", "i2m", "(", "pkt", ",", "x", ")", ")", ")", "<", "7", ":", "# short address", "return", "hex", "(", "self", ".", "i2m", "(", "pkt", ",", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
dot15d4AddressField.addfield
Add an internal value to a string
scapy/layers/dot15d4.py
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): """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: ...
[ "Add", "an", "internal", "value", "to", "a", "string" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/dot15d4.py#L48-L55
[ "def", "addfield", "(", "self", ",", "pkt", ",", "s", ",", "val", ")", ":", "if", "self", ".", "adjust", "(", "pkt", ",", "self", ".", "length_of", ")", "==", "2", ":", "return", "s", "+", "struct", ".", "pack", "(", "self", ".", "fmt", "[", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_tls_P_hash
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...
scapy/layers/tls/crypto/prf.py
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): """ 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 ...
[ "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", "...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/crypto/prf.py#L22-L51
[ "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", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_ssl_PRF
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.
scapy/layers/tls/crypto/prf.py
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): """ 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...
[ "Provides", "the", "implementation", "of", "SSLv3", "PRF", "function", ":" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/crypto/prf.py#L93-L121
[ "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\"...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_tls_PRF
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...
scapy/layers/tls/crypto/prf.py
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): """ 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...
[ "Provides", "the", "implementation", "of", "TLS", "PRF", "function", "as", "defined", "in", "section", "5", "of", "RFC", "4346", ":" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/crypto/prf.py#L124-L148
[ "def", "_tls_PRF", "(", "secret", ",", "label", ",", "seed", ",", "req_len", ")", ":", "tmp_len", "=", "(", "len", "(", "secret", ")", "+", "1", ")", "//", "2", "S1", "=", "secret", "[", ":", "tmp_len", "]", "S2", "=", "secret", "[", "-", "tmp_...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_tls12_SHA256PRF
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...
scapy/layers/tls/crypto/prf.py
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): """ 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...
[ "Provides", "the", "implementation", "of", "TLS", "1", ".", "2", "PRF", "function", "as", "defined", "in", "section", "5", "of", "RFC", "5246", ":" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/crypto/prf.py#L151-L167
[ "def", "_tls12_SHA256PRF", "(", "secret", ",", "label", ",", "seed", ",", "req_len", ")", ":", "return", "_tls_P_SHA256", "(", "secret", ",", "label", "+", "seed", ",", "req_len", ")" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
train
PRF.compute_master_secret
Return the 48-byte master_secret, computed from pre_master_secret, client_random and server_random. See RFC 5246, section 6.3.
scapy/layers/tls/crypto/prf.py
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): """ 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...
[ "Return", "the", "48", "-", "byte", "master_secret", "computed", "from", "pre_master_secret", "client_random", "and", "server_random", ".", "See", "RFC", "5246", "section", "6", ".", "3", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/crypto/prf.py#L210-L222
[ "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...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
PRF.derive_key_block
Perform the derivation of master_secret into a key_block of req_len requested length. See RFC 5246, section 6.3.
scapy/layers/tls/crypto/prf.py
def derive_key_block(self, master_secret, server_random, client_random, req_len): """ Perform the derivation of master_secret into a key_block of req_len requested length. See RFC 5246, section 6.3. """ seed = server_random + client_random if self...
def derive_key_block(self, master_secret, server_random, client_random, req_len): """ Perform the derivation of master_secret into a key_block of req_len requested length. See RFC 5246, section 6.3. """ seed = server_random + client_random if self...
[ "Perform", "the", "derivation", "of", "master_secret", "into", "a", "key_block", "of", "req_len", "requested", "length", ".", "See", "RFC", "5246", "section", "6", ".", "3", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/crypto/prf.py#L224-L234
[ "def", "derive_key_block", "(", "self", ",", "master_secret", ",", "server_random", ",", "client_random", ",", "req_len", ")", ":", "seed", "=", "server_random", "+", "client_random", "if", "self", ".", "tls_version", "<=", "0x0300", ":", "return", "self", "."...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
PRF.compute_verify_data
Return verify_data based on handshake messages, connection end, master secret, and read_or_write position. See RFC 5246, section 7.4.9. Every TLS 1.2 cipher suite has a verify_data of length 12. Note also: "This PRF with the SHA-256 hash function is used for all cipher suites defined i...
scapy/layers/tls/crypto/prf.py
def compute_verify_data(self, con_end, read_or_write, handshake_msg, master_secret): """ Return verify_data based on handshake messages, connection end, master secret, and read_or_write position. See RFC 5246, section 7.4.9. Every TLS 1.2 cipher suite has a v...
def compute_verify_data(self, con_end, read_or_write, handshake_msg, master_secret): """ Return verify_data based on handshake messages, connection end, master secret, and read_or_write position. See RFC 5246, section 7.4.9. Every TLS 1.2 cipher suite has a v...
[ "Return", "verify_data", "based", "on", "handshake", "messages", "connection", "end", "master", "secret", "and", "read_or_write", "position", ".", "See", "RFC", "5246", "section", "7", ".", "4", ".", "9", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/crypto/prf.py#L236-L294
[ "def", "compute_verify_data", "(", "self", ",", "con_end", ",", "read_or_write", ",", "handshake_msg", ",", "master_secret", ")", ":", "if", "self", ".", "tls_version", "<", "0x0300", ":", "return", "None", "elif", "self", ".", "tls_version", "==", "0x0300", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
PRF.postprocess_key_for_export
Postprocess cipher key for EXPORT ciphersuite, i.e. weakens it. An export key generation example is given in section 6.3.1 of RFC 2246. See also page 86 of EKR's book.
scapy/layers/tls/crypto/prf.py
def postprocess_key_for_export(self, key, client_random, server_random, con_end, read_or_write, req_len): """ Postprocess cipher key for EXPORT ciphersuite, i.e. weakens it. An export key generation example is given in section 6.3.1 of RFC 2246. See als...
def postprocess_key_for_export(self, key, client_random, server_random, con_end, read_or_write, req_len): """ Postprocess cipher key for EXPORT ciphersuite, i.e. weakens it. An export key generation example is given in section 6.3.1 of RFC 2246. See als...
[ "Postprocess", "cipher", "key", "for", "EXPORT", "ciphersuite", "i", ".", "e", ".", "weakens", "it", ".", "An", "export", "key", "generation", "example", "is", "given", "in", "section", "6", ".", "3", ".", "1", "of", "RFC", "2246", ".", "See", "also", ...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/crypto/prf.py#L296-L323
[ "def", "postprocess_key_for_export", "(", "self", ",", "key", ",", "client_random", ",", "server_random", ",", "con_end", ",", "read_or_write", ",", "req_len", ")", ":", "s", "=", "con_end", "+", "read_or_write", "s", "=", "(", "s", "==", "\"clientwrite\"", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
PRF.generate_iv_for_export
Generate IV for EXPORT ciphersuite, i.e. weakens it. An export IV generation example is given in section 6.3.1 of RFC 2246. See also page 86 of EKR's book.
scapy/layers/tls/crypto/prf.py
def generate_iv_for_export(self, client_random, server_random, con_end, read_or_write, req_len): """ Generate IV for EXPORT ciphersuite, i.e. weakens it. An export IV generation example is given in section 6.3.1 of RFC 2246. See also page 86 of EKR's book. ...
def generate_iv_for_export(self, client_random, server_random, con_end, read_or_write, req_len): """ Generate IV for EXPORT ciphersuite, i.e. weakens it. An export IV generation example is given in section 6.3.1 of RFC 2246. See also page 86 of EKR's book. ...
[ "Generate", "IV", "for", "EXPORT", "ciphersuite", "i", ".", "e", ".", "weakens", "it", ".", "An", "export", "IV", "generation", "example", "is", "given", "in", "section", "6", ".", "3", ".", "1", "of", "RFC", "2246", ".", "See", "also", "page", "86",...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/crypto/prf.py#L325-L352
[ "def", "generate_iv_for_export", "(", "self", ",", "client_random", ",", "server_random", ",", "con_end", ",", "read_or_write", ",", "req_len", ")", ":", "s", "=", "con_end", "+", "read_or_write", "s", "=", "(", "s", "==", "\"clientwrite\"", "or", "s", "==",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
load_protocols
Parse /etc/protocols and return values as a dictionary.
scapy/data.py
def load_protocols(filename, _integer_base=10): """"Parse /etc/protocols and return values as a dictionary.""" spaces = re.compile(b"[ \t]+|\n") dct = DADict(_name=filename) try: with open(filename, "rb") as fdesc: for line in fdesc: try: shrp = li...
def load_protocols(filename, _integer_base=10): """"Parse /etc/protocols and return values as a dictionary.""" spaces = re.compile(b"[ \t]+|\n") dct = DADict(_name=filename) try: with open(filename, "rb") as fdesc: for line in fdesc: try: shrp = li...
[ "Parse", "/", "etc", "/", "protocols", "and", "return", "values", "as", "a", "dictionary", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/data.py#L157-L184
[ "def", "load_protocols", "(", "filename", ",", "_integer_base", "=", "10", ")", ":", "spaces", "=", "re", ".", "compile", "(", "b\"[ \\t]+|\\n\"", ")", "dct", "=", "DADict", "(", "_name", "=", "filename", ")", "try", ":", "with", "open", "(", "filename",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
load_manuf
Load manuf file from Wireshark. param: - filename: the file to load the manuf file from
scapy/data.py
def load_manuf(filename): """Load manuf file from Wireshark. param: - filename: the file to load the manuf file from""" manufdb = ManufDA(_name=filename) with open(filename, "rb") as fdesc: for line in fdesc: try: line = line.strip() if not line o...
def load_manuf(filename): """Load manuf file from Wireshark. param: - filename: the file to load the manuf file from""" manufdb = ManufDA(_name=filename) with open(filename, "rb") as fdesc: for line in fdesc: try: line = line.strip() if not line o...
[ "Load", "manuf", "file", "from", "Wireshark", ".", "param", ":", "-", "filename", ":", "the", "file", "to", "load", "the", "manuf", "file", "from" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/data.py#L269-L288
[ "def", "load_manuf", "(", "filename", ")", ":", "manufdb", "=", "ManufDA", "(", "_name", "=", "filename", ")", "with", "open", "(", "filename", ",", "\"rb\"", ")", "as", "fdesc", ":", "for", "line", "in", "fdesc", ":", "try", ":", "line", "=", "line"...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
ManufDA.lookup
Find OUI name matching to a MAC
scapy/data.py
def lookup(self, mac): """Find OUI name matching to a MAC""" oui = ":".join(mac.split(":")[:3]).upper() return self[oui]
def lookup(self, mac): """Find OUI name matching to a MAC""" oui = ":".join(mac.split(":")[:3]).upper() return self[oui]
[ "Find", "OUI", "name", "matching", "to", "a", "MAC" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/data.py#L248-L251
[ "def", "lookup", "(", "self", ",", "mac", ")", ":", "oui", "=", "\":\"", ".", "join", "(", "mac", ".", "split", "(", "\":\"", ")", "[", ":", "3", "]", ")", ".", "upper", "(", ")", "return", "self", "[", "oui", "]" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
train
ManufDA.reverse_lookup
Find all MACs registered to a OUI params: - name: the OUI name - case_sensitive: default to False returns: a dict of mac:tuples (Name, Extended Name)
scapy/data.py
def reverse_lookup(self, name, case_sensitive=False): """Find all MACs registered to a OUI params: - name: the OUI name - case_sensitive: default to False returns: a dict of mac:tuples (Name, Extended Name) """ if case_sensitive: filtr = lambda x, l:...
def reverse_lookup(self, name, case_sensitive=False): """Find all MACs registered to a OUI params: - name: the OUI name - case_sensitive: default to False returns: a dict of mac:tuples (Name, Extended Name) """ if case_sensitive: filtr = lambda x, l:...
[ "Find", "all", "MACs", "registered", "to", "a", "OUI", "params", ":", "-", "name", ":", "the", "OUI", "name", "-", "case_sensitive", ":", "default", "to", "False", "returns", ":", "a", "dict", "of", "mac", ":", "tuples", "(", "Name", "Extended", "Name"...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/data.py#L253-L266
[ "def", "reverse_lookup", "(", "self", ",", "name", ",", "case_sensitive", "=", "False", ")", ":", "if", "case_sensitive", ":", "filtr", "=", "lambda", "x", ",", "l", ":", "any", "(", "x", "==", "z", "for", "z", "in", "l", ")", "else", ":", "name", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
DTO.answers
In CCP, the payload of a DTO packet is dependent on the cmd field of a corresponding CRO packet. Two packets correspond, if there ctr field is equal. If answers detect the corresponding CRO, it will interpret the payload of a DTO with the correct class. In CCP, there is no other way, to ...
scapy/contrib/automotive/ccp.py
def answers(self, other): """In CCP, the payload of a DTO packet is dependent on the cmd field of a corresponding CRO packet. Two packets correspond, if there ctr field is equal. If answers detect the corresponding CRO, it will interpret the payload of a DTO with the correct class. In CC...
def answers(self, other): """In CCP, the payload of a DTO packet is dependent on the cmd field of a corresponding CRO packet. Two packets correspond, if there ctr field is equal. If answers detect the corresponding CRO, it will interpret the payload of a DTO with the correct class. In CC...
[ "In", "CCP", "the", "payload", "of", "a", "DTO", "packet", "is", "dependent", "on", "the", "cmd", "field", "of", "a", "corresponding", "CRO", "packet", ".", "Two", "packets", "correspond", "if", "there", "ctr", "field", "is", "equal", ".", "If", "answers...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/automotive/ccp.py#L562-L584
[ "def", "answers", "(", "self", ",", "other", ")", ":", "if", "not", "hasattr", "(", "other", ",", "\"ctr\"", ")", ":", "return", "0", "if", "self", ".", "ctr", "!=", "other", ".", "ctr", ":", "return", "0", "if", "not", "hasattr", "(", "other", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_version_from_git_describe
Read the version from ``git describe``. It returns the latest tag with an optional suffix if the current directory is not exactly on the tag. Example:: $ git describe --always v2.3.2-346-g164a52c075c8 The tag prefix (``v``) and the git commit sha1 (``-g164a52c075c8``) are removed if p...
scapy/__init__.py
def _version_from_git_describe(): """ Read the version from ``git describe``. It returns the latest tag with an optional suffix if the current directory is not exactly on the tag. Example:: $ git describe --always v2.3.2-346-g164a52c075c8 The tag prefix (``v``) and the git commit ...
def _version_from_git_describe(): """ Read the version from ``git describe``. It returns the latest tag with an optional suffix if the current directory is not exactly on the tag. Example:: $ git describe --always v2.3.2-346-g164a52c075c8 The tag prefix (``v``) and the git commit ...
[ "Read", "the", "version", "from", "git", "describe", ".", "It", "returns", "the", "latest", "tag", "with", "an", "optional", "suffix", "if", "the", "current", "directory", "is", "not", "exactly", "on", "the", "tag", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/__init__.py#L21-L61
[ "def", "_version_from_git_describe", "(", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "_SCAPY_PKG_DIR", ")", ",", "'.git'", ")", ")", ":", "# noqa: E501", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_TLS_Ext_CertTypeDispatcher
We need to select the correct one on dissection. We use the length for that, as 1 for client version would emply an empty list.
scapy/layers/tls/extensions.py
def _TLS_Ext_CertTypeDispatcher(m, *args, **kargs): """ We need to select the correct one on dissection. We use the length for that, as 1 for client version would emply an empty list. """ tmp_len = struct.unpack("!H", m[2:4])[0] if tmp_len == 1: cls = TLS_Ext_ServerCertType else: ...
def _TLS_Ext_CertTypeDispatcher(m, *args, **kargs): """ We need to select the correct one on dissection. We use the length for that, as 1 for client version would emply an empty list. """ tmp_len = struct.unpack("!H", m[2:4])[0] if tmp_len == 1: cls = TLS_Ext_ServerCertType else: ...
[ "We", "need", "to", "select", "the", "correct", "one", "on", "dissection", ".", "We", "use", "the", "length", "for", "that", "as", "1", "for", "client", "version", "would", "emply", "an", "empty", "list", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/extensions.py#L372-L382
[ "def", "_TLS_Ext_CertTypeDispatcher", "(", "m", ",", "*", "args", ",", "*", "*", "kargs", ")", ":", "tmp_len", "=", "struct", ".", "unpack", "(", "\"!H\"", ",", "m", "[", "2", ":", "4", "]", ")", "[", "0", "]", "if", "tmp_len", "==", "1", ":", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
TLS_Ext_PrettyPacketList._show_or_dump
Reproduced from packet.py
scapy/layers/tls/extensions.py
def _show_or_dump(self, dump=False, indent=3, lvl="", label_lvl="", first_call=True): """ Reproduced from packet.py """ ct = AnsiColorTheme() if dump else conf.color_theme s = "%s%s %s %s \n" % (label_lvl, ct.punct("###["), ct.layer_name(self....
def _show_or_dump(self, dump=False, indent=3, lvl="", label_lvl="", first_call=True): """ Reproduced from packet.py """ ct = AnsiColorTheme() if dump else conf.color_theme s = "%s%s %s %s \n" % (label_lvl, ct.punct("###["), ct.layer_name(self....
[ "Reproduced", "from", "packet", ".", "py" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/extensions.py#L96-L135
[ "def", "_show_or_dump", "(", "self", ",", "dump", "=", "False", ",", "indent", "=", "3", ",", "lvl", "=", "\"\"", ",", "label_lvl", "=", "\"\"", ",", "first_call", "=", "True", ")", ":", "ct", "=", "AnsiColorTheme", "(", ")", "if", "dump", "else", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_ExtensionsLenField.getfield
We try to compute a length, usually from a msglen parsed earlier. If this length is 0, we consider 'selection_present' (from RFC 5246) to be False. This means that there should not be any length field. However, with TLS 1.3, zero lengths are always explicit.
scapy/layers/tls/extensions.py
def getfield(self, pkt, s): """ We try to compute a length, usually from a msglen parsed earlier. If this length is 0, we consider 'selection_present' (from RFC 5246) to be False. This means that there should not be any length field. However, with TLS 1.3, zero lengths are always...
def getfield(self, pkt, s): """ We try to compute a length, usually from a msglen parsed earlier. If this length is 0, we consider 'selection_present' (from RFC 5246) to be False. This means that there should not be any length field. However, with TLS 1.3, zero lengths are always...
[ "We", "try", "to", "compute", "a", "length", "usually", "from", "a", "msglen", "parsed", "earlier", ".", "If", "this", "length", "is", "0", "we", "consider", "selection_present", "(", "from", "RFC", "5246", ")", "to", "be", "False", ".", "This", "means",...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/extensions.py#L615-L628
[ "def", "getfield", "(", "self", ",", "pkt", ",", "s", ")", ":", "ext", "=", "pkt", ".", "get_field", "(", "self", ".", "length_of", ")", "tmp_len", "=", "ext", ".", "length_from", "(", "pkt", ")", "if", "tmp_len", "is", "None", "or", "tmp_len", "<=...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_ExtensionsLenField.addfield
There is a hack with the _ExtensionsField.i2len. It works only because we expect _ExtensionsField.i2m to return a string of the same size (if not of the same value) upon successive calls (e.g. through i2len here, then i2m when directly building the _ExtensionsField). XXX A proper way to...
scapy/layers/tls/extensions.py
def addfield(self, pkt, s, i): """ There is a hack with the _ExtensionsField.i2len. It works only because we expect _ExtensionsField.i2m to return a string of the same size (if not of the same value) upon successive calls (e.g. through i2len here, then i2m when directly building ...
def addfield(self, pkt, s, i): """ There is a hack with the _ExtensionsField.i2len. It works only because we expect _ExtensionsField.i2m to return a string of the same size (if not of the same value) upon successive calls (e.g. through i2len here, then i2m when directly building ...
[ "There", "is", "a", "hack", "with", "the", "_ExtensionsField", ".", "i2len", ".", "It", "works", "only", "because", "we", "expect", "_ExtensionsField", ".", "i2m", "to", "return", "a", "string", "of", "the", "same", "size", "(", "if", "not", "of", "the",...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/extensions.py#L630-L652
[ "def", "addfield", "(", "self", ",", "pkt", ",", "s", ",", "i", ")", ":", "if", "i", "is", "None", ":", "if", "self", ".", "length_of", "is", "not", "None", ":", "fld", ",", "fval", "=", "pkt", ".", "getfield_and_val", "(", "self", ".", "length_o...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_GenNetflowRecordV9
Internal function used to generate the Records from their template.
scapy/layers/netflow.py
def _GenNetflowRecordV9(cls, lengths_list): """Internal function used to generate the Records from their template. """ _fields_desc = [] for j, k in lengths_list: _f_data = NetflowV9TemplateFieldDecoders.get(k, None) _f_type, _f_args = ( _f_data if isinstance(_f_data, tup...
def _GenNetflowRecordV9(cls, lengths_list): """Internal function used to generate the Records from their template. """ _fields_desc = [] for j, k in lengths_list: _f_data = NetflowV9TemplateFieldDecoders.get(k, None) _f_type, _f_args = ( _f_data if isinstance(_f_data, tup...
[ "Internal", "function", "used", "to", "generate", "the", "Records", "from", "their", "template", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/netflow.py#L1284-L1318
[ "def", "_GenNetflowRecordV9", "(", "cls", ",", "lengths_list", ")", ":", "_fields_desc", "=", "[", "]", "for", "j", ",", "k", "in", "lengths_list", ":", "_f_data", "=", "NetflowV9TemplateFieldDecoders", ".", "get", "(", "k", ",", "None", ")", "_f_type", ",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_netflowv9_defragment_packet
Used internally to process a single packet during defragmenting
scapy/layers/netflow.py
def _netflowv9_defragment_packet(pkt, definitions, definitions_opts, ignored): """Used internally to process a single packet during defragmenting""" # Dataflowset definitions if NetflowFlowsetV9 in pkt: current = pkt while NetflowFlowsetV9 in current: current = current[NetflowFlo...
def _netflowv9_defragment_packet(pkt, definitions, definitions_opts, ignored): """Used internally to process a single packet during defragmenting""" # Dataflowset definitions if NetflowFlowsetV9 in pkt: current = pkt while NetflowFlowsetV9 in current: current = current[NetflowFlo...
[ "Used", "internally", "to", "process", "a", "single", "packet", "during", "defragmenting" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/netflow.py#L1358-L1453
[ "def", "_netflowv9_defragment_packet", "(", "pkt", ",", "definitions", ",", "definitions_opts", ",", "ignored", ")", ":", "# Dataflowset definitions", "if", "NetflowFlowsetV9", "in", "pkt", ":", "current", "=", "pkt", "while", "NetflowFlowsetV9", "in", "current", ":...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
netflowv9_defragment
Process all NetflowV9/10 Packets to match IDs of the DataFlowsets with the Headers params: - plist: the list of mixed NetflowV9/10 packets. - verb: verbose print (0/1)
scapy/layers/netflow.py
def netflowv9_defragment(plist, verb=1): """Process all NetflowV9/10 Packets to match IDs of the DataFlowsets with the Headers params: - plist: the list of mixed NetflowV9/10 packets. - verb: verbose print (0/1) """ if not isinstance(plist, (PacketList, list)): plist = [plist] ...
def netflowv9_defragment(plist, verb=1): """Process all NetflowV9/10 Packets to match IDs of the DataFlowsets with the Headers params: - plist: the list of mixed NetflowV9/10 packets. - verb: verbose print (0/1) """ if not isinstance(plist, (PacketList, list)): plist = [plist] ...
[ "Process", "all", "NetflowV9", "/", "10", "Packets", "to", "match", "IDs", "of", "the", "DataFlowsets", "with", "the", "Headers" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/netflow.py#L1456-L1479
[ "def", "netflowv9_defragment", "(", "plist", ",", "verb", "=", "1", ")", ":", "if", "not", "isinstance", "(", "plist", ",", "(", "PacketList", ",", "list", ")", ")", ":", "plist", "=", "[", "plist", "]", "# We need the whole packet to be dissected to access fi...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
der2pem
Convert DER octet string to PEM format (with optional header)
scapy/layers/tls/cert.py
def der2pem(der_string, obj="UNKNOWN"): """Convert DER octet string to PEM format (with optional header)""" # Encode a byte string in PEM format. Header advertizes <obj> type. pem_string = ("-----BEGIN %s-----\n" % obj).encode() base64_string = base64.b64encode(der_string) chunks = [base64_string[i:...
def der2pem(der_string, obj="UNKNOWN"): """Convert DER octet string to PEM format (with optional header)""" # Encode a byte string in PEM format. Header advertizes <obj> type. pem_string = ("-----BEGIN %s-----\n" % obj).encode() base64_string = base64.b64encode(der_string) chunks = [base64_string[i:...
[ "Convert", "DER", "octet", "string", "to", "PEM", "format", "(", "with", "optional", "header", ")" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/cert.py#L68-L76
[ "def", "der2pem", "(", "der_string", ",", "obj", "=", "\"UNKNOWN\"", ")", ":", "# Encode a byte string in PEM format. Header advertizes <obj> type.", "pem_string", "=", "(", "\"-----BEGIN %s-----\\n\"", "%", "obj", ")", ".", "encode", "(", ")", "base64_string", "=", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
pem2der
Convert PEM string to DER format
scapy/layers/tls/cert.py
def pem2der(pem_string): """Convert PEM string to DER format""" # Encode all lines between the first '-----\n' and the 2nd-to-last '-----'. pem_string = pem_string.replace(b"\r", b"") first_idx = pem_string.find(b"-----\n") + 6 if pem_string.find(b"-----BEGIN", first_idx) != -1: raise Except...
def pem2der(pem_string): """Convert PEM string to DER format""" # Encode all lines between the first '-----\n' and the 2nd-to-last '-----'. pem_string = pem_string.replace(b"\r", b"") first_idx = pem_string.find(b"-----\n") + 6 if pem_string.find(b"-----BEGIN", first_idx) != -1: raise Except...
[ "Convert", "PEM", "string", "to", "DER", "format" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/cert.py#L80-L91
[ "def", "pem2der", "(", "pem_string", ")", ":", "# Encode all lines between the first '-----\\n' and the 2nd-to-last '-----'.", "pem_string", "=", "pem_string", ".", "replace", "(", "b\"\\r\"", ",", "b\"\"", ")", "first_idx", "=", "pem_string", ".", "find", "(", "b\"----...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
split_pem
Split PEM objects. Useful to process concatenated certificates.
scapy/layers/tls/cert.py
def split_pem(s): """ Split PEM objects. Useful to process concatenated certificates. """ pem_strings = [] while s != b"": start_idx = s.find(b"-----BEGIN") if start_idx == -1: break end_idx = s.find(b"-----END") end_idx = s.find(b"\n", end_idx) + 1 ...
def split_pem(s): """ Split PEM objects. Useful to process concatenated certificates. """ pem_strings = [] while s != b"": start_idx = s.find(b"-----BEGIN") if start_idx == -1: break end_idx = s.find(b"-----END") end_idx = s.find(b"\n", end_idx) + 1 ...
[ "Split", "PEM", "objects", ".", "Useful", "to", "process", "concatenated", "certificates", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/cert.py#L94-L107
[ "def", "split_pem", "(", "s", ")", ":", "pem_strings", "=", "[", "]", "while", "s", "!=", "b\"\"", ":", "start_idx", "=", "s", ".", "find", "(", "b\"-----BEGIN\"", ")", "if", "start_idx", "==", "-", "1", ":", "break", "end_idx", "=", "s", ".", "fin...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_create_ca_file
Concatenate all the certificates (PEM format for the export) in 'anchor_list' and write the result to file 'filename'. On success 'filename' is returned, None otherwise. If you are used to OpenSSL tools, this function builds a CAfile that can be used for certificate and CRL check.
scapy/layers/tls/cert.py
def _create_ca_file(anchor_list, filename): """ Concatenate all the certificates (PEM format for the export) in 'anchor_list' and write the result to file 'filename'. On success 'filename' is returned, None otherwise. If you are used to OpenSSL tools, this function builds a CAfile that can be u...
def _create_ca_file(anchor_list, filename): """ Concatenate all the certificates (PEM format for the export) in 'anchor_list' and write the result to file 'filename'. On success 'filename' is returned, None otherwise. If you are used to OpenSSL tools, this function builds a CAfile that can be u...
[ "Concatenate", "all", "the", "certificates", "(", "PEM", "format", "for", "the", "export", ")", "in", "anchor_list", "and", "write", "the", "result", "to", "file", "filename", ".", "On", "success", "filename", "is", "returned", "None", "otherwise", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/cert.py#L1010-L1026
[ "def", "_create_ca_file", "(", "anchor_list", ",", "filename", ")", ":", "try", ":", "with", "open", "(", "filename", ",", "\"w\"", ")", "as", "f", ":", "for", "a", "in", "anchor_list", ":", "s", "=", "a", ".", "output", "(", "fmt", "=", "\"PEM\"", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
PubKey.verifyCert
Verifies either a Cert or an X509_Cert.
scapy/layers/tls/cert.py
def verifyCert(self, cert): """ Verifies either a Cert or an X509_Cert. """ tbsCert = cert.tbsCertificate sigAlg = tbsCert.signature h = hash_by_oid[sigAlg.algorithm.val] sigVal = raw(cert.signatureValue) return self.verify(raw(tbsCert), sigVal, h=h, t='pkcs')
def verifyCert(self, cert): """ Verifies either a Cert or an X509_Cert. """ tbsCert = cert.tbsCertificate sigAlg = tbsCert.signature h = hash_by_oid[sigAlg.algorithm.val] sigVal = raw(cert.signatureValue) return self.verify(raw(tbsCert), sigVal, h=h, t='pkcs')
[ "Verifies", "either", "a", "Cert", "or", "an", "X509_Cert", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/cert.py#L245-L251
[ "def", "verifyCert", "(", "self", ",", "cert", ")", ":", "tbsCert", "=", "cert", ".", "tbsCertificate", "sigAlg", "=", "tbsCert", ".", "signature", "h", "=", "hash_by_oid", "[", "sigAlg", ".", "algorithm", ".", "val", "]", "sigVal", "=", "raw", "(", "c...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
PrivKey.signTBSCert
Note that this will always copy the signature field from the tbsCertificate into the signatureAlgorithm field of the result, regardless of the coherence between its contents (which might indicate ecdsa-with-SHA512) and the result (e.g. RSA signing MD2). There is a small inheritance tric...
scapy/layers/tls/cert.py
def signTBSCert(self, tbsCert, h="sha256"): """ Note that this will always copy the signature field from the tbsCertificate into the signatureAlgorithm field of the result, regardless of the coherence between its contents (which might indicate ecdsa-with-SHA512) and the result (e...
def signTBSCert(self, tbsCert, h="sha256"): """ Note that this will always copy the signature field from the tbsCertificate into the signatureAlgorithm field of the result, regardless of the coherence between its contents (which might indicate ecdsa-with-SHA512) and the result (e...
[ "Note", "that", "this", "will", "always", "copy", "the", "signature", "field", "from", "the", "tbsCertificate", "into", "the", "signatureAlgorithm", "field", "of", "the", "result", "regardless", "of", "the", "coherence", "between", "its", "contents", "(", "which...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/cert.py#L423-L444
[ "def", "signTBSCert", "(", "self", ",", "tbsCert", ",", "h", "=", "\"sha256\"", ")", ":", "sigAlg", "=", "tbsCert", ".", "signature", "h", "=", "h", "or", "hash_by_oid", "[", "sigAlg", ".", "algorithm", ".", "val", "]", "sigVal", "=", "self", ".", "s...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
Cert.isSelfSigned
Return True if the certificate is self-signed: - issuer and subject are the same - the signature of the certificate is valid.
scapy/layers/tls/cert.py
def isSelfSigned(self): """ Return True if the certificate is self-signed: - issuer and subject are the same - the signature of the certificate is valid. """ if self.issuer_hash == self.subject_hash: return self.isIssuerCert(self) return False
def isSelfSigned(self): """ Return True if the certificate is self-signed: - issuer and subject are the same - the signature of the certificate is valid. """ if self.issuer_hash == self.subject_hash: return self.isIssuerCert(self) return False
[ "Return", "True", "if", "the", "certificate", "is", "self", "-", "signed", ":", "-", "issuer", "and", "subject", "are", "the", "same", "-", "the", "signature", "of", "the", "certificate", "is", "valid", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/cert.py#L659-L667
[ "def", "isSelfSigned", "(", "self", ")", ":", "if", "self", ".", "issuer_hash", "==", "self", ".", "subject_hash", ":", "return", "self", ".", "isIssuerCert", "(", "self", ")", "return", "False" ]
3ffe757c184017dd46464593a8f80f85abc1e79a