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
whois
Whois client for Python
scapy/utils.py
def whois(ip_address): """Whois client for Python""" whois_ip = str(ip_address) try: query = socket.gethostbyname(whois_ip) except Exception: query = whois_ip s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(("whois.ripe.net", 43)) s.send(query.encode("utf8") +...
def whois(ip_address): """Whois client for Python""" whois_ip = str(ip_address) try: query = socket.gethostbyname(whois_ip) except Exception: query = whois_ip s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(("whois.ripe.net", 43)) s.send(query.encode("utf8") +...
[ "Whois", "client", "for", "Python" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils.py#L1835-L1861
[ "def", "whois", "(", "ip_address", ")", ":", "whois_ip", "=", "str", "(", "ip_address", ")", "try", ":", "query", "=", "socket", ".", "gethostbyname", "(", "whois_ip", ")", "except", "Exception", ":", "query", "=", "whois_ip", "s", "=", "socket", ".", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
PcapReader_metaclass.open
Open (if necessary) filename, and read the magic.
scapy/utils.py
def open(filename): """Open (if necessary) filename, and read the magic.""" if isinstance(filename, six.string_types): try: fdesc = gzip.open(filename, "rb") magic = fdesc.read(4) except IOError: fdesc = open(filename, "rb") ...
def open(filename): """Open (if necessary) filename, and read the magic.""" if isinstance(filename, six.string_types): try: fdesc = gzip.open(filename, "rb") magic = fdesc.read(4) except IOError: fdesc = open(filename, "rb") ...
[ "Open", "(", "if", "necessary", ")", "filename", "and", "read", "the", "magic", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils.py#L904-L917
[ "def", "open", "(", "filename", ")", ":", "if", "isinstance", "(", "filename", ",", "six", ".", "string_types", ")", ":", "try", ":", "fdesc", "=", "gzip", ".", "open", "(", "filename", ",", "\"rb\"", ")", "magic", "=", "fdesc", ".", "read", "(", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
RawPcapReader.read_all
return a list of all packets in the pcap file
scapy/utils.py
def read_all(self, count=-1): """return a list of all packets in the pcap file """ res = [] while count != 0: count -= 1 p = self.read_packet() if p is None: break res.append(p) return res
def read_all(self, count=-1): """return a list of all packets in the pcap file """ res = [] while count != 0: count -= 1 p = self.read_packet() if p is None: break res.append(p) return res
[ "return", "a", "list", "of", "all", "packets", "in", "the", "pcap", "file" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils.py#L988-L998
[ "def", "read_all", "(", "self", ",", "count", "=", "-", "1", ")", ":", "res", "=", "[", "]", "while", "count", "!=", "0", ":", "count", "-=", "1", "p", "=", "self", ".", "read_packet", "(", ")", "if", "p", "is", "None", ":", "break", "res", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
RawPcapNgReader.read_packet
Read blocks until it reaches either EOF or a packet, and returns None or (packet, (linktype, sec, usec, wirelen)), where packet is a string.
scapy/utils.py
def read_packet(self, size=MTU): """Read blocks until it reaches either EOF or a packet, and returns None or (packet, (linktype, sec, usec, wirelen)), where packet is a string. """ while True: try: blocktype, blocklen = struct.unpack(self.endian + "2I...
def read_packet(self, size=MTU): """Read blocks until it reaches either EOF or a packet, and returns None or (packet, (linktype, sec, usec, wirelen)), where packet is a string. """ while True: try: blocktype, blocklen = struct.unpack(self.endian + "2I...
[ "Read", "blocks", "until", "it", "reaches", "either", "EOF", "or", "a", "packet", "and", "returns", "None", "or", "(", "packet", "(", "linktype", "sec", "usec", "wirelen", "))", "where", "packet", "is", "a", "string", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils.py#L1101-L1127
[ "def", "read_packet", "(", "self", ",", "size", "=", "MTU", ")", ":", "while", "True", ":", "try", ":", "blocktype", ",", "blocklen", "=", "struct", ".", "unpack", "(", "self", ".", "endian", "+", "\"2I\"", ",", "self", ".", "f", ".", "read", "(", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
RawPcapNgReader.read_block_idb
Interface Description Block
scapy/utils.py
def read_block_idb(self, block, _): """Interface Description Block""" options = block[16:] tsresol = 1000000 while len(options) >= 4: code, length = struct.unpack(self.endian + "HH", options[:4]) # PCAP Next Generation (pcapng) Capture File Format # 4....
def read_block_idb(self, block, _): """Interface Description Block""" options = block[16:] tsresol = 1000000 while len(options) >= 4: code, length = struct.unpack(self.endian + "HH", options[:4]) # PCAP Next Generation (pcapng) Capture File Format # 4....
[ "Interface", "Description", "Block" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils.py#L1129-L1149
[ "def", "read_block_idb", "(", "self", ",", "block", ",", "_", ")", ":", "options", "=", "block", "[", "16", ":", "]", "tsresol", "=", "1000000", "while", "len", "(", "options", ")", ">=", "4", ":", "code", ",", "length", "=", "struct", ".", "unpack...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
RawPcapNgReader.read_block_epb
Enhanced Packet Block
scapy/utils.py
def read_block_epb(self, block, size): """Enhanced Packet Block""" intid, tshigh, tslow, caplen, wirelen = struct.unpack( self.endian + "5I", block[:20], ) return (block[20:20 + caplen][:size], RawPcapNgReader.PacketMetadata(linktype=self.interface...
def read_block_epb(self, block, size): """Enhanced Packet Block""" intid, tshigh, tslow, caplen, wirelen = struct.unpack( self.endian + "5I", block[:20], ) return (block[20:20 + caplen][:size], RawPcapNgReader.PacketMetadata(linktype=self.interface...
[ "Enhanced", "Packet", "Block" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils.py#L1151-L1162
[ "def", "read_block_epb", "(", "self", ",", "block", ",", "size", ")", ":", "intid", ",", "tshigh", ",", "tslow", ",", "caplen", ",", "wirelen", "=", "struct", ".", "unpack", "(", "self", ".", "endian", "+", "\"5I\"", ",", "block", "[", ":", "20", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
RawPcapWriter.write
Writes a Packet or bytes to a pcap file. :param pkt: Packet(s) to write (one record for each Packet), or raw bytes to write (as one record). :type pkt: iterable[Packet], Packet or bytes
scapy/utils.py
def write(self, pkt): """ Writes a Packet or bytes to a pcap file. :param pkt: Packet(s) to write (one record for each Packet), or raw bytes to write (as one record). :type pkt: iterable[Packet], Packet or bytes """ if isinstance(pkt, bytes): ...
def write(self, pkt): """ Writes a Packet or bytes to a pcap file. :param pkt: Packet(s) to write (one record for each Packet), or raw bytes to write (as one record). :type pkt: iterable[Packet], Packet or bytes """ if isinstance(pkt, bytes): ...
[ "Writes", "a", "Packet", "or", "bytes", "to", "a", "pcap", "file", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils.py#L1282-L1299
[ "def", "write", "(", "self", ",", "pkt", ")", ":", "if", "isinstance", "(", "pkt", ",", "bytes", ")", ":", "if", "not", "self", ".", "header_present", ":", "self", ".", "_write_header", "(", "pkt", ")", "self", ".", "_write_packet", "(", "pkt", ")", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
PcapWriter._write_packet
Writes a single packet to the pcap file. :param packet: Packet, or bytes for a single packet :type packet: Packet or bytes :param sec: time the packet was captured, in seconds since epoch. If not supplied, defaults to now. :type sec: int or long :param usec: ...
scapy/utils.py
def _write_packet(self, packet, sec=None, usec=None, caplen=None, wirelen=None): """ Writes a single packet to the pcap file. :param packet: Packet, or bytes for a single packet :type packet: Packet or bytes :param sec: time the packet was captured, in seco...
def _write_packet(self, packet, sec=None, usec=None, caplen=None, wirelen=None): """ Writes a single packet to the pcap file. :param packet: Packet, or bytes for a single packet :type packet: Packet or bytes :param sec: time the packet was captured, in seco...
[ "Writes", "a", "single", "packet", "to", "the", "pcap", "file", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils.py#L1373-L1417
[ "def", "_write_packet", "(", "self", ",", "packet", ",", "sec", "=", "None", ",", "usec", "=", "None", ",", "caplen", "=", "None", ",", "wirelen", "=", "None", ")", ":", "if", "hasattr", "(", "packet", ",", "\"time\"", ")", ":", "if", "sec", "is", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
voip_play
Play VoIP packets with RAW data that are either sniffed either from an IP, or specified as a list. It will play only the incoming packets ! :param s1: The IP of the src of all VoIP packets. :param lst: (optional) A list of packets to load :type s1: string :type lst: list :Example: ...
scapy/modules/voip.py
def voip_play(s1, lst=None, **kargs): """Play VoIP packets with RAW data that are either sniffed either from an IP, or specified as a list. It will play only the incoming packets ! :param s1: The IP of the src of all VoIP packets. :param lst: (optional) A list of packets to load :type s1: ...
def voip_play(s1, lst=None, **kargs): """Play VoIP packets with RAW data that are either sniffed either from an IP, or specified as a list. It will play only the incoming packets ! :param s1: The IP of the src of all VoIP packets. :param lst: (optional) A list of packets to load :type s1: ...
[ "Play", "VoIP", "packets", "with", "RAW", "data", "that", "are", "either", "sniffed", "either", "from", "an", "IP", "or", "specified", "as", "a", "list", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/modules/voip.py#L49-L96
[ "def", "voip_play", "(", "s1", ",", "lst", "=", "None", ",", "*", "*", "kargs", ")", ":", "dsp", ",", "rd", "=", "os", ".", "popen2", "(", "sox_base", "%", "\"\"", ")", "def", "play", "(", "pkt", ")", ":", "if", "not", "pkt", ":", "return", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
voip_play2
Same than voip_play, but will play both incoming and outcoming packets. The sound will surely suffer distortion. Only supports sniffing. .. seealso:: voip_play to play only incoming packets.
scapy/modules/voip.py
def voip_play2(s1, **kargs): """ Same than voip_play, but will play both incoming and outcoming packets. The sound will surely suffer distortion. Only supports sniffing. .. seealso:: voip_play to play only incoming packets. """ dsp, rd = os.popen2(sox_base % "-c 2") global x1, ...
def voip_play2(s1, **kargs): """ Same than voip_play, but will play both incoming and outcoming packets. The sound will surely suffer distortion. Only supports sniffing. .. seealso:: voip_play to play only incoming packets. """ dsp, rd = os.popen2(sox_base % "-c 2") global x1, ...
[ "Same", "than", "voip_play", "but", "will", "play", "both", "incoming", "and", "outcoming", "packets", ".", "The", "sound", "will", "surely", "suffer", "distortion", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/modules/voip.py#L105-L136
[ "def", "voip_play2", "(", "s1", ",", "*", "*", "kargs", ")", ":", "dsp", ",", "rd", "=", "os", ".", "popen2", "(", "sox_base", "%", "\"-c 2\"", ")", "global", "x1", ",", "x2", "x1", "=", "\"\"", "x2", "=", "\"\"", "def", "play", "(", "pkt", ")"...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
phantom_mode
We expect this. If tls_version is not set, this means we did not process any complete ClientHello, so we're most probably reading/building a signature_algorithms extension, hence we cannot be in phantom_mode. However, if the tls_version has been set, we test for TLS 1.2.
scapy/layers/tls/keyexchange.py
def phantom_mode(pkt): """ We expect this. If tls_version is not set, this means we did not process any complete ClientHello, so we're most probably reading/building a signature_algorithms extension, hence we cannot be in phantom_mode. However, if the tls_version has been set, we test for TLS 1.2. ...
def phantom_mode(pkt): """ We expect this. If tls_version is not set, this means we did not process any complete ClientHello, so we're most probably reading/building a signature_algorithms extension, hence we cannot be in phantom_mode. However, if the tls_version has been set, we test for TLS 1.2. ...
[ "We", "expect", "this", ".", "If", "tls_version", "is", "not", "set", "this", "means", "we", "did", "not", "process", "any", "complete", "ClientHello", "so", "we", "re", "most", "probably", "reading", "/", "building", "a", "signature_algorithms", "extension", ...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/keyexchange.py#L59-L70
[ "def", "phantom_mode", "(", "pkt", ")", ":", "if", "not", "pkt", ".", "tls_session", ":", "return", "False", "if", "not", "pkt", ".", "tls_session", ".", "tls_version", ":", "return", "False", "return", "pkt", ".", "tls_session", ".", "tls_version", "<", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
phantom_decorate
Decorator for version-dependent fields. If get_or_add is True (means get), we return s, self.phantom_value. If it is False (means add), we return s.
scapy/layers/tls/keyexchange.py
def phantom_decorate(f, get_or_add): """ Decorator for version-dependent fields. If get_or_add is True (means get), we return s, self.phantom_value. If it is False (means add), we return s. """ def wrapper(*args): self, pkt, s = args[:3] if phantom_mode(pkt): if get_o...
def phantom_decorate(f, get_or_add): """ Decorator for version-dependent fields. If get_or_add is True (means get), we return s, self.phantom_value. If it is False (means add), we return s. """ def wrapper(*args): self, pkt, s = args[:3] if phantom_mode(pkt): if get_o...
[ "Decorator", "for", "version", "-", "dependent", "fields", ".", "If", "get_or_add", "is", "True", "(", "means", "get", ")", "we", "return", "s", "self", ".", "phantom_value", ".", "If", "it", "is", "False", "(", "means", "add", ")", "we", "return", "s"...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/keyexchange.py#L73-L86
[ "def", "phantom_decorate", "(", "f", ",", "get_or_add", ")", ":", "def", "wrapper", "(", "*", "args", ")", ":", "self", ",", "pkt", ",", "s", "=", "args", "[", ":", "3", "]", "if", "phantom_mode", "(", "pkt", ")", ":", "if", "get_or_add", ":", "r...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
SigLenField.addfield
With SSLv2 you will never be able to add a sig_len.
scapy/layers/tls/keyexchange.py
def addfield(self, pkt, s, val): """With SSLv2 you will never be able to add a sig_len.""" v = pkt.tls_session.tls_version if v and v < 0x0300: return s return super(SigLenField, self).addfield(pkt, s, val)
def addfield(self, pkt, s, val): """With SSLv2 you will never be able to add a sig_len.""" v = pkt.tls_session.tls_version if v and v < 0x0300: return s return super(SigLenField, self).addfield(pkt, s, val)
[ "With", "SSLv2", "you", "will", "never", "be", "able", "to", "add", "a", "sig_len", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/keyexchange.py#L119-L124
[ "def", "addfield", "(", "self", ",", "pkt", ",", "s", ",", "val", ")", ":", "v", "=", "pkt", ".", "tls_session", ".", "tls_version", "if", "v", "and", "v", "<", "0x0300", ":", "return", "s", "return", "super", "(", "SigLenField", ",", "self", ")", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_TLSSignature._update_sig
Sign 'm' with the PrivKey 'key' and update our own 'sig_val'. Note that, even when 'sig_alg' is not None, we use the signature scheme of the PrivKey (neither do we care to compare the both of them).
scapy/layers/tls/keyexchange.py
def _update_sig(self, m, key): """ Sign 'm' with the PrivKey 'key' and update our own 'sig_val'. Note that, even when 'sig_alg' is not None, we use the signature scheme of the PrivKey (neither do we care to compare the both of them). """ if self.sig_alg is None: ...
def _update_sig(self, m, key): """ Sign 'm' with the PrivKey 'key' and update our own 'sig_val'. Note that, even when 'sig_alg' is not None, we use the signature scheme of the PrivKey (neither do we care to compare the both of them). """ if self.sig_alg is None: ...
[ "Sign", "m", "with", "the", "PrivKey", "key", "and", "update", "our", "own", "sig_val", ".", "Note", "that", "even", "when", "sig_alg", "is", "not", "None", "we", "use", "the", "signature", "scheme", "of", "the", "PrivKey", "(", "neither", "do", "we", ...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/keyexchange.py#L171-L188
[ "def", "_update_sig", "(", "self", ",", "m", ",", "key", ")", ":", "if", "self", ".", "sig_alg", "is", "None", ":", "if", "self", ".", "tls_session", ".", "tls_version", ">=", "0x0300", ":", "self", ".", "sig_val", "=", "key", ".", "sign", "(", "m"...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_TLSSignature._verify_sig
Verify that our own 'sig_val' carries the signature of 'm' by the key associated to the Cert 'cert'.
scapy/layers/tls/keyexchange.py
def _verify_sig(self, m, cert): """ Verify that our own 'sig_val' carries the signature of 'm' by the key associated to the Cert 'cert'. """ if self.sig_val: if self.sig_alg: h, sig = _tls_hash_sig[self.sig_alg].split('+') if sig.endswi...
def _verify_sig(self, m, cert): """ Verify that our own 'sig_val' carries the signature of 'm' by the key associated to the Cert 'cert'. """ if self.sig_val: if self.sig_alg: h, sig = _tls_hash_sig[self.sig_alg].split('+') if sig.endswi...
[ "Verify", "that", "our", "own", "sig_val", "carries", "the", "signature", "of", "m", "by", "the", "key", "associated", "to", "the", "Cert", "cert", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/keyexchange.py#L190-L208
[ "def", "_verify_sig", "(", "self", ",", "m", ",", "cert", ")", ":", "if", "self", ".", "sig_val", ":", "if", "self", ".", "sig_alg", ":", "h", ",", "sig", "=", "_tls_hash_sig", "[", "self", ".", "sig_alg", "]", ".", "split", "(", "'+'", ")", "if"...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
ServerDHParams.fill_missing
We do not want TLSServerKeyExchange.build() to overload and recompute things every time it is called. This method can be called specifically to have things filled in a smart fashion. Note that we do not expect default_params.g to be more than 0xff.
scapy/layers/tls/keyexchange.py
def fill_missing(self): """ We do not want TLSServerKeyExchange.build() to overload and recompute things every time it is called. This method can be called specifically to have things filled in a smart fashion. Note that we do not expect default_params.g to be more than 0xff. ...
def fill_missing(self): """ We do not want TLSServerKeyExchange.build() to overload and recompute things every time it is called. This method can be called specifically to have things filled in a smart fashion. Note that we do not expect default_params.g to be more than 0xff. ...
[ "We", "do", "not", "want", "TLSServerKeyExchange", ".", "build", "()", "to", "overload", "and", "recompute", "things", "every", "time", "it", "is", "called", ".", "This", "method", "can", "be", "called", "specifically", "to", "have", "things", "filled", "in"...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/keyexchange.py#L311-L348
[ "def", "fill_missing", "(", "self", ")", ":", "s", "=", "self", ".", "tls_session", "default_params", "=", "_ffdh_groups", "[", "'modp2048'", "]", "[", "0", "]", ".", "parameter_numbers", "(", ")", "default_mLen", "=", "_ffdh_groups", "[", "'modp2048'", "]",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
ServerDHParams.register_pubkey
XXX Check that the pubkey received is in the group.
scapy/layers/tls/keyexchange.py
def register_pubkey(self): """ XXX Check that the pubkey received is in the group. """ p = pkcs_os2ip(self.dh_p) g = pkcs_os2ip(self.dh_g) pn = dh.DHParameterNumbers(p, g) y = pkcs_os2ip(self.dh_Ys) public_numbers = dh.DHPublicNumbers(y, pn) s = ...
def register_pubkey(self): """ XXX Check that the pubkey received is in the group. """ p = pkcs_os2ip(self.dh_p) g = pkcs_os2ip(self.dh_g) pn = dh.DHParameterNumbers(p, g) y = pkcs_os2ip(self.dh_Ys) public_numbers = dh.DHPublicNumbers(y, pn) s = ...
[ "XXX", "Check", "that", "the", "pubkey", "received", "is", "in", "the", "group", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/keyexchange.py#L351-L366
[ "def", "register_pubkey", "(", "self", ")", ":", "p", "=", "pkcs_os2ip", "(", "self", ".", "dh_p", ")", "g", "=", "pkcs_os2ip", "(", "self", ".", "dh_g", ")", "pn", "=", "dh", ".", "DHParameterNumbers", "(", "p", ",", "g", ")", "y", "=", "pkcs_os2i...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
ServerECDHNamedCurveParams.fill_missing
We do not want TLSServerKeyExchange.build() to overload and recompute things every time it is called. This method can be called specifically to have things filled in a smart fashion. XXX We should account for the point_format (before 'point' filling).
scapy/layers/tls/keyexchange.py
def fill_missing(self): """ We do not want TLSServerKeyExchange.build() to overload and recompute things every time it is called. This method can be called specifically to have things filled in a smart fashion. XXX We should account for the point_format (before 'point' filling)....
def fill_missing(self): """ We do not want TLSServerKeyExchange.build() to overload and recompute things every time it is called. This method can be called specifically to have things filled in a smart fashion. XXX We should account for the point_format (before 'point' filling)....
[ "We", "do", "not", "want", "TLSServerKeyExchange", ".", "build", "()", "to", "overload", "and", "recompute", "things", "every", "time", "it", "is", "called", ".", "This", "method", "can", "be", "called", "specifically", "to", "have", "things", "filled", "in"...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/keyexchange.py#L553-L603
[ "def", "fill_missing", "(", "self", ")", ":", "s", "=", "self", ".", "tls_session", "if", "self", ".", "curve_type", "is", "None", ":", "self", ".", "curve_type", "=", "_tls_ec_curve_types", "[", "\"named_curve\"", "]", "if", "self", ".", "named_curve", "i...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
ServerECDHNamedCurveParams.register_pubkey
XXX Support compressed point format. XXX Check that the pubkey received is on the curve.
scapy/layers/tls/keyexchange.py
def register_pubkey(self): """ XXX Support compressed point format. XXX Check that the pubkey received is on the curve. """ # point_format = 0 # if self.point[0] in [b'\x02', b'\x03']: # point_format = 1 curve_name = _tls_named_curves[self.named_curve]...
def register_pubkey(self): """ XXX Support compressed point format. XXX Check that the pubkey received is on the curve. """ # point_format = 0 # if self.point[0] in [b'\x02', b'\x03']: # point_format = 1 curve_name = _tls_named_curves[self.named_curve]...
[ "XXX", "Support", "compressed", "point", "format", ".", "XXX", "Check", "that", "the", "pubkey", "received", "is", "on", "the", "curve", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/keyexchange.py#L606-L623
[ "def", "register_pubkey", "(", "self", ")", ":", "# point_format = 0", "# if self.point[0] in [b'\\x02', b'\\x03']:", "# point_format = 1", "curve_name", "=", "_tls_named_curves", "[", "self", ".", "named_curve", "]", "curve", "=", "ec", ".", "_CURVE_TYPES", "[", "cu...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
ClientDiffieHellmanPublic.post_dissection
First we update the client DHParams. Then, we try to update the server DHParams generated during Server*DHParams building, with the shared secret. Finally, we derive the session keys and update the context.
scapy/layers/tls/keyexchange.py
def post_dissection(self, m): """ First we update the client DHParams. Then, we try to update the server DHParams generated during Server*DHParams building, with the shared secret. Finally, we derive the session keys and update the context. """ s = self.tls_session ...
def post_dissection(self, m): """ First we update the client DHParams. Then, we try to update the server DHParams generated during Server*DHParams building, with the shared secret. Finally, we derive the session keys and update the context. """ s = self.tls_session ...
[ "First", "we", "update", "the", "client", "DHParams", ".", "Then", "we", "try", "to", "update", "the", "server", "DHParams", "generated", "during", "Server", "*", "DHParams", "building", "with", "the", "shared", "secret", ".", "Finally", "we", "derive", "the...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/keyexchange.py#L769-L787
[ "def", "post_dissection", "(", "self", ",", "m", ")", ":", "s", "=", "self", ".", "tls_session", "# if there are kx params and keys, we assume the crypto library is ok", "if", "s", ".", "client_kx_ffdh_params", ":", "y", "=", "pkcs_os2ip", "(", "self", ".", "dh_Yc",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
EncryptedPreMasterSecret.post_build
We encrypt the premaster secret (the 48 bytes) with either the server certificate or the temporary RSA key provided in a server key exchange message. After that step, we add the 2 bytes to provide the length, as described in implementation notes at the end of section 7.4.7.1.
scapy/layers/tls/keyexchange.py
def post_build(self, pkt, pay): """ We encrypt the premaster secret (the 48 bytes) with either the server certificate or the temporary RSA key provided in a server key exchange message. After that step, we add the 2 bytes to provide the length, as described in implementation note...
def post_build(self, pkt, pay): """ We encrypt the premaster secret (the 48 bytes) with either the server certificate or the temporary RSA key provided in a server key exchange message. After that step, we add the 2 bytes to provide the length, as described in implementation note...
[ "We", "encrypt", "the", "premaster", "secret", "(", "the", "48", "bytes", ")", "with", "either", "the", "server", "certificate", "or", "the", "temporary", "RSA", "key", "provided", "in", "a", "server", "key", "exchange", "message", ".", "After", "that", "s...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/keyexchange.py#L907-L930
[ "def", "post_build", "(", "self", ",", "pkt", ",", "pay", ")", ":", "enc", "=", "pkt", "s", "=", "self", ".", "tls_session", "s", ".", "pre_master_secret", "=", "enc", "s", ".", "compute_ms_and_derive_keys", "(", ")", "if", "s", ".", "server_tmp_rsa_key"...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
lambda_tuple_converter
Converts a Python 2 function as lambda (x,y): x + y In the Python 3 format: lambda x,y : x + y
scapy/compat.py
def lambda_tuple_converter(func): """ Converts a Python 2 function as lambda (x,y): x + y In the Python 3 format: lambda x,y : x + y """ if func is not None and func.__code__.co_argcount == 1: return lambda *args: func(args[0] if len(args) == 1 else args) else: return...
def lambda_tuple_converter(func): """ Converts a Python 2 function as lambda (x,y): x + y In the Python 3 format: lambda x,y : x + y """ if func is not None and func.__code__.co_argcount == 1: return lambda *args: func(args[0] if len(args) == 1 else args) else: return...
[ "Converts", "a", "Python", "2", "function", "as", "lambda", "(", "x", "y", ")", ":", "x", "+", "y", "In", "the", "Python", "3", "format", ":", "lambda", "x", "y", ":", "x", "+", "y" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/compat.py#L23-L33
[ "def", "lambda_tuple_converter", "(", "func", ")", ":", "if", "func", "is", "not", "None", "and", "func", ".", "__code__", ".", "co_argcount", "==", "1", ":", "return", "lambda", "*", "args", ":", "func", "(", "args", "[", "0", "]", "if", "len", "(",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
base64_bytes
Turn base64 into bytes
scapy/compat.py
def base64_bytes(x): """Turn base64 into bytes""" if six.PY2: return base64.decodestring(x) return base64.decodebytes(bytes_encode(x))
def base64_bytes(x): """Turn base64 into bytes""" if six.PY2: return base64.decodestring(x) return base64.decodebytes(bytes_encode(x))
[ "Turn", "base64", "into", "bytes" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/compat.py#L88-L92
[ "def", "base64_bytes", "(", "x", ")", ":", "if", "six", ".", "PY2", ":", "return", "base64", ".", "decodestring", "(", "x", ")", "return", "base64", ".", "decodebytes", "(", "bytes_encode", "(", "x", ")", ")" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
train
bytes_base64
Turn bytes into base64
scapy/compat.py
def bytes_base64(x): """Turn bytes into base64""" if six.PY2: return base64.encodestring(x).replace('\n', '') return base64.encodebytes(bytes_encode(x)).replace(b'\n', b'')
def bytes_base64(x): """Turn bytes into base64""" if six.PY2: return base64.encodestring(x).replace('\n', '') return base64.encodebytes(bytes_encode(x)).replace(b'\n', b'')
[ "Turn", "bytes", "into", "base64" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/compat.py#L95-L99
[ "def", "bytes_base64", "(", "x", ")", ":", "if", "six", ".", "PY2", ":", "return", "base64", ".", "encodestring", "(", "x", ")", ".", "replace", "(", "'\\n'", ",", "''", ")", "return", "base64", ".", "encodebytes", "(", "bytes_encode", "(", "x", ")",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_TLSMsgListField.m2i
Try to parse one of the TLS subprotocols (ccs, alert, handshake or application_data). This is used inside a loop managed by .getfield().
scapy/layers/tls/record.py
def m2i(self, pkt, m): """ Try to parse one of the TLS subprotocols (ccs, alert, handshake or application_data). This is used inside a loop managed by .getfield(). """ cls = Raw if pkt.type == 22: if len(m) >= 1: msgtype = orb(m[0]) ...
def m2i(self, pkt, m): """ Try to parse one of the TLS subprotocols (ccs, alert, handshake or application_data). This is used inside a loop managed by .getfield(). """ cls = Raw if pkt.type == 22: if len(m) >= 1: msgtype = orb(m[0]) ...
[ "Try", "to", "parse", "one", "of", "the", "TLS", "subprotocols", "(", "ccs", "alert", "handshake", "or", "application_data", ")", ".", "This", "is", "used", "inside", "a", "loop", "managed", "by", ".", "getfield", "()", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/record.py#L83-L108
[ "def", "m2i", "(", "self", ",", "pkt", ",", "m", ")", ":", "cls", "=", "Raw", "if", "pkt", ".", "type", "==", "22", ":", "if", "len", "(", "m", ")", ">=", "1", ":", "msgtype", "=", "orb", "(", "m", "[", "0", "]", ")", "cls", "=", "_tls_ha...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_TLSMsgListField.getfield
If the decryption of the content did not fail with a CipherError, we begin a loop on the clear content in order to get as much messages as possible, of the type advertised in the record header. This is notably important for several TLS handshake implementations, which may for instance pa...
scapy/layers/tls/record.py
def getfield(self, pkt, s): """ If the decryption of the content did not fail with a CipherError, we begin a loop on the clear content in order to get as much messages as possible, of the type advertised in the record header. This is notably important for several TLS handshake im...
def getfield(self, pkt, s): """ If the decryption of the content did not fail with a CipherError, we begin a loop on the clear content in order to get as much messages as possible, of the type advertised in the record header. This is notably important for several TLS handshake im...
[ "If", "the", "decryption", "of", "the", "content", "did", "not", "fail", "with", "a", "CipherError", "we", "begin", "a", "loop", "on", "the", "clear", "content", "in", "order", "to", "get", "as", "much", "messages", "as", "possible", "of", "the", "type",...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/record.py#L110-L159
[ "def", "getfield", "(", "self", ",", "pkt", ",", "s", ")", ":", "tmp_len", "=", "self", ".", "length_from", "(", "pkt", ")", "lst", "=", "[", "]", "ret", "=", "b\"\"", "remain", "=", "s", "if", "tmp_len", "is", "not", "None", ":", "remain", ",", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_TLSMsgListField.i2m
Update the context with information from the built packet. If no type was given at the record layer, we try to infer it.
scapy/layers/tls/record.py
def i2m(self, pkt, p): """ Update the context with information from the built packet. If no type was given at the record layer, we try to infer it. """ cur = b"" if isinstance(p, _GenericTLSSessionInheritance): if pkt.type is None: if isinstanc...
def i2m(self, pkt, p): """ Update the context with information from the built packet. If no type was given at the record layer, we try to infer it. """ cur = b"" if isinstance(p, _GenericTLSSessionInheritance): if pkt.type is None: if isinstanc...
[ "Update", "the", "context", "with", "information", "from", "the", "built", "packet", ".", "If", "no", "type", "was", "given", "at", "the", "record", "layer", "we", "try", "to", "infer", "it", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/record.py#L161-L186
[ "def", "i2m", "(", "self", ",", "pkt", ",", "p", ")", ":", "cur", "=", "b\"\"", "if", "isinstance", "(", "p", ",", "_GenericTLSSessionInheritance", ")", ":", "if", "pkt", ".", "type", "is", "None", ":", "if", "isinstance", "(", "p", ",", "TLSChangeCi...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_TLSMsgListField.addfield
Reconstruct the header because the TLS type may have been updated. Then, append the content.
scapy/layers/tls/record.py
def addfield(self, pkt, s, val): """ Reconstruct the header because the TLS type may have been updated. Then, append the content. """ res = b"" for p in val: res += self.i2m(pkt, p) if (isinstance(pkt, _GenericTLSSessionInheritance) and _tl...
def addfield(self, pkt, s, val): """ Reconstruct the header because the TLS type may have been updated. Then, append the content. """ res = b"" for p in val: res += self.i2m(pkt, p) if (isinstance(pkt, _GenericTLSSessionInheritance) and _tl...
[ "Reconstruct", "the", "header", "because", "the", "TLS", "type", "may", "have", "been", "updated", ".", "Then", "append", "the", "content", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/record.py#L188-L203
[ "def", "addfield", "(", "self", ",", "pkt", ",", "s", ",", "val", ")", ":", "res", "=", "b\"\"", "for", "p", "in", "val", ":", "res", "+=", "self", ".", "i2m", "(", "pkt", ",", "p", ")", "if", "(", "isinstance", "(", "pkt", ",", "_GenericTLSSes...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
TLS.dispatch_hook
If the TLS class was called on raw SSLv2 data, we want to return an SSLv2 record instance. We acknowledge the risk of SSLv2 packets with a msglen of 0x1403, 0x1503, 0x1603 or 0x1703 which will never be casted as SSLv2 records but TLS ones instead, but hey, we can't be held responsible fo...
scapy/layers/tls/record.py
def dispatch_hook(cls, _pkt=None, *args, **kargs): """ If the TLS class was called on raw SSLv2 data, we want to return an SSLv2 record instance. We acknowledge the risk of SSLv2 packets with a msglen of 0x1403, 0x1503, 0x1603 or 0x1703 which will never be casted as SSLv2 records...
def dispatch_hook(cls, _pkt=None, *args, **kargs): """ If the TLS class was called on raw SSLv2 data, we want to return an SSLv2 record instance. We acknowledge the risk of SSLv2 packets with a msglen of 0x1403, 0x1503, 0x1603 or 0x1703 which will never be casted as SSLv2 records...
[ "If", "the", "TLS", "class", "was", "called", "on", "raw", "SSLv2", "data", "we", "want", "to", "return", "an", "SSLv2", "record", "instance", ".", "We", "acknowledge", "the", "risk", "of", "SSLv2", "packets", "with", "a", "msglen", "of", "0x1403", "0x15...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/record.py#L276-L301
[ "def", "dispatch_hook", "(", "cls", ",", "_pkt", "=", "None", ",", "*", "args", ",", "*", "*", "kargs", ")", ":", "if", "_pkt", "and", "len", "(", "_pkt", ")", ">=", "2", ":", "byte0", "=", "orb", "(", "_pkt", "[", "0", "]", ")", "byte1", "="...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
TLS._tls_hmac_verify
Provided with the record header, the TLSCompressed.fragment and the HMAC, return True if the HMAC is correct. If we could not compute the HMAC because the key was missing, there is no sense in verifying anything, thus we also return True. Meant to be used with a block cipher or a stream...
scapy/layers/tls/record.py
def _tls_hmac_verify(self, hdr, msg, mac): """ Provided with the record header, the TLSCompressed.fragment and the HMAC, return True if the HMAC is correct. If we could not compute the HMAC because the key was missing, there is no sense in verifying anything, thus we also return ...
def _tls_hmac_verify(self, hdr, msg, mac): """ Provided with the record header, the TLSCompressed.fragment and the HMAC, return True if the HMAC is correct. If we could not compute the HMAC because the key was missing, there is no sense in verifying anything, thus we also return ...
[ "Provided", "with", "the", "record", "header", "the", "TLSCompressed", ".", "fragment", "and", "the", "HMAC", "return", "True", "if", "the", "HMAC", "is", "correct", ".", "If", "we", "could", "not", "compute", "the", "HMAC", "because", "the", "key", "was",...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/record.py#L339-L370
[ "def", "_tls_hmac_verify", "(", "self", ",", "hdr", ",", "msg", ",", "mac", ")", ":", "read_seq_num", "=", "struct", ".", "pack", "(", "\"!Q\"", ",", "self", ".", "tls_session", ".", "rcs", ".", "seq_num", ")", "self", ".", "tls_session", ".", "rcs", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
TLS._tls_decompress
Provided with the TLSCompressed.fragment, return the TLSPlaintext.fragment.
scapy/layers/tls/record.py
def _tls_decompress(self, s): """ Provided with the TLSCompressed.fragment, return the TLSPlaintext.fragment. """ alg = self.tls_session.rcs.compression return alg.decompress(s)
def _tls_decompress(self, s): """ Provided with the TLSCompressed.fragment, return the TLSPlaintext.fragment. """ alg = self.tls_session.rcs.compression return alg.decompress(s)
[ "Provided", "with", "the", "TLSCompressed", ".", "fragment", "return", "the", "TLSPlaintext", ".", "fragment", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/record.py#L372-L378
[ "def", "_tls_decompress", "(", "self", ",", "s", ")", ":", "alg", "=", "self", ".", "tls_session", ".", "rcs", ".", "compression", "return", "alg", ".", "decompress", "(", "s", ")" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
train
TLS.pre_dissect
Decrypt, verify and decompress the message, i.e. apply the previous methods according to the reading cipher type. If the decryption was successful, 'len' will be the length of the TLSPlaintext.fragment. Else, it should be the length of the _TLSEncryptedContent.
scapy/layers/tls/record.py
def pre_dissect(self, s): """ Decrypt, verify and decompress the message, i.e. apply the previous methods according to the reading cipher type. If the decryption was successful, 'len' will be the length of the TLSPlaintext.fragment. Else, it should be the length of the _T...
def pre_dissect(self, s): """ Decrypt, verify and decompress the message, i.e. apply the previous methods according to the reading cipher type. If the decryption was successful, 'len' will be the length of the TLSPlaintext.fragment. Else, it should be the length of the _T...
[ "Decrypt", "verify", "and", "decompress", "the", "message", "i", ".", "e", ".", "apply", "the", "previous", "methods", "according", "to", "the", "reading", "cipher", "type", ".", "If", "the", "decryption", "was", "successful", "len", "will", "be", "the", "...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/record.py#L380-L496
[ "def", "pre_dissect", "(", "self", ",", "s", ")", ":", "if", "len", "(", "s", ")", "<", "5", ":", "raise", "Exception", "(", "\"Invalid record: header is too short.\"", ")", "msglen", "=", "struct", ".", "unpack", "(", "'!H'", ",", "s", "[", "3", ":", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
TLS.post_dissect
Commit the pending r/w state if it has been triggered (e.g. by an underlying TLSChangeCipherSpec or a SSLv2ClientMasterKey). We update nothing if the prcs was not set, as this probably means that we're working out-of-context (and we need to keep the default rcs).
scapy/layers/tls/record.py
def post_dissect(self, s): """ Commit the pending r/w state if it has been triggered (e.g. by an underlying TLSChangeCipherSpec or a SSLv2ClientMasterKey). We update nothing if the prcs was not set, as this probably means that we're working out-of-context (and we need to keep the...
def post_dissect(self, s): """ Commit the pending r/w state if it has been triggered (e.g. by an underlying TLSChangeCipherSpec or a SSLv2ClientMasterKey). We update nothing if the prcs was not set, as this probably means that we're working out-of-context (and we need to keep the...
[ "Commit", "the", "pending", "r", "/", "w", "state", "if", "it", "has", "been", "triggered", "(", "e", ".", "g", ".", "by", "an", "underlying", "TLSChangeCipherSpec", "or", "a", "SSLv2ClientMasterKey", ")", ".", "We", "update", "nothing", "if", "the", "pr...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/record.py#L498-L515
[ "def", "post_dissect", "(", "self", ",", "s", ")", ":", "if", "self", ".", "tls_session", ".", "triggered_prcs_commit", ":", "if", "self", ".", "tls_session", ".", "prcs", "is", "not", "None", ":", "self", ".", "tls_session", ".", "rcs", "=", "self", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
TLS._tls_compress
Provided with the TLSPlaintext.fragment, return the TLSCompressed.fragment.
scapy/layers/tls/record.py
def _tls_compress(self, s): """ Provided with the TLSPlaintext.fragment, return the TLSCompressed.fragment. """ alg = self.tls_session.wcs.compression return alg.compress(s)
def _tls_compress(self, s): """ Provided with the TLSPlaintext.fragment, return the TLSCompressed.fragment. """ alg = self.tls_session.wcs.compression return alg.compress(s)
[ "Provided", "with", "the", "TLSPlaintext", ".", "fragment", "return", "the", "TLSCompressed", ".", "fragment", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/record.py#L535-L541
[ "def", "_tls_compress", "(", "self", ",", "s", ")", ":", "alg", "=", "self", ".", "tls_session", ".", "wcs", ".", "compression", "return", "alg", ".", "compress", "(", "s", ")" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
train
TLS._tls_auth_encrypt
Return the TLSCiphertext.fragment for AEAD ciphers, i.e. the whole GenericAEADCipher. Also, the additional data is computed right here.
scapy/layers/tls/record.py
def _tls_auth_encrypt(self, s): """ Return the TLSCiphertext.fragment for AEAD ciphers, i.e. the whole GenericAEADCipher. Also, the additional data is computed right here. """ write_seq_num = struct.pack("!Q", self.tls_session.wcs.seq_num) self.tls_session.wcs.seq_num += ...
def _tls_auth_encrypt(self, s): """ Return the TLSCiphertext.fragment for AEAD ciphers, i.e. the whole GenericAEADCipher. Also, the additional data is computed right here. """ write_seq_num = struct.pack("!Q", self.tls_session.wcs.seq_num) self.tls_session.wcs.seq_num += ...
[ "Return", "the", "TLSCiphertext", ".", "fragment", "for", "AEAD", "ciphers", "i", ".", "e", ".", "the", "whole", "GenericAEADCipher", ".", "Also", "the", "additional", "data", "is", "computed", "right", "here", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/record.py#L543-L555
[ "def", "_tls_auth_encrypt", "(", "self", ",", "s", ")", ":", "write_seq_num", "=", "struct", ".", "pack", "(", "\"!Q\"", ",", "self", ".", "tls_session", ".", "wcs", ".", "seq_num", ")", "self", ".", "tls_session", ".", "wcs", ".", "seq_num", "+=", "1"...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
TLS._tls_hmac_add
Provided with the record header (concatenation of the TLSCompressed type, version and length fields) and the TLSCompressed.fragment, return the concatenation of the TLSCompressed.fragment and the HMAC. Meant to be used with a block cipher or a stream cipher. It would fail with an AEAD c...
scapy/layers/tls/record.py
def _tls_hmac_add(self, hdr, msg): """ Provided with the record header (concatenation of the TLSCompressed type, version and length fields) and the TLSCompressed.fragment, return the concatenation of the TLSCompressed.fragment and the HMAC. Meant to be used with a block cipher o...
def _tls_hmac_add(self, hdr, msg): """ Provided with the record header (concatenation of the TLSCompressed type, version and length fields) and the TLSCompressed.fragment, return the concatenation of the TLSCompressed.fragment and the HMAC. Meant to be used with a block cipher o...
[ "Provided", "with", "the", "record", "header", "(", "concatenation", "of", "the", "TLSCompressed", "type", "version", "and", "length", "fields", ")", "and", "the", "TLSCompressed", ".", "fragment", "return", "the", "concatenation", "of", "the", "TLSCompressed", ...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/record.py#L557-L578
[ "def", "_tls_hmac_add", "(", "self", ",", "hdr", ",", "msg", ")", ":", "write_seq_num", "=", "struct", ".", "pack", "(", "\"!Q\"", ",", "self", ".", "tls_session", ".", "wcs", ".", "seq_num", ")", "self", ".", "tls_session", ".", "wcs", ".", "seq_num",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
TLS._tls_pad
Provided with the concatenation of the TLSCompressed.fragment and the HMAC, append the right padding and return it as a whole. This is the TLS-style padding: while SSL allowed for random padding, TLS (misguidedly) specifies the repetition of the same byte all over, and this byte must be ...
scapy/layers/tls/record.py
def _tls_pad(self, s): """ Provided with the concatenation of the TLSCompressed.fragment and the HMAC, append the right padding and return it as a whole. This is the TLS-style padding: while SSL allowed for random padding, TLS (misguidedly) specifies the repetition of the same by...
def _tls_pad(self, s): """ Provided with the concatenation of the TLSCompressed.fragment and the HMAC, append the right padding and return it as a whole. This is the TLS-style padding: while SSL allowed for random padding, TLS (misguidedly) specifies the repetition of the same by...
[ "Provided", "with", "the", "concatenation", "of", "the", "TLSCompressed", ".", "fragment", "and", "the", "HMAC", "append", "the", "right", "padding", "and", "return", "it", "as", "a", "whole", ".", "This", "is", "the", "TLS", "-", "style", "padding", ":", ...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/record.py#L580-L597
[ "def", "_tls_pad", "(", "self", ",", "s", ")", ":", "padding", "=", "b\"\"", "block_size", "=", "self", ".", "tls_session", ".", "wcs", ".", "cipher", ".", "block_size", "padlen", "=", "block_size", "-", "(", "(", "len", "(", "s", ")", "+", "1", ")...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
TLS.post_build
Apply the previous methods according to the writing cipher type.
scapy/layers/tls/record.py
def post_build(self, pkt, pay): """ Apply the previous methods according to the writing cipher type. """ # Compute the length of TLSPlaintext fragment hdr, frag = pkt[:5], pkt[5:] tmp_len = len(frag) hdr = hdr[:3] + struct.pack("!H", tmp_len) # Compressio...
def post_build(self, pkt, pay): """ Apply the previous methods according to the writing cipher type. """ # Compute the length of TLSPlaintext fragment hdr, frag = pkt[:5], pkt[5:] tmp_len = len(frag) hdr = hdr[:3] + struct.pack("!H", tmp_len) # Compressio...
[ "Apply", "the", "previous", "methods", "according", "to", "the", "writing", "cipher", "type", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/record.py#L607-L676
[ "def", "post_build", "(", "self", ",", "pkt", ",", "pay", ")", ":", "# Compute the length of TLSPlaintext fragment", "hdr", ",", "frag", "=", "pkt", "[", ":", "5", "]", ",", "pkt", "[", "5", ":", "]", "tmp_len", "=", "len", "(", "frag", ")", "hdr", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
SuperSocket.select
This function is called during sendrecv() routine to select the available sockets. params: - sockets: an array of sockets that need to be selected returns: - an array of sockets that were selected - the function to be called next to get the packets (i.g. recv)
scapy/supersocket.py
def select(sockets, remain=conf.recv_poll_rate): """This function is called during sendrecv() routine to select the available sockets. params: - sockets: an array of sockets that need to be selected returns: - an array of sockets that were selected - the funct...
def select(sockets, remain=conf.recv_poll_rate): """This function is called during sendrecv() routine to select the available sockets. params: - sockets: an array of sockets that need to be selected returns: - an array of sockets that were selected - the funct...
[ "This", "function", "is", "called", "during", "sendrecv", "()", "routine", "to", "select", "the", "available", "sockets", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/supersocket.py#L109-L125
[ "def", "select", "(", "sockets", ",", "remain", "=", "conf", ".", "recv_poll_rate", ")", ":", "try", ":", "inp", ",", "_", ",", "_", "=", "select", "(", "sockets", ",", "[", "]", ",", "[", "]", ",", "remain", ")", "except", "(", "IOError", ",", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
TunTapInterface.open
Open the TUN or TAP device.
scapy/supersocket.py
def open(self): """Open the TUN or TAP device.""" if not self.closed: return self.outs = self.ins = open( "/dev/net/tun" if LINUX else ("/dev/%s" % self.iface), "r+b", buffering=0 ) if LINUX: from fcntl import ioctl # TU...
def open(self): """Open the TUN or TAP device.""" if not self.closed: return self.outs = self.ins = open( "/dev/net/tun" if LINUX else ("/dev/%s" % self.iface), "r+b", buffering=0 ) if LINUX: from fcntl import ioctl # TU...
[ "Open", "the", "TUN", "or", "TAP", "device", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/supersocket.py#L309-L327
[ "def", "open", "(", "self", ")", ":", "if", "not", "self", ".", "closed", ":", "return", "self", ".", "outs", "=", "self", ".", "ins", "=", "open", "(", "\"/dev/net/tun\"", "if", "LINUX", "else", "(", "\"/dev/%s\"", "%", "self", ".", "iface", ")", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
util_mic_len
Calculate the length of the attribute value field
scapy/layers/zigbee.py
def util_mic_len(pkt): ''' Calculate the length of the attribute value field ''' if (pkt.nwk_seclevel == 0): # no encryption, no mic return 0 elif (pkt.nwk_seclevel == 1): # MIC-32 return 4 elif (pkt.nwk_seclevel == 2): # MIC-64 return 8 elif (pkt.nwk_seclevel == 3): # MI...
def util_mic_len(pkt): ''' Calculate the length of the attribute value field ''' if (pkt.nwk_seclevel == 0): # no encryption, no mic return 0 elif (pkt.nwk_seclevel == 1): # MIC-32 return 4 elif (pkt.nwk_seclevel == 2): # MIC-64 return 8 elif (pkt.nwk_seclevel == 3): # MI...
[ "Calculate", "the", "length", "of", "the", "attribute", "value", "field" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/zigbee.py#L460-L479
[ "def", "util_mic_len", "(", "pkt", ")", ":", "if", "(", "pkt", ".", "nwk_seclevel", "==", "0", ")", ":", "# no encryption, no mic", "return", "0", "elif", "(", "pkt", ".", "nwk_seclevel", "==", "1", ")", ":", "# MIC-32", "return", "4", "elif", "(", "pk...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
Eddystone_Frame.build_eir
Builds a list of EIR messages to wrap this frame.
scapy/contrib/eddystone.py
def build_eir(self): """Builds a list of EIR messages to wrap this frame.""" return LowEnergyBeaconHelper.base_eir + [ EIR_Hdr() / EIR_CompleteList16BitServiceUUIDs(svc_uuids=[ EDDYSTONE_UUID]), EIR_Hdr() / EIR_ServiceData16BitUUID() / self ]
def build_eir(self): """Builds a list of EIR messages to wrap this frame.""" return LowEnergyBeaconHelper.base_eir + [ EIR_Hdr() / EIR_CompleteList16BitServiceUUIDs(svc_uuids=[ EDDYSTONE_UUID]), EIR_Hdr() / EIR_ServiceData16BitUUID() / self ]
[ "Builds", "a", "list", "of", "EIR", "messages", "to", "wrap", "this", "frame", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/eddystone.py#L117-L124
[ "def", "build_eir", "(", "self", ")", ":", "return", "LowEnergyBeaconHelper", ".", "base_eir", "+", "[", "EIR_Hdr", "(", ")", "/", "EIR_CompleteList16BitServiceUUIDs", "(", "svc_uuids", "=", "[", "EDDYSTONE_UUID", "]", ")", ",", "EIR_Hdr", "(", ")", "/", "EI...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
Eddystone_URL.from_url
Creates an Eddystone_Frame with a Eddystone_URL for a given URL.
scapy/contrib/eddystone.py
def from_url(url): """Creates an Eddystone_Frame with a Eddystone_URL for a given URL.""" url = url.encode('ascii') scheme = None for k, v in EDDYSTONE_URL_SCHEMES.items(): if url.startswith(v): scheme = k url = url[len(v):] bre...
def from_url(url): """Creates an Eddystone_Frame with a Eddystone_URL for a given URL.""" url = url.encode('ascii') scheme = None for k, v in EDDYSTONE_URL_SCHEMES.items(): if url.startswith(v): scheme = k url = url[len(v):] bre...
[ "Creates", "an", "Eddystone_Frame", "with", "a", "Eddystone_URL", "for", "a", "given", "URL", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/eddystone.py#L159-L173
[ "def", "from_url", "(", "url", ")", ":", "url", "=", "url", ".", "encode", "(", "'ascii'", ")", "scheme", "=", "None", "for", "k", ",", "v", "in", "EDDYSTONE_URL_SCHEMES", ".", "items", "(", ")", ":", "if", "url", ".", "startswith", "(", "v", ")", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
Route6.add
Ex: add(dst="2001:db8:cafe:f000::/56") add(dst="2001:db8:cafe:f000::/56", gw="2001:db8:cafe::1") add(dst="2001:db8:cafe:f000::/64", gw="2001:db8:cafe::1", dev="eth0")
scapy/route6.py
def add(self, *args, **kargs): """Ex: add(dst="2001:db8:cafe:f000::/56") add(dst="2001:db8:cafe:f000::/56", gw="2001:db8:cafe::1") add(dst="2001:db8:cafe:f000::/64", gw="2001:db8:cafe::1", dev="eth0") """ self.invalidate_cache() self.routes.append(self.make_route(...
def add(self, *args, **kargs): """Ex: add(dst="2001:db8:cafe:f000::/56") add(dst="2001:db8:cafe:f000::/56", gw="2001:db8:cafe::1") add(dst="2001:db8:cafe:f000::/64", gw="2001:db8:cafe::1", dev="eth0") """ self.invalidate_cache() self.routes.append(self.make_route(...
[ "Ex", ":", "add", "(", "dst", "=", "2001", ":", "db8", ":", "cafe", ":", "f000", "::", "/", "56", ")", "add", "(", "dst", "=", "2001", ":", "db8", ":", "cafe", ":", "f000", "::", "/", "56", "gw", "=", "2001", ":", "db8", ":", "cafe", "::", ...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/route6.py#L91-L98
[ "def", "add", "(", "self", ",", "*", "args", ",", "*", "*", "kargs", ")", ":", "self", ".", "invalidate_cache", "(", ")", "self", ".", "routes", ".", "append", "(", "self", ".", "make_route", "(", "*", "args", ",", "*", "*", "kargs", ")", ")" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
train
Route6.ifdel
removes all route entries that uses 'iff' interface.
scapy/route6.py
def ifdel(self, iff): """ removes all route entries that uses 'iff' interface. """ new_routes = [] for rt in self.routes: if rt[3] != iff: new_routes.append(rt) self.invalidate_cache() self.routes = new_routes
def ifdel(self, iff): """ removes all route entries that uses 'iff' interface. """ new_routes = [] for rt in self.routes: if rt[3] != iff: new_routes.append(rt) self.invalidate_cache() self.routes = new_routes
[ "removes", "all", "route", "entries", "that", "uses", "iff", "interface", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/route6.py#L143-L150
[ "def", "ifdel", "(", "self", ",", "iff", ")", ":", "new_routes", "=", "[", "]", "for", "rt", "in", "self", ".", "routes", ":", "if", "rt", "[", "3", "]", "!=", "iff", ":", "new_routes", ".", "append", "(", "rt", ")", "self", ".", "invalidate_cach...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
Route6.ifadd
Add an interface 'iff' with provided address into routing table. Ex: ifadd('eth0', '2001:bd8:cafe:1::1/64') will add following entry into # noqa: E501 Scapy6 internal routing table: Destination Next Hop iface Def src @ Metric 2001:bd8:cafe:1::/64 :: ...
scapy/route6.py
def ifadd(self, iff, addr): """ Add an interface 'iff' with provided address into routing table. Ex: ifadd('eth0', '2001:bd8:cafe:1::1/64') will add following entry into # noqa: E501 Scapy6 internal routing table: Destination Next Hop iface Def src @ ...
def ifadd(self, iff, addr): """ Add an interface 'iff' with provided address into routing table. Ex: ifadd('eth0', '2001:bd8:cafe:1::1/64') will add following entry into # noqa: E501 Scapy6 internal routing table: Destination Next Hop iface Def src @ ...
[ "Add", "an", "interface", "iff", "with", "provided", "address", "into", "routing", "table", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/route6.py#L152-L172
[ "def", "ifadd", "(", "self", ",", "iff", ",", "addr", ")", ":", "addr", ",", "plen", "=", "(", "addr", ".", "split", "(", "\"/\"", ")", "+", "[", "\"128\"", "]", ")", "[", ":", "2", "]", "addr", "=", "in6_ptop", "(", "addr", ")", "plen", "=",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
Route6.route
Provide best route to IPv6 destination address, based on Scapy internal routing table content. When a set of address is passed (e.g. 2001:db8:cafe:*::1-5) an address of the set is used. Be aware of that behavior when using wildcards in upper parts of addresses ! If 'dst' parame...
scapy/route6.py
def route(self, dst=None, dev=None, verbose=conf.verb): """ Provide best route to IPv6 destination address, based on Scapy internal routing table content. When a set of address is passed (e.g. 2001:db8:cafe:*::1-5) an address of the set is used. Be aware of that behavior when us...
def route(self, dst=None, dev=None, verbose=conf.verb): """ Provide best route to IPv6 destination address, based on Scapy internal routing table content. When a set of address is passed (e.g. 2001:db8:cafe:*::1-5) an address of the set is used. Be aware of that behavior when us...
[ "Provide", "best", "route", "to", "IPv6", "destination", "address", "based", "on", "Scapy", "internal", "routing", "table", "content", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/route6.py#L174-L282
[ "def", "route", "(", "self", ",", "dst", "=", "None", ",", "dev", "=", "None", ",", "verbose", "=", "conf", ".", "verb", ")", ":", "dst", "=", "dst", "or", "\"::/0\"", "# Enable route(None) to return default route", "# Transform \"2001:db8:cafe:*::1-5:0/120\" to o...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_tls_compress
Compress p (a TLSPlaintext instance) using compression algorithm instance alg and return a TLSCompressed instance.
scapy/layers/tls/tools.py
def _tls_compress(alg, p): """ Compress p (a TLSPlaintext instance) using compression algorithm instance alg and return a TLSCompressed instance. """ c = TLSCompressed() c.type = p.type c.version = p.version c.data = alg.compress(p.data) c.len = len(c.data) return c
def _tls_compress(alg, p): """ Compress p (a TLSPlaintext instance) using compression algorithm instance alg and return a TLSCompressed instance. """ c = TLSCompressed() c.type = p.type c.version = p.version c.data = alg.compress(p.data) c.len = len(c.data) return c
[ "Compress", "p", "(", "a", "TLSPlaintext", "instance", ")", "using", "compression", "algorithm", "instance", "alg", "and", "return", "a", "TLSCompressed", "instance", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/tools.py#L39-L49
[ "def", "_tls_compress", "(", "alg", ",", "p", ")", ":", "c", "=", "TLSCompressed", "(", ")", "c", ".", "type", "=", "p", ".", "type", "c", ".", "version", "=", "p", ".", "version", "c", ".", "data", "=", "alg", ".", "compress", "(", "p", ".", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_tls_decompress
Decompress c (a TLSCompressed instance) using compression algorithm instance alg and return a TLSPlaintext instance.
scapy/layers/tls/tools.py
def _tls_decompress(alg, c): """ Decompress c (a TLSCompressed instance) using compression algorithm instance alg and return a TLSPlaintext instance. """ p = TLSPlaintext() p.type = c.type p.version = c.version p.data = alg.decompress(c.data) p.len = len(p.data) return p
def _tls_decompress(alg, c): """ Decompress c (a TLSCompressed instance) using compression algorithm instance alg and return a TLSPlaintext instance. """ p = TLSPlaintext() p.type = c.type p.version = c.version p.data = alg.decompress(c.data) p.len = len(p.data) return p
[ "Decompress", "c", "(", "a", "TLSCompressed", "instance", ")", "using", "compression", "algorithm", "instance", "alg", "and", "return", "a", "TLSPlaintext", "instance", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/tools.py#L52-L62
[ "def", "_tls_decompress", "(", "alg", ",", "c", ")", ":", "p", "=", "TLSPlaintext", "(", ")", "p", ".", "type", "=", "c", ".", "type", "p", ".", "version", "=", "c", ".", "version", "p", ".", "data", "=", "alg", ".", "decompress", "(", "c", "."...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_tls_mac_add
Compute the MAC using provided MAC alg instance over TLSCiphertext c using current write sequence number write_seq_num. Computed MAC is then appended to c.data and c.len is updated to reflect that change. It is the caller responsibility to increment the sequence number after the operation. The function ...
scapy/layers/tls/tools.py
def _tls_mac_add(alg, c, write_seq_num): """ Compute the MAC using provided MAC alg instance over TLSCiphertext c using current write sequence number write_seq_num. Computed MAC is then appended to c.data and c.len is updated to reflect that change. It is the caller responsibility to increment the s...
def _tls_mac_add(alg, c, write_seq_num): """ Compute the MAC using provided MAC alg instance over TLSCiphertext c using current write sequence number write_seq_num. Computed MAC is then appended to c.data and c.len is updated to reflect that change. It is the caller responsibility to increment the s...
[ "Compute", "the", "MAC", "using", "provided", "MAC", "alg", "instance", "over", "TLSCiphertext", "c", "using", "current", "write", "sequence", "number", "write_seq_num", ".", "Computed", "MAC", "is", "then", "appended", "to", "c", ".", "data", "and", "c", "....
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/tools.py#L65-L76
[ "def", "_tls_mac_add", "(", "alg", ",", "c", ",", "write_seq_num", ")", ":", "write_seq_num", "=", "struct", ".", "pack", "(", "\"!Q\"", ",", "write_seq_num", ")", "h", "=", "alg", ".", "digest", "(", "write_seq_num", "+", "bytes", "(", "c", ")", ")", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_tls_mac_verify
Verify if the MAC in provided message (message resulting from decryption and padding removal) is valid. Current read sequence number is used in the verification process. If the MAC is valid: - The function returns True - The packet p is updated in the following way: trailing MAC value is r...
scapy/layers/tls/tools.py
def _tls_mac_verify(alg, p, read_seq_num): """ Verify if the MAC in provided message (message resulting from decryption and padding removal) is valid. Current read sequence number is used in the verification process. If the MAC is valid: - The function returns True - The packet p is updat...
def _tls_mac_verify(alg, p, read_seq_num): """ Verify if the MAC in provided message (message resulting from decryption and padding removal) is valid. Current read sequence number is used in the verification process. If the MAC is valid: - The function returns True - The packet p is updat...
[ "Verify", "if", "the", "MAC", "in", "provided", "message", "(", "message", "resulting", "from", "decryption", "and", "padding", "removal", ")", "is", "valid", ".", "Current", "read", "sequence", "number", "is", "used", "in", "the", "verification", "process", ...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/tools.py#L79-L104
[ "def", "_tls_mac_verify", "(", "alg", ",", "p", ",", "read_seq_num", ")", ":", "h_size", "=", "alg", ".", "hash_len", "if", "p", ".", "len", "<", "h_size", ":", "return", "False", "received_h", "=", "p", ".", "data", "[", "-", "h_size", ":", "]", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_tls_add_pad
Provided with cipher block size parameter and current TLSCompressed packet p (after MAC addition), the function adds required, deterministic padding to p.data before encryption step, as it is defined for TLS (i.e. not SSL and its allowed random padding). The function has no return value.
scapy/layers/tls/tools.py
def _tls_add_pad(p, block_size): """ Provided with cipher block size parameter and current TLSCompressed packet p (after MAC addition), the function adds required, deterministic padding to p.data before encryption step, as it is defined for TLS (i.e. not SSL and its allowed random padding). The func...
def _tls_add_pad(p, block_size): """ Provided with cipher block size parameter and current TLSCompressed packet p (after MAC addition), the function adds required, deterministic padding to p.data before encryption step, as it is defined for TLS (i.e. not SSL and its allowed random padding). The func...
[ "Provided", "with", "cipher", "block", "size", "parameter", "and", "current", "TLSCompressed", "packet", "p", "(", "after", "MAC", "addition", ")", "the", "function", "adds", "required", "deterministic", "padding", "to", "p", ".", "data", "before", "encryption",...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/tools.py#L107-L117
[ "def", "_tls_add_pad", "(", "p", ",", "block_size", ")", ":", "padlen", "=", "-", "p", ".", "len", "%", "block_size", "padding", "=", "chb", "(", "padlen", ")", "*", "(", "padlen", "+", "1", ")", "p", ".", "len", "+=", "len", "(", "padding", ")",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_tls_del_pad
Provided with a just decrypted TLSCiphertext (now a TLSPlaintext instance) p, the function removes the trailing padding found in p.data. It also performs some sanity checks on the padding (length, content, ...). False is returned if one of the check fails. Otherwise, True is returned, indicating that p....
scapy/layers/tls/tools.py
def _tls_del_pad(p): """ Provided with a just decrypted TLSCiphertext (now a TLSPlaintext instance) p, the function removes the trailing padding found in p.data. It also performs some sanity checks on the padding (length, content, ...). False is returned if one of the check fails. Otherwise, True is...
def _tls_del_pad(p): """ Provided with a just decrypted TLSCiphertext (now a TLSPlaintext instance) p, the function removes the trailing padding found in p.data. It also performs some sanity checks on the padding (length, content, ...). False is returned if one of the check fails. Otherwise, True is...
[ "Provided", "with", "a", "just", "decrypted", "TLSCiphertext", "(", "now", "a", "TLSPlaintext", "instance", ")", "p", "the", "function", "removes", "the", "trailing", "padding", "found", "in", "p", ".", "data", ".", "It", "also", "performs", "some", "sanity"...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/tools.py#L120-L147
[ "def", "_tls_del_pad", "(", "p", ")", ":", "if", "p", ".", "len", "<", "1", ":", "warning", "(", "\"Message format is invalid (padding)\"", ")", "return", "False", "padlen", "=", "orb", "(", "p", ".", "data", "[", "-", "1", "]", ")", "padsize", "=", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_tls_encrypt
Provided with an already MACed TLSCompressed packet, and a stream or block cipher alg, the function converts it into a TLSCiphertext (i.e. encrypts it and updates length). The function returns a newly created TLSCiphertext instance.
scapy/layers/tls/tools.py
def _tls_encrypt(alg, p): """ Provided with an already MACed TLSCompressed packet, and a stream or block cipher alg, the function converts it into a TLSCiphertext (i.e. encrypts it and updates length). The function returns a newly created TLSCiphertext instance. """ c = TLSCiphertext() c...
def _tls_encrypt(alg, p): """ Provided with an already MACed TLSCompressed packet, and a stream or block cipher alg, the function converts it into a TLSCiphertext (i.e. encrypts it and updates length). The function returns a newly created TLSCiphertext instance. """ c = TLSCiphertext() c...
[ "Provided", "with", "an", "already", "MACed", "TLSCompressed", "packet", "and", "a", "stream", "or", "block", "cipher", "alg", "the", "function", "converts", "it", "into", "a", "TLSCiphertext", "(", "i", ".", "e", ".", "encrypts", "it", "and", "updates", "...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/tools.py#L150-L162
[ "def", "_tls_encrypt", "(", "alg", ",", "p", ")", ":", "c", "=", "TLSCiphertext", "(", ")", "c", ".", "type", "=", "p", ".", "type", "c", ".", "version", "=", "p", ".", "version", "c", ".", "data", "=", "alg", ".", "encrypt", "(", "p", ".", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_tls_decrypt
Provided with a TLSCiphertext instance c, and a stream or block cipher alg, the function decrypts c.data and returns a newly created TLSPlaintext.
scapy/layers/tls/tools.py
def _tls_decrypt(alg, c): """ Provided with a TLSCiphertext instance c, and a stream or block cipher alg, the function decrypts c.data and returns a newly created TLSPlaintext. """ p = TLSPlaintext() p.type = c.type p.version = c.version p.data = alg.decrypt(c.data) p.len = len(p.dat...
def _tls_decrypt(alg, c): """ Provided with a TLSCiphertext instance c, and a stream or block cipher alg, the function decrypts c.data and returns a newly created TLSPlaintext. """ p = TLSPlaintext() p.type = c.type p.version = c.version p.data = alg.decrypt(c.data) p.len = len(p.dat...
[ "Provided", "with", "a", "TLSCiphertext", "instance", "c", "and", "a", "stream", "or", "block", "cipher", "alg", "the", "function", "decrypts", "c", ".", "data", "and", "returns", "a", "newly", "created", "TLSPlaintext", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/tools.py#L165-L175
[ "def", "_tls_decrypt", "(", "alg", ",", "c", ")", ":", "p", "=", "TLSPlaintext", "(", ")", "p", ".", "type", "=", "c", ".", "type", "p", ".", "version", "=", "c", ".", "version", "p", ".", "data", "=", "alg", ".", "decrypt", "(", "c", ".", "d...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_tls_aead_auth_encrypt
Provided with a TLSCompressed instance p, the function applies AEAD cipher alg to p.data and builds a new TLSCiphertext instance. Unlike for block and stream ciphers, for which the authentication step is done separately, AEAD alg does it simultaneously: this is the reason why write_seq_num is passed to ...
scapy/layers/tls/tools.py
def _tls_aead_auth_encrypt(alg, p, write_seq_num): """ Provided with a TLSCompressed instance p, the function applies AEAD cipher alg to p.data and builds a new TLSCiphertext instance. Unlike for block and stream ciphers, for which the authentication step is done separately, AEAD alg does it simulta...
def _tls_aead_auth_encrypt(alg, p, write_seq_num): """ Provided with a TLSCompressed instance p, the function applies AEAD cipher alg to p.data and builds a new TLSCiphertext instance. Unlike for block and stream ciphers, for which the authentication step is done separately, AEAD alg does it simulta...
[ "Provided", "with", "a", "TLSCompressed", "instance", "p", "the", "function", "applies", "AEAD", "cipher", "alg", "to", "p", ".", "data", "and", "builds", "a", "new", "TLSCiphertext", "instance", ".", "Unlike", "for", "block", "and", "stream", "ciphers", "fo...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/tools.py#L178-L197
[ "def", "_tls_aead_auth_encrypt", "(", "alg", ",", "p", ",", "write_seq_num", ")", ":", "P", "=", "bytes", "(", "p", ")", "write_seq_num", "=", "struct", ".", "pack", "(", "\"!Q\"", ",", "write_seq_num", ")", "A", "=", "write_seq_num", "+", "P", "[", ":...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_tls_aead_auth_decrypt
Provided with a TLSCiphertext instance c, the function applies AEAD cipher alg auth_decrypt function to c.data (and additional data) in order to authenticate the data and decrypt c.data. When those steps succeed, the result is a newly created TLSCompressed instance. On error, None is returned. Note that...
scapy/layers/tls/tools.py
def _tls_aead_auth_decrypt(alg, c, read_seq_num): """ Provided with a TLSCiphertext instance c, the function applies AEAD cipher alg auth_decrypt function to c.data (and additional data) in order to authenticate the data and decrypt c.data. When those steps succeed, the result is a newly created TLS...
def _tls_aead_auth_decrypt(alg, c, read_seq_num): """ Provided with a TLSCiphertext instance c, the function applies AEAD cipher alg auth_decrypt function to c.data (and additional data) in order to authenticate the data and decrypt c.data. When those steps succeed, the result is a newly created TLS...
[ "Provided", "with", "a", "TLSCiphertext", "instance", "c", "the", "function", "applies", "AEAD", "cipher", "alg", "auth_decrypt", "function", "to", "c", ".", "data", "(", "and", "additional", "data", ")", "in", "order", "to", "authenticate", "the", "data", "...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/tools.py#L200-L225
[ "def", "_tls_aead_auth_decrypt", "(", "alg", ",", "c", ",", "read_seq_num", ")", ":", "# 'Deduce' TLSCompressed length from TLSCiphertext length", "# There is actually no guaranty of this equality, but this is defined as", "# such in TLS 1.2 specifications, and it works for GCM and CCM at le...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_extcap_call
Function used to call a program using the extcap format, then parse the results
scapy/layers/usb.py
def _extcap_call(prog, args, keyword, values): """Function used to call a program using the extcap format, then parse the results""" p = subprocess.Popen( [prog] + args, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) data, err = p.communicate() if p.returncode != 0: rai...
def _extcap_call(prog, args, keyword, values): """Function used to call a program using the extcap format, then parse the results""" p = subprocess.Popen( [prog] + args, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) data, err = p.communicate() if p.returncode != 0: rai...
[ "Function", "used", "to", "call", "a", "program", "using", "the", "extcap", "format", "then", "parse", "the", "results" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/usb.py#L156-L176
[ "def", "_extcap_call", "(", "prog", ",", "args", ",", "keyword", ",", "values", ")", ":", "p", "=", "subprocess", ".", "Popen", "(", "[", "prog", "]", "+", "args", ",", "stdout", "=", "subprocess", ".", "PIPE", ",", "stderr", "=", "subprocess", ".", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_hcsi_null_range
Builds a list of _HCSINullField with numbered "Reserved" names. Takes the same arguments as the ``range`` built-in. :returns: list[HCSINullField]
scapy/contrib/ppi_geotag.py
def _hcsi_null_range(*args, **kwargs): """Builds a list of _HCSINullField with numbered "Reserved" names. Takes the same arguments as the ``range`` built-in. :returns: list[HCSINullField] """ return [ HCSINullField('Reserved{:02d}'.format(x)) for x in range(*args, **kwargs) ]
def _hcsi_null_range(*args, **kwargs): """Builds a list of _HCSINullField with numbered "Reserved" names. Takes the same arguments as the ``range`` built-in. :returns: list[HCSINullField] """ return [ HCSINullField('Reserved{:02d}'.format(x)) for x in range(*args, **kwargs) ]
[ "Builds", "a", "list", "of", "_HCSINullField", "with", "numbered", "Reserved", "names", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/ppi_geotag.py#L243-L253
[ "def", "_hcsi_null_range", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "[", "HCSINullField", "(", "'Reserved{:02d}'", ".", "format", "(", "x", ")", ")", "for", "x", "in", "range", "(", "*", "args", ",", "*", "*", "kwargs", ")", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_RMMLEIntField.i2m
Convert internal value to machine value
scapy/contrib/ppi_geotag.py
def i2m(self, pkt, x): """Convert internal value to machine value""" if x is None: # Try to return zero if undefined x = self.h2i(pkt, 0) return x
def i2m(self, pkt, x): """Convert internal value to machine value""" if x is None: # Try to return zero if undefined x = self.h2i(pkt, 0) return x
[ "Convert", "internal", "value", "to", "machine", "value" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/ppi_geotag.py#L86-L91
[ "def", "i2m", "(", "self", ",", "pkt", ",", "x", ")", ":", "if", "x", "is", "None", ":", "# Try to return zero if undefined", "x", "=", "self", ".", "h2i", "(", "pkt", ",", "0", ")", "return", "x" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
train
get_if_addr6
Returns the main global unicast address associated with provided interface, in human readable form. If no global address is found, None is returned.
scapy/arch/__init__.py
def get_if_addr6(iff): """ Returns the main global unicast address associated with provided interface, in human readable form. If no global address is found, None is returned. """ return next((x[0] for x in in6_getifaddr() if x[2] == iff and x[1] == IPV6_ADDR_GLOBAL), None)
def get_if_addr6(iff): """ Returns the main global unicast address associated with provided interface, in human readable form. If no global address is found, None is returned. """ return next((x[0] for x in in6_getifaddr() if x[2] == iff and x[1] == IPV6_ADDR_GLOBAL), None)
[ "Returns", "the", "main", "global", "unicast", "address", "associated", "with", "provided", "interface", "in", "human", "readable", "form", ".", "If", "no", "global", "address", "is", "found", "None", "is", "returned", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/__init__.py#L76-L83
[ "def", "get_if_addr6", "(", "iff", ")", ":", "return", "next", "(", "(", "x", "[", "0", "]", "for", "x", "in", "in6_getifaddr", "(", ")", "if", "x", "[", "2", "]", "==", "iff", "and", "x", "[", "1", "]", "==", "IPV6_ADDR_GLOBAL", ")", ",", "Non...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
get_if_raw_addr6
Returns the main global unicast address associated with provided interface, in network format. If no global address is found, None is returned.
scapy/arch/__init__.py
def get_if_raw_addr6(iff): """ Returns the main global unicast address associated with provided interface, in network format. If no global address is found, None is returned. """ ip6 = get_if_addr6(iff) if ip6 is not None: return inet_pton(socket.AF_INET6, ip6) return None
def get_if_raw_addr6(iff): """ Returns the main global unicast address associated with provided interface, in network format. If no global address is found, None is returned. """ ip6 = get_if_addr6(iff) if ip6 is not None: return inet_pton(socket.AF_INET6, ip6) return None
[ "Returns", "the", "main", "global", "unicast", "address", "associated", "with", "provided", "interface", "in", "network", "format", ".", "If", "no", "global", "address", "is", "found", "None", "is", "returned", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/__init__.py#L86-L96
[ "def", "get_if_raw_addr6", "(", "iff", ")", ":", "ip6", "=", "get_if_addr6", "(", "iff", ")", "if", "ip6", "is", "not", "None", ":", "return", "inet_pton", "(", "socket", ".", "AF_INET6", ",", "ip6", ")", "return", "None" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
train
i2s_frameid
Get representation name of a pnio frame ID :param x: a key of the PNIO_FRAME_IDS dictionary :returns: str
scapy/contrib/pnio.py
def i2s_frameid(x): """ Get representation name of a pnio frame ID :param x: a key of the PNIO_FRAME_IDS dictionary :returns: str """ try: return PNIO_FRAME_IDS[x] except KeyError: pass if 0x0100 <= x < 0x1000: return "RT_CLASS_3 (%4x)" % x if 0x8000 <= x < 0xC00...
def i2s_frameid(x): """ Get representation name of a pnio frame ID :param x: a key of the PNIO_FRAME_IDS dictionary :returns: str """ try: return PNIO_FRAME_IDS[x] except KeyError: pass if 0x0100 <= x < 0x1000: return "RT_CLASS_3 (%4x)" % x if 0x8000 <= x < 0xC00...
[ "Get", "representation", "name", "of", "a", "pnio", "frame", "ID" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/pnio.py#L53-L71
[ "def", "i2s_frameid", "(", "x", ")", ":", "try", ":", "return", "PNIO_FRAME_IDS", "[", "x", "]", "except", "KeyError", ":", "pass", "if", "0x0100", "<=", "x", "<", "0x1000", ":", "return", "\"RT_CLASS_3 (%4x)\"", "%", "x", "if", "0x8000", "<=", "x", "<...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
s2i_frameid
Get pnio frame ID from a representation name Performs a reverse look-up in PNIO_FRAME_IDS dictionary :param x: a value of PNIO_FRAME_IDS dict :returns: integer
scapy/contrib/pnio.py
def s2i_frameid(x): """ Get pnio frame ID from a representation name Performs a reverse look-up in PNIO_FRAME_IDS dictionary :param x: a value of PNIO_FRAME_IDS dict :returns: integer """ try: return { "RT_CLASS_3": 0x0100, "RT_CLASS_1": 0x8000, "RT_...
def s2i_frameid(x): """ Get pnio frame ID from a representation name Performs a reverse look-up in PNIO_FRAME_IDS dictionary :param x: a value of PNIO_FRAME_IDS dict :returns: integer """ try: return { "RT_CLASS_3": 0x0100, "RT_CLASS_1": 0x8000, "RT_...
[ "Get", "pnio", "frame", "ID", "from", "a", "representation", "name" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/pnio.py#L74-L96
[ "def", "s2i_frameid", "(", "x", ")", ":", "try", ":", "return", "{", "\"RT_CLASS_3\"", ":", "0x0100", ",", "\"RT_CLASS_1\"", ":", "0x8000", ",", "\"RT_CLASS_UDP\"", ":", "0xC000", ",", "\"FragmentationFrameID\"", ":", "0xFF80", ",", "}", "[", "x", "]", "ex...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
RTR.dispatch_hook
Attribution of correct type depending on version and pdu_type
scapy/contrib/rtr.py
def dispatch_hook(cls, _pkt=None, *args, **kargs): ''' Attribution of correct type depending on version and pdu_type ''' if _pkt and len(_pkt) >= 2: version = orb(_pkt[0]) pdu_type = orb(_pkt[1]) if version == 0: return PDU_CLASS_VERS...
def dispatch_hook(cls, _pkt=None, *args, **kargs): ''' Attribution of correct type depending on version and pdu_type ''' if _pkt and len(_pkt) >= 2: version = orb(_pkt[0]) pdu_type = orb(_pkt[1]) if version == 0: return PDU_CLASS_VERS...
[ "Attribution", "of", "correct", "type", "depending", "on", "version", "and", "pdu_type" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/rtr.py#L322-L333
[ "def", "dispatch_hook", "(", "cls", ",", "_pkt", "=", "None", ",", "*", "args", ",", "*", "*", "kargs", ")", ":", "if", "_pkt", "and", "len", "(", "_pkt", ")", ">=", "2", ":", "version", "=", "orb", "(", "_pkt", "[", "0", "]", ")", "pdu_type", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
AS_resolver_cymru.parse
Parse bulk cymru data
scapy/as_resolvers.py
def parse(self, data): """Parse bulk cymru data""" ASNlist = [] for line in data.splitlines()[1:]: line = plain_str(line) if "|" not in line: continue asn, ip, desc = [elt.strip() for elt in line.split('|')] if asn == "NA": ...
def parse(self, data): """Parse bulk cymru data""" ASNlist = [] for line in data.splitlines()[1:]: line = plain_str(line) if "|" not in line: continue asn, ip, desc = [elt.strip() for elt in line.split('|')] if asn == "NA": ...
[ "Parse", "bulk", "cymru", "data" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/as_resolvers.py#L102-L115
[ "def", "parse", "(", "self", ",", "data", ")", ":", "ASNlist", "=", "[", "]", "for", "line", "in", "data", ".", "splitlines", "(", ")", "[", "1", ":", "]", ":", "line", "=", "plain_str", "(", "line", ")", "if", "\"|\"", "not", "in", "line", ":"...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
IGMPv3.encode_maxrespcode
Encode and replace the mrcode value to its IGMPv3 encoded time value if needed, # noqa: E501 as specified in rfc3376#section-4.1.1. If value < 128, return the value specified. If >= 128, encode as a floating # noqa: E501 point value. Value can be 0 - 31744.
scapy/contrib/igmpv3.py
def encode_maxrespcode(self): """Encode and replace the mrcode value to its IGMPv3 encoded time value if needed, # noqa: E501 as specified in rfc3376#section-4.1.1. If value < 128, return the value specified. If >= 128, encode as a floating # noqa: E501 point value. Value can be 0 - 3...
def encode_maxrespcode(self): """Encode and replace the mrcode value to its IGMPv3 encoded time value if needed, # noqa: E501 as specified in rfc3376#section-4.1.1. If value < 128, return the value specified. If >= 128, encode as a floating # noqa: E501 point value. Value can be 0 - 3...
[ "Encode", "and", "replace", "the", "mrcode", "value", "to", "its", "IGMPv3", "encoded", "time", "value", "if", "needed", "#", "noqa", ":", "E501", "as", "specified", "in", "rfc3376#section", "-", "4", ".", "1", ".", "1", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/igmpv3.py#L74-L94
[ "def", "encode_maxrespcode", "(", "self", ")", ":", "value", "=", "self", ".", "mrcode", "if", "value", "<", "128", ":", "code", "=", "value", "elif", "value", ">", "31743", ":", "code", "=", "255", "else", ":", "exp", "=", "0", "value", ">>=", "3"...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_register_lltd_specific_class
This can be used as a class decorator; if we want to support Python 2.5, we have to replace @_register_lltd_specific_class(x[, y[, ...]]) class LLTDAttributeSpecific(LLTDAttribute): [...] by class LLTDAttributeSpecific(LLTDAttribute): [...] LLTDAttributeSpecific = _register_lltd_specific_class(x[, y[, ...]])( ...
scapy/layers/lltd.py
def _register_lltd_specific_class(*attr_types): """This can be used as a class decorator; if we want to support Python 2.5, we have to replace @_register_lltd_specific_class(x[, y[, ...]]) class LLTDAttributeSpecific(LLTDAttribute): [...] by class LLTDAttributeSpecific(LLTDAttribute): [...] LLTDAttributeSpec...
def _register_lltd_specific_class(*attr_types): """This can be used as a class decorator; if we want to support Python 2.5, we have to replace @_register_lltd_specific_class(x[, y[, ...]]) class LLTDAttributeSpecific(LLTDAttribute): [...] by class LLTDAttributeSpecific(LLTDAttribute): [...] LLTDAttributeSpec...
[ "This", "can", "be", "used", "as", "a", "class", "decorator", ";", "if", "we", "want", "to", "support", "Python", "2", ".", "5", "we", "have", "to", "replace" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/lltd.py#L312-L336
[ "def", "_register_lltd_specific_class", "(", "*", "attr_types", ")", ":", "def", "_register", "(", "cls", ")", ":", "for", "attr_type", "in", "attr_types", ":", "SPECIFIC_CLASSES", "[", "attr_type", "]", "=", "cls", "type_fld", "=", "LLTDAttribute", ".", "fiel...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
LargeTlvBuilder.parse
Update the builder using the provided `plist`. `plist` can be either a Packet() or a PacketList().
scapy/layers/lltd.py
def parse(self, plist): """Update the builder using the provided `plist`. `plist` can be either a Packet() or a PacketList(). """ if not isinstance(plist, PacketList): plist = PacketList(plist) for pkt in plist[LLTD]: if LLTDQueryLargeTlv in pkt: ...
def parse(self, plist): """Update the builder using the provided `plist`. `plist` can be either a Packet() or a PacketList(). """ if not isinstance(plist, PacketList): plist = PacketList(plist) for pkt in plist[LLTD]: if LLTDQueryLargeTlv in pkt: ...
[ "Update", "the", "builder", "using", "the", "provided", "plist", ".", "plist", "can", "be", "either", "a", "Packet", "()", "or", "a", "PacketList", "()", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/lltd.py#L809-L836
[ "def", "parse", "(", "self", ",", "plist", ")", ":", "if", "not", "isinstance", "(", "plist", ",", "PacketList", ")", ":", "plist", "=", "PacketList", "(", "plist", ")", "for", "pkt", "in", "plist", "[", "LLTD", "]", ":", "if", "LLTDQueryLargeTlv", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
LargeTlvBuilder.get_data
Returns a dictionary object, keys are strings "source > destincation [content type]", and values are the content fetched, also as a string.
scapy/layers/lltd.py
def get_data(self): """Returns a dictionary object, keys are strings "source > destincation [content type]", and values are the content fetched, also as a string. """ return {key: "".join(chr(byte) for byte in data) for key, data in six.iteritems(self.data)}
def get_data(self): """Returns a dictionary object, keys are strings "source > destincation [content type]", and values are the content fetched, also as a string. """ return {key: "".join(chr(byte) for byte in data) for key, data in six.iteritems(self.data)}
[ "Returns", "a", "dictionary", "object", "keys", "are", "strings", "source", ">", "destincation", "[", "content", "type", "]", "and", "values", "are", "the", "content", "fetched", "also", "as", "a", "string", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/lltd.py#L838-L845
[ "def", "get_data", "(", "self", ")", ":", "return", "{", "key", ":", "\"\"", ".", "join", "(", "chr", "(", "byte", ")", "for", "byte", "in", "data", ")", "for", "key", ",", "data", "in", "six", ".", "iteritems", "(", "self", ".", "data", ")", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_inet6_pton
Convert an IPv6 address from text representation into binary form, used when socket.inet_pton is not available.
scapy/pton_ntop.py
def _inet6_pton(addr): """Convert an IPv6 address from text representation into binary form, used when socket.inet_pton is not available. """ joker_pos = None result = b"" addr = plain_str(addr) if addr == '::': return b'\x00' * 16 if addr.startswith('::'): addr = addr[1:] ...
def _inet6_pton(addr): """Convert an IPv6 address from text representation into binary form, used when socket.inet_pton is not available. """ joker_pos = None result = b"" addr = plain_str(addr) if addr == '::': return b'\x00' * 16 if addr.startswith('::'): addr = addr[1:] ...
[ "Convert", "an", "IPv6", "address", "from", "text", "representation", "into", "binary", "form", "used", "when", "socket", ".", "inet_pton", "is", "not", "available", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/pton_ntop.py#L24-L72
[ "def", "_inet6_pton", "(", "addr", ")", ":", "joker_pos", "=", "None", "result", "=", "b\"\"", "addr", "=", "plain_str", "(", "addr", ")", "if", "addr", "==", "'::'", ":", "return", "b'\\x00'", "*", "16", "if", "addr", ".", "startswith", "(", "'::'", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
inet_pton
Convert an IP address from text representation into binary form.
scapy/pton_ntop.py
def inet_pton(af, addr): """Convert an IP address from text representation into binary form.""" # Will replace Net/Net6 objects addr = plain_str(addr) # Use inet_pton if available try: return socket.inet_pton(af, addr) except AttributeError: try: return _INET_PTON[af]...
def inet_pton(af, addr): """Convert an IP address from text representation into binary form.""" # Will replace Net/Net6 objects addr = plain_str(addr) # Use inet_pton if available try: return socket.inet_pton(af, addr) except AttributeError: try: return _INET_PTON[af]...
[ "Convert", "an", "IP", "address", "from", "text", "representation", "into", "binary", "form", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/pton_ntop.py#L81-L92
[ "def", "inet_pton", "(", "af", ",", "addr", ")", ":", "# Will replace Net/Net6 objects", "addr", "=", "plain_str", "(", "addr", ")", "# Use inet_pton if available", "try", ":", "return", "socket", ".", "inet_pton", "(", "af", ",", "addr", ")", "except", "Attri...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_inet6_ntop
Convert an IPv6 address from binary form into text representation, used when socket.inet_pton is not available.
scapy/pton_ntop.py
def _inet6_ntop(addr): """Convert an IPv6 address from binary form into text representation, used when socket.inet_pton is not available. """ # IPv6 addresses have 128bits (16 bytes) if len(addr) != 16: raise ValueError("invalid length of packed IP address string") # Decode to hex represen...
def _inet6_ntop(addr): """Convert an IPv6 address from binary form into text representation, used when socket.inet_pton is not available. """ # IPv6 addresses have 128bits (16 bytes) if len(addr) != 16: raise ValueError("invalid length of packed IP address string") # Decode to hex represen...
[ "Convert", "an", "IPv6", "address", "from", "binary", "form", "into", "text", "representation", "used", "when", "socket", ".", "inet_pton", "is", "not", "available", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/pton_ntop.py#L95-L118
[ "def", "_inet6_ntop", "(", "addr", ")", ":", "# IPv6 addresses have 128bits (16 bytes)", "if", "len", "(", "addr", ")", "!=", "16", ":", "raise", "ValueError", "(", "\"invalid length of packed IP address string\"", ")", "# Decode to hex representation", "address", "=", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
inet_ntop
Convert an IP address from binary form into text representation.
scapy/pton_ntop.py
def inet_ntop(af, addr): """Convert an IP address from binary form into text representation.""" # Use inet_ntop if available addr = bytes_encode(addr) try: return socket.inet_ntop(af, addr) except AttributeError: try: return _INET_NTOP[af](addr) except KeyError: ...
def inet_ntop(af, addr): """Convert an IP address from binary form into text representation.""" # Use inet_ntop if available addr = bytes_encode(addr) try: return socket.inet_ntop(af, addr) except AttributeError: try: return _INET_NTOP[af](addr) except KeyError: ...
[ "Convert", "an", "IP", "address", "from", "binary", "form", "into", "text", "representation", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/pton_ntop.py#L127-L137
[ "def", "inet_ntop", "(", "af", ",", "addr", ")", ":", "# Use inet_ntop if available", "addr", "=", "bytes_encode", "(", "addr", ")", "try", ":", "return", "socket", ".", "inet_ntop", "(", "af", ",", "addr", ")", "except", "AttributeError", ":", "try", ":",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_L2pcapdnetSocket.recv_raw
Receives a packet, then returns a tuple containing (cls, pkt_data, time)
scapy/arch/pcapdnet.py
def recv_raw(self, x=MTU): """Receives a packet, then returns a tuple containing (cls, pkt_data, time)""" # noqa: E501 ll = self.ins.datalink() if ll in conf.l2types: cls = conf.l2types[ll] else: cls = conf.default_l2 warning("Unable to guess datalink...
def recv_raw(self, x=MTU): """Receives a packet, then returns a tuple containing (cls, pkt_data, time)""" # noqa: E501 ll = self.ins.datalink() if ll in conf.l2types: cls = conf.l2types[ll] else: cls = conf.default_l2 warning("Unable to guess datalink...
[ "Receives", "a", "packet", "then", "returns", "a", "tuple", "containing", "(", "cls", "pkt_data", "time", ")" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/pcapdnet.py#L46-L65
[ "def", "recv_raw", "(", "self", ",", "x", "=", "MTU", ")", ":", "# noqa: E501", "ll", "=", "self", ".", "ins", ".", "datalink", "(", ")", "if", "ll", "in", "conf", ".", "l2types", ":", "cls", "=", "conf", ".", "l2types", "[", "ll", "]", "else", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_L2pcapdnetSocket.nonblock_recv
Receives and dissect a packet in non-blocking mode. Note: on Windows, this won't do anything.
scapy/arch/pcapdnet.py
def nonblock_recv(self): """Receives and dissect a packet in non-blocking mode. Note: on Windows, this won't do anything.""" self.ins.setnonblock(1) p = self.recv(MTU) self.ins.setnonblock(0) return p
def nonblock_recv(self): """Receives and dissect a packet in non-blocking mode. Note: on Windows, this won't do anything.""" self.ins.setnonblock(1) p = self.recv(MTU) self.ins.setnonblock(0) return p
[ "Receives", "and", "dissect", "a", "packet", "in", "non", "-", "blocking", "mode", ".", "Note", ":", "on", "Windows", "this", "won", "t", "do", "anything", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/pcapdnet.py#L67-L73
[ "def", "nonblock_recv", "(", "self", ")", ":", "self", ".", "ins", ".", "setnonblock", "(", "1", ")", "p", "=", "self", ".", "recv", "(", "MTU", ")", "self", ".", "ins", ".", "setnonblock", "(", "0", ")", "return", "p" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
train
Route.delt
delt(host|net, gw|dev)
scapy/route.py
def delt(self, *args, **kargs): """delt(host|net, gw|dev)""" self.invalidate_cache() route = self.make_route(*args, **kargs) try: i = self.routes.index(route) del(self.routes[i]) except ValueError: warning("no matching route found")
def delt(self, *args, **kargs): """delt(host|net, gw|dev)""" self.invalidate_cache() route = self.make_route(*args, **kargs) try: i = self.routes.index(route) del(self.routes[i]) except ValueError: warning("no matching route found")
[ "delt", "(", "host|net", "gw|dev", ")" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/route.py#L78-L86
[ "def", "delt", "(", "self", ",", "*", "args", ",", "*", "*", "kargs", ")", ":", "self", ".", "invalidate_cache", "(", ")", "route", "=", "self", ".", "make_route", "(", "*", "args", ",", "*", "*", "kargs", ")", "try", ":", "i", "=", "self", "."...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
Route.route
Returns the IPv4 routes to a host. parameters: - dst: the IPv4 of the destination host returns: (iface, output_ip, gateway_ip) - iface: the interface used to connect to the host - output_ip: the outgoing IP that will be used - gateway_ip: the gateway IP that will be ...
scapy/route.py
def route(self, dst=None, verbose=conf.verb): """Returns the IPv4 routes to a host. parameters: - dst: the IPv4 of the destination host returns: (iface, output_ip, gateway_ip) - iface: the interface used to connect to the host - output_ip: the outgoing IP that will be...
def route(self, dst=None, verbose=conf.verb): """Returns the IPv4 routes to a host. parameters: - dst: the IPv4 of the destination host returns: (iface, output_ip, gateway_ip) - iface: the interface used to connect to the host - output_ip: the outgoing IP that will be...
[ "Returns", "the", "IPv4", "routes", "to", "a", "host", ".", "parameters", ":", "-", "dst", ":", "the", "IPv4", "of", "the", "destination", "host" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/route.py#L128-L178
[ "def", "route", "(", "self", ",", "dst", "=", "None", ",", "verbose", "=", "conf", ".", "verb", ")", ":", "dst", "=", "dst", "or", "\"0.0.0.0\"", "# Enable route(None) to return default route", "if", "isinstance", "(", "dst", ",", "bytes", ")", ":", "try",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
open_icmp_firewall
Temporarily open the ICMP firewall. Tricks Windows into allowing ICMP packets for a short period of time (~ 1 minute)
scapy/arch/windows/native.py
def open_icmp_firewall(host): """Temporarily open the ICMP firewall. Tricks Windows into allowing ICMP packets for a short period of time (~ 1 minute)""" # We call ping with a timeout of 1ms: will return instantly with open(os.devnull, 'wb') as DEVNULL: return subprocess.Popen("ping -4 -w 1 -n 1...
def open_icmp_firewall(host): """Temporarily open the ICMP firewall. Tricks Windows into allowing ICMP packets for a short period of time (~ 1 minute)""" # We call ping with a timeout of 1ms: will return instantly with open(os.devnull, 'wb') as DEVNULL: return subprocess.Popen("ping -4 -w 1 -n 1...
[ "Temporarily", "open", "the", "ICMP", "firewall", ".", "Tricks", "Windows", "into", "allowing", "ICMP", "packets", "for", "a", "short", "period", "of", "time", "(", "~", "1", "minute", ")" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/native.py#L203-L211
[ "def", "open_icmp_firewall", "(", "host", ")", ":", "# We call ping with a timeout of 1ms: will return instantly", "with", "open", "(", "os", ".", "devnull", ",", "'wb'", ")", "as", "DEVNULL", ":", "return", "subprocess", ".", "Popen", "(", "\"ping -4 -w 1 -n 1 %s\"",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
TLSClientHello.tls_session_update
Either for parsing or building, we store the client_random along with the raw string representing this handshake message.
scapy/layers/tls/handshake.py
def tls_session_update(self, msg_str): """ Either for parsing or building, we store the client_random along with the raw string representing this handshake message. """ super(TLSClientHello, self).tls_session_update(msg_str) self.tls_session.advertised_tls_version = self...
def tls_session_update(self, msg_str): """ Either for parsing or building, we store the client_random along with the raw string representing this handshake message. """ super(TLSClientHello, self).tls_session_update(msg_str) self.tls_session.advertised_tls_version = self...
[ "Either", "for", "parsing", "or", "building", "we", "store", "the", "client_random", "along", "with", "the", "raw", "string", "representing", "this", "handshake", "message", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/handshake.py#L280-L298
[ "def", "tls_session_update", "(", "self", ",", "msg_str", ")", ":", "super", "(", "TLSClientHello", ",", "self", ")", ".", "tls_session_update", "(", "msg_str", ")", "self", ".", "tls_session", ".", "advertised_tls_version", "=", "self", ".", "version", "self"...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
TLSServerHello.tls_session_update
Either for parsing or building, we store the server_random along with the raw string representing this handshake message. We also store the session_id, the cipher suite (if recognized), the compression method, and finally we instantiate the pending write and read connection states. Usual...
scapy/layers/tls/handshake.py
def tls_session_update(self, msg_str): """ Either for parsing or building, we store the server_random along with the raw string representing this handshake message. We also store the session_id, the cipher suite (if recognized), the compression method, and finally we instantiate ...
def tls_session_update(self, msg_str): """ Either for parsing or building, we store the server_random along with the raw string representing this handshake message. We also store the session_id, the cipher suite (if recognized), the compression method, and finally we instantiate ...
[ "Either", "for", "parsing", "or", "building", "we", "store", "the", "server_random", "along", "with", "the", "raw", "string", "representing", "this", "handshake", "message", ".", "We", "also", "store", "the", "session_id", "the", "cipher", "suite", "(", "if", ...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/handshake.py#L354-L399
[ "def", "tls_session_update", "(", "self", ",", "msg_str", ")", ":", "super", "(", "TLSClientHello", ",", "self", ")", ".", "tls_session_update", "(", "msg_str", ")", "self", ".", "tls_session", ".", "tls_version", "=", "self", ".", "version", "self", ".", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
TLS13ServerHello.tls_session_update
Either for parsing or building, we store the server_random along with the raw string representing this handshake message. We also store the cipher suite (if recognized), and finally we instantiate the write and read connection states.
scapy/layers/tls/handshake.py
def tls_session_update(self, msg_str): """ Either for parsing or building, we store the server_random along with the raw string representing this handshake message. We also store the cipher suite (if recognized), and finally we instantiate the write and read connection states. ...
def tls_session_update(self, msg_str): """ Either for parsing or building, we store the server_random along with the raw string representing this handshake message. We also store the cipher suite (if recognized), and finally we instantiate the write and read connection states. ...
[ "Either", "for", "parsing", "or", "building", "we", "store", "the", "server_random", "along", "with", "the", "raw", "string", "representing", "this", "handshake", "message", ".", "We", "also", "store", "the", "cipher", "suite", "(", "if", "recognized", ")", ...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/handshake.py#L415-L451
[ "def", "tls_session_update", "(", "self", ",", "msg_str", ")", ":", "super", "(", "TLSClientHello", ",", "self", ")", ".", "tls_session_update", "(", "msg_str", ")", "s", "=", "self", ".", "tls_session", "s", ".", "tls_version", "=", "self", ".", "version"...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
TLSServerKeyExchange.build
We overload build() method in order to provide a valid default value for params based on TLS session if not provided. This cannot be done by overriding i2m() because the method is called on a copy of the packet. The 'params' field is built according to key_exchange.server_kx_msg_cls whi...
scapy/layers/tls/handshake.py
def build(self, *args, **kargs): """ We overload build() method in order to provide a valid default value for params based on TLS session if not provided. This cannot be done by overriding i2m() because the method is called on a copy of the packet. The 'params' field is built ac...
def build(self, *args, **kargs): """ We overload build() method in order to provide a valid default value for params based on TLS session if not provided. This cannot be done by overriding i2m() because the method is called on a copy of the packet. The 'params' field is built ac...
[ "We", "overload", "build", "()", "method", "in", "order", "to", "provide", "a", "valid", "default", "value", "for", "params", "based", "on", "TLS", "session", "if", "not", "provided", ".", "This", "cannot", "be", "done", "by", "overriding", "i2m", "()", ...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/handshake.py#L689-L746
[ "def", "build", "(", "self", ",", "*", "args", ",", "*", "*", "kargs", ")", ":", "fval", "=", "self", ".", "getfieldval", "(", "\"params\"", ")", "if", "fval", "is", "None", ":", "s", "=", "self", ".", "tls_session", "if", "s", ".", "pwcs", ":", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
TLSServerKeyExchange.post_dissection
While previously dissecting Server*DHParams, the session server_kx_pubkey should have been updated. XXX Add a 'fixed_dh' OR condition to the 'anonymous' test.
scapy/layers/tls/handshake.py
def post_dissection(self, pkt): """ While previously dissecting Server*DHParams, the session server_kx_pubkey should have been updated. XXX Add a 'fixed_dh' OR condition to the 'anonymous' test. """ s = self.tls_session if s.prcs and s.prcs.key_exchange.no_ske: ...
def post_dissection(self, pkt): """ While previously dissecting Server*DHParams, the session server_kx_pubkey should have been updated. XXX Add a 'fixed_dh' OR condition to the 'anonymous' test. """ s = self.tls_session if s.prcs and s.prcs.key_exchange.no_ske: ...
[ "While", "previously", "dissecting", "Server", "*", "DHParams", "the", "session", "server_kx_pubkey", "should", "have", "been", "updated", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/handshake.py#L748-L767
[ "def", "post_dissection", "(", "self", ",", "pkt", ")", ":", "s", "=", "self", ".", "tls_session", "if", "s", ".", "prcs", "and", "s", ".", "prcs", ".", "key_exchange", ".", "no_ske", ":", "pkt_info", "=", "pkt", ".", "firstlayer", "(", ")", ".", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_TLSCKExchKeysField.m2i
The client_kx_msg may be either None, EncryptedPreMasterSecret (for RSA encryption key exchange), ClientDiffieHellmanPublic, or ClientECDiffieHellmanPublic. When either one of them gets dissected, the session context is updated accordingly.
scapy/layers/tls/handshake.py
def m2i(self, pkt, m): """ The client_kx_msg may be either None, EncryptedPreMasterSecret (for RSA encryption key exchange), ClientDiffieHellmanPublic, or ClientECDiffieHellmanPublic. When either one of them gets dissected, the session context is updated accordingly. """ ...
def m2i(self, pkt, m): """ The client_kx_msg may be either None, EncryptedPreMasterSecret (for RSA encryption key exchange), ClientDiffieHellmanPublic, or ClientECDiffieHellmanPublic. When either one of them gets dissected, the session context is updated accordingly. """ ...
[ "The", "client_kx_msg", "may", "be", "either", "None", "EncryptedPreMasterSecret", "(", "for", "RSA", "encryption", "key", "exchange", ")", "ClientDiffieHellmanPublic", "or", "ClientECDiffieHellmanPublic", ".", "When", "either", "one", "of", "them", "gets", "dissected...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/handshake.py#L923-L942
[ "def", "m2i", "(", "self", ",", "pkt", ",", "m", ")", ":", "tmp_len", "=", "self", ".", "length_from", "(", "pkt", ")", "tbd", ",", "rem", "=", "m", "[", ":", "tmp_len", "]", ",", "m", "[", "tmp_len", ":", "]", "s", "=", "pkt", ".", "tls_sess...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
nmap_fp
nmap fingerprinting nmap_fp(target, [oport=80,] [cport=81,]) -> list of best guesses with accuracy
scapy/modules/nmap.py
def nmap_fp(target, oport=80, cport=81): """nmap fingerprinting nmap_fp(target, [oport=80,] [cport=81,]) -> list of best guesses with accuracy """ sigs = nmap_sig(target, oport, cport) return nmap_search(sigs)
def nmap_fp(target, oport=80, cport=81): """nmap fingerprinting nmap_fp(target, [oport=80,] [cport=81,]) -> list of best guesses with accuracy """ sigs = nmap_sig(target, oport, cport) return nmap_search(sigs)
[ "nmap", "fingerprinting", "nmap_fp", "(", "target", "[", "oport", "=", "80", "]", "[", "cport", "=", "81", "]", ")", "-", ">", "list", "of", "best", "guesses", "with", "accuracy" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/modules/nmap.py#L198-L203
[ "def", "nmap_fp", "(", "target", ",", "oport", "=", "80", ",", "cport", "=", "81", ")", ":", "sigs", "=", "nmap_sig", "(", "target", ",", "oport", ",", "cport", ")", "return", "nmap_search", "(", "sigs", ")" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
train
process_kwargs
Convenience wrapper around binwalk.core.module.Modules.kwargs. @obj - The class object (an instance of a sub-class of binwalk.core.module.Module). @kwargs - The kwargs provided to the object's __init__ method. Returns None.
src/binwalk/core/module.py
def process_kwargs(obj, kwargs): ''' Convenience wrapper around binwalk.core.module.Modules.kwargs. @obj - The class object (an instance of a sub-class of binwalk.core.module.Module). @kwargs - The kwargs provided to the object's __init__ method. Returns None. ''' with Modules() as m: ...
def process_kwargs(obj, kwargs): ''' Convenience wrapper around binwalk.core.module.Modules.kwargs. @obj - The class object (an instance of a sub-class of binwalk.core.module.Module). @kwargs - The kwargs provided to the object's __init__ method. Returns None. ''' with Modules() as m: ...
[ "Convenience", "wrapper", "around", "binwalk", ".", "core", ".", "module", ".", "Modules", ".", "kwargs", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/module.py#L996-L1007
[ "def", "process_kwargs", "(", "obj", ",", "kwargs", ")", ":", "with", "Modules", "(", ")", "as", "m", ":", "kwargs", "=", "m", ".", "kwargs", "(", "obj", ",", "kwargs", ")", "return", "kwargs" ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
show_help
Convenience wrapper around binwalk.core.module.Modules.help. @fd - An object with a write method (e.g., sys.stdout, sys.stderr, etc). Returns None.
src/binwalk/core/module.py
def show_help(fd=sys.stdout): ''' Convenience wrapper around binwalk.core.module.Modules.help. @fd - An object with a write method (e.g., sys.stdout, sys.stderr, etc). Returns None. ''' with Modules() as m: fd.write(m.help())
def show_help(fd=sys.stdout): ''' Convenience wrapper around binwalk.core.module.Modules.help. @fd - An object with a write method (e.g., sys.stdout, sys.stderr, etc). Returns None. ''' with Modules() as m: fd.write(m.help())
[ "Convenience", "wrapper", "around", "binwalk", ".", "core", ".", "module", ".", "Modules", ".", "help", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/module.py#L1010-L1019
[ "def", "show_help", "(", "fd", "=", "sys", ".", "stdout", ")", ":", "with", "Modules", "(", ")", "as", "m", ":", "fd", ".", "write", "(", "m", ".", "help", "(", ")", ")" ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Module.next_file
Gets the next file to be scanned (including pending extracted files, if applicable). Also re/initializes self.status. All modules should access the target file list through this method.
src/binwalk/core/module.py
def next_file(self, close_previous=True): ''' Gets the next file to be scanned (including pending extracted files, if applicable). Also re/initializes self.status. All modules should access the target file list through this method. ''' fp = None # Ensure files ar...
def next_file(self, close_previous=True): ''' Gets the next file to be scanned (including pending extracted files, if applicable). Also re/initializes self.status. All modules should access the target file list through this method. ''' fp = None # Ensure files ar...
[ "Gets", "the", "next", "file", "to", "be", "scanned", "(", "including", "pending", "extracted", "files", "if", "applicable", ")", ".", "Also", "re", "/", "initializes", "self", ".", "status", ".", "All", "modules", "should", "access", "the", "target", "fil...
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/module.py#L386-L447
[ "def", "next_file", "(", "self", ",", "close_previous", "=", "True", ")", ":", "fp", "=", "None", "# Ensure files are close to prevent IOError (too many open files)", "if", "close_previous", ":", "try", ":", "self", ".", "previous_next_file_fp", ".", "close", "(", "...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Module.clear
Clears results and errors lists.
src/binwalk/core/module.py
def clear(self, results=True, errors=True): ''' Clears results and errors lists. ''' if results: self.results = [] if errors: self.errors = []
def clear(self, results=True, errors=True): ''' Clears results and errors lists. ''' if results: self.results = [] if errors: self.errors = []
[ "Clears", "results", "and", "errors", "lists", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/module.py#L449-L456
[ "def", "clear", "(", "self", ",", "results", "=", "True", ",", "errors", "=", "True", ")", ":", "if", "results", ":", "self", ".", "results", "=", "[", "]", "if", "errors", ":", "self", ".", "errors", "=", "[", "]" ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Module.result
Validates a result, stores it in self.results and prints it. Accepts the same kwargs as the binwalk.core.module.Result class. @r - An existing instance of binwalk.core.module.Result. Returns an instance of binwalk.core.module.Result.
src/binwalk/core/module.py
def result(self, r=None, **kwargs): ''' Validates a result, stores it in self.results and prints it. Accepts the same kwargs as the binwalk.core.module.Result class. @r - An existing instance of binwalk.core.module.Result. Returns an instance of binwalk.core.module.Result. ...
def result(self, r=None, **kwargs): ''' Validates a result, stores it in self.results and prints it. Accepts the same kwargs as the binwalk.core.module.Result class. @r - An existing instance of binwalk.core.module.Result. Returns an instance of binwalk.core.module.Result. ...
[ "Validates", "a", "result", "stores", "it", "in", "self", ".", "results", "and", "prints", "it", ".", "Accepts", "the", "same", "kwargs", "as", "the", "binwalk", ".", "core", ".", "module", ".", "Result", "class", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/module.py#L458-L503
[ "def", "result", "(", "self", ",", "r", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "r", "is", "None", ":", "r", "=", "Result", "(", "*", "*", "kwargs", ")", "# Add the name of the current module to the result", "r", ".", "module", "=", "self...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Module.error
Stores the specified error in self.errors. Accepts the same kwargs as the binwalk.core.module.Error class. Returns None.
src/binwalk/core/module.py
def error(self, **kwargs): ''' Stores the specified error in self.errors. Accepts the same kwargs as the binwalk.core.module.Error class. Returns None. ''' exception_header_width = 100 e = Error(**kwargs) e.module = self.__class__.__name__ self...
def error(self, **kwargs): ''' Stores the specified error in self.errors. Accepts the same kwargs as the binwalk.core.module.Error class. Returns None. ''' exception_header_width = 100 e = Error(**kwargs) e.module = self.__class__.__name__ self...
[ "Stores", "the", "specified", "error", "in", "self", ".", "errors", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/module.py#L505-L526
[ "def", "error", "(", "self", ",", "*", "*", "kwargs", ")", ":", "exception_header_width", "=", "100", "e", "=", "Error", "(", "*", "*", "kwargs", ")", "e", ".", "module", "=", "self", ".", "__class__", ".", "__name__", "self", ".", "errors", ".", "...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Module.header
Displays the scan header, as defined by self.HEADER and self.HEADER_FORMAT. Returns None.
src/binwalk/core/module.py
def header(self): ''' Displays the scan header, as defined by self.HEADER and self.HEADER_FORMAT. Returns None. ''' self.config.display.format_strings(self.HEADER_FORMAT, self.RESULT_FORMAT) self.config.display.add_custom_header(self.VERBOSE_FORMAT, self.VERBOSE) ...
def header(self): ''' Displays the scan header, as defined by self.HEADER and self.HEADER_FORMAT. Returns None. ''' self.config.display.format_strings(self.HEADER_FORMAT, self.RESULT_FORMAT) self.config.display.add_custom_header(self.VERBOSE_FORMAT, self.VERBOSE) ...
[ "Displays", "the", "scan", "header", "as", "defined", "by", "self", ".", "HEADER", "and", "self", ".", "HEADER_FORMAT", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/module.py#L528-L540
[ "def", "header", "(", "self", ")", ":", "self", ".", "config", ".", "display", ".", "format_strings", "(", "self", ".", "HEADER_FORMAT", ",", "self", ".", "RESULT_FORMAT", ")", "self", ".", "config", ".", "display", ".", "add_custom_header", "(", "self", ...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Module.main
Responsible for calling self.init, initializing self.config.display, and calling self.run. Returns the value returned from self.run.
src/binwalk/core/module.py
def main(self): ''' Responsible for calling self.init, initializing self.config.display, and calling self.run. Returns the value returned from self.run. ''' self.status = self.parent.status self.modules = self.parent.executed_modules # A special exception for th...
def main(self): ''' Responsible for calling self.init, initializing self.config.display, and calling self.run. Returns the value returned from self.run. ''' self.status = self.parent.status self.modules = self.parent.executed_modules # A special exception for th...
[ "Responsible", "for", "calling", "self", ".", "init", "initializing", "self", ".", "config", ".", "display", "and", "calling", "self", ".", "run", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/module.py#L556-L605
[ "def", "main", "(", "self", ")", ":", "self", ".", "status", "=", "self", ".", "parent", ".", "status", "self", ".", "modules", "=", "self", ".", "parent", ".", "executed_modules", "# A special exception for the extractor module, which should be allowed to", "# over...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Modules.list
Finds all modules with the specified attribute. @attribute - The desired module attribute. Returns a list of modules that contain the specified attribute, in the order they should be executed.
src/binwalk/core/module.py
def list(self, attribute="run"): ''' Finds all modules with the specified attribute. @attribute - The desired module attribute. Returns a list of modules that contain the specified attribute, in the order they should be executed. ''' import binwalk.modules modul...
def list(self, attribute="run"): ''' Finds all modules with the specified attribute. @attribute - The desired module attribute. Returns a list of modules that contain the specified attribute, in the order they should be executed. ''' import binwalk.modules modul...
[ "Finds", "all", "modules", "with", "the", "specified", "attribute", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/module.py#L692-L725
[ "def", "list", "(", "self", ",", "attribute", "=", "\"run\"", ")", ":", "import", "binwalk", ".", "modules", "modules", "=", "{", "}", "for", "(", "name", ",", "module", ")", "in", "inspect", ".", "getmembers", "(", "binwalk", ".", "modules", ")", ":...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Modules.help
Generates formatted help output. Returns the help string.
src/binwalk/core/module.py
def help(self): ''' Generates formatted help output. Returns the help string. ''' modules = {} help_string = "\n" help_string += "Binwalk v%s\n" % binwalk.__version__ help_string += "Craig Heffner, ReFirmLabs\n" help_string += "https://github.com/...
def help(self): ''' Generates formatted help output. Returns the help string. ''' modules = {} help_string = "\n" help_string += "Binwalk v%s\n" % binwalk.__version__ help_string += "Craig Heffner, ReFirmLabs\n" help_string += "https://github.com/...
[ "Generates", "formatted", "help", "output", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/module.py#L727-L768
[ "def", "help", "(", "self", ")", ":", "modules", "=", "{", "}", "help_string", "=", "\"\\n\"", "help_string", "+=", "\"Binwalk v%s\\n\"", "%", "binwalk", ".", "__version__", "help_string", "+=", "\"Craig Heffner, ReFirmLabs\\n\"", "help_string", "+=", "\"https://git...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Modules.execute
Executes all appropriate modules according to the options specified in args/kwargs. Returns a list of executed module objects.
src/binwalk/core/module.py
def execute(self, *args, **kwargs): ''' Executes all appropriate modules according to the options specified in args/kwargs. Returns a list of executed module objects. ''' run_modules = [] orig_arguments = self.arguments if args or kwargs: self._set_a...
def execute(self, *args, **kwargs): ''' Executes all appropriate modules according to the options specified in args/kwargs. Returns a list of executed module objects. ''' run_modules = [] orig_arguments = self.arguments if args or kwargs: self._set_a...
[ "Executes", "all", "appropriate", "modules", "according", "to", "the", "options", "specified", "in", "args", "/", "kwargs", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/module.py#L770-L796
[ "def", "execute", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "run_modules", "=", "[", "]", "orig_arguments", "=", "self", ".", "arguments", "if", "args", "or", "kwargs", ":", "self", ".", "_set_arguments", "(", "list", "(", "ar...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Modules.run
Runs a specific module.
src/binwalk/core/module.py
def run(self, module, dependency=False, kwargs={}): ''' Runs a specific module. ''' try: obj = self.load(module, kwargs) if isinstance(obj, binwalk.core.module.Module) and obj.enabled: obj.main() self.status.clear() # ...
def run(self, module, dependency=False, kwargs={}): ''' Runs a specific module. ''' try: obj = self.load(module, kwargs) if isinstance(obj, binwalk.core.module.Module) and obj.enabled: obj.main() self.status.clear() # ...
[ "Runs", "a", "specific", "module", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/module.py#L798-L829
[ "def", "run", "(", "self", ",", "module", ",", "dependency", "=", "False", ",", "kwargs", "=", "{", "}", ")", ":", "try", ":", "obj", "=", "self", ".", "load", "(", "module", ",", "kwargs", ")", "if", "isinstance", "(", "obj", ",", "binwalk", "."...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Modules.argv
Processes argv for any options specific to the specified module. @module - The module to process argv for. @argv - A list of command line arguments (excluding argv[0]). Returns a dictionary of kwargs for the specified module.
src/binwalk/core/module.py
def argv(self, module, argv=sys.argv[1:]): ''' Processes argv for any options specific to the specified module. @module - The module to process argv for. @argv - A list of command line arguments (excluding argv[0]). Returns a dictionary of kwargs for the specified module. ...
def argv(self, module, argv=sys.argv[1:]): ''' Processes argv for any options specific to the specified module. @module - The module to process argv for. @argv - A list of command line arguments (excluding argv[0]). Returns a dictionary of kwargs for the specified module. ...
[ "Processes", "argv", "for", "any", "options", "specific", "to", "the", "specified", "module", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/module.py#L872-L953
[ "def", "argv", "(", "self", ",", "module", ",", "argv", "=", "sys", ".", "argv", "[", "1", ":", "]", ")", ":", "kwargs", "=", "{", "'enabled'", ":", "False", "}", "last_priority", "=", "{", "}", "parser", "=", "argparse", ".", "ArgumentParser", "("...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
train
Modules.kwargs
Processes a module's kwargs. All modules should use this for kwarg processing. @obj - An instance of the module (e.g., self) @kwargs - The kwargs passed to the module Returns None.
src/binwalk/core/module.py
def kwargs(self, obj, kwargs): ''' Processes a module's kwargs. All modules should use this for kwarg processing. @obj - An instance of the module (e.g., self) @kwargs - The kwargs passed to the module Returns None. ''' if hasattr(obj, "KWARGS"): ...
def kwargs(self, obj, kwargs): ''' Processes a module's kwargs. All modules should use this for kwarg processing. @obj - An instance of the module (e.g., self) @kwargs - The kwargs passed to the module Returns None. ''' if hasattr(obj, "KWARGS"): ...
[ "Processes", "a", "module", "s", "kwargs", ".", "All", "modules", "should", "use", "this", "for", "kwarg", "processing", "." ]
ReFirmLabs/binwalk
python
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/module.py#L955-L977
[ "def", "kwargs", "(", "self", ",", "obj", ",", "kwargs", ")", ":", "if", "hasattr", "(", "obj", ",", "\"KWARGS\"", ")", ":", "for", "module_argument", "in", "obj", ".", "KWARGS", ":", "if", "has_key", "(", "kwargs", ",", "module_argument", ".", "name",...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2