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
PacketList.diffplot
diffplot(f, delay=1, lfilter=None) Applies a function to couples (l[i],l[i+delay]) A list of matplotlib.lines.Line2D is returned.
scapy/plist.py
def diffplot(self, f, delay=1, lfilter=None, **kargs): """diffplot(f, delay=1, lfilter=None) Applies a function to couples (l[i],l[i+delay]) A list of matplotlib.lines.Line2D is returned. """ # Get the list of packets if lfilter is None: lst_pkts = [f(self.r...
def diffplot(self, f, delay=1, lfilter=None, **kargs): """diffplot(f, delay=1, lfilter=None) Applies a function to couples (l[i],l[i+delay]) A list of matplotlib.lines.Line2D is returned. """ # Get the list of packets if lfilter is None: lst_pkts = [f(self.r...
[ "diffplot", "(", "f", "delay", "=", "1", "lfilter", "=", "None", ")", "Applies", "a", "function", "to", "couples", "(", "l", "[", "i", "]", "l", "[", "i", "+", "delay", "]", ")" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/plist.py#L213-L238
[ "def", "diffplot", "(", "self", ",", "f", ",", "delay", "=", "1", ",", "lfilter", "=", "None", ",", "*", "*", "kargs", ")", ":", "# Get the list of packets", "if", "lfilter", "is", "None", ":", "lst_pkts", "=", "[", "f", "(", "self", ".", "res", "[...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
PacketList.multiplot
Uses a function that returns a label and a value for this label, then plots all the values label by label. A list of matplotlib.lines.Line2D is returned.
scapy/plist.py
def multiplot(self, f, lfilter=None, plot_xy=False, **kargs): """Uses a function that returns a label and a value for this label, then plots all the values label by label. A list of matplotlib.lines.Line2D is returned. """ # Python 2 backward compatibility f = lambda_tu...
def multiplot(self, f, lfilter=None, plot_xy=False, **kargs): """Uses a function that returns a label and a value for this label, then plots all the values label by label. A list of matplotlib.lines.Line2D is returned. """ # Python 2 backward compatibility f = lambda_tu...
[ "Uses", "a", "function", "that", "returns", "a", "label", "and", "a", "value", "for", "this", "label", "then", "plots", "all", "the", "values", "label", "by", "label", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/plist.py#L240-L278
[ "def", "multiplot", "(", "self", ",", "f", ",", "lfilter", "=", "None", ",", "plot_xy", "=", "False", ",", "*", "*", "kargs", ")", ":", "# Python 2 backward compatibility", "f", "=", "lambda_tuple_converter", "(", "f", ")", "lfilter", "=", "lambda_tuple_conv...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
PacketList.hexraw
Same as nsummary(), except that if a packet has a Raw layer, it will be hexdumped # noqa: E501 lfilter: a truth function that decides whether a packet must be displayed
scapy/plist.py
def hexraw(self, lfilter=None): """Same as nsummary(), except that if a packet has a Raw layer, it will be hexdumped # noqa: E501 lfilter: a truth function that decides whether a packet must be displayed""" # noqa: E501 for i, res in enumerate(self.res): p = self._elt2pkt(res) ...
def hexraw(self, lfilter=None): """Same as nsummary(), except that if a packet has a Raw layer, it will be hexdumped # noqa: E501 lfilter: a truth function that decides whether a packet must be displayed""" # noqa: E501 for i, res in enumerate(self.res): p = self._elt2pkt(res) ...
[ "Same", "as", "nsummary", "()", "except", "that", "if", "a", "packet", "has", "a", "Raw", "layer", "it", "will", "be", "hexdumped", "#", "noqa", ":", "E501", "lfilter", ":", "a", "truth", "function", "that", "decides", "whether", "a", "packet", "must", ...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/plist.py#L285-L296
[ "def", "hexraw", "(", "self", ",", "lfilter", "=", "None", ")", ":", "# noqa: E501", "for", "i", ",", "res", "in", "enumerate", "(", "self", ".", "res", ")", ":", "p", "=", "self", ".", "_elt2pkt", "(", "res", ")", "if", "lfilter", "is", "not", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
PacketList.hexdump
Same as nsummary(), except that packets are also hexdumped lfilter: a truth function that decides whether a packet must be displayed
scapy/plist.py
def hexdump(self, lfilter=None): """Same as nsummary(), except that packets are also hexdumped lfilter: a truth function that decides whether a packet must be displayed""" # noqa: E501 for i, res in enumerate(self.res): p = self._elt2pkt(res) if lfilter is not None and n...
def hexdump(self, lfilter=None): """Same as nsummary(), except that packets are also hexdumped lfilter: a truth function that decides whether a packet must be displayed""" # noqa: E501 for i, res in enumerate(self.res): p = self._elt2pkt(res) if lfilter is not None and n...
[ "Same", "as", "nsummary", "()", "except", "that", "packets", "are", "also", "hexdumped", "lfilter", ":", "a", "truth", "function", "that", "decides", "whether", "a", "packet", "must", "be", "displayed" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/plist.py#L298-L308
[ "def", "hexdump", "(", "self", ",", "lfilter", "=", "None", ")", ":", "# noqa: E501", "for", "i", ",", "res", "in", "enumerate", "(", "self", ".", "res", ")", ":", "p", "=", "self", ".", "_elt2pkt", "(", "res", ")", "if", "lfilter", "is", "not", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
PacketList.conversations
Graphes a conversations between sources and destinations and display it (using graphviz and imagemagick) getsrcdst: a function that takes an element of the list and returns the source, the destination and optionally a label. By default, returns the IP source and ...
scapy/plist.py
def conversations(self, getsrcdst=None, **kargs): """Graphes a conversations between sources and destinations and display it (using graphviz and imagemagick) getsrcdst: a function that takes an element of the list and returns the source, the destination and optionally ...
def conversations(self, getsrcdst=None, **kargs): """Graphes a conversations between sources and destinations and display it (using graphviz and imagemagick) getsrcdst: a function that takes an element of the list and returns the source, the destination and optionally ...
[ "Graphes", "a", "conversations", "between", "sources", "and", "destinations", "and", "display", "it", "(", "using", "graphviz", "and", "imagemagick", ")", "getsrcdst", ":", "a", "function", "that", "takes", "an", "element", "of", "the", "list", "and", "returns...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/plist.py#L335-L377
[ "def", "conversations", "(", "self", ",", "getsrcdst", "=", "None", ",", "*", "*", "kargs", ")", ":", "if", "getsrcdst", "is", "None", ":", "def", "getsrcdst", "(", "pkt", ")", ":", "\"\"\"Extract src and dst addresses\"\"\"", "if", "'IP'", "in", "pkt", ":...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
PacketList.afterglow
Experimental clone attempt of http://sourceforge.net/projects/afterglow each datum is reduced as src -> event -> dst and the data are graphed. by default we have IP.src -> IP.dport -> IP.dst
scapy/plist.py
def afterglow(self, src=None, event=None, dst=None, **kargs): """Experimental clone attempt of http://sourceforge.net/projects/afterglow each datum is reduced as src -> event -> dst and the data are graphed. by default we have IP.src -> IP.dport -> IP.dst""" if src is None: s...
def afterglow(self, src=None, event=None, dst=None, **kargs): """Experimental clone attempt of http://sourceforge.net/projects/afterglow each datum is reduced as src -> event -> dst and the data are graphed. by default we have IP.src -> IP.dport -> IP.dst""" if src is None: s...
[ "Experimental", "clone", "attempt", "of", "http", ":", "//", "sourceforge", ".", "net", "/", "projects", "/", "afterglow", "each", "datum", "is", "reduced", "as", "src", "-", ">", "event", "-", ">", "dst", "and", "the", "data", "are", "graphed", ".", "...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/plist.py#L379-L461
[ "def", "afterglow", "(", "self", ",", "src", "=", "None", ",", "event", "=", "None", ",", "dst", "=", "None", ",", "*", "*", "kargs", ")", ":", "if", "src", "is", "None", ":", "src", "=", "lambda", "x", ":", "x", "[", "'IP'", "]", ".", "src",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
PacketList.sr
sr([multi=1]) -> (SndRcvList, PacketList) Matches packets in the list and return ( (matched couples), (unmatched packets) )
scapy/plist.py
def sr(self, multi=0): """sr([multi=1]) -> (SndRcvList, PacketList) Matches packets in the list and return ( (matched couples), (unmatched packets) )""" # noqa: E501 remain = self.res[:] sr = [] i = 0 while i < len(remain): s = remain[i] j = i ...
def sr(self, multi=0): """sr([multi=1]) -> (SndRcvList, PacketList) Matches packets in the list and return ( (matched couples), (unmatched packets) )""" # noqa: E501 remain = self.res[:] sr = [] i = 0 while i < len(remain): s = remain[i] j = i ...
[ "sr", "(", "[", "multi", "=", "1", "]", ")", "-", ">", "(", "SndRcvList", "PacketList", ")", "Matches", "packets", "in", "the", "list", "and", "return", "(", "(", "matched", "couples", ")", "(", "unmatched", "packets", ")", ")" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/plist.py#L478-L503
[ "def", "sr", "(", "self", ",", "multi", "=", "0", ")", ":", "# noqa: E501", "remain", "=", "self", ".", "res", "[", ":", "]", "sr", "=", "[", "]", "i", "=", "0", "while", "i", "<", "len", "(", "remain", ")", ":", "s", "=", "remain", "[", "i...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
PacketList.replace
lst.replace(<field>,[<oldvalue>,]<newvalue>) lst.replace( (fld,[ov],nv),(fld,[ov,]nv),...) if ov is None, all values are replaced ex: lst.replace( IP.src, "192.168.1.1", "10.0.0.1" ) lst.replace( IP.ttl, 64 ) lst.replace( (IP.ttl, 64), (TCP.sport, 666, 777), )
scapy/plist.py
def replace(self, *args, **kargs): """ lst.replace(<field>,[<oldvalue>,]<newvalue>) lst.replace( (fld,[ov],nv),(fld,[ov,]nv),...) if ov is None, all values are replaced ex: lst.replace( IP.src, "192.168.1.1", "10.0.0.1" ) lst.replace( IP.ttl, 64 ) ...
def replace(self, *args, **kargs): """ lst.replace(<field>,[<oldvalue>,]<newvalue>) lst.replace( (fld,[ov],nv),(fld,[ov,]nv),...) if ov is None, all values are replaced ex: lst.replace( IP.src, "192.168.1.1", "10.0.0.1" ) lst.replace( IP.ttl, 64 ) ...
[ "lst", ".", "replace", "(", "<field", ">", "[", "<oldvalue", ">", "]", "<newvalue", ">", ")", "lst", ".", "replace", "(", "(", "fld", "[", "ov", "]", "nv", ")", "(", "fld", "[", "ov", "]", "nv", ")", "...", ")", "if", "ov", "is", "None", "all...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/plist.py#L540-L571
[ "def", "replace", "(", "self", ",", "*", "args", ",", "*", "*", "kargs", ")", ":", "delete_checksums", "=", "kargs", ".", "get", "(", "\"delete_checksums\"", ",", "False", ")", "x", "=", "PacketList", "(", "name", "=", "\"Replaced %s\"", "%", "self", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_check_tcpdump
Return True if the tcpdump command can be started
scapy/arch/common.py
def _check_tcpdump(): """ Return True if the tcpdump command can be started """ with open(os.devnull, 'wb') as devnull: try: proc = subprocess.Popen([conf.prog.tcpdump, "--version"], stdout=devnull, stderr=subprocess.STDOUT) except OSError:...
def _check_tcpdump(): """ Return True if the tcpdump command can be started """ with open(os.devnull, 'wb') as devnull: try: proc = subprocess.Popen([conf.prog.tcpdump, "--version"], stdout=devnull, stderr=subprocess.STDOUT) except OSError:...
[ "Return", "True", "if", "the", "tcpdump", "command", "can", "be", "started" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/common.py#L31-L46
[ "def", "_check_tcpdump", "(", ")", ":", "with", "open", "(", "os", ".", "devnull", ",", "'wb'", ")", "as", "devnull", ":", "try", ":", "proc", "=", "subprocess", ".", "Popen", "(", "[", "conf", ".", "prog", ".", "tcpdump", ",", "\"--version\"", "]", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
get_if
Ease SIOCGIF* ioctl calls
scapy/arch/common.py
def get_if(iff, cmd): """Ease SIOCGIF* ioctl calls""" sck = socket.socket() ifreq = ioctl(sck, cmd, struct.pack("16s16x", iff.encode("utf8"))) sck.close() return ifreq
def get_if(iff, cmd): """Ease SIOCGIF* ioctl calls""" sck = socket.socket() ifreq = ioctl(sck, cmd, struct.pack("16s16x", iff.encode("utf8"))) sck.close() return ifreq
[ "Ease", "SIOCGIF", "*", "ioctl", "calls" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/common.py#L55-L61
[ "def", "get_if", "(", "iff", ",", "cmd", ")", ":", "sck", "=", "socket", ".", "socket", "(", ")", "ifreq", "=", "ioctl", "(", "sck", ",", "cmd", ",", "struct", ".", "pack", "(", "\"16s16x\"", ",", "iff", ".", "encode", "(", "\"utf8\"", ")", ")", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_select_nonblock
This function is called during sendrecv() routine to select the available sockets.
scapy/arch/common.py
def _select_nonblock(sockets, remain=None): """This function is called during sendrecv() routine to select the available sockets. """ # pcap sockets aren't selectable, so we return all of them # and ask the selecting functions to use nonblock_recv instead of recv def _sleep_nonblock_recv(self): ...
def _select_nonblock(sockets, remain=None): """This function is called during sendrecv() routine to select the available sockets. """ # pcap sockets aren't selectable, so we return all of them # and ask the selecting functions to use nonblock_recv instead of recv def _sleep_nonblock_recv(self): ...
[ "This", "function", "is", "called", "during", "sendrecv", "()", "routine", "to", "select", "the", "available", "sockets", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/common.py#L70-L84
[ "def", "_select_nonblock", "(", "sockets", ",", "remain", "=", "None", ")", ":", "# pcap sockets aren't selectable, so we return all of them", "# and ask the selecting functions to use nonblock_recv instead of recv", "def", "_sleep_nonblock_recv", "(", "self", ")", ":", "try", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_legacy_bpf_pointer
Get old-format BPF Pointer. Deprecated
scapy/arch/common.py
def _legacy_bpf_pointer(tcpdump_lines): """Get old-format BPF Pointer. Deprecated""" X86_64 = os.uname()[4] in ['x86_64', 'aarch64'] size = int(tcpdump_lines[0]) bpf = b"" for l in tcpdump_lines[1:]: if six.PY2: int_type = long # noqa: F821 else: int_type = i...
def _legacy_bpf_pointer(tcpdump_lines): """Get old-format BPF Pointer. Deprecated""" X86_64 = os.uname()[4] in ['x86_64', 'aarch64'] size = int(tcpdump_lines[0]) bpf = b"" for l in tcpdump_lines[1:]: if six.PY2: int_type = long # noqa: F821 else: int_type = i...
[ "Get", "old", "-", "format", "BPF", "Pointer", ".", "Deprecated" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/common.py#L103-L125
[ "def", "_legacy_bpf_pointer", "(", "tcpdump_lines", ")", ":", "X86_64", "=", "os", ".", "uname", "(", ")", "[", "4", "]", "in", "[", "'x86_64'", ",", "'aarch64'", "]", "size", "=", "int", "(", "tcpdump_lines", "[", "0", "]", ")", "bpf", "=", "b\"\"",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
get_bpf_pointer
Create a BPF Pointer for TCPDump filter
scapy/arch/common.py
def get_bpf_pointer(tcpdump_lines): """Create a BPF Pointer for TCPDump filter""" if conf.use_pypy: return _legacy_bpf_pointer(tcpdump_lines) # Allocate BPF instructions size = int(tcpdump_lines[0]) bpf_insn_a = bpf_insn * size bip = bpf_insn_a() # Fill the BPF instruction structur...
def get_bpf_pointer(tcpdump_lines): """Create a BPF Pointer for TCPDump filter""" if conf.use_pypy: return _legacy_bpf_pointer(tcpdump_lines) # Allocate BPF instructions size = int(tcpdump_lines[0]) bpf_insn_a = bpf_insn * size bip = bpf_insn_a() # Fill the BPF instruction structur...
[ "Create", "a", "BPF", "Pointer", "for", "TCPDump", "filter" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/common.py#L128-L150
[ "def", "get_bpf_pointer", "(", "tcpdump_lines", ")", ":", "if", "conf", ".", "use_pypy", ":", "return", "_legacy_bpf_pointer", "(", "tcpdump_lines", ")", "# Allocate BPF instructions", "size", "=", "int", "(", "tcpdump_lines", "[", "0", "]", ")", "bpf_insn_a", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
compile_filter
Asks Tcpdump to parse the filter, then build the matching BPF bytecode using get_bpf_pointer.
scapy/arch/common.py
def compile_filter(bpf_filter, iface=None): """Asks Tcpdump to parse the filter, then build the matching BPF bytecode using get_bpf_pointer. """ if not TCPDUMP: raise Scapy_Exception("tcpdump is not available. Cannot use filter !") try: process = subprocess.Popen([ conf.p...
def compile_filter(bpf_filter, iface=None): """Asks Tcpdump to parse the filter, then build the matching BPF bytecode using get_bpf_pointer. """ if not TCPDUMP: raise Scapy_Exception("tcpdump is not available. Cannot use filter !") try: process = subprocess.Popen([ conf.p...
[ "Asks", "Tcpdump", "to", "parse", "the", "filter", "then", "build", "the", "matching", "BPF", "bytecode", "using", "get_bpf_pointer", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/common.py#L153-L179
[ "def", "compile_filter", "(", "bpf_filter", ",", "iface", "=", "None", ")", ":", "if", "not", "TCPDUMP", ":", "raise", "Scapy_Exception", "(", "\"tcpdump is not available. Cannot use filter !\"", ")", "try", ":", "process", "=", "subprocess", ".", "Popen", "(", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_ldp_id_adjustlen
Return the length of the `id` field, according to its real encoded type
scapy/contrib/lldp.py
def _ldp_id_adjustlen(pkt, x): """Return the length of the `id` field, according to its real encoded type""" f, v = pkt.getfield_and_val('id') return len(_LLDPidField.i2m(f, pkt, v)) + 1
def _ldp_id_adjustlen(pkt, x): """Return the length of the `id` field, according to its real encoded type""" f, v = pkt.getfield_and_val('id') return len(_LLDPidField.i2m(f, pkt, v)) + 1
[ "Return", "the", "length", "of", "the", "id", "field", "according", "to", "its", "real", "encoded", "type" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/lldp.py#L326-L330
[ "def", "_ldp_id_adjustlen", "(", "pkt", ",", "x", ")", ":", "f", ",", "v", "=", "pkt", ".", "getfield_and_val", "(", "'id'", ")", "return", "len", "(", "_LLDPidField", ".", "i2m", "(", "f", ",", "pkt", ",", "v", ")", ")", "+", "1" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
train
LLDPDU._dot1q_headers_size
calculate size of lower dot1q layers (if present) :param layer: the layer to start at :return: size of vlan headers, layer below lowest vlan header
scapy/contrib/lldp.py
def _dot1q_headers_size(layer): """ calculate size of lower dot1q layers (if present) :param layer: the layer to start at :return: size of vlan headers, layer below lowest vlan header """ vlan_headers_size = 0 under_layer = layer while under_layer and is...
def _dot1q_headers_size(layer): """ calculate size of lower dot1q layers (if present) :param layer: the layer to start at :return: size of vlan headers, layer below lowest vlan header """ vlan_headers_size = 0 under_layer = layer while under_layer and is...
[ "calculate", "size", "of", "lower", "dot1q", "layers", "(", "if", "present", ")", ":", "param", "layer", ":", "the", "layer", "to", "start", "at", ":", "return", ":", "size", "of", "vlan", "headers", "layer", "below", "lowest", "vlan", "header" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/lldp.py#L135-L149
[ "def", "_dot1q_headers_size", "(", "layer", ")", ":", "vlan_headers_size", "=", "0", "under_layer", "=", "layer", "while", "under_layer", "and", "isinstance", "(", "under_layer", ",", "Dot1Q", ")", ":", "vlan_headers_size", "+=", "LLDPDU", ".", "DOT1Q_HEADER_LEN",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
LLDPDU._frame_structure_check
check if the structure of the frame is conform to the basic frame structure defined by the standard :param structure_description: string-list reflecting LLDP-msg structure
scapy/contrib/lldp.py
def _frame_structure_check(structure_description): """ check if the structure of the frame is conform to the basic frame structure defined by the standard :param structure_description: string-list reflecting LLDP-msg structure """ standard_frame_structure = [LLDPDUChassi...
def _frame_structure_check(structure_description): """ check if the structure of the frame is conform to the basic frame structure defined by the standard :param structure_description: string-list reflecting LLDP-msg structure """ standard_frame_structure = [LLDPDUChassi...
[ "check", "if", "the", "structure", "of", "the", "frame", "is", "conform", "to", "the", "basic", "frame", "structure", "defined", "by", "the", "standard", ":", "param", "structure_description", ":", "string", "-", "list", "reflecting", "LLDP", "-", "msg", "st...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/lldp.py#L188-L221
[ "def", "_frame_structure_check", "(", "structure_description", ")", ":", "standard_frame_structure", "=", "[", "LLDPDUChassisID", ".", "__name__", ",", "LLDPDUPortID", ".", "__name__", ",", "LLDPDUTimeToLive", ".", "__name__", ",", "'<...>'", ",", "LLDPDUEndOfLLDPDU", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
LLDPDU._tlv_multiplicities_check
check if multiplicity of present TLVs conforms to the standard :param tlv_type_count: dict containing counte-per-TLV
scapy/contrib/lldp.py
def _tlv_multiplicities_check(tlv_type_count): """ check if multiplicity of present TLVs conforms to the standard :param tlv_type_count: dict containing counte-per-TLV """ # * : 0..n, 1 : one and only one. standard_multiplicities = { LLDPDUEndOfLLDPDU.__name_...
def _tlv_multiplicities_check(tlv_type_count): """ check if multiplicity of present TLVs conforms to the standard :param tlv_type_count: dict containing counte-per-TLV """ # * : 0..n, 1 : one and only one. standard_multiplicities = { LLDPDUEndOfLLDPDU.__name_...
[ "check", "if", "multiplicity", "of", "present", "TLVs", "conforms", "to", "the", "standard", ":", "param", "tlv_type_count", ":", "dict", "containing", "counte", "-", "per", "-", "TLV" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/lldp.py#L224-L261
[ "def", "_tlv_multiplicities_check", "(", "tlv_type_count", ")", ":", "# * : 0..n, 1 : one and only one.", "standard_multiplicities", "=", "{", "LLDPDUEndOfLLDPDU", ".", "__name__", ":", "1", ",", "LLDPDUChassisID", ".", "__name__", ":", "1", ",", "LLDPDUPortID", ".", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
LLDPDUTimeToLive._check
run layer specific checks
scapy/contrib/lldp.py
def _check(self): """ run layer specific checks """ if conf.contribs['LLDP'].strict_mode() and self._length != 2: raise LLDPInvalidLengthField('length must be 2 - got ' '{}'.format(self._length))
def _check(self): """ run layer specific checks """ if conf.contribs['LLDP'].strict_mode() and self._length != 2: raise LLDPInvalidLengthField('length must be 2 - got ' '{}'.format(self._length))
[ "run", "layer", "specific", "checks" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/lldp.py#L435-L441
[ "def", "_check", "(", "self", ")", ":", "if", "conf", ".", "contribs", "[", "'LLDP'", "]", ".", "strict_mode", "(", ")", "and", "self", ".", "_length", "!=", "2", ":", "raise", "LLDPInvalidLengthField", "(", "'length must be 2 - got '", "'{}'", ".", "forma...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
LLDPDUManagementAddress._check
run layer specific checks
scapy/contrib/lldp.py
def _check(self): """ run layer specific checks """ if conf.contribs['LLDP'].strict_mode(): management_address_len = len(self.management_address) if management_address_len == 0 or management_address_len > 31: raise LLDPInvalidLengthField( ...
def _check(self): """ run layer specific checks """ if conf.contribs['LLDP'].strict_mode(): management_address_len = len(self.management_address) if management_address_len == 0 or management_address_len > 31: raise LLDPInvalidLengthField( ...
[ "run", "layer", "specific", "checks" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/lldp.py#L668-L677
[ "def", "_check", "(", "self", ")", ":", "if", "conf", ".", "contribs", "[", "'LLDP'", "]", ".", "strict_mode", "(", ")", ":", "management_address_len", "=", "len", "(", "self", ".", "management_address", ")", "if", "management_address_len", "==", "0", "or"...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
GetIcmpStatistics
Return all Windows ICMP stats from iphlpapi
scapy/arch/windows/structures.py
def GetIcmpStatistics(): """Return all Windows ICMP stats from iphlpapi""" statistics = MIB_ICMP() _GetIcmpStatistics(byref(statistics)) results = _struct_to_dict(statistics) del(statistics) return results
def GetIcmpStatistics(): """Return all Windows ICMP stats from iphlpapi""" statistics = MIB_ICMP() _GetIcmpStatistics(byref(statistics)) results = _struct_to_dict(statistics) del(statistics) return results
[ "Return", "all", "Windows", "ICMP", "stats", "from", "iphlpapi" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/structures.py#L166-L172
[ "def", "GetIcmpStatistics", "(", ")", ":", "statistics", "=", "MIB_ICMP", "(", ")", "_GetIcmpStatistics", "(", "byref", "(", "statistics", ")", ")", "results", "=", "_struct_to_dict", "(", "statistics", ")", "del", "(", "statistics", ")", "return", "results" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
train
GetAdaptersAddresses
Return all Windows Adapters addresses from iphlpapi
scapy/arch/windows/structures.py
def GetAdaptersAddresses(AF=AF_UNSPEC): """Return all Windows Adapters addresses from iphlpapi""" # We get the size first size = ULONG() flags = GAA_FLAG_INCLUDE_PREFIX res = _GetAdaptersAddresses(AF, flags, None, None, byref(size)) ...
def GetAdaptersAddresses(AF=AF_UNSPEC): """Return all Windows Adapters addresses from iphlpapi""" # We get the size first size = ULONG() flags = GAA_FLAG_INCLUDE_PREFIX res = _GetAdaptersAddresses(AF, flags, None, None, byref(size)) ...
[ "Return", "all", "Windows", "Adapters", "addresses", "from", "iphlpapi" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/structures.py#L377-L399
[ "def", "GetAdaptersAddresses", "(", "AF", "=", "AF_UNSPEC", ")", ":", "# We get the size first", "size", "=", "ULONG", "(", ")", "flags", "=", "GAA_FLAG_INCLUDE_PREFIX", "res", "=", "_GetAdaptersAddresses", "(", "AF", ",", "flags", ",", "None", ",", "None", ",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
GetIpForwardTable
Return all Windows routes (IPv4 only) from iphlpapi
scapy/arch/windows/structures.py
def GetIpForwardTable(): """Return all Windows routes (IPv4 only) from iphlpapi""" # We get the size first size = ULONG() res = _GetIpForwardTable(None, byref(size), False) if res != 0x7a: # ERROR_INSUFFICIENT_BUFFER -> populate size raise RuntimeError("Error getting structure length (%d)" ...
def GetIpForwardTable(): """Return all Windows routes (IPv4 only) from iphlpapi""" # We get the size first size = ULONG() res = _GetIpForwardTable(None, byref(size), False) if res != 0x7a: # ERROR_INSUFFICIENT_BUFFER -> populate size raise RuntimeError("Error getting structure length (%d)" ...
[ "Return", "all", "Windows", "routes", "(", "IPv4", "only", ")", "from", "iphlpapi" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/structures.py#L439-L458
[ "def", "GetIpForwardTable", "(", ")", ":", "# We get the size first", "size", "=", "ULONG", "(", ")", "res", "=", "_GetIpForwardTable", "(", "None", ",", "byref", "(", "size", ")", ",", "False", ")", "if", "res", "!=", "0x7a", ":", "# ERROR_INSUFFICIENT_BUFF...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
GetIpForwardTable2
Return all Windows routes (IPv4/IPv6) from iphlpapi
scapy/arch/windows/structures.py
def GetIpForwardTable2(AF=AF_UNSPEC): """Return all Windows routes (IPv4/IPv6) from iphlpapi""" if WINDOWS_XP: raise OSError("Not available on Windows XP !") table = PMIB_IPFORWARD_TABLE2() res = _GetIpForwardTable2(AF, byref(table)) if res != NO_ERROR: raise RuntimeError("Error retr...
def GetIpForwardTable2(AF=AF_UNSPEC): """Return all Windows routes (IPv4/IPv6) from iphlpapi""" if WINDOWS_XP: raise OSError("Not available on Windows XP !") table = PMIB_IPFORWARD_TABLE2() res = _GetIpForwardTable2(AF, byref(table)) if res != NO_ERROR: raise RuntimeError("Error retr...
[ "Return", "all", "Windows", "routes", "(", "IPv4", "/", "IPv6", ")", "from", "iphlpapi" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/structures.py#L516-L528
[ "def", "GetIpForwardTable2", "(", "AF", "=", "AF_UNSPEC", ")", ":", "if", "WINDOWS_XP", ":", "raise", "OSError", "(", "\"Not available on Windows XP !\"", ")", "table", "=", "PMIB_IPFORWARD_TABLE2", "(", ")", "res", "=", "_GetIpForwardTable2", "(", "AF", ",", "b...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_BlockCipher.encrypt
Encrypt the data. Also, update the cipher iv. This is needed for SSLv3 and TLS 1.0. For TLS 1.1/1.2, it is overwritten in TLS.post_build().
scapy/layers/tls/crypto/cipher_block.py
def encrypt(self, data): """ Encrypt the data. Also, update the cipher iv. This is needed for SSLv3 and TLS 1.0. For TLS 1.1/1.2, it is overwritten in TLS.post_build(). """ if False in six.itervalues(self.ready): raise CipherError(data) encryptor = self._ciphe...
def encrypt(self, data): """ Encrypt the data. Also, update the cipher iv. This is needed for SSLv3 and TLS 1.0. For TLS 1.1/1.2, it is overwritten in TLS.post_build(). """ if False in six.itervalues(self.ready): raise CipherError(data) encryptor = self._ciphe...
[ "Encrypt", "the", "data", ".", "Also", "update", "the", "cipher", "iv", ".", "This", "is", "needed", "for", "SSLv3", "and", "TLS", "1", ".", "0", ".", "For", "TLS", "1", ".", "1", "/", "1", ".", "2", "it", "is", "overwritten", "in", "TLS", ".", ...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/crypto/cipher_block.py#L77-L87
[ "def", "encrypt", "(", "self", ",", "data", ")", ":", "if", "False", "in", "six", ".", "itervalues", "(", "self", ".", "ready", ")", ":", "raise", "CipherError", "(", "data", ")", "encryptor", "=", "self", ".", "_cipher", ".", "encryptor", "(", ")", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_BlockCipher.decrypt
Decrypt the data. Also, update the cipher iv. This is needed for SSLv3 and TLS 1.0. For TLS 1.1/1.2, it is overwritten in TLS.pre_dissect(). If we lack the key, we raise a CipherError which contains the input.
scapy/layers/tls/crypto/cipher_block.py
def decrypt(self, data): """ Decrypt the data. Also, update the cipher iv. This is needed for SSLv3 and TLS 1.0. For TLS 1.1/1.2, it is overwritten in TLS.pre_dissect(). If we lack the key, we raise a CipherError which contains the input. """ if False in six.itervalues(se...
def decrypt(self, data): """ Decrypt the data. Also, update the cipher iv. This is needed for SSLv3 and TLS 1.0. For TLS 1.1/1.2, it is overwritten in TLS.pre_dissect(). If we lack the key, we raise a CipherError which contains the input. """ if False in six.itervalues(se...
[ "Decrypt", "the", "data", ".", "Also", "update", "the", "cipher", "iv", ".", "This", "is", "needed", "for", "SSLv3", "and", "TLS", "1", ".", "0", ".", "For", "TLS", "1", ".", "1", "/", "1", ".", "2", "it", "is", "overwritten", "in", "TLS", ".", ...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/crypto/cipher_block.py#L89-L100
[ "def", "decrypt", "(", "self", ",", "data", ")", ":", "if", "False", "in", "six", ".", "itervalues", "(", "self", ".", "ready", ")", ":", "raise", "CipherError", "(", "data", ")", "decryptor", "=", "self", ".", "_cipher", ".", "decryptor", "(", ")", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
prepare_packed_data
Pack RADIUS data prior computing the authentication MAC
scapy/layers/radius.py
def prepare_packed_data(radius_packet, packed_req_authenticator): """ Pack RADIUS data prior computing the authentication MAC """ packed_hdr = struct.pack("!B", radius_packet.code) packed_hdr += struct.pack("!B", radius_packet.id) packed_hdr += struct.pack("!H", radius_packet.len) packed_a...
def prepare_packed_data(radius_packet, packed_req_authenticator): """ Pack RADIUS data prior computing the authentication MAC """ packed_hdr = struct.pack("!B", radius_packet.code) packed_hdr += struct.pack("!B", radius_packet.id) packed_hdr += struct.pack("!H", radius_packet.len) packed_a...
[ "Pack", "RADIUS", "data", "prior", "computing", "the", "authentication", "MAC" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/radius.py#L534-L547
[ "def", "prepare_packed_data", "(", "radius_packet", ",", "packed_req_authenticator", ")", ":", "packed_hdr", "=", "struct", ".", "pack", "(", "\"!B\"", ",", "radius_packet", ".", "code", ")", "packed_hdr", "+=", "struct", ".", "pack", "(", "\"!B\"", ",", "radi...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
RadiusAttribute.register_variant
Registers the RADIUS attributes defined in this module.
scapy/layers/radius.py
def register_variant(cls): """ Registers the RADIUS attributes defined in this module. """ if hasattr(cls, "val"): cls.registered_attributes[cls.val] = cls else: cls.registered_attributes[cls.type.default] = cls
def register_variant(cls): """ Registers the RADIUS attributes defined in this module. """ if hasattr(cls, "val"): cls.registered_attributes[cls.val] = cls else: cls.registered_attributes[cls.type.default] = cls
[ "Registers", "the", "RADIUS", "attributes", "defined", "in", "this", "module", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/radius.py#L239-L247
[ "def", "register_variant", "(", "cls", ")", ":", "if", "hasattr", "(", "cls", ",", "\"val\"", ")", ":", "cls", ".", "registered_attributes", "[", "cls", ".", "val", "]", "=", "cls", "else", ":", "cls", ".", "registered_attributes", "[", "cls", ".", "ty...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
RadiusAttribute.dispatch_hook
Returns the right RadiusAttribute class for the given data.
scapy/layers/radius.py
def dispatch_hook(cls, _pkt=None, *args, **kargs): """ Returns the right RadiusAttribute class for the given data. """ if _pkt: attr_type = orb(_pkt[0]) return cls.registered_attributes.get(attr_type, cls) return cls
def dispatch_hook(cls, _pkt=None, *args, **kargs): """ Returns the right RadiusAttribute class for the given data. """ if _pkt: attr_type = orb(_pkt[0]) return cls.registered_attributes.get(attr_type, cls) return cls
[ "Returns", "the", "right", "RadiusAttribute", "class", "for", "the", "given", "data", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/radius.py#L250-L258
[ "def", "dispatch_hook", "(", "cls", ",", "_pkt", "=", "None", ",", "*", "args", ",", "*", "*", "kargs", ")", ":", "if", "_pkt", ":", "attr_type", "=", "orb", "(", "_pkt", "[", "0", "]", ")", "return", "cls", ".", "registered_attributes", ".", "get"...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
RadiusAttr_Message_Authenticator.compute_message_authenticator
Computes the "Message-Authenticator" of a given RADIUS packet.
scapy/layers/radius.py
def compute_message_authenticator(radius_packet, packed_req_authenticator, shared_secret): """ Computes the "Message-Authenticator" of a given RADIUS packet. """ data = prepare_packed_data(radius_packet, packed_req_authenticator) radius_hmac...
def compute_message_authenticator(radius_packet, packed_req_authenticator, shared_secret): """ Computes the "Message-Authenticator" of a given RADIUS packet. """ data = prepare_packed_data(radius_packet, packed_req_authenticator) radius_hmac...
[ "Computes", "the", "Message", "-", "Authenticator", "of", "a", "given", "RADIUS", "packet", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/radius.py#L566-L575
[ "def", "compute_message_authenticator", "(", "radius_packet", ",", "packed_req_authenticator", ",", "shared_secret", ")", ":", "data", "=", "prepare_packed_data", "(", "radius_packet", ",", "packed_req_authenticator", ")", "radius_hmac", "=", "hmac", ".", "new", "(", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
Radius.compute_authenticator
Computes the authenticator field (RFC 2865 - Section 3)
scapy/layers/radius.py
def compute_authenticator(self, packed_request_auth, shared_secret): """ Computes the authenticator field (RFC 2865 - Section 3) """ data = prepare_packed_data(self, packed_request_auth) radius_mac = hashlib.md5(data + shared_secret) return radius_mac.digest()
def compute_authenticator(self, packed_request_auth, shared_secret): """ Computes the authenticator field (RFC 2865 - Section 3) """ data = prepare_packed_data(self, packed_request_auth) radius_mac = hashlib.md5(data + shared_secret) return radius_mac.digest()
[ "Computes", "the", "authenticator", "field", "(", "RFC", "2865", "-", "Section", "3", ")" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/radius.py#L1132-L1139
[ "def", "compute_authenticator", "(", "self", ",", "packed_request_auth", ",", "shared_secret", ")", ":", "data", "=", "prepare_packed_data", "(", "self", ",", "packed_request_auth", ")", "radius_mac", "=", "hashlib", ".", "md5", "(", "data", "+", "shared_secret", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
KeyShareEntry.do_build
We need this hack, else 'self' would be replaced by __iter__.next().
scapy/layers/tls/keyexchange_tls13.py
def do_build(self): """ We need this hack, else 'self' would be replaced by __iter__.next(). """ tmp = self.explicit self.explicit = True b = super(KeyShareEntry, self).do_build() self.explicit = tmp return b
def do_build(self): """ We need this hack, else 'self' would be replaced by __iter__.next(). """ tmp = self.explicit self.explicit = True b = super(KeyShareEntry, self).do_build() self.explicit = tmp return b
[ "We", "need", "this", "hack", "else", "self", "would", "be", "replaced", "by", "__iter__", ".", "next", "()", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/keyexchange_tls13.py#L48-L56
[ "def", "do_build", "(", "self", ")", ":", "tmp", "=", "self", ".", "explicit", "self", ".", "explicit", "=", "True", "b", "=", "super", "(", "KeyShareEntry", ",", "self", ")", ".", "do_build", "(", ")", "self", ".", "explicit", "=", "tmp", "return", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
KeyShareEntry.create_privkey
This is called by post_build() for key creation.
scapy/layers/tls/keyexchange_tls13.py
def create_privkey(self): """ This is called by post_build() for key creation. """ if self.group in _tls_named_ffdh_groups: params = _ffdh_groups[_tls_named_ffdh_groups[self.group]][0] privkey = params.generate_private_key() self.privkey = privkey ...
def create_privkey(self): """ This is called by post_build() for key creation. """ if self.group in _tls_named_ffdh_groups: params = _ffdh_groups[_tls_named_ffdh_groups[self.group]][0] privkey = params.generate_private_key() self.privkey = privkey ...
[ "This", "is", "called", "by", "post_build", "()", "for", "key", "creation", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/keyexchange_tls13.py#L59-L89
[ "def", "create_privkey", "(", "self", ")", ":", "if", "self", ".", "group", "in", "_tls_named_ffdh_groups", ":", "params", "=", "_ffdh_groups", "[", "_tls_named_ffdh_groups", "[", "self", ".", "group", "]", "]", "[", "0", "]", "privkey", "=", "params", "."...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_guess_iface_name
We attempt to guess the name of interfaces that are truncated from the output of ifconfig -l. If there is only one possible candidate matching the interface name then we return it. If there are none or more, then we return None.
scapy/arch/unix.py
def _guess_iface_name(netif): """ We attempt to guess the name of interfaces that are truncated from the output of ifconfig -l. If there is only one possible candidate matching the interface name then we return it. If there are none or more, then we return None. """ with os.popen('%s -l'...
def _guess_iface_name(netif): """ We attempt to guess the name of interfaces that are truncated from the output of ifconfig -l. If there is only one possible candidate matching the interface name then we return it. If there are none or more, then we return None. """ with os.popen('%s -l'...
[ "We", "attempt", "to", "guess", "the", "name", "of", "interfaces", "that", "are", "truncated", "from", "the", "output", "of", "ifconfig", "-", "l", ".", "If", "there", "is", "only", "one", "possible", "candidate", "matching", "the", "interface", "name", "t...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/unix.py#L28-L41
[ "def", "_guess_iface_name", "(", "netif", ")", ":", "with", "os", ".", "popen", "(", "'%s -l'", "%", "conf", ".", "prog", ".", "ifconfig", ")", "as", "fdesc", ":", "ifaces", "=", "fdesc", ".", "readline", "(", ")", ".", "strip", "(", ")", ".", "spl...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_in6_getifaddr
Returns a list of IPv6 addresses configured on the interface ifname.
scapy/arch/unix.py
def _in6_getifaddr(ifname): """ Returns a list of IPv6 addresses configured on the interface ifname. """ # Get the output of ifconfig try: f = os.popen("%s %s" % (conf.prog.ifconfig, ifname)) except OSError: log_interactive.warning("Failed to execute ifconfig.") return [...
def _in6_getifaddr(ifname): """ Returns a list of IPv6 addresses configured on the interface ifname. """ # Get the output of ifconfig try: f = os.popen("%s %s" % (conf.prog.ifconfig, ifname)) except OSError: log_interactive.warning("Failed to execute ifconfig.") return [...
[ "Returns", "a", "list", "of", "IPv6", "addresses", "configured", "on", "the", "interface", "ifname", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/unix.py#L149-L181
[ "def", "_in6_getifaddr", "(", "ifname", ")", ":", "# Get the output of ifconfig", "try", ":", "f", "=", "os", ".", "popen", "(", "\"%s %s\"", "%", "(", "conf", ".", "prog", ".", "ifconfig", ",", "ifname", ")", ")", "except", "OSError", ":", "log_interactiv...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
in6_getifaddr
Returns a list of 3-tuples of the form (addr, scope, iface) where 'addr' is the address of scope 'scope' associated to the interface 'iface'. This is the list of all addresses of all interfaces available on the system.
scapy/arch/unix.py
def in6_getifaddr(): """ Returns a list of 3-tuples of the form (addr, scope, iface) where 'addr' is the address of scope 'scope' associated to the interface 'iface'. This is the list of all addresses of all interfaces available on the system. """ # List all network interfaces if O...
def in6_getifaddr(): """ Returns a list of 3-tuples of the form (addr, scope, iface) where 'addr' is the address of scope 'scope' associated to the interface 'iface'. This is the list of all addresses of all interfaces available on the system. """ # List all network interfaces if O...
[ "Returns", "a", "list", "of", "3", "-", "tuples", "of", "the", "form", "(", "addr", "scope", "iface", ")", "where", "addr", "is", "the", "address", "of", "scope", "scope", "associated", "to", "the", "interface", "iface", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/unix.py#L184-L222
[ "def", "in6_getifaddr", "(", ")", ":", "# List all network interfaces", "if", "OPENBSD", ":", "try", ":", "f", "=", "os", ".", "popen", "(", "\"%s\"", "%", "conf", ".", "prog", ".", "ifconfig", ")", "except", "OSError", ":", "log_interactive", ".", "warnin...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
read_routes6
Return a list of IPv6 routes than can be used by Scapy.
scapy/arch/unix.py
def read_routes6(): """Return a list of IPv6 routes than can be used by Scapy.""" # Call netstat to retrieve IPv6 routes fd_netstat = os.popen("netstat -rn -f inet6") # List interfaces IPv6 addresses lifaddr = in6_getifaddr() if not lifaddr: return [] # Routes header information ...
def read_routes6(): """Return a list of IPv6 routes than can be used by Scapy.""" # Call netstat to retrieve IPv6 routes fd_netstat = os.popen("netstat -rn -f inet6") # List interfaces IPv6 addresses lifaddr = in6_getifaddr() if not lifaddr: return [] # Routes header information ...
[ "Return", "a", "list", "of", "IPv6", "routes", "than", "can", "be", "used", "by", "Scapy", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/unix.py#L225-L339
[ "def", "read_routes6", "(", ")", ":", "# Call netstat to retrieve IPv6 routes", "fd_netstat", "=", "os", ".", "popen", "(", "\"netstat -rn -f inet6\"", ")", "# List interfaces IPv6 addresses", "lifaddr", "=", "in6_getifaddr", "(", ")", "if", "not", "lifaddr", ":", "re...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_read_config_file
Read a config file: execute a python file while loading scapy, that may contain # noqa: E501 some pre-configured values. If _globals or _locals are specified, they will be updated with the loaded vars. # noqa: E501 This allows an external program to use the function. Otherwise, vars are only available #...
scapy/main.py
def _read_config_file(cf, _globals=globals(), _locals=locals(), interactive=True): # noqa: E501 """Read a config file: execute a python file while loading scapy, that may contain # noqa: E501 some pre-configured values. If _globals or _locals are specified, they will be updated with the loaded vars. # n...
def _read_config_file(cf, _globals=globals(), _locals=locals(), interactive=True): # noqa: E501 """Read a config file: execute a python file while loading scapy, that may contain # noqa: E501 some pre-configured values. If _globals or _locals are specified, they will be updated with the loaded vars. # n...
[ "Read", "a", "config", "file", ":", "execute", "a", "python", "file", "while", "loading", "scapy", "that", "may", "contain", "#", "noqa", ":", "E501", "some", "pre", "-", "configured", "values", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/main.py#L64-L95
[ "def", "_read_config_file", "(", "cf", ",", "_globals", "=", "globals", "(", ")", ",", "_locals", "=", "locals", "(", ")", ",", "interactive", "=", "True", ")", ":", "# noqa: E501", "log_loading", ".", "debug", "(", "\"Loading config file [%s]\"", ",", "cf",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_load
Loads a Python module to make variables, objects and functions available globally. The idea is to load the module using importlib, then copy the symbols to the global symbol table.
scapy/main.py
def _load(module, globals_dict=None, symb_list=None): """Loads a Python module to make variables, objects and functions available globally. The idea is to load the module using importlib, then copy the symbols to the global symbol table. """ if globals_dict is None: globals_dict = six.moves.bu...
def _load(module, globals_dict=None, symb_list=None): """Loads a Python module to make variables, objects and functions available globally. The idea is to load the module using importlib, then copy the symbols to the global symbol table. """ if globals_dict is None: globals_dict = six.moves.bu...
[ "Loads", "a", "Python", "module", "to", "make", "variables", "objects", "and", "functions", "available", "globally", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/main.py#L123-L149
[ "def", "_load", "(", "module", ",", "globals_dict", "=", "None", ",", "symb_list", "=", "None", ")", ":", "if", "globals_dict", "is", "None", ":", "globals_dict", "=", "six", ".", "moves", ".", "builtins", ".", "__dict__", "try", ":", "mod", "=", "impo...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
load_module
Loads a Scapy module to make variables, objects and functions available globally.
scapy/main.py
def load_module(name, globals_dict=None, symb_list=None): """Loads a Scapy module to make variables, objects and functions available globally. """ _load("scapy.modules." + name, globals_dict=globals_dict, symb_list=symb_list)
def load_module(name, globals_dict=None, symb_list=None): """Loads a Scapy module to make variables, objects and functions available globally. """ _load("scapy.modules." + name, globals_dict=globals_dict, symb_list=symb_list)
[ "Loads", "a", "Scapy", "module", "to", "make", "variables", "objects", "and", "functions", "available", "globally", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/main.py#L152-L158
[ "def", "load_module", "(", "name", ",", "globals_dict", "=", "None", ",", "symb_list", "=", "None", ")", ":", "_load", "(", "\"scapy.modules.\"", "+", "name", ",", "globals_dict", "=", "globals_dict", ",", "symb_list", "=", "symb_list", ")" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
train
load_layer
Loads a Scapy layer module to make variables, objects and functions available globally.
scapy/main.py
def load_layer(name, globals_dict=None, symb_list=None): """Loads a Scapy layer module to make variables, objects and functions available globally. """ _load("scapy.layers." + LAYER_ALIASES.get(name, name), globals_dict=globals_dict, symb_list=symb_list)
def load_layer(name, globals_dict=None, symb_list=None): """Loads a Scapy layer module to make variables, objects and functions available globally. """ _load("scapy.layers." + LAYER_ALIASES.get(name, name), globals_dict=globals_dict, symb_list=symb_list)
[ "Loads", "a", "Scapy", "layer", "module", "to", "make", "variables", "objects", "and", "functions", "available", "globally", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/main.py#L161-L167
[ "def", "load_layer", "(", "name", ",", "globals_dict", "=", "None", ",", "symb_list", "=", "None", ")", ":", "_load", "(", "\"scapy.layers.\"", "+", "LAYER_ALIASES", ".", "get", "(", "name", ",", "name", ")", ",", "globals_dict", "=", "globals_dict", ",", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
load_contrib
Loads a Scapy contrib module to make variables, objects and functions available globally. If no contrib module can be found with the given name, try to find a layer module, since a contrib module may become a layer module.
scapy/main.py
def load_contrib(name, globals_dict=None, symb_list=None): """Loads a Scapy contrib module to make variables, objects and functions available globally. If no contrib module can be found with the given name, try to find a layer module, since a contrib module may become a layer module. """ try: ...
def load_contrib(name, globals_dict=None, symb_list=None): """Loads a Scapy contrib module to make variables, objects and functions available globally. If no contrib module can be found with the given name, try to find a layer module, since a contrib module may become a layer module. """ try: ...
[ "Loads", "a", "Scapy", "contrib", "module", "to", "make", "variables", "objects", "and", "functions", "available", "globally", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/main.py#L170-L188
[ "def", "load_contrib", "(", "name", ",", "globals_dict", "=", "None", ",", "symb_list", "=", "None", ")", ":", "try", ":", "importlib", ".", "import_module", "(", "\"scapy.contrib.\"", "+", "name", ")", "_load", "(", "\"scapy.contrib.\"", "+", "name", ",", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
list_contrib
Show the list of all existing contribs. Params: - name: filter to search the contribs - ret: whether the function should return a dict instead of printing it
scapy/main.py
def list_contrib(name=None, ret=False, _debug=False): """Show the list of all existing contribs. Params: - name: filter to search the contribs - ret: whether the function should return a dict instead of printing it """ # _debug: checks that all contrib modules have correctly defined: # # s...
def list_contrib(name=None, ret=False, _debug=False): """Show the list of all existing contribs. Params: - name: filter to search the contribs - ret: whether the function should return a dict instead of printing it """ # _debug: checks that all contrib modules have correctly defined: # # s...
[ "Show", "the", "list", "of", "all", "existing", "contribs", ".", "Params", ":", "-", "name", ":", "filter", "to", "search", "the", "contribs", "-", "ret", ":", "whether", "the", "function", "should", "return", "a", "dict", "instead", "of", "printing", "i...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/main.py#L191-L249
[ "def", "list_contrib", "(", "name", "=", "None", ",", "ret", "=", "False", ",", "_debug", "=", "False", ")", ":", "# _debug: checks that all contrib modules have correctly defined:", "# # scapy.contrib.description = [...]", "# # scapy.contrib.status = [...]", "# # scapy.contrib...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
save_session
Save current Scapy session to the file specified in the fname arg. params: - fname: file to save the scapy session in - session: scapy session to use. If None, the console one will be used - pickleProto: pickle proto version (default: -1 = latest)
scapy/main.py
def save_session(fname=None, session=None, pickleProto=-1): """Save current Scapy session to the file specified in the fname arg. params: - fname: file to save the scapy session in - session: scapy session to use. If None, the console one will be used - pickleProto: pickle proto version (default...
def save_session(fname=None, session=None, pickleProto=-1): """Save current Scapy session to the file specified in the fname arg. params: - fname: file to save the scapy session in - session: scapy session to use. If None, the console one will be used - pickleProto: pickle proto version (default...
[ "Save", "current", "Scapy", "session", "to", "the", "file", "specified", "in", "the", "fname", "arg", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/main.py#L265-L308
[ "def", "save_session", "(", "fname", "=", "None", ",", "session", "=", "None", ",", "pickleProto", "=", "-", "1", ")", ":", "from", "scapy", "import", "utils", "if", "fname", "is", "None", ":", "fname", "=", "conf", ".", "session", "if", "not", "fnam...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
load_session
Load current Scapy session from the file specified in the fname arg. This will erase any existing session. params: - fname: file to load the scapy session from
scapy/main.py
def load_session(fname=None): """Load current Scapy session from the file specified in the fname arg. This will erase any existing session. params: - fname: file to load the scapy session from""" if fname is None: fname = conf.session try: s = six.moves.cPickle.load(gzip.open(f...
def load_session(fname=None): """Load current Scapy session from the file specified in the fname arg. This will erase any existing session. params: - fname: file to load the scapy session from""" if fname is None: fname = conf.session try: s = six.moves.cPickle.load(gzip.open(f...
[ "Load", "current", "Scapy", "session", "from", "the", "file", "specified", "in", "the", "fname", "arg", ".", "This", "will", "erase", "any", "existing", "session", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/main.py#L311-L333
[ "def", "load_session", "(", "fname", "=", "None", ")", ":", "if", "fname", "is", "None", ":", "fname", "=", "conf", ".", "session", "try", ":", "s", "=", "six", ".", "moves", ".", "cPickle", ".", "load", "(", "gzip", ".", "open", "(", "fname", ",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
update_session
Update current Scapy session from the file specified in the fname arg. params: - fname: file to load the scapy session from
scapy/main.py
def update_session(fname=None): """Update current Scapy session from the file specified in the fname arg. params: - fname: file to load the scapy session from""" if fname is None: fname = conf.session try: s = six.moves.cPickle.load(gzip.open(fname, "rb")) except IOError: ...
def update_session(fname=None): """Update current Scapy session from the file specified in the fname arg. params: - fname: file to load the scapy session from""" if fname is None: fname = conf.session try: s = six.moves.cPickle.load(gzip.open(fname, "rb")) except IOError: ...
[ "Update", "current", "Scapy", "session", "from", "the", "file", "specified", "in", "the", "fname", "arg", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/main.py#L336-L349
[ "def", "update_session", "(", "fname", "=", "None", ")", ":", "if", "fname", "is", "None", ":", "fname", "=", "conf", ".", "session", "try", ":", "s", "=", "six", ".", "moves", ".", "cPickle", ".", "load", "(", "gzip", ".", "open", "(", "fname", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_prepare_quote
This function processes a quote and returns a string that is ready to be used in the fancy prompt.
scapy/main.py
def _prepare_quote(quote, author, max_len=78): """This function processes a quote and returns a string that is ready to be used in the fancy prompt. """ quote = quote.split(' ') max_len -= 6 lines = [] cur_line = [] def _len(line): return sum(len(elt) for elt in line) + len(line) -...
def _prepare_quote(quote, author, max_len=78): """This function processes a quote and returns a string that is ready to be used in the fancy prompt. """ quote = quote.split(' ') max_len -= 6 lines = [] cur_line = [] def _len(line): return sum(len(elt) for elt in line) + len(line) -...
[ "This", "function", "processes", "a", "quote", "and", "returns", "a", "string", "that", "is", "ready", "to", "be", "used", "in", "the", "fancy", "prompt", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/main.py#L413-L435
[ "def", "_prepare_quote", "(", "quote", ",", "author", ",", "max_len", "=", "78", ")", ":", "quote", "=", "quote", ".", "split", "(", "' '", ")", "max_len", "-=", "6", "lines", "=", "[", "]", "cur_line", "=", "[", "]", "def", "_len", "(", "line", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
autorun_get_interactive_session
Create an interactive session and execute the commands passed as "cmds" and return all output params: - cmds: a list of commands to run returns: (output, returned) The output contains both sys.stdout and sys.stderr logs
scapy/autorun.py
def autorun_get_interactive_session(cmds, **kargs): """Create an interactive session and execute the commands passed as "cmds" and return all output params: - cmds: a list of commands to run returns: (output, returned) The output contains both sys.stdout and sys.stderr logs""" sstdout, s...
def autorun_get_interactive_session(cmds, **kargs): """Create an interactive session and execute the commands passed as "cmds" and return all output params: - cmds: a list of commands to run returns: (output, returned) The output contains both sys.stdout and sys.stderr logs""" sstdout, s...
[ "Create", "an", "interactive", "session", "and", "execute", "the", "commands", "passed", "as", "cmds", "and", "return", "all", "output" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/autorun.py#L103-L123
[ "def", "autorun_get_interactive_session", "(", "cmds", ",", "*", "*", "kargs", ")", ":", "sstdout", ",", "sstderr", "=", "sys", ".", "stdout", ",", "sys", ".", "stderr", "sw", "=", "StringWriter", "(", ")", "try", ":", "try", ":", "sys", ".", "stdout",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
LEBitField._check_field_type
check if the field addressed by given index relative to this field shares type of this field so we can catch a mix of LEBitField and BitField/other types
scapy/contrib/ethercat.py
def _check_field_type(self, pkt, index): """ check if the field addressed by given index relative to this field shares type of this field so we can catch a mix of LEBitField and BitField/other types """ my_idx = pkt.fields_desc.index(self) try: next_fi...
def _check_field_type(self, pkt, index): """ check if the field addressed by given index relative to this field shares type of this field so we can catch a mix of LEBitField and BitField/other types """ my_idx = pkt.fields_desc.index(self) try: next_fi...
[ "check", "if", "the", "field", "addressed", "by", "given", "index", "relative", "to", "this", "field", "shares", "type", "of", "this", "field", "so", "we", "can", "catch", "a", "mix", "of", "LEBitField", "and", "BitField", "/", "other", "types" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/ethercat.py#L78-L96
[ "def", "_check_field_type", "(", "self", ",", "pkt", ",", "index", ")", ":", "my_idx", "=", "pkt", ".", "fields_desc", ".", "index", "(", "self", ")", "try", ":", "next_field", "=", "pkt", ".", "fields_desc", "[", "my_idx", "+", "index", "]", "if", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
LEBitField.getfield
extract data from raw str collect all instances belonging to the bit field set. if we reach a field that ends at a octet boundary, dissect the whole bit field at once # noqa: E501 :param pkt: packet instance the field belongs to :param s: raw string representing the frame -or- tuple c...
scapy/contrib/ethercat.py
def getfield(self, pkt, s): """ extract data from raw str collect all instances belonging to the bit field set. if we reach a field that ends at a octet boundary, dissect the whole bit field at once # noqa: E501 :param pkt: packet instance the field belongs to :param ...
def getfield(self, pkt, s): """ extract data from raw str collect all instances belonging to the bit field set. if we reach a field that ends at a octet boundary, dissect the whole bit field at once # noqa: E501 :param pkt: packet instance the field belongs to :param ...
[ "extract", "data", "from", "raw", "str" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/ethercat.py#L160-L251
[ "def", "getfield", "(", "self", ",", "pkt", ",", "s", ")", ":", "if", "type", "(", "s", ")", "is", "tuple", "and", "len", "(", "s", ")", "==", "3", ":", "s", ",", "bits_in_set", ",", "fields", "=", "s", "else", ":", "bits_in_set", "=", "0", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
EtherCat.post_build
need to set the length of the whole PDU manually to avoid any bit fiddling use a dummy class to build the layer content also add padding if frame is < 64 bytes Note: padding only handles Ether/n*Dot1Q/EtherCat (no special mumbo jumbo) :param pkt: raw string containing th...
scapy/contrib/ethercat.py
def post_build(self, pkt, pay): """ need to set the length of the whole PDU manually to avoid any bit fiddling use a dummy class to build the layer content also add padding if frame is < 64 bytes Note: padding only handles Ether/n*Dot1Q/EtherCat (no special mumbo ...
def post_build(self, pkt, pay): """ need to set the length of the whole PDU manually to avoid any bit fiddling use a dummy class to build the layer content also add padding if frame is < 64 bytes Note: padding only handles Ether/n*Dot1Q/EtherCat (no special mumbo ...
[ "need", "to", "set", "the", "length", "of", "the", "whole", "PDU", "manually", "to", "avoid", "any", "bit", "fiddling", "use", "a", "dummy", "class", "to", "build", "the", "layer", "content" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/ethercat.py#L561-L619
[ "def", "post_build", "(", "self", ",", "pkt", ",", "pay", ")", ":", "class", "_EtherCatLengthCalc", "(", "Packet", ")", ":", "\"\"\"\n dummy class used to generate str representation easily\n \"\"\"", "fields_desc", "=", "[", "LEBitField", "(", "'len...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
get_source_addr_from_candidate_set
This function implement a limited version of source address selection algorithm defined in section 5 of RFC 3484. The format is very different from that described in the document because it operates on a set of candidate source address for some specific route.
scapy/utils6.py
def get_source_addr_from_candidate_set(dst, candidate_set): """ This function implement a limited version of source address selection algorithm defined in section 5 of RFC 3484. The format is very different from that described in the document because it operates on a set of candidate source address ...
def get_source_addr_from_candidate_set(dst, candidate_set): """ This function implement a limited version of source address selection algorithm defined in section 5 of RFC 3484. The format is very different from that described in the document because it operates on a set of candidate source address ...
[ "This", "function", "implement", "a", "limited", "version", "of", "source", "address", "selection", "algorithm", "defined", "in", "section", "5", "of", "RFC", "3484", ".", "The", "format", "is", "very", "different", "from", "that", "described", "in", "the", ...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L86-L165
[ "def", "get_source_addr_from_candidate_set", "(", "dst", ",", "candidate_set", ")", ":", "def", "scope_cmp", "(", "a", ",", "b", ")", ":", "\"\"\"\n Given two addresses, returns -1, 0 or 1 based on comparison of\n their scope\n \"\"\"", "scope_mapper", "=", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
in6_mactoifaceid
Compute the interface ID in modified EUI-64 format associated to the Ethernet address provided as input. value taken by U/L bit in the interface identifier is basically the reversed value of that in given MAC address it can be forced to a specific value by using optional 'ulbit' parameter.
scapy/utils6.py
def in6_mactoifaceid(mac, ulbit=None): """ Compute the interface ID in modified EUI-64 format associated to the Ethernet address provided as input. value taken by U/L bit in the interface identifier is basically the reversed value of that in given MAC address it can be forced to a specific value...
def in6_mactoifaceid(mac, ulbit=None): """ Compute the interface ID in modified EUI-64 format associated to the Ethernet address provided as input. value taken by U/L bit in the interface identifier is basically the reversed value of that in given MAC address it can be forced to a specific value...
[ "Compute", "the", "interface", "ID", "in", "modified", "EUI", "-", "64", "format", "associated", "to", "the", "Ethernet", "address", "provided", "as", "input", ".", "value", "taken", "by", "U", "/", "L", "bit", "in", "the", "interface", "identifier", "is",...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L203-L222
[ "def", "in6_mactoifaceid", "(", "mac", ",", "ulbit", "=", "None", ")", ":", "if", "len", "(", "mac", ")", "!=", "17", ":", "return", "None", "m", "=", "\"\"", ".", "join", "(", "mac", ".", "split", "(", "':'", ")", ")", "if", "len", "(", "m", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
in6_ifaceidtomac
Extract the mac address from provided iface ID. Iface ID is provided in printable format ("XXXX:XXFF:FEXX:XXXX", eventually compressed). None is returned on error.
scapy/utils6.py
def in6_ifaceidtomac(ifaceid): """ Extract the mac address from provided iface ID. Iface ID is provided in printable format ("XXXX:XXFF:FEXX:XXXX", eventually compressed). None is returned on error. """ try: # Set ifaceid to a binary form ifaceid = inet_pton(socket.AF_INET6, "::"...
def in6_ifaceidtomac(ifaceid): """ Extract the mac address from provided iface ID. Iface ID is provided in printable format ("XXXX:XXFF:FEXX:XXXX", eventually compressed). None is returned on error. """ try: # Set ifaceid to a binary form ifaceid = inet_pton(socket.AF_INET6, "::"...
[ "Extract", "the", "mac", "address", "from", "provided", "iface", "ID", ".", "Iface", "ID", "is", "provided", "in", "printable", "format", "(", "XXXX", ":", "XXFF", ":", "FEXX", ":", "XXXX", "eventually", "compressed", ")", ".", "None", "is", "returned", ...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L225-L248
[ "def", "in6_ifaceidtomac", "(", "ifaceid", ")", ":", "try", ":", "# Set ifaceid to a binary form", "ifaceid", "=", "inet_pton", "(", "socket", ".", "AF_INET6", ",", "\"::\"", "+", "ifaceid", ")", "[", "8", ":", "16", "]", "except", "Exception", ":", "return"...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
in6_addrtomac
Extract the mac address from provided address. None is returned on error.
scapy/utils6.py
def in6_addrtomac(addr): """ Extract the mac address from provided address. None is returned on error. """ mask = inet_pton(socket.AF_INET6, "::ffff:ffff:ffff:ffff") x = in6_and(mask, inet_pton(socket.AF_INET6, addr)) ifaceid = inet_ntop(socket.AF_INET6, x)[2:] return in6_ifaceidtomac(if...
def in6_addrtomac(addr): """ Extract the mac address from provided address. None is returned on error. """ mask = inet_pton(socket.AF_INET6, "::ffff:ffff:ffff:ffff") x = in6_and(mask, inet_pton(socket.AF_INET6, addr)) ifaceid = inet_ntop(socket.AF_INET6, x)[2:] return in6_ifaceidtomac(if...
[ "Extract", "the", "mac", "address", "from", "provided", "address", ".", "None", "is", "returned", "on", "error", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L251-L259
[ "def", "in6_addrtomac", "(", "addr", ")", ":", "mask", "=", "inet_pton", "(", "socket", ".", "AF_INET6", ",", "\"::ffff:ffff:ffff:ffff\"", ")", "x", "=", "in6_and", "(", "mask", ",", "inet_pton", "(", "socket", ".", "AF_INET6", ",", "addr", ")", ")", "if...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
in6_addrtovendor
Extract the MAC address from a modified EUI-64 constructed IPv6 address provided and use the IANA oui.txt file to get the vendor. The database used for the conversion is the one loaded by Scapy from a Wireshark installation if discovered in a well-known location. None is returned on error, "UNKNOWN" if ...
scapy/utils6.py
def in6_addrtovendor(addr): """ Extract the MAC address from a modified EUI-64 constructed IPv6 address provided and use the IANA oui.txt file to get the vendor. The database used for the conversion is the one loaded by Scapy from a Wireshark installation if discovered in a well-known location. ...
def in6_addrtovendor(addr): """ Extract the MAC address from a modified EUI-64 constructed IPv6 address provided and use the IANA oui.txt file to get the vendor. The database used for the conversion is the one loaded by Scapy from a Wireshark installation if discovered in a well-known location. ...
[ "Extract", "the", "MAC", "address", "from", "a", "modified", "EUI", "-", "64", "constructed", "IPv6", "address", "provided", "and", "use", "the", "IANA", "oui", ".", "txt", "file", "to", "get", "the", "vendor", ".", "The", "database", "used", "for", "the...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L262-L279
[ "def", "in6_addrtovendor", "(", "addr", ")", ":", "mac", "=", "in6_addrtomac", "(", "addr", ")", "if", "mac", "is", "None", "or", "conf", ".", "manufdb", "is", "None", ":", "return", "None", "res", "=", "conf", ".", "manufdb", ".", "_get_manuf", "(", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
in6_getLinkScopedMcastAddr
Generate a Link-Scoped Multicast Address as described in RFC 4489. Returned value is in printable notation. 'addr' parameter specifies the link-local address to use for generating Link-scoped multicast address IID. By default, the function returns a ::/96 prefix (aka last 32 bits of returned addre...
scapy/utils6.py
def in6_getLinkScopedMcastAddr(addr, grpid=None, scope=2): """ Generate a Link-Scoped Multicast Address as described in RFC 4489. Returned value is in printable notation. 'addr' parameter specifies the link-local address to use for generating Link-scoped multicast address IID. By default, the ...
def in6_getLinkScopedMcastAddr(addr, grpid=None, scope=2): """ Generate a Link-Scoped Multicast Address as described in RFC 4489. Returned value is in printable notation. 'addr' parameter specifies the link-local address to use for generating Link-scoped multicast address IID. By default, the ...
[ "Generate", "a", "Link", "-", "Scoped", "Multicast", "Address", "as", "described", "in", "RFC", "4489", ".", "Returned", "value", "is", "in", "printable", "notation", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L282-L338
[ "def", "in6_getLinkScopedMcastAddr", "(", "addr", ",", "grpid", "=", "None", ",", "scope", "=", "2", ")", ":", "if", "scope", "not", "in", "[", "0", ",", "1", ",", "2", "]", ":", "return", "None", "try", ":", "if", "not", "in6_islladdr", "(", "addr...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
in6_getLocalUniquePrefix
Returns a pseudo-randomly generated Local Unique prefix. Function follows recommendation of Section 3.2.2 of RFC 4193 for prefix generation.
scapy/utils6.py
def in6_getLocalUniquePrefix(): """ Returns a pseudo-randomly generated Local Unique prefix. Function follows recommendation of Section 3.2.2 of RFC 4193 for prefix generation. """ # Extracted from RFC 1305 (NTP) : # NTP timestamps are represented as a 64-bit unsigned fixed-point number, ...
def in6_getLocalUniquePrefix(): """ Returns a pseudo-randomly generated Local Unique prefix. Function follows recommendation of Section 3.2.2 of RFC 4193 for prefix generation. """ # Extracted from RFC 1305 (NTP) : # NTP timestamps are represented as a 64-bit unsigned fixed-point number, ...
[ "Returns", "a", "pseudo", "-", "randomly", "generated", "Local", "Unique", "prefix", ".", "Function", "follows", "recommendation", "of", "Section", "3", ".", "2", ".", "2", "of", "RFC", "4193", "for", "prefix", "generation", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L369-L395
[ "def", "in6_getLocalUniquePrefix", "(", ")", ":", "# Extracted from RFC 1305 (NTP) :", "# NTP timestamps are represented as a 64-bit unsigned fixed-point number,", "# in seconds relative to 0h on 1 January 1900. The integer part is in the", "# first 32 bits and the fraction part in the last 32 bits....
3ffe757c184017dd46464593a8f80f85abc1e79a
train
in6_getRandomizedIfaceId
Implements the interface ID generation algorithm described in RFC 3041. The function takes the Modified EUI-64 interface identifier generated as described in RFC 4291 and an optional previous history value (the first element of the output of this function). If no previous interface identifier is provide...
scapy/utils6.py
def in6_getRandomizedIfaceId(ifaceid, previous=None): """ Implements the interface ID generation algorithm described in RFC 3041. The function takes the Modified EUI-64 interface identifier generated as described in RFC 4291 and an optional previous history value (the first element of the output of ...
def in6_getRandomizedIfaceId(ifaceid, previous=None): """ Implements the interface ID generation algorithm described in RFC 3041. The function takes the Modified EUI-64 interface identifier generated as described in RFC 4291 and an optional previous history value (the first element of the output of ...
[ "Implements", "the", "interface", "ID", "generation", "algorithm", "described", "in", "RFC", "3041", ".", "The", "function", "takes", "the", "Modified", "EUI", "-", "64", "interface", "identifier", "generated", "as", "described", "in", "RFC", "4291", "and", "a...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L398-L430
[ "def", "in6_getRandomizedIfaceId", "(", "ifaceid", ",", "previous", "=", "None", ")", ":", "s", "=", "b\"\"", "if", "previous", "is", "None", ":", "d", "=", "b\"\"", ".", "join", "(", "chb", "(", "x", ")", "for", "x", "in", "range", "(", "256", ")"...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
in6_ptoc
Converts an IPv6 address in printable representation to RFC 1924 Compact Representation ;-) Returns None on error.
scapy/utils6.py
def in6_ptoc(addr): """ Converts an IPv6 address in printable representation to RFC 1924 Compact Representation ;-) Returns None on error. """ try: d = struct.unpack("!IIII", inet_pton(socket.AF_INET6, addr)) except Exception: return None res = 0 m = [2**96, 2**64, 2*...
def in6_ptoc(addr): """ Converts an IPv6 address in printable representation to RFC 1924 Compact Representation ;-) Returns None on error. """ try: d = struct.unpack("!IIII", inet_pton(socket.AF_INET6, addr)) except Exception: return None res = 0 m = [2**96, 2**64, 2*...
[ "Converts", "an", "IPv6", "address", "in", "printable", "representation", "to", "RFC", "1924", "Compact", "Representation", ";", "-", ")", "Returns", "None", "on", "error", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L462-L482
[ "def", "in6_ptoc", "(", "addr", ")", ":", "try", ":", "d", "=", "struct", ".", "unpack", "(", "\"!IIII\"", ",", "inet_pton", "(", "socket", ".", "AF_INET6", ",", "addr", ")", ")", "except", "Exception", ":", "return", "None", "res", "=", "0", "m", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
in6_isaddrTeredo
Return True if provided address is a Teredo, meaning it is under the /32 conf.teredoPrefix prefix value (by default, 2001::). Otherwise, False is returned. Address must be passed in printable format.
scapy/utils6.py
def in6_isaddrTeredo(x): """ Return True if provided address is a Teredo, meaning it is under the /32 conf.teredoPrefix prefix value (by default, 2001::). Otherwise, False is returned. Address must be passed in printable format. """ our = inet_pton(socket.AF_INET6, x)[0:4] teredoPrefix =...
def in6_isaddrTeredo(x): """ Return True if provided address is a Teredo, meaning it is under the /32 conf.teredoPrefix prefix value (by default, 2001::). Otherwise, False is returned. Address must be passed in printable format. """ our = inet_pton(socket.AF_INET6, x)[0:4] teredoPrefix =...
[ "Return", "True", "if", "provided", "address", "is", "a", "Teredo", "meaning", "it", "is", "under", "the", "/", "32", "conf", ".", "teredoPrefix", "prefix", "value", "(", "by", "default", "2001", "::", ")", ".", "Otherwise", "False", "is", "returned", "....
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L498-L507
[ "def", "in6_isaddrTeredo", "(", "x", ")", ":", "our", "=", "inet_pton", "(", "socket", ".", "AF_INET6", ",", "x", ")", "[", "0", ":", "4", "]", "teredoPrefix", "=", "inet_pton", "(", "socket", ".", "AF_INET6", ",", "conf", ".", "teredoPrefix", ")", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
teredoAddrExtractInfo
Extract information from a Teredo address. Return value is a 4-tuple made of IPv4 address of Teredo server, flag value (int), mapped address (non obfuscated) and mapped port (non obfuscated). No specific checks are performed on passed address.
scapy/utils6.py
def teredoAddrExtractInfo(x): """ Extract information from a Teredo address. Return value is a 4-tuple made of IPv4 address of Teredo server, flag value (int), mapped address (non obfuscated) and mapped port (non obfuscated). No specific checks are performed on passed address. """ addr = ine...
def teredoAddrExtractInfo(x): """ Extract information from a Teredo address. Return value is a 4-tuple made of IPv4 address of Teredo server, flag value (int), mapped address (non obfuscated) and mapped port (non obfuscated). No specific checks are performed on passed address. """ addr = ine...
[ "Extract", "information", "from", "a", "Teredo", "address", ".", "Return", "value", "is", "a", "4", "-", "tuple", "made", "of", "IPv4", "address", "of", "Teredo", "server", "flag", "value", "(", "int", ")", "mapped", "address", "(", "non", "obfuscated", ...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L510-L522
[ "def", "teredoAddrExtractInfo", "(", "x", ")", ":", "addr", "=", "inet_pton", "(", "socket", ".", "AF_INET6", ",", "x", ")", "server", "=", "inet_ntop", "(", "socket", ".", "AF_INET", ",", "addr", "[", "4", ":", "8", "]", ")", "flag", "=", "struct", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
in6_iseui64
Return True if provided address has an interface identifier part created in modified EUI-64 format (meaning it matches *::*:*ff:fe*:*). Otherwise, False is returned. Address must be passed in printable format.
scapy/utils6.py
def in6_iseui64(x): """ Return True if provided address has an interface identifier part created in modified EUI-64 format (meaning it matches *::*:*ff:fe*:*). Otherwise, False is returned. Address must be passed in printable format. """ eui64 = inet_pton(socket.AF_INET6, '::ff:fe00:0') ...
def in6_iseui64(x): """ Return True if provided address has an interface identifier part created in modified EUI-64 format (meaning it matches *::*:*ff:fe*:*). Otherwise, False is returned. Address must be passed in printable format. """ eui64 = inet_pton(socket.AF_INET6, '::ff:fe00:0') ...
[ "Return", "True", "if", "provided", "address", "has", "an", "interface", "identifier", "part", "created", "in", "modified", "EUI", "-", "64", "format", "(", "meaning", "it", "matches", "*", "::", "*", ":", "*", "ff", ":", "fe", "*", ":", "*", ")", "....
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L525-L534
[ "def", "in6_iseui64", "(", "x", ")", ":", "eui64", "=", "inet_pton", "(", "socket", ".", "AF_INET6", ",", "'::ff:fe00:0'", ")", "x", "=", "in6_and", "(", "inet_pton", "(", "socket", ".", "AF_INET6", ",", "x", ")", ",", "eui64", ")", "return", "x", "=...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
in6_getnsma
Return link-local solicited-node multicast address for given address. Passed address must be provided in network format. Returned value is also in network format.
scapy/utils6.py
def in6_getnsma(a): """ Return link-local solicited-node multicast address for given address. Passed address must be provided in network format. Returned value is also in network format. """ r = in6_and(a, inet_pton(socket.AF_INET6, '::ff:ffff')) r = in6_or(inet_pton(socket.AF_INET6, 'ff02:...
def in6_getnsma(a): """ Return link-local solicited-node multicast address for given address. Passed address must be provided in network format. Returned value is also in network format. """ r = in6_and(a, inet_pton(socket.AF_INET6, '::ff:ffff')) r = in6_or(inet_pton(socket.AF_INET6, 'ff02:...
[ "Return", "link", "-", "local", "solicited", "-", "node", "multicast", "address", "for", "given", "address", ".", "Passed", "address", "must", "be", "provided", "in", "network", "format", ".", "Returned", "value", "is", "also", "in", "network", "format", "."...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L611-L620
[ "def", "in6_getnsma", "(", "a", ")", ":", "r", "=", "in6_and", "(", "a", ",", "inet_pton", "(", "socket", ".", "AF_INET6", ",", "'::ff:ffff'", ")", ")", "r", "=", "in6_or", "(", "inet_pton", "(", "socket", ".", "AF_INET6", ",", "'ff02::1:ff00:0'", ")",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
in6_getha
Return the anycast address associated with all home agents on a given subnet.
scapy/utils6.py
def in6_getha(prefix): """ Return the anycast address associated with all home agents on a given subnet. """ r = in6_and(inet_pton(socket.AF_INET6, prefix), in6_cidr2mask(64)) r = in6_or(r, inet_pton(socket.AF_INET6, '::fdff:ffff:ffff:fffe')) return inet_ntop(socket.AF_INET6, r)
def in6_getha(prefix): """ Return the anycast address associated with all home agents on a given subnet. """ r = in6_and(inet_pton(socket.AF_INET6, prefix), in6_cidr2mask(64)) r = in6_or(r, inet_pton(socket.AF_INET6, '::fdff:ffff:ffff:fffe')) return inet_ntop(socket.AF_INET6, r)
[ "Return", "the", "anycast", "address", "associated", "with", "all", "home", "agents", "on", "a", "given", "subnet", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L635-L642
[ "def", "in6_getha", "(", "prefix", ")", ":", "r", "=", "in6_and", "(", "inet_pton", "(", "socket", ".", "AF_INET6", ",", "prefix", ")", ",", "in6_cidr2mask", "(", "64", ")", ")", "r", "=", "in6_or", "(", "r", ",", "inet_pton", "(", "socket", ".", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
in6_isincluded
Returns True when 'addr' belongs to prefix/plen. False otherwise.
scapy/utils6.py
def in6_isincluded(addr, prefix, plen): """ Returns True when 'addr' belongs to prefix/plen. False otherwise. """ temp = inet_pton(socket.AF_INET6, addr) pref = in6_cidr2mask(plen) zero = inet_pton(socket.AF_INET6, prefix) return zero == in6_and(temp, pref)
def in6_isincluded(addr, prefix, plen): """ Returns True when 'addr' belongs to prefix/plen. False otherwise. """ temp = inet_pton(socket.AF_INET6, addr) pref = in6_cidr2mask(plen) zero = inet_pton(socket.AF_INET6, prefix) return zero == in6_and(temp, pref)
[ "Returns", "True", "when", "addr", "belongs", "to", "prefix", "/", "plen", ".", "False", "otherwise", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L653-L660
[ "def", "in6_isincluded", "(", "addr", ",", "prefix", ",", "plen", ")", ":", "temp", "=", "inet_pton", "(", "socket", ".", "AF_INET6", ",", "addr", ")", "pref", "=", "in6_cidr2mask", "(", "plen", ")", "zero", "=", "inet_pton", "(", "socket", ".", "AF_IN...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
in6_isllsnmaddr
Return True if provided address is a link-local solicited node multicast address, i.e. belongs to ff02::1:ff00:0/104. False is returned otherwise.
scapy/utils6.py
def in6_isllsnmaddr(str): """ Return True if provided address is a link-local solicited node multicast address, i.e. belongs to ff02::1:ff00:0/104. False is returned otherwise. """ temp = in6_and(b"\xff" * 13 + b"\x00" * 3, inet_pton(socket.AF_INET6, str)) temp2 = b'\xff\x02\x00\x00\x00\x00\...
def in6_isllsnmaddr(str): """ Return True if provided address is a link-local solicited node multicast address, i.e. belongs to ff02::1:ff00:0/104. False is returned otherwise. """ temp = in6_and(b"\xff" * 13 + b"\x00" * 3, inet_pton(socket.AF_INET6, str)) temp2 = b'\xff\x02\x00\x00\x00\x00\...
[ "Return", "True", "if", "provided", "address", "is", "a", "link", "-", "local", "solicited", "node", "multicast", "address", "i", ".", "e", ".", "belongs", "to", "ff02", "::", "1", ":", "ff00", ":", "0", "/", "104", ".", "False", "is", "returned", "o...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L663-L671
[ "def", "in6_isllsnmaddr", "(", "str", ")", ":", "temp", "=", "in6_and", "(", "b\"\\xff\"", "*", "13", "+", "b\"\\x00\"", "*", "3", ",", "inet_pton", "(", "socket", ".", "AF_INET6", ",", "str", ")", ")", "temp2", "=", "b'\\xff\\x02\\x00\\x00\\x00\\x00\\x00\\x...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
in6_getscope
Returns the scope of the address.
scapy/utils6.py
def in6_getscope(addr): """ Returns the scope of the address. """ if in6_isgladdr(addr) or in6_isuladdr(addr): scope = IPV6_ADDR_GLOBAL elif in6_islladdr(addr): scope = IPV6_ADDR_LINKLOCAL elif in6_issladdr(addr): scope = IPV6_ADDR_SITELOCAL elif in6_ismaddr(addr): ...
def in6_getscope(addr): """ Returns the scope of the address. """ if in6_isgladdr(addr) or in6_isuladdr(addr): scope = IPV6_ADDR_GLOBAL elif in6_islladdr(addr): scope = IPV6_ADDR_LINKLOCAL elif in6_issladdr(addr): scope = IPV6_ADDR_SITELOCAL elif in6_ismaddr(addr): ...
[ "Returns", "the", "scope", "of", "the", "address", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L783-L808
[ "def", "in6_getscope", "(", "addr", ")", ":", "if", "in6_isgladdr", "(", "addr", ")", "or", "in6_isuladdr", "(", "addr", ")", ":", "scope", "=", "IPV6_ADDR_GLOBAL", "elif", "in6_islladdr", "(", "addr", ")", ":", "scope", "=", "IPV6_ADDR_LINKLOCAL", "elif", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
in6_get_common_plen
Return common prefix length of IPv6 addresses a and b.
scapy/utils6.py
def in6_get_common_plen(a, b): """ Return common prefix length of IPv6 addresses a and b. """ def matching_bits(byte1, byte2): for i in range(8): cur_mask = 0x80 >> i if (byte1 & cur_mask) != (byte2 & cur_mask): return i return 8 tmpA = inet_p...
def in6_get_common_plen(a, b): """ Return common prefix length of IPv6 addresses a and b. """ def matching_bits(byte1, byte2): for i in range(8): cur_mask = 0x80 >> i if (byte1 & cur_mask) != (byte2 & cur_mask): return i return 8 tmpA = inet_p...
[ "Return", "common", "prefix", "length", "of", "IPv6", "addresses", "a", "and", "b", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L811-L828
[ "def", "in6_get_common_plen", "(", "a", ",", "b", ")", ":", "def", "matching_bits", "(", "byte1", ",", "byte2", ")", ":", "for", "i", "in", "range", "(", "8", ")", ":", "cur_mask", "=", "0x80", ">>", "i", "if", "(", "byte1", "&", "cur_mask", ")", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
in6_isvalid
Return True if 'address' is a valid IPv6 address string, False otherwise.
scapy/utils6.py
def in6_isvalid(address): """Return True if 'address' is a valid IPv6 address string, False otherwise.""" try: socket.inet_pton(socket.AF_INET6, address) return True except Exception: return False
def in6_isvalid(address): """Return True if 'address' is a valid IPv6 address string, False otherwise.""" try: socket.inet_pton(socket.AF_INET6, address) return True except Exception: return False
[ "Return", "True", "if", "address", "is", "a", "valid", "IPv6", "address", "string", "False", "otherwise", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L831-L839
[ "def", "in6_isvalid", "(", "address", ")", ":", "try", ":", "socket", ".", "inet_pton", "(", "socket", ".", "AF_INET6", ",", "address", ")", "return", "True", "except", "Exception", ":", "return", "False" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
train
get_if_raw_addr
Returns the IPv4 address configured on 'ifname', packed with inet_pton.
scapy/arch/bpf/core.py
def get_if_raw_addr(ifname): """Returns the IPv4 address configured on 'ifname', packed with inet_pton.""" # noqa: E501 # Get ifconfig output try: fd = os.popen("%s %s" % (conf.prog.ifconfig, ifname)) except OSError as msg: warning("Failed to execute ifconfig: (%s)", msg) retur...
def get_if_raw_addr(ifname): """Returns the IPv4 address configured on 'ifname', packed with inet_pton.""" # noqa: E501 # Get ifconfig output try: fd = os.popen("%s %s" % (conf.prog.ifconfig, ifname)) except OSError as msg: warning("Failed to execute ifconfig: (%s)", msg) retur...
[ "Returns", "the", "IPv4", "address", "configured", "on", "ifname", "packed", "with", "inet_pton", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/core.py#L36-L56
[ "def", "get_if_raw_addr", "(", "ifname", ")", ":", "# noqa: E501", "# Get ifconfig output", "try", ":", "fd", "=", "os", ".", "popen", "(", "\"%s %s\"", "%", "(", "conf", ".", "prog", ".", "ifconfig", ",", "ifname", ")", ")", "except", "OSError", "as", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
get_if_raw_hwaddr
Returns the packed MAC address configured on 'ifname'.
scapy/arch/bpf/core.py
def get_if_raw_hwaddr(ifname): """Returns the packed MAC address configured on 'ifname'.""" NULL_MAC_ADDRESS = b'\x00' * 6 # Handle the loopback interface separately if ifname == LOOPBACK_NAME: return (ARPHDR_LOOPBACK, NULL_MAC_ADDRESS) # Get ifconfig output try: fd = os.popen...
def get_if_raw_hwaddr(ifname): """Returns the packed MAC address configured on 'ifname'.""" NULL_MAC_ADDRESS = b'\x00' * 6 # Handle the loopback interface separately if ifname == LOOPBACK_NAME: return (ARPHDR_LOOPBACK, NULL_MAC_ADDRESS) # Get ifconfig output try: fd = os.popen...
[ "Returns", "the", "packed", "MAC", "address", "configured", "on", "ifname", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/core.py#L59-L84
[ "def", "get_if_raw_hwaddr", "(", "ifname", ")", ":", "NULL_MAC_ADDRESS", "=", "b'\\x00'", "*", "6", "# Handle the loopback interface separately", "if", "ifname", "==", "LOOPBACK_NAME", ":", "return", "(", "ARPHDR_LOOPBACK", ",", "NULL_MAC_ADDRESS", ")", "# Get ifconfig ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
get_dev_bpf
Returns an opened BPF file object
scapy/arch/bpf/core.py
def get_dev_bpf(): """Returns an opened BPF file object""" # Get the first available BPF handle for bpf in range(256): try: fd = os.open("/dev/bpf%i" % bpf, os.O_RDWR) return (fd, bpf) except OSError: continue raise Scapy_Exception("No /dev/bpf handl...
def get_dev_bpf(): """Returns an opened BPF file object""" # Get the first available BPF handle for bpf in range(256): try: fd = os.open("/dev/bpf%i" % bpf, os.O_RDWR) return (fd, bpf) except OSError: continue raise Scapy_Exception("No /dev/bpf handl...
[ "Returns", "an", "opened", "BPF", "file", "object" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/core.py#L89-L100
[ "def", "get_dev_bpf", "(", ")", ":", "# Get the first available BPF handle", "for", "bpf", "in", "range", "(", "256", ")", ":", "try", ":", "fd", "=", "os", ".", "open", "(", "\"/dev/bpf%i\"", "%", "bpf", ",", "os", ".", "O_RDWR", ")", "return", "(", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
attach_filter
Attach a BPF filter to the BPF file descriptor
scapy/arch/bpf/core.py
def attach_filter(fd, bpf_filter, iface): """Attach a BPF filter to the BPF file descriptor""" bp = compile_filter(bpf_filter, iface) # Assign the BPF program to the interface ret = LIBC.ioctl(c_int(fd), BIOCSETF, cast(pointer(bp), c_char_p)) if ret < 0: raise Scapy_Exception("Can't attach t...
def attach_filter(fd, bpf_filter, iface): """Attach a BPF filter to the BPF file descriptor""" bp = compile_filter(bpf_filter, iface) # Assign the BPF program to the interface ret = LIBC.ioctl(c_int(fd), BIOCSETF, cast(pointer(bp), c_char_p)) if ret < 0: raise Scapy_Exception("Can't attach t...
[ "Attach", "a", "BPF", "filter", "to", "the", "BPF", "file", "descriptor" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/core.py#L103-L109
[ "def", "attach_filter", "(", "fd", ",", "bpf_filter", ",", "iface", ")", ":", "bp", "=", "compile_filter", "(", "bpf_filter", ",", "iface", ")", "# Assign the BPF program to the interface", "ret", "=", "LIBC", ".", "ioctl", "(", "c_int", "(", "fd", ")", ",",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
get_if_list
Returns a list containing all network interfaces.
scapy/arch/bpf/core.py
def get_if_list(): """Returns a list containing all network interfaces.""" # Get ifconfig output try: fd = os.popen("%s -a" % conf.prog.ifconfig) except OSError as msg: raise Scapy_Exception("Failed to execute ifconfig: (%s)" % msg) # Get interfaces interfaces = [line[:line.fin...
def get_if_list(): """Returns a list containing all network interfaces.""" # Get ifconfig output try: fd = os.popen("%s -a" % conf.prog.ifconfig) except OSError as msg: raise Scapy_Exception("Failed to execute ifconfig: (%s)" % msg) # Get interfaces interfaces = [line[:line.fin...
[ "Returns", "a", "list", "containing", "all", "network", "interfaces", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/core.py#L114-L126
[ "def", "get_if_list", "(", ")", ":", "# Get ifconfig output", "try", ":", "fd", "=", "os", ".", "popen", "(", "\"%s -a\"", "%", "conf", ".", "prog", ".", "ifconfig", ")", "except", "OSError", "as", "msg", ":", "raise", "Scapy_Exception", "(", "\"Failed to ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
get_working_ifaces
Returns an ordered list of interfaces that could be used with BPF. Note: the order mimics pcap_findalldevs() behavior
scapy/arch/bpf/core.py
def get_working_ifaces(): """ Returns an ordered list of interfaces that could be used with BPF. Note: the order mimics pcap_findalldevs() behavior """ # Only root is allowed to perform the following ioctl() call if os.getuid() != 0: return [] # Test all network interfaces inte...
def get_working_ifaces(): """ Returns an ordered list of interfaces that could be used with BPF. Note: the order mimics pcap_findalldevs() behavior """ # Only root is allowed to perform the following ioctl() call if os.getuid() != 0: return [] # Test all network interfaces inte...
[ "Returns", "an", "ordered", "list", "of", "interfaces", "that", "could", "be", "used", "with", "BPF", ".", "Note", ":", "the", "order", "mimics", "pcap_findalldevs", "()", "behavior" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/core.py#L132-L182
[ "def", "get_working_ifaces", "(", ")", ":", "# Only root is allowed to perform the following ioctl() call", "if", "os", ".", "getuid", "(", ")", "!=", "0", ":", "return", "[", "]", "# Test all network interfaces", "interfaces", "=", "[", "]", "for", "ifname", "in", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
get_temp_file
Creates a temporary file. :param keep: If False, automatically delete the file when Scapy exits. :param autoext: Suffix to add to the generated file name. :param fd: If True, this returns a file-like object with the temporary file opened. If False (default), this returns a file path.
scapy/utils.py
def get_temp_file(keep=False, autoext="", fd=False): """Creates a temporary file. :param keep: If False, automatically delete the file when Scapy exits. :param autoext: Suffix to add to the generated file name. :param fd: If True, this returns a file-like object with the temporary file o...
def get_temp_file(keep=False, autoext="", fd=False): """Creates a temporary file. :param keep: If False, automatically delete the file when Scapy exits. :param autoext: Suffix to add to the generated file name. :param fd: If True, this returns a file-like object with the temporary file o...
[ "Creates", "a", "temporary", "file", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils.py#L51-L69
[ "def", "get_temp_file", "(", "keep", "=", "False", ",", "autoext", "=", "\"\"", ",", "fd", "=", "False", ")", ":", "f", "=", "tempfile", ".", "NamedTemporaryFile", "(", "prefix", "=", "\"scapy\"", ",", "suffix", "=", "autoext", ",", "delete", "=", "Fal...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
get_temp_dir
Creates a temporary file, and returns its name. :param keep: If False (default), the directory will be recursively deleted when Scapy exits. :return: A full path to a temporary directory.
scapy/utils.py
def get_temp_dir(keep=False): """Creates a temporary file, and returns its name. :param keep: If False (default), the directory will be recursively deleted when Scapy exits. :return: A full path to a temporary directory. """ dname = tempfile.mkdtemp(prefix="scapy") if not kee...
def get_temp_dir(keep=False): """Creates a temporary file, and returns its name. :param keep: If False (default), the directory will be recursively deleted when Scapy exits. :return: A full path to a temporary directory. """ dname = tempfile.mkdtemp(prefix="scapy") if not kee...
[ "Creates", "a", "temporary", "file", "and", "returns", "its", "name", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils.py#L72-L85
[ "def", "get_temp_dir", "(", "keep", "=", "False", ")", ":", "dname", "=", "tempfile", ".", "mkdtemp", "(", "prefix", "=", "\"scapy\"", ")", "if", "not", "keep", ":", "conf", ".", "temp_files", ".", "append", "(", "dname", ")", "return", "dname" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
train
restart
Restarts scapy
scapy/utils.py
def restart(): """Restarts scapy""" if not conf.interactive or not os.path.isfile(sys.argv[0]): raise OSError("Scapy was not started from console") if WINDOWS: try: res_code = subprocess.call([sys.executable] + sys.argv) except KeyboardInterrupt: res_code = 1 ...
def restart(): """Restarts scapy""" if not conf.interactive or not os.path.isfile(sys.argv[0]): raise OSError("Scapy was not started from console") if WINDOWS: try: res_code = subprocess.call([sys.executable] + sys.argv) except KeyboardInterrupt: res_code = 1 ...
[ "Restarts", "scapy" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils.py#L111-L122
[ "def", "restart", "(", ")", ":", "if", "not", "conf", ".", "interactive", "or", "not", "os", ".", "path", ".", "isfile", "(", "sys", ".", "argv", "[", "0", "]", ")", ":", "raise", "OSError", "(", "\"Scapy was not started from console\"", ")", "if", "WI...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
hexdump
Build a tcpdump like hexadecimal view :param x: a Packet :param dump: define if the result must be printed or returned in a variable :returns: a String only when dump=True
scapy/utils.py
def hexdump(x, dump=False): """Build a tcpdump like hexadecimal view :param x: a Packet :param dump: define if the result must be printed or returned in a variable :returns: a String only when dump=True """ s = "" x = bytes_encode(x) x_len = len(x) i = 0 while i < x_len: ...
def hexdump(x, dump=False): """Build a tcpdump like hexadecimal view :param x: a Packet :param dump: define if the result must be printed or returned in a variable :returns: a String only when dump=True """ s = "" x = bytes_encode(x) x_len = len(x) i = 0 while i < x_len: ...
[ "Build", "a", "tcpdump", "like", "hexadecimal", "view" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils.py#L137-L162
[ "def", "hexdump", "(", "x", ",", "dump", "=", "False", ")", ":", "s", "=", "\"\"", "x", "=", "bytes_encode", "(", "x", ")", "x_len", "=", "len", "(", "x", ")", "i", "=", "0", "while", "i", "<", "x_len", ":", "s", "+=", "\"%04x \"", "%", "i",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
linehexdump
Build an equivalent view of hexdump() on a single line Note that setting both onlyasc and onlyhex to 1 results in a empty output :param x: a Packet :param onlyasc: 1 to display only the ascii view :param onlyhex: 1 to display only the hexadecimal view :param dump: print the view if False :retu...
scapy/utils.py
def linehexdump(x, onlyasc=0, onlyhex=0, dump=False): """Build an equivalent view of hexdump() on a single line Note that setting both onlyasc and onlyhex to 1 results in a empty output :param x: a Packet :param onlyasc: 1 to display only the ascii view :param onlyhex: 1 to display only the hexade...
def linehexdump(x, onlyasc=0, onlyhex=0, dump=False): """Build an equivalent view of hexdump() on a single line Note that setting both onlyasc and onlyhex to 1 results in a empty output :param x: a Packet :param onlyasc: 1 to display only the ascii view :param onlyhex: 1 to display only the hexade...
[ "Build", "an", "equivalent", "view", "of", "hexdump", "()", "on", "a", "single", "line" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils.py#L166-L182
[ "def", "linehexdump", "(", "x", ",", "onlyasc", "=", "0", ",", "onlyhex", "=", "0", ",", "dump", "=", "False", ")", ":", "s", "=", "\"\"", "s", "=", "hexstr", "(", "x", ",", "onlyasc", "=", "onlyasc", ",", "onlyhex", "=", "onlyhex", ",", "color",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
chexdump
Build a per byte hexadecimal representation Example: >>> chexdump(IP()) 0x45, 0x00, 0x00, 0x14, 0x00, 0x01, 0x00, 0x00, 0x40, 0x00, 0x7c, 0xe7, 0x7f, 0x00, 0x00, 0x01, 0x7f, 0x00, 0x00, 0x01 # noqa: E501 :param x: a Packet :param dump: print the view if False :returns: a String only i...
scapy/utils.py
def chexdump(x, dump=False): """Build a per byte hexadecimal representation Example: >>> chexdump(IP()) 0x45, 0x00, 0x00, 0x14, 0x00, 0x01, 0x00, 0x00, 0x40, 0x00, 0x7c, 0xe7, 0x7f, 0x00, 0x00, 0x01, 0x7f, 0x00, 0x00, 0x01 # noqa: E501 :param x: a Packet :param dump: print the view if...
def chexdump(x, dump=False): """Build a per byte hexadecimal representation Example: >>> chexdump(IP()) 0x45, 0x00, 0x00, 0x14, 0x00, 0x01, 0x00, 0x00, 0x40, 0x00, 0x7c, 0xe7, 0x7f, 0x00, 0x00, 0x01, 0x7f, 0x00, 0x00, 0x01 # noqa: E501 :param x: a Packet :param dump: print the view if...
[ "Build", "a", "per", "byte", "hexadecimal", "representation" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils.py#L186-L202
[ "def", "chexdump", "(", "x", ",", "dump", "=", "False", ")", ":", "x", "=", "bytes_encode", "(", "x", ")", "s", "=", "\", \"", ".", "join", "(", "\"%#04x\"", "%", "orb", "(", "x", ")", "for", "x", "in", "x", ")", "if", "dump", ":", "return", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
hexstr
Build a fancy tcpdump like hex from bytes.
scapy/utils.py
def hexstr(x, onlyasc=0, onlyhex=0, color=False): """Build a fancy tcpdump like hex from bytes.""" x = bytes_encode(x) _sane_func = sane_color if color else sane s = [] if not onlyasc: s.append(" ".join("%02X" % orb(b) for b in x)) if not onlyhex: s.append(_sane_func(x)) retu...
def hexstr(x, onlyasc=0, onlyhex=0, color=False): """Build a fancy tcpdump like hex from bytes.""" x = bytes_encode(x) _sane_func = sane_color if color else sane s = [] if not onlyasc: s.append(" ".join("%02X" % orb(b) for b in x)) if not onlyhex: s.append(_sane_func(x)) retu...
[ "Build", "a", "fancy", "tcpdump", "like", "hex", "from", "bytes", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils.py#L206-L215
[ "def", "hexstr", "(", "x", ",", "onlyasc", "=", "0", ",", "onlyhex", "=", "0", ",", "color", "=", "False", ")", ":", "x", "=", "bytes_encode", "(", "x", ")", "_sane_func", "=", "sane_color", "if", "color", "else", "sane", "s", "=", "[", "]", "if"...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
hexdiff
Show differences between 2 binary strings
scapy/utils.py
def hexdiff(x, y): """Show differences between 2 binary strings""" x = bytes_encode(x)[::-1] y = bytes_encode(y)[::-1] SUBST = 1 INSERT = 1 d = {(-1, -1): (0, (-1, -1))} for j in range(len(y)): d[-1, j] = d[-1, j - 1][0] + INSERT, (-1, j - 1) for i in range(len(x)): d[i, ...
def hexdiff(x, y): """Show differences between 2 binary strings""" x = bytes_encode(x)[::-1] y = bytes_encode(y)[::-1] SUBST = 1 INSERT = 1 d = {(-1, -1): (0, (-1, -1))} for j in range(len(y)): d[-1, j] = d[-1, j - 1][0] + INSERT, (-1, j - 1) for i in range(len(x)): d[i, ...
[ "Show", "differences", "between", "2", "binary", "strings" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils.py#L224-L325
[ "def", "hexdiff", "(", "x", ",", "y", ")", ":", "x", "=", "bytes_encode", "(", "x", ")", "[", ":", ":", "-", "1", "]", "y", "=", "bytes_encode", "(", "y", ")", "[", ":", ":", "-", "1", "]", "SUBST", "=", "1", "INSERT", "=", "1", "d", "=",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
fletcher16_checkbytes
Calculates the Fletcher-16 checkbytes returned as 2 byte binary-string. Including the bytes into the buffer (at the position marked by offset) the # noqa: E501 global Fletcher-16 checksum of the buffer will be 0. Thus it is easy to verify # noqa: E501 the integrity of the buffer on the receiver ...
scapy/utils.py
def fletcher16_checkbytes(binbuf, offset): """Calculates the Fletcher-16 checkbytes returned as 2 byte binary-string. Including the bytes into the buffer (at the position marked by offset) the # noqa: E501 global Fletcher-16 checksum of the buffer will be 0. Thus it is easy to verify # noqa: E501 ...
def fletcher16_checkbytes(binbuf, offset): """Calculates the Fletcher-16 checkbytes returned as 2 byte binary-string. Including the bytes into the buffer (at the position marked by offset) the # noqa: E501 global Fletcher-16 checksum of the buffer will be 0. Thus it is easy to verify # noqa: E501 ...
[ "Calculates", "the", "Fletcher", "-", "16", "checkbytes", "returned", "as", "2", "byte", "binary", "-", "string", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils.py#L373-L399
[ "def", "fletcher16_checkbytes", "(", "binbuf", ",", "offset", ")", ":", "# This is based on the GPLed C implementation in Zebra <http://www.zebra.org/> # noqa: E501", "if", "len", "(", "binbuf", ")", "<", "offset", ":", "raise", "Exception", "(", "\"Packet too short for chec...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
randstring
Returns a random string of length l (l >= 0)
scapy/utils.py
def randstring(l): """ Returns a random string of length l (l >= 0) """ return b"".join(struct.pack('B', random.randint(0, 255)) for _ in range(l))
def randstring(l): """ Returns a random string of length l (l >= 0) """ return b"".join(struct.pack('B', random.randint(0, 255)) for _ in range(l))
[ "Returns", "a", "random", "string", "of", "length", "l", "(", "l", ">", "=", "0", ")" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils.py#L420-L424
[ "def", "randstring", "(", "l", ")", ":", "return", "b\"\"", ".", "join", "(", "struct", ".", "pack", "(", "'B'", ",", "random", ".", "randint", "(", "0", ",", "255", ")", ")", "for", "_", "in", "range", "(", "l", ")", ")" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
train
strxor
Returns the binary XOR of the 2 provided strings s1 and s2. s1 and s2 must be of same length.
scapy/utils.py
def strxor(s1, s2): """ Returns the binary XOR of the 2 provided strings s1 and s2. s1 and s2 must be of same length. """ return b"".join(map(lambda x, y: chb(orb(x) ^ orb(y)), s1, s2))
def strxor(s1, s2): """ Returns the binary XOR of the 2 provided strings s1 and s2. s1 and s2 must be of same length. """ return b"".join(map(lambda x, y: chb(orb(x) ^ orb(y)), s1, s2))
[ "Returns", "the", "binary", "XOR", "of", "the", "2", "provided", "strings", "s1", "and", "s2", ".", "s1", "and", "s2", "must", "be", "of", "same", "length", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils.py#L434-L439
[ "def", "strxor", "(", "s1", ",", "s2", ")", ":", "return", "b\"\"", ".", "join", "(", "map", "(", "lambda", "x", ",", "y", ":", "chb", "(", "orb", "(", "x", ")", "^", "orb", "(", "y", ")", ")", ",", "s1", ",", "s2", ")", ")" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
train
do_graph
do_graph(graph, prog=conf.prog.dot, format="svg", target="| conf.prog.display", options=None, [string=1]): string: if not None, simply return the graph string graph: GraphViz graph description format: output type (svg, ps, gif, jpg, etc.), passed to dot's "-T" option target: filename or redirec...
scapy/utils.py
def do_graph(graph, prog=None, format=None, target=None, type=None, string=None, options=None): # noqa: E501 """do_graph(graph, prog=conf.prog.dot, format="svg", target="| conf.prog.display", options=None, [string=1]): string: if not None, simply return the graph string graph: GraphViz graph descr...
def do_graph(graph, prog=None, format=None, target=None, type=None, string=None, options=None): # noqa: E501 """do_graph(graph, prog=conf.prog.dot, format="svg", target="| conf.prog.display", options=None, [string=1]): string: if not None, simply return the graph string graph: GraphViz graph descr...
[ "do_graph", "(", "graph", "prog", "=", "conf", ".", "prog", ".", "dot", "format", "=", "svg", "target", "=", "|", "conf", ".", "prog", ".", "display", "options", "=", "None", "[", "string", "=", "1", "]", ")", ":", "string", ":", "if", "not", "No...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils.py#L600-L662
[ "def", "do_graph", "(", "graph", ",", "prog", "=", "None", ",", "format", "=", "None", ",", "target", "=", "None", ",", "type", "=", "None", ",", "string", "=", "None", ",", "options", "=", "None", ")", ":", "# noqa: E501", "if", "format", "is", "N...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
save_object
Pickle a Python object
scapy/utils.py
def save_object(fname, obj): """Pickle a Python object""" fd = gzip.open(fname, "wb") six.moves.cPickle.dump(obj, fd) fd.close()
def save_object(fname, obj): """Pickle a Python object""" fd = gzip.open(fname, "wb") six.moves.cPickle.dump(obj, fd) fd.close()
[ "Pickle", "a", "Python", "object" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils.py#L794-L799
[ "def", "save_object", "(", "fname", ",", "obj", ")", ":", "fd", "=", "gzip", ".", "open", "(", "fname", ",", "\"wb\"", ")", "six", ".", "moves", ".", "cPickle", ".", "dump", "(", "obj", ",", "fd", ")", "fd", ".", "close", "(", ")" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
train
corrupt_bytes
Corrupt a given percentage or number of bytes from a string
scapy/utils.py
def corrupt_bytes(s, p=0.01, n=None): """Corrupt a given percentage or number of bytes from a string""" s = array.array("B", bytes_encode(s)) s_len = len(s) if n is None: n = max(1, int(s_len * p)) for i in random.sample(range(s_len), n): s[i] = (s[i] + random.randint(1, 255)) % 256 ...
def corrupt_bytes(s, p=0.01, n=None): """Corrupt a given percentage or number of bytes from a string""" s = array.array("B", bytes_encode(s)) s_len = len(s) if n is None: n = max(1, int(s_len * p)) for i in random.sample(range(s_len), n): s[i] = (s[i] + random.randint(1, 255)) % 256 ...
[ "Corrupt", "a", "given", "percentage", "or", "number", "of", "bytes", "from", "a", "string" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils.py#L808-L816
[ "def", "corrupt_bytes", "(", "s", ",", "p", "=", "0.01", ",", "n", "=", "None", ")", ":", "s", "=", "array", ".", "array", "(", "\"B\"", ",", "bytes_encode", "(", "s", ")", ")", "s_len", "=", "len", "(", "s", ")", "if", "n", "is", "None", ":"...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
wrpcap
Write a list of packets to a pcap file filename: the name of the file to write packets to, or an open, writable file-like object. The file descriptor will be closed at the end of the call, so do not use an object you do not want to close (e.g., running wrpcap(sys.stdout, []) in ...
scapy/utils.py
def wrpcap(filename, pkt, *args, **kargs): """Write a list of packets to a pcap file filename: the name of the file to write packets to, or an open, writable file-like object. The file descriptor will be closed at the end of the call, so do not use an object you do not want to close (...
def wrpcap(filename, pkt, *args, **kargs): """Write a list of packets to a pcap file filename: the name of the file to write packets to, or an open, writable file-like object. The file descriptor will be closed at the end of the call, so do not use an object you do not want to close (...
[ "Write", "a", "list", "of", "packets", "to", "a", "pcap", "file" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils.py#L836-L851
[ "def", "wrpcap", "(", "filename", ",", "pkt", ",", "*", "args", ",", "*", "*", "kargs", ")", ":", "with", "PcapWriter", "(", "filename", ",", "*", "args", ",", "*", "*", "kargs", ")", "as", "fdesc", ":", "fdesc", ".", "write", "(", "pkt", ")" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
train
rdpcap
Read a pcap or pcapng file and return a packet list count: read only <count> packets
scapy/utils.py
def rdpcap(filename, count=-1): """Read a pcap or pcapng file and return a packet list count: read only <count> packets """ with PcapReader(filename) as fdesc: return fdesc.read_all(count=count)
def rdpcap(filename, count=-1): """Read a pcap or pcapng file and return a packet list count: read only <count> packets """ with PcapReader(filename) as fdesc: return fdesc.read_all(count=count)
[ "Read", "a", "pcap", "or", "pcapng", "file", "and", "return", "a", "packet", "list" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils.py#L855-L862
[ "def", "rdpcap", "(", "filename", ",", "count", "=", "-", "1", ")", ":", "with", "PcapReader", "(", "filename", ")", "as", "fdesc", ":", "return", "fdesc", ".", "read_all", "(", "count", "=", "count", ")" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
train
import_hexcap
Imports a tcpdump like hexadecimal view e.g: exported via hexdump() or tcpdump or wireshark's "export as hex"
scapy/utils.py
def import_hexcap(): """Imports a tcpdump like hexadecimal view e.g: exported via hexdump() or tcpdump or wireshark's "export as hex" """ re_extract_hexcap = re.compile(r"^((0x)?[0-9a-fA-F]{2,}[ :\t]{,3}|) *(([0-9a-fA-F]{2} {,2}){,16})") # noqa: E501 p = "" try: while True: ...
def import_hexcap(): """Imports a tcpdump like hexadecimal view e.g: exported via hexdump() or tcpdump or wireshark's "export as hex" """ re_extract_hexcap = re.compile(r"^((0x)?[0-9a-fA-F]{2,}[ :\t]{,3}|) *(([0-9a-fA-F]{2} {,2}){,16})") # noqa: E501 p = "" try: while True: ...
[ "Imports", "a", "tcpdump", "like", "hexadecimal", "view" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils.py#L1421-L1442
[ "def", "import_hexcap", "(", ")", ":", "re_extract_hexcap", "=", "re", ".", "compile", "(", "r\"^((0x)?[0-9a-fA-F]{2,}[ :\\t]{,3}|) *(([0-9a-fA-F]{2} {,2}){,16})\"", ")", "# noqa: E501", "p", "=", "\"\"", "try", ":", "while", "True", ":", "line", "=", "input", "(", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
wireshark
Runs Wireshark on a list of packets. See :func:`tcpdump` for more parameter description. Note: this defaults to wait=False, to run Wireshark in the background.
scapy/utils.py
def wireshark(pktlist, wait=False, **kwargs): """ Runs Wireshark on a list of packets. See :func:`tcpdump` for more parameter description. Note: this defaults to wait=False, to run Wireshark in the background. """ return tcpdump(pktlist, prog=conf.prog.wireshark, wait=wait, **kwargs)
def wireshark(pktlist, wait=False, **kwargs): """ Runs Wireshark on a list of packets. See :func:`tcpdump` for more parameter description. Note: this defaults to wait=False, to run Wireshark in the background. """ return tcpdump(pktlist, prog=conf.prog.wireshark, wait=wait, **kwargs)
[ "Runs", "Wireshark", "on", "a", "list", "of", "packets", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils.py#L1446-L1454
[ "def", "wireshark", "(", "pktlist", ",", "wait", "=", "False", ",", "*", "*", "kwargs", ")", ":", "return", "tcpdump", "(", "pktlist", ",", "prog", "=", "conf", ".", "prog", ".", "wireshark", ",", "wait", "=", "wait", ",", "*", "*", "kwargs", ")" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
train
tdecode
Run tshark on a list of packets. :param args: If not specified, defaults to ``tshark -V``. See :func:`tcpdump` for more parameters.
scapy/utils.py
def tdecode(pktlist, args=None, **kwargs): """ Run tshark on a list of packets. :param args: If not specified, defaults to ``tshark -V``. See :func:`tcpdump` for more parameters. """ if args is None: args = ["-V"] return tcpdump(pktlist, prog=conf.prog.tshark, args=args, **kwargs)
def tdecode(pktlist, args=None, **kwargs): """ Run tshark on a list of packets. :param args: If not specified, defaults to ``tshark -V``. See :func:`tcpdump` for more parameters. """ if args is None: args = ["-V"] return tcpdump(pktlist, prog=conf.prog.tshark, args=args, **kwargs)
[ "Run", "tshark", "on", "a", "list", "of", "packets", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils.py#L1458-L1468
[ "def", "tdecode", "(", "pktlist", ",", "args", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "args", "is", "None", ":", "args", "=", "[", "\"-V\"", "]", "return", "tcpdump", "(", "pktlist", ",", "prog", "=", "conf", ".", "prog", ".", "tsh...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
tcpdump
Run tcpdump or tshark on a list of packets. When using ``tcpdump`` on OSX (``prog == conf.prog.tcpdump``), this uses a temporary file to store the packets. This works around a bug in Apple's version of ``tcpdump``: http://apple.stackexchange.com/questions/152682/ Otherwise, the packets are passed in s...
scapy/utils.py
def tcpdump(pktlist, dump=False, getfd=False, args=None, prog=None, getproc=False, quiet=False, use_tempfile=None, read_stdin_opts=None, linktype=None, wait=True): """Run tcpdump or tshark on a list of packets. When using ``tcpdump`` on OSX (``prog == conf.prog.tcpdump``), this uses a ...
def tcpdump(pktlist, dump=False, getfd=False, args=None, prog=None, getproc=False, quiet=False, use_tempfile=None, read_stdin_opts=None, linktype=None, wait=True): """Run tcpdump or tshark on a list of packets. When using ``tcpdump`` on OSX (``prog == conf.prog.tcpdump``), this uses a ...
[ "Run", "tcpdump", "or", "tshark", "on", "a", "list", "of", "packets", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils.py#L1472-L1644
[ "def", "tcpdump", "(", "pktlist", ",", "dump", "=", "False", ",", "getfd", "=", "False", ",", "args", "=", "None", ",", "prog", "=", "None", ",", "getproc", "=", "False", ",", "quiet", "=", "False", ",", "use_tempfile", "=", "None", ",", "read_stdin_...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
hexedit
Run hexedit on a list of packets, then return the edited packets.
scapy/utils.py
def hexedit(pktlist): """Run hexedit on a list of packets, then return the edited packets.""" f = get_temp_file() wrpcap(f, pktlist) with ContextManagerSubprocess("hexedit()", conf.prog.hexedit): subprocess.call([conf.prog.hexedit, f]) pktlist = rdpcap(f) os.unlink(f) return pktlist
def hexedit(pktlist): """Run hexedit on a list of packets, then return the edited packets.""" f = get_temp_file() wrpcap(f, pktlist) with ContextManagerSubprocess("hexedit()", conf.prog.hexedit): subprocess.call([conf.prog.hexedit, f]) pktlist = rdpcap(f) os.unlink(f) return pktlist
[ "Run", "hexedit", "on", "a", "list", "of", "packets", "then", "return", "the", "edited", "packets", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils.py#L1648-L1656
[ "def", "hexedit", "(", "pktlist", ")", ":", "f", "=", "get_temp_file", "(", ")", "wrpcap", "(", "f", ",", "pktlist", ")", "with", "ContextManagerSubprocess", "(", "\"hexedit()\"", ",", "conf", ".", "prog", ".", "hexedit", ")", ":", "subprocess", ".", "ca...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
get_terminal_width
Get terminal width (number of characters) if in a window. Notice: this will try several methods in order to support as many terminals and OS as possible.
scapy/utils.py
def get_terminal_width(): """Get terminal width (number of characters) if in a window. Notice: this will try several methods in order to support as many terminals and OS as possible. """ # Let's first try using the official API # (Python 3.3+) if not six.PY2: import shutil s...
def get_terminal_width(): """Get terminal width (number of characters) if in a window. Notice: this will try several methods in order to support as many terminals and OS as possible. """ # Let's first try using the official API # (Python 3.3+) if not six.PY2: import shutil s...
[ "Get", "terminal", "width", "(", "number", "of", "characters", ")", "if", "in", "a", "window", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils.py#L1659-L1705
[ "def", "get_terminal_width", "(", ")", ":", "# Let's first try using the official API", "# (Python 3.3+)", "if", "not", "six", ".", "PY2", ":", "import", "shutil", "sizex", "=", "shutil", ".", "get_terminal_size", "(", "fallback", "=", "(", "0", ",", "0", ")", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
pretty_list
Pretty list to fit the terminal, and add header
scapy/utils.py
def pretty_list(rtlst, header, sortBy=0, borders=False): """Pretty list to fit the terminal, and add header""" if borders: _space = "|" else: _space = " " # Windows has a fat terminal border _spacelen = len(_space) * (len(header) - 1) + (10 if WINDOWS else 0) _croped = False ...
def pretty_list(rtlst, header, sortBy=0, borders=False): """Pretty list to fit the terminal, and add header""" if borders: _space = "|" else: _space = " " # Windows has a fat terminal border _spacelen = len(_space) * (len(header) - 1) + (10 if WINDOWS else 0) _croped = False ...
[ "Pretty", "list", "to", "fit", "the", "terminal", "and", "add", "header" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils.py#L1708-L1752
[ "def", "pretty_list", "(", "rtlst", ",", "header", ",", "sortBy", "=", "0", ",", "borders", "=", "False", ")", ":", "if", "borders", ":", "_space", "=", "\"|\"", "else", ":", "_space", "=", "\" \"", "# Windows has a fat terminal border", "_spacelen", "=", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
__make_table
Core function of the make_table suite, which generates the table
scapy/utils.py
def __make_table(yfmtfunc, fmtfunc, endline, data, fxyz, sortx=None, sorty=None, seplinefunc=None): # noqa: E501 """Core function of the make_table suite, which generates the table""" vx = {} vy = {} vz = {} vxf = {} # Python 2 backward compatibility fxyz = lambda_tuple_converter(fxyz) ...
def __make_table(yfmtfunc, fmtfunc, endline, data, fxyz, sortx=None, sorty=None, seplinefunc=None): # noqa: E501 """Core function of the make_table suite, which generates the table""" vx = {} vy = {} vz = {} vxf = {} # Python 2 backward compatibility fxyz = lambda_tuple_converter(fxyz) ...
[ "Core", "function", "of", "the", "make_table", "suite", "which", "generates", "the", "table" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils.py#L1755-L1814
[ "def", "__make_table", "(", "yfmtfunc", ",", "fmtfunc", ",", "endline", ",", "data", ",", "fxyz", ",", "sortx", "=", "None", ",", "sorty", "=", "None", ",", "seplinefunc", "=", "None", ")", ":", "# noqa: E501", "vx", "=", "{", "}", "vy", "=", "{", ...
3ffe757c184017dd46464593a8f80f85abc1e79a