repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
secdev/scapy
scapy/layers/tls/handshake_sslv2.py
SSLv2ServerHello.tls_session_update
def tls_session_update(self, msg_str): """ XXX Something should be done about the session ID here. """ super(SSLv2ServerHello, self).tls_session_update(msg_str) s = self.tls_session client_cs = s.sslv2_common_cs css = [cs for cs in client_cs if cs in self.ciphers...
python
def tls_session_update(self, msg_str): """ XXX Something should be done about the session ID here. """ super(SSLv2ServerHello, self).tls_session_update(msg_str) s = self.tls_session client_cs = s.sslv2_common_cs css = [cs for cs in client_cs if cs in self.ciphers...
[ "def", "tls_session_update", "(", "self", ",", "msg_str", ")", ":", "super", "(", "SSLv2ServerHello", ",", "self", ")", ".", "tls_session_update", "(", "msg_str", ")", "s", "=", "self", ".", "tls_session", "client_cs", "=", "s", ".", "sslv2_common_cs", "css"...
XXX Something should be done about the session ID here.
[ "XXX", "Something", "should", "be", "done", "about", "the", "session", "ID", "here", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/handshake_sslv2.py#L186-L199
train
secdev/scapy
scapy/base_classes.py
_get_values
def _get_values(value): """Generate a range object from (start, stop[, step]) tuples, or return value. """ if (isinstance(value, tuple) and (2 <= len(value) <= 3) and all(hasattr(i, "__int__") for i in value)): # We use values[1] + 1 as stop value for (x)range to maintain # ...
python
def _get_values(value): """Generate a range object from (start, stop[, step]) tuples, or return value. """ if (isinstance(value, tuple) and (2 <= len(value) <= 3) and all(hasattr(i, "__int__") for i in value)): # We use values[1] + 1 as stop value for (x)range to maintain # ...
[ "def", "_get_values", "(", "value", ")", ":", "if", "(", "isinstance", "(", "value", ",", "tuple", ")", "and", "(", "2", "<=", "len", "(", "value", ")", "<=", "3", ")", "and", "all", "(", "hasattr", "(", "i", ",", "\"__int__\"", ")", "for", "i", ...
Generate a range object from (start, stop[, step]) tuples, or return value.
[ "Generate", "a", "range", "object", "from", "(", "start", "stop", "[", "step", "]", ")", "tuples", "or", "return", "value", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/base_classes.py#L39-L50
train
secdev/scapy
scapy/base_classes.py
_CanvasDumpExtended.psdump
def psdump(self, filename=None, **kargs): """ psdump(filename=None, layer_shift=0, rebuild=1) Creates an EPS file describing a packet. If filename is not provided a temporary file is created and gs is called. :param filename: the file's filename """ from scapy.c...
python
def psdump(self, filename=None, **kargs): """ psdump(filename=None, layer_shift=0, rebuild=1) Creates an EPS file describing a packet. If filename is not provided a temporary file is created and gs is called. :param filename: the file's filename """ from scapy.c...
[ "def", "psdump", "(", "self", ",", "filename", "=", "None", ",", "*", "*", "kargs", ")", ":", "from", "scapy", ".", "config", "import", "conf", "from", "scapy", ".", "utils", "import", "get_temp_file", ",", "ContextManagerSubprocess", "canvas", "=", "self"...
psdump(filename=None, layer_shift=0, rebuild=1) Creates an EPS file describing a packet. If filename is not provided a temporary file is created and gs is called. :param filename: the file's filename
[ "psdump", "(", "filename", "=", "None", "layer_shift", "=", "0", "rebuild", "=", "1", ")" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/base_classes.py#L305-L327
train
secdev/scapy
scapy/base_classes.py
_CanvasDumpExtended.pdfdump
def pdfdump(self, filename=None, **kargs): """ pdfdump(filename=None, layer_shift=0, rebuild=1) Creates a PDF file describing a packet. If filename is not provided a temporary file is created and xpdf is called. :param filename: the file's filename """ from scap...
python
def pdfdump(self, filename=None, **kargs): """ pdfdump(filename=None, layer_shift=0, rebuild=1) Creates a PDF file describing a packet. If filename is not provided a temporary file is created and xpdf is called. :param filename: the file's filename """ from scap...
[ "def", "pdfdump", "(", "self", ",", "filename", "=", "None", ",", "*", "*", "kargs", ")", ":", "from", "scapy", ".", "config", "import", "conf", "from", "scapy", ".", "utils", "import", "get_temp_file", ",", "ContextManagerSubprocess", "canvas", "=", "self...
pdfdump(filename=None, layer_shift=0, rebuild=1) Creates a PDF file describing a packet. If filename is not provided a temporary file is created and xpdf is called. :param filename: the file's filename
[ "pdfdump", "(", "filename", "=", "None", "layer_shift", "=", "0", "rebuild", "=", "1", ")" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/base_classes.py#L329-L352
train
secdev/scapy
scapy/base_classes.py
_CanvasDumpExtended.svgdump
def svgdump(self, filename=None, **kargs): """ svgdump(filename=None, layer_shift=0, rebuild=1) Creates an SVG file describing a packet. If filename is not provided a temporary file is created and gs is called. :param filename: the file's filename """ from scapy...
python
def svgdump(self, filename=None, **kargs): """ svgdump(filename=None, layer_shift=0, rebuild=1) Creates an SVG file describing a packet. If filename is not provided a temporary file is created and gs is called. :param filename: the file's filename """ from scapy...
[ "def", "svgdump", "(", "self", ",", "filename", "=", "None", ",", "*", "*", "kargs", ")", ":", "from", "scapy", ".", "config", "import", "conf", "from", "scapy", ".", "utils", "import", "get_temp_file", ",", "ContextManagerSubprocess", "canvas", "=", "self...
svgdump(filename=None, layer_shift=0, rebuild=1) Creates an SVG file describing a packet. If filename is not provided a temporary file is created and gs is called. :param filename: the file's filename
[ "svgdump", "(", "filename", "=", "None", "layer_shift", "=", "0", "rebuild", "=", "1", ")" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/base_classes.py#L354-L377
train
secdev/scapy
setup.py
get_long_description
def get_long_description(): """Extract description from README.md, for PyPI's usage""" try: fpath = os.path.join(os.path.dirname(__file__), "README.md") with io.open(fpath, encoding="utf-8") as f: readme = f.read() desc = readme.partition("<!-- start_ppi_description -->")...
python
def get_long_description(): """Extract description from README.md, for PyPI's usage""" try: fpath = os.path.join(os.path.dirname(__file__), "README.md") with io.open(fpath, encoding="utf-8") as f: readme = f.read() desc = readme.partition("<!-- start_ppi_description -->")...
[ "def", "get_long_description", "(", ")", ":", "try", ":", "fpath", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ",", "\"README.md\"", ")", "with", "io", ".", "open", "(", "fpath", ",", "encoding",...
Extract description from README.md, for PyPI's usage
[ "Extract", "description", "from", "README", ".", "md", "for", "PyPI", "s", "usage" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/setup.py#L15-L25
train
secdev/scapy
scapy/contrib/cdp.py
_CDPChecksum._check_len
def _check_len(self, pkt): """Check for odd packet length and pad according to Cisco spec. This padding is only used for checksum computation. The original packet should not be altered.""" if len(pkt) % 2: last_chr = pkt[-1] if last_chr <= b'\x80': ...
python
def _check_len(self, pkt): """Check for odd packet length and pad according to Cisco spec. This padding is only used for checksum computation. The original packet should not be altered.""" if len(pkt) % 2: last_chr = pkt[-1] if last_chr <= b'\x80': ...
[ "def", "_check_len", "(", "self", ",", "pkt", ")", ":", "if", "len", "(", "pkt", ")", "%", "2", ":", "last_chr", "=", "pkt", "[", "-", "1", "]", "if", "last_chr", "<=", "b'\\x80'", ":", "return", "pkt", "[", ":", "-", "1", "]", "+", "b'\\x00'",...
Check for odd packet length and pad according to Cisco spec. This padding is only used for checksum computation. The original packet should not be altered.
[ "Check", "for", "odd", "packet", "length", "and", "pad", "according", "to", "Cisco", "spec", ".", "This", "padding", "is", "only", "used", "for", "checksum", "computation", ".", "The", "original", "packet", "should", "not", "be", "altered", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/cdp.py#L355-L366
train
secdev/scapy
scapy/layers/tls/crypto/pkcs1.py
_legacy_pkcs1_v1_5_encode_md5_sha1
def _legacy_pkcs1_v1_5_encode_md5_sha1(M, emLen): """ Legacy method for PKCS1 v1.5 encoding with MD5-SHA1 hash. """ M = bytes_encode(M) md5_hash = hashes.Hash(_get_hash("md5"), backend=default_backend()) md5_hash.update(M) sha1_hash = hashes.Hash(_get_hash("sha1"), backend=default_backend())...
python
def _legacy_pkcs1_v1_5_encode_md5_sha1(M, emLen): """ Legacy method for PKCS1 v1.5 encoding with MD5-SHA1 hash. """ M = bytes_encode(M) md5_hash = hashes.Hash(_get_hash("md5"), backend=default_backend()) md5_hash.update(M) sha1_hash = hashes.Hash(_get_hash("sha1"), backend=default_backend())...
[ "def", "_legacy_pkcs1_v1_5_encode_md5_sha1", "(", "M", ",", "emLen", ")", ":", "M", "=", "bytes_encode", "(", "M", ")", "md5_hash", "=", "hashes", ".", "Hash", "(", "_get_hash", "(", "\"md5\"", ")", ",", "backend", "=", "default_backend", "(", ")", ")", ...
Legacy method for PKCS1 v1.5 encoding with MD5-SHA1 hash.
[ "Legacy", "method", "for", "PKCS1", "v1", ".", "5", "encoding", "with", "MD5", "-", "SHA1", "hash", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/crypto/pkcs1.py#L72-L87
train
secdev/scapy
scapy/layers/dhcp.py
dhcp_request
def dhcp_request(iface=None, **kargs): """Send a DHCP discover request and return the answer""" if conf.checkIPaddr != 0: warning("conf.checkIPaddr is not 0, I may not be able to match the answer") # noqa: E501 if iface is None: iface = conf.iface fam, hw = get_if_raw_hwaddr(iface) ...
python
def dhcp_request(iface=None, **kargs): """Send a DHCP discover request and return the answer""" if conf.checkIPaddr != 0: warning("conf.checkIPaddr is not 0, I may not be able to match the answer") # noqa: E501 if iface is None: iface = conf.iface fam, hw = get_if_raw_hwaddr(iface) ...
[ "def", "dhcp_request", "(", "iface", "=", "None", ",", "*", "*", "kargs", ")", ":", "if", "conf", ".", "checkIPaddr", "!=", "0", ":", "warning", "(", "\"conf.checkIPaddr is not 0, I may not be able to match the answer\"", ")", "# noqa: E501", "if", "iface", "is", ...
Send a DHCP discover request and return the answer
[ "Send", "a", "DHCP", "discover", "request", "and", "return", "the", "answer" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/dhcp.py#L347-L355
train
secdev/scapy
scapy/themes.py
apply_ipython_style
def apply_ipython_style(shell): """Updates the specified IPython console shell with the conf.color_theme scapy theme.""" try: from IPython.terminal.prompts import Prompts, Token except Exception: from scapy.error import log_loading log_loading.warning( "IPython too ol...
python
def apply_ipython_style(shell): """Updates the specified IPython console shell with the conf.color_theme scapy theme.""" try: from IPython.terminal.prompts import Prompts, Token except Exception: from scapy.error import log_loading log_loading.warning( "IPython too ol...
[ "def", "apply_ipython_style", "(", "shell", ")", ":", "try", ":", "from", "IPython", ".", "terminal", ".", "prompts", "import", "Prompts", ",", "Token", "except", "Exception", ":", "from", "scapy", ".", "error", "import", "log_loading", "log_loading", ".", "...
Updates the specified IPython console shell with the conf.color_theme scapy theme.
[ "Updates", "the", "specified", "IPython", "console", "shell", "with", "the", "conf", ".", "color_theme", "scapy", "theme", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/themes.py#L328-L397
train
secdev/scapy
scapy/automaton.py
SelectableObject._wait_non_ressources
def _wait_non_ressources(self, callback): """This get started as a thread, and waits for the data lock to be freed then advertise itself to the SelectableSelector using the callback""" # noqa: E501 self.trigger = threading.Lock() self.was_ended = False self.trigger.acquire() sel...
python
def _wait_non_ressources(self, callback): """This get started as a thread, and waits for the data lock to be freed then advertise itself to the SelectableSelector using the callback""" # noqa: E501 self.trigger = threading.Lock() self.was_ended = False self.trigger.acquire() sel...
[ "def", "_wait_non_ressources", "(", "self", ",", "callback", ")", ":", "# noqa: E501", "self", ".", "trigger", "=", "threading", ".", "Lock", "(", ")", "self", ".", "was_ended", "=", "False", "self", ".", "trigger", ".", "acquire", "(", ")", "self", ".",...
This get started as a thread, and waits for the data lock to be freed then advertise itself to the SelectableSelector using the callback
[ "This", "get", "started", "as", "a", "thread", "and", "waits", "for", "the", "data", "lock", "to", "be", "freed", "then", "advertise", "itself", "to", "the", "SelectableSelector", "using", "the", "callback" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/automaton.py#L87-L94
train
secdev/scapy
scapy/automaton.py
SelectableObject.wait_return
def wait_return(self, callback): """Entry point of SelectableObject: register the callback""" if self.check_recv(): return callback(self) _t = threading.Thread(target=self._wait_non_ressources, args=(callback,)) # noqa: E501 _t.setDaemon(True) _t.start()
python
def wait_return(self, callback): """Entry point of SelectableObject: register the callback""" if self.check_recv(): return callback(self) _t = threading.Thread(target=self._wait_non_ressources, args=(callback,)) # noqa: E501 _t.setDaemon(True) _t.start()
[ "def", "wait_return", "(", "self", ",", "callback", ")", ":", "if", "self", ".", "check_recv", "(", ")", ":", "return", "callback", "(", "self", ")", "_t", "=", "threading", ".", "Thread", "(", "target", "=", "self", ".", "_wait_non_ressources", ",", "...
Entry point of SelectableObject: register the callback
[ "Entry", "point", "of", "SelectableObject", ":", "register", "the", "callback" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/automaton.py#L96-L102
train
secdev/scapy
scapy/automaton.py
SelectableObject.call_release
def call_release(self, arborted=False): """DEV: Must be call when the object becomes ready to read. Relesases the lock of _wait_non_ressources""" self.was_ended = arborted try: self.trigger.release() except (threading.ThreadError, AttributeError): pass
python
def call_release(self, arborted=False): """DEV: Must be call when the object becomes ready to read. Relesases the lock of _wait_non_ressources""" self.was_ended = arborted try: self.trigger.release() except (threading.ThreadError, AttributeError): pass
[ "def", "call_release", "(", "self", ",", "arborted", "=", "False", ")", ":", "self", ".", "was_ended", "=", "arborted", "try", ":", "self", ".", "trigger", ".", "release", "(", ")", "except", "(", "threading", ".", "ThreadError", ",", "AttributeError", "...
DEV: Must be call when the object becomes ready to read. Relesases the lock of _wait_non_ressources
[ "DEV", ":", "Must", "be", "call", "when", "the", "object", "becomes", "ready", "to", "read", ".", "Relesases", "the", "lock", "of", "_wait_non_ressources" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/automaton.py#L104-L111
train
secdev/scapy
scapy/automaton.py
SelectableSelector._release_all
def _release_all(self): """Releases all locks to kill all threads""" for i in self.inputs: i.call_release(True) self.available_lock.release()
python
def _release_all(self): """Releases all locks to kill all threads""" for i in self.inputs: i.call_release(True) self.available_lock.release()
[ "def", "_release_all", "(", "self", ")", ":", "for", "i", "in", "self", ".", "inputs", ":", "i", ".", "call_release", "(", "True", ")", "self", ".", "available_lock", ".", "release", "(", ")" ]
Releases all locks to kill all threads
[ "Releases", "all", "locks", "to", "kill", "all", "threads" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/automaton.py#L123-L127
train
secdev/scapy
scapy/automaton.py
SelectableSelector._timeout_thread
def _timeout_thread(self, remain): """Timeout before releasing every thing, if nothing was returned""" time.sleep(remain) if not self._ended: self._ended = True self._release_all()
python
def _timeout_thread(self, remain): """Timeout before releasing every thing, if nothing was returned""" time.sleep(remain) if not self._ended: self._ended = True self._release_all()
[ "def", "_timeout_thread", "(", "self", ",", "remain", ")", ":", "time", ".", "sleep", "(", "remain", ")", "if", "not", "self", ".", "_ended", ":", "self", ".", "_ended", "=", "True", "self", ".", "_release_all", "(", ")" ]
Timeout before releasing every thing, if nothing was returned
[ "Timeout", "before", "releasing", "every", "thing", "if", "nothing", "was", "returned" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/automaton.py#L129-L134
train
secdev/scapy
scapy/automaton.py
SelectableSelector._exit_door
def _exit_door(self, _input): """This function is passed to each SelectableObject as a callback The SelectableObjects have to call it once there are ready""" self.results.append(_input) if self._ended: return self._ended = True self._release_all()
python
def _exit_door(self, _input): """This function is passed to each SelectableObject as a callback The SelectableObjects have to call it once there are ready""" self.results.append(_input) if self._ended: return self._ended = True self._release_all()
[ "def", "_exit_door", "(", "self", ",", "_input", ")", ":", "self", ".", "results", ".", "append", "(", "_input", ")", "if", "self", ".", "_ended", ":", "return", "self", ".", "_ended", "=", "True", "self", ".", "_release_all", "(", ")" ]
This function is passed to each SelectableObject as a callback The SelectableObjects have to call it once there are ready
[ "This", "function", "is", "passed", "to", "each", "SelectableObject", "as", "a", "callback", "The", "SelectableObjects", "have", "to", "call", "it", "once", "there", "are", "ready" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/automaton.py#L136-L143
train
secdev/scapy
scapy/automaton.py
SelectableSelector.process
def process(self): """Entry point of SelectableSelector""" if WINDOWS: select_inputs = [] for i in self.inputs: if not isinstance(i, SelectableObject): warning("Unknown ignored object type: %s", type(i)) elif i.__selectable_forc...
python
def process(self): """Entry point of SelectableSelector""" if WINDOWS: select_inputs = [] for i in self.inputs: if not isinstance(i, SelectableObject): warning("Unknown ignored object type: %s", type(i)) elif i.__selectable_forc...
[ "def", "process", "(", "self", ")", ":", "if", "WINDOWS", ":", "select_inputs", "=", "[", "]", "for", "i", "in", "self", ".", "inputs", ":", "if", "not", "isinstance", "(", "i", ",", "SelectableObject", ")", ":", "warning", "(", "\"Unknown ignored object...
Entry point of SelectableSelector
[ "Entry", "point", "of", "SelectableSelector" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/automaton.py#L153-L179
train
secdev/scapy
scapy/config.py
_version_checker
def _version_checker(module, minver): """Checks that module has a higher version that minver. params: - module: a module to test - minver: a tuple of versions """ # We could use LooseVersion, but distutils imports imp which is deprecated version_regexp = r'[a-z]?((?:\d|\.)+\d+)(?:\.dev[0-...
python
def _version_checker(module, minver): """Checks that module has a higher version that minver. params: - module: a module to test - minver: a tuple of versions """ # We could use LooseVersion, but distutils imports imp which is deprecated version_regexp = r'[a-z]?((?:\d|\.)+\d+)(?:\.dev[0-...
[ "def", "_version_checker", "(", "module", ",", "minver", ")", ":", "# We could use LooseVersion, but distutils imports imp which is deprecated", "version_regexp", "=", "r'[a-z]?((?:\\d|\\.)+\\d+)(?:\\.dev[0-9]+)?'", "version_tags", "=", "re", ".", "match", "(", "version_regexp", ...
Checks that module has a higher version that minver. params: - module: a module to test - minver: a tuple of versions
[ "Checks", "that", "module", "has", "a", "higher", "version", "that", "minver", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/config.py#L356-L370
train
secdev/scapy
scapy/config.py
isCryptographyAdvanced
def isCryptographyAdvanced(): """ Check if the cryptography library is present, and if it supports X25519, ChaCha20Poly1305 and such (v2.0 or later). """ try: from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey # noqa: E501 X25519PrivateKey.generate() e...
python
def isCryptographyAdvanced(): """ Check if the cryptography library is present, and if it supports X25519, ChaCha20Poly1305 and such (v2.0 or later). """ try: from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey # noqa: E501 X25519PrivateKey.generate() e...
[ "def", "isCryptographyAdvanced", "(", ")", ":", "try", ":", "from", "cryptography", ".", "hazmat", ".", "primitives", ".", "asymmetric", ".", "x25519", "import", "X25519PrivateKey", "# noqa: E501", "X25519PrivateKey", ".", "generate", "(", ")", "except", "Exceptio...
Check if the cryptography library is present, and if it supports X25519, ChaCha20Poly1305 and such (v2.0 or later).
[ "Check", "if", "the", "cryptography", "library", "is", "present", "and", "if", "it", "supports", "X25519", "ChaCha20Poly1305", "and", "such", "(", "v2", ".", "0", "or", "later", ")", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/config.py#L396-L407
train
secdev/scapy
scapy/config.py
_prompt_changer
def _prompt_changer(attr, val): """Change the current prompt theme""" try: sys.ps1 = conf.color_theme.prompt(conf.prompt) except Exception: pass try: apply_ipython_style(get_ipython()) except NameError: pass
python
def _prompt_changer(attr, val): """Change the current prompt theme""" try: sys.ps1 = conf.color_theme.prompt(conf.prompt) except Exception: pass try: apply_ipython_style(get_ipython()) except NameError: pass
[ "def", "_prompt_changer", "(", "attr", ",", "val", ")", ":", "try", ":", "sys", ".", "ps1", "=", "conf", ".", "color_theme", ".", "prompt", "(", "conf", ".", "prompt", ")", "except", "Exception", ":", "pass", "try", ":", "apply_ipython_style", "(", "ge...
Change the current prompt theme
[ "Change", "the", "current", "prompt", "theme" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/config.py#L419-L428
train
secdev/scapy
scapy/config.py
_set_conf_sockets
def _set_conf_sockets(): """Populate the conf.L2Socket and conf.L3Socket according to the various use_* parameters """ if conf.use_bpf and not BSD: Interceptor.set_from_hook(conf, "use_bpf", False) raise ScapyInvalidPlatformException("BSD-like (OSX, *BSD...) only !") if conf.use_winp...
python
def _set_conf_sockets(): """Populate the conf.L2Socket and conf.L3Socket according to the various use_* parameters """ if conf.use_bpf and not BSD: Interceptor.set_from_hook(conf, "use_bpf", False) raise ScapyInvalidPlatformException("BSD-like (OSX, *BSD...) only !") if conf.use_winp...
[ "def", "_set_conf_sockets", "(", ")", ":", "if", "conf", ".", "use_bpf", "and", "not", "BSD", ":", "Interceptor", ".", "set_from_hook", "(", "conf", ",", "\"use_bpf\"", ",", "False", ")", "raise", "ScapyInvalidPlatformException", "(", "\"BSD-like (OSX, *BSD...) on...
Populate the conf.L2Socket and conf.L3Socket according to the various use_* parameters
[ "Populate", "the", "conf", ".", "L2Socket", "and", "conf", ".", "L3Socket", "according", "to", "the", "various", "use_", "*", "parameters" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/config.py#L431-L482
train
secdev/scapy
scapy/config.py
crypto_validator
def crypto_validator(func): """ This a decorator to be used for any method relying on the cryptography library. # noqa: E501 Its behaviour depends on the 'crypto_valid' attribute of the global 'conf'. """ def func_in(*args, **kwargs): if not conf.crypto_valid: raise ImportError(...
python
def crypto_validator(func): """ This a decorator to be used for any method relying on the cryptography library. # noqa: E501 Its behaviour depends on the 'crypto_valid' attribute of the global 'conf'. """ def func_in(*args, **kwargs): if not conf.crypto_valid: raise ImportError(...
[ "def", "crypto_validator", "(", "func", ")", ":", "def", "func_in", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "conf", ".", "crypto_valid", ":", "raise", "ImportError", "(", "\"Cannot execute crypto-related method! \"", "\"Please install p...
This a decorator to be used for any method relying on the cryptography library. # noqa: E501 Its behaviour depends on the 'crypto_valid' attribute of the global 'conf'.
[ "This", "a", "decorator", "to", "be", "used", "for", "any", "method", "relying", "on", "the", "cryptography", "library", ".", "#", "noqa", ":", "E501", "Its", "behaviour", "depends", "on", "the", "crypto_valid", "attribute", "of", "the", "global", "conf", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/config.py#L640-L650
train
secdev/scapy
scapy/plist.py
PacketList.filter
def filter(self, func): """Returns a packet list filtered by a truth function. This truth function has to take a packet as the only argument and return a boolean value.""" # noqa: E501 return self.__class__([x for x in self.res if func(x)], name="filtered %s" % sel...
python
def filter(self, func): """Returns a packet list filtered by a truth function. This truth function has to take a packet as the only argument and return a boolean value.""" # noqa: E501 return self.__class__([x for x in self.res if func(x)], name="filtered %s" % sel...
[ "def", "filter", "(", "self", ",", "func", ")", ":", "# noqa: E501", "return", "self", ".", "__class__", "(", "[", "x", "for", "x", "in", "self", ".", "res", "if", "func", "(", "x", ")", "]", ",", "name", "=", "\"filtered %s\"", "%", "self", ".", ...
Returns a packet list filtered by a truth function. This truth function has to take a packet as the only argument and return a boolean value.
[ "Returns", "a", "packet", "list", "filtered", "by", "a", "truth", "function", ".", "This", "truth", "function", "has", "to", "take", "a", "packet", "as", "the", "only", "argument", "and", "return", "a", "boolean", "value", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/plist.py#L163-L167
train
secdev/scapy
scapy/plist.py
PacketList.plot
def plot(self, f, lfilter=None, plot_xy=False, **kargs): """Applies a function to each packet to get a value that will be plotted with matplotlib. A list of matplotlib.lines.Line2D is returned. lfilter: a truth function that decides whether a packet must be plotted """ # Python...
python
def plot(self, f, lfilter=None, plot_xy=False, **kargs): """Applies a function to each packet to get a value that will be plotted with matplotlib. A list of matplotlib.lines.Line2D is returned. lfilter: a truth function that decides whether a packet must be plotted """ # Python...
[ "def", "plot", "(", "self", ",", "f", ",", "lfilter", "=", "None", ",", "plot_xy", "=", "False", ",", "*", "*", "kargs", ")", ":", "# Python 2 backward compatibility", "f", "=", "lambda_tuple_converter", "(", "f", ")", "lfilter", "=", "lambda_tuple_converter...
Applies a function to each packet to get a value that will be plotted with matplotlib. A list of matplotlib.lines.Line2D is returned. lfilter: a truth function that decides whether a packet must be plotted
[ "Applies", "a", "function", "to", "each", "packet", "to", "get", "a", "value", "that", "will", "be", "plotted", "with", "matplotlib", ".", "A", "list", "of", "matplotlib", ".", "lines", ".", "Line2D", "is", "returned", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/plist.py#L182-L211
train
secdev/scapy
scapy/plist.py
PacketList.diffplot
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...
python
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", ")", ":", "# Get the list of packets", "if", "lfilter", "is", "None", ":", "lst_pkts", "=", "[", "f", "(", "self", ".", "res", "[...
diffplot(f, delay=1, lfilter=None) Applies a function to couples (l[i],l[i+delay]) A list of matplotlib.lines.Line2D is returned.
[ "diffplot", "(", "f", "delay", "=", "1", "lfilter", "=", "None", ")", "Applies", "a", "function", "to", "couples", "(", "l", "[", "i", "]", "l", "[", "i", "+", "delay", "]", ")" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/plist.py#L213-L238
train
secdev/scapy
scapy/plist.py
PacketList.multiplot
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...
python
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", ")", ":", "# Python 2 backward compatibility", "f", "=", "lambda_tuple_converter", "(", "f", ")", "lfilter", "=", "lambda_tuple_conv...
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.
[ "Uses", "a", "function", "that", "returns", "a", "label", "and", "a", "value", "for", "this", "label", "then", "plots", "all", "the", "values", "label", "by", "label", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/plist.py#L240-L278
train
secdev/scapy
scapy/plist.py
PacketList.hexraw
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) ...
python
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", ")", ":", "# noqa: E501", "for", "i", ",", "res", "in", "enumerate", "(", "self", ".", "res", ")", ":", "p", "=", "self", ".", "_elt2pkt", "(", "res", ")", "if", "lfilter", "is", "not", "...
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
[ "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", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/plist.py#L285-L296
train
secdev/scapy
scapy/plist.py
PacketList.hexdump
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...
python
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", ")", ":", "# noqa: E501", "for", "i", ",", "res", "in", "enumerate", "(", "self", ".", "res", ")", ":", "p", "=", "self", ".", "_elt2pkt", "(", "res", ")", "if", "lfilter", "is", "not", ...
Same as nsummary(), except that packets are also hexdumped lfilter: a truth function that decides whether a packet must be displayed
[ "Same", "as", "nsummary", "()", "except", "that", "packets", "are", "also", "hexdumped", "lfilter", ":", "a", "truth", "function", "that", "decides", "whether", "a", "packet", "must", "be", "displayed" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/plist.py#L298-L308
train
secdev/scapy
scapy/plist.py
PacketList.conversations
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 ...
python
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", ")", ":", "if", "getsrcdst", "is", "None", ":", "def", "getsrcdst", "(", "pkt", ")", ":", "\"\"\"Extract src and dst addresses\"\"\"", "if", "'IP'", "in", "pkt", ":...
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 ...
[ "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...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/plist.py#L335-L377
train
secdev/scapy
scapy/plist.py
PacketList.afterglow
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...
python
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", ")", ":", "if", "src", "is", "None", ":", "src", "=", "lambda", "x", ":", "x", "[", "'IP'", "]", ".", "src",...
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
[ "Experimental", "clone", "attempt", "of", "http", ":", "//", "sourceforge", ".", "net", "/", "projects", "/", "afterglow", "each", "datum", "is", "reduced", "as", "src", "-", ">", "event", "-", ">", "dst", "and", "the", "data", "are", "graphed", ".", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/plist.py#L379-L461
train
secdev/scapy
scapy/plist.py
PacketList.sr
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 ...
python
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", ")", ":", "# noqa: E501", "remain", "=", "self", ".", "res", "[", ":", "]", "sr", "=", "[", "]", "i", "=", "0", "while", "i", "<", "len", "(", "remain", ")", ":", "s", "=", "remain", "[", "i...
sr([multi=1]) -> (SndRcvList, PacketList) Matches packets in the list and return ( (matched couples), (unmatched packets) )
[ "sr", "(", "[", "multi", "=", "1", "]", ")", "-", ">", "(", "SndRcvList", "PacketList", ")", "Matches", "packets", "in", "the", "list", "and", "return", "(", "(", "matched", "couples", ")", "(", "unmatched", "packets", ")", ")" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/plist.py#L478-L503
train
secdev/scapy
scapy/plist.py
PacketList.replace
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 ) ...
python
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", ")", ":", "delete_checksums", "=", "kargs", ".", "get", "(", "\"delete_checksums\"", ",", "False", ")", "x", "=", "PacketList", "(", "name", "=", "\"Replaced %s\"", "%", "self", "...
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), )
[ "lst", ".", "replace", "(", "<field", ">", "[", "<oldvalue", ">", "]", "<newvalue", ">", ")", "lst", ".", "replace", "(", "(", "fld", "[", "ov", "]", "nv", ")", "(", "fld", "[", "ov", "]", "nv", ")", "...", ")", "if", "ov", "is", "None", "all...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/plist.py#L540-L571
train
secdev/scapy
scapy/arch/common.py
_check_tcpdump
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:...
python
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", "(", ")", ":", "with", "open", "(", "os", ".", "devnull", ",", "'wb'", ")", "as", "devnull", ":", "try", ":", "proc", "=", "subprocess", ".", "Popen", "(", "[", "conf", ".", "prog", ".", "tcpdump", ",", "\"--version\"", "]", ...
Return True if the tcpdump command can be started
[ "Return", "True", "if", "the", "tcpdump", "command", "can", "be", "started" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/common.py#L31-L46
train
secdev/scapy
scapy/arch/common.py
get_if
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
python
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", ")", ":", "sck", "=", "socket", ".", "socket", "(", ")", "ifreq", "=", "ioctl", "(", "sck", ",", "cmd", ",", "struct", ".", "pack", "(", "\"16s16x\"", ",", "iff", ".", "encode", "(", "\"utf8\"", ")", ")", ...
Ease SIOCGIF* ioctl calls
[ "Ease", "SIOCGIF", "*", "ioctl", "calls" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/common.py#L55-L61
train
secdev/scapy
scapy/arch/common.py
_select_nonblock
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): ...
python
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", ")", ":", "# 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", ...
This function is called during sendrecv() routine to select the available sockets.
[ "This", "function", "is", "called", "during", "sendrecv", "()", "routine", "to", "select", "the", "available", "sockets", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/common.py#L70-L84
train
secdev/scapy
scapy/arch/common.py
_legacy_bpf_pointer
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...
python
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", ")", ":", "X86_64", "=", "os", ".", "uname", "(", ")", "[", "4", "]", "in", "[", "'x86_64'", ",", "'aarch64'", "]", "size", "=", "int", "(", "tcpdump_lines", "[", "0", "]", ")", "bpf", "=", "b\"\"",...
Get old-format BPF Pointer. Deprecated
[ "Get", "old", "-", "format", "BPF", "Pointer", ".", "Deprecated" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/common.py#L103-L125
train
secdev/scapy
scapy/arch/common.py
get_bpf_pointer
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...
python
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", ")", ":", "if", "conf", ".", "use_pypy", ":", "return", "_legacy_bpf_pointer", "(", "tcpdump_lines", ")", "# Allocate BPF instructions", "size", "=", "int", "(", "tcpdump_lines", "[", "0", "]", ")", "bpf_insn_a", "...
Create a BPF Pointer for TCPDump filter
[ "Create", "a", "BPF", "Pointer", "for", "TCPDump", "filter" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/common.py#L128-L150
train
secdev/scapy
scapy/arch/common.py
compile_filter
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...
python
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", ")", ":", "if", "not", "TCPDUMP", ":", "raise", "Scapy_Exception", "(", "\"tcpdump is not available. Cannot use filter !\"", ")", "try", ":", "process", "=", "subprocess", ".", "Popen", "(", ...
Asks Tcpdump to parse the filter, then build the matching BPF bytecode using get_bpf_pointer.
[ "Asks", "Tcpdump", "to", "parse", "the", "filter", "then", "build", "the", "matching", "BPF", "bytecode", "using", "get_bpf_pointer", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/common.py#L153-L179
train
secdev/scapy
scapy/contrib/lldp.py
_ldp_id_adjustlen
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
python
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", ")", ":", "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
[ "Return", "the", "length", "of", "the", "id", "field", "according", "to", "its", "real", "encoded", "type" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/lldp.py#L326-L330
train
secdev/scapy
scapy/contrib/lldp.py
LLDPDU._dot1q_headers_size
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...
python
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", ")", ":", "vlan_headers_size", "=", "0", "under_layer", "=", "layer", "while", "under_layer", "and", "isinstance", "(", "under_layer", ",", "Dot1Q", ")", ":", "vlan_headers_size", "+=", "LLDPDU", ".", "DOT1Q_HEADER_LEN",...
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
[ "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" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/lldp.py#L135-L149
train
secdev/scapy
scapy/contrib/lldp.py
LLDPDU._frame_structure_check
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...
python
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", ")", ":", "standard_frame_structure", "=", "[", "LLDPDUChassisID", ".", "__name__", ",", "LLDPDUPortID", ".", "__name__", ",", "LLDPDUTimeToLive", ".", "__name__", ",", "'<...>'", ",", "LLDPDUEndOfLLDPDU", ...
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
[ "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...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/lldp.py#L188-L221
train
secdev/scapy
scapy/contrib/lldp.py
LLDPDU._tlv_multiplicities_check
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_...
python
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", ")", ":", "# * : 0..n, 1 : one and only one.", "standard_multiplicities", "=", "{", "LLDPDUEndOfLLDPDU", ".", "__name__", ":", "1", ",", "LLDPDUChassisID", ".", "__name__", ":", "1", ",", "LLDPDUPortID", ".", ...
check if multiplicity of present TLVs conforms to the standard :param tlv_type_count: dict containing counte-per-TLV
[ "check", "if", "multiplicity", "of", "present", "TLVs", "conforms", "to", "the", "standard", ":", "param", "tlv_type_count", ":", "dict", "containing", "counte", "-", "per", "-", "TLV" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/lldp.py#L224-L261
train
secdev/scapy
scapy/contrib/lldp.py
LLDPDUTimeToLive._check
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))
python
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", ")", ":", "if", "conf", ".", "contribs", "[", "'LLDP'", "]", ".", "strict_mode", "(", ")", "and", "self", ".", "_length", "!=", "2", ":", "raise", "LLDPInvalidLengthField", "(", "'length must be 2 - got '", "'{}'", ".", "forma...
run layer specific checks
[ "run", "layer", "specific", "checks" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/lldp.py#L435-L441
train
secdev/scapy
scapy/contrib/lldp.py
LLDPDUManagementAddress._check
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( ...
python
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", ")", ":", "if", "conf", ".", "contribs", "[", "'LLDP'", "]", ".", "strict_mode", "(", ")", ":", "management_address_len", "=", "len", "(", "self", ".", "management_address", ")", "if", "management_address_len", "==", "0", "or"...
run layer specific checks
[ "run", "layer", "specific", "checks" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/lldp.py#L668-L677
train
secdev/scapy
scapy/arch/windows/structures.py
GetIcmpStatistics
def GetIcmpStatistics(): """Return all Windows ICMP stats from iphlpapi""" statistics = MIB_ICMP() _GetIcmpStatistics(byref(statistics)) results = _struct_to_dict(statistics) del(statistics) return results
python
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", "(", ")", ":", "statistics", "=", "MIB_ICMP", "(", ")", "_GetIcmpStatistics", "(", "byref", "(", "statistics", ")", ")", "results", "=", "_struct_to_dict", "(", "statistics", ")", "del", "(", "statistics", ")", "return", "results" ]
Return all Windows ICMP stats from iphlpapi
[ "Return", "all", "Windows", "ICMP", "stats", "from", "iphlpapi" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/structures.py#L166-L172
train
secdev/scapy
scapy/arch/windows/structures.py
GetAdaptersAddresses
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)) ...
python
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", ")", ":", "# We get the size first", "size", "=", "ULONG", "(", ")", "flags", "=", "GAA_FLAG_INCLUDE_PREFIX", "res", "=", "_GetAdaptersAddresses", "(", "AF", ",", "flags", ",", "None", ",", "None", ",...
Return all Windows Adapters addresses from iphlpapi
[ "Return", "all", "Windows", "Adapters", "addresses", "from", "iphlpapi" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/structures.py#L377-L399
train
secdev/scapy
scapy/arch/windows/structures.py
GetIpForwardTable
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)" ...
python
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", "(", ")", ":", "# We get the size first", "size", "=", "ULONG", "(", ")", "res", "=", "_GetIpForwardTable", "(", "None", ",", "byref", "(", "size", ")", ",", "False", ")", "if", "res", "!=", "0x7a", ":", "# ERROR_INSUFFICIENT_BUFF...
Return all Windows routes (IPv4 only) from iphlpapi
[ "Return", "all", "Windows", "routes", "(", "IPv4", "only", ")", "from", "iphlpapi" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/structures.py#L439-L458
train
secdev/scapy
scapy/arch/windows/structures.py
GetIpForwardTable2
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...
python
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", ")", ":", "if", "WINDOWS_XP", ":", "raise", "OSError", "(", "\"Not available on Windows XP !\"", ")", "table", "=", "PMIB_IPFORWARD_TABLE2", "(", ")", "res", "=", "_GetIpForwardTable2", "(", "AF", ",", "b...
Return all Windows routes (IPv4/IPv6) from iphlpapi
[ "Return", "all", "Windows", "routes", "(", "IPv4", "/", "IPv6", ")", "from", "iphlpapi" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/structures.py#L516-L528
train
secdev/scapy
scapy/layers/tls/crypto/cipher_block.py
_BlockCipher.encrypt
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...
python
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", ")", ":", "if", "False", "in", "six", ".", "itervalues", "(", "self", ".", "ready", ")", ":", "raise", "CipherError", "(", "data", ")", "encryptor", "=", "self", ".", "_cipher", ".", "encryptor", "(", ")", ...
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().
[ "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", ".", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/crypto/cipher_block.py#L77-L87
train
secdev/scapy
scapy/layers/tls/crypto/cipher_block.py
_BlockCipher.decrypt
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...
python
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", ")", ":", "if", "False", "in", "six", ".", "itervalues", "(", "self", ".", "ready", ")", ":", "raise", "CipherError", "(", "data", ")", "decryptor", "=", "self", ".", "_cipher", ".", "decryptor", "(", ")", ...
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.
[ "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", ".", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/crypto/cipher_block.py#L89-L100
train
secdev/scapy
scapy/layers/radius.py
prepare_packed_data
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...
python
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", ")", ":", "packed_hdr", "=", "struct", ".", "pack", "(", "\"!B\"", ",", "radius_packet", ".", "code", ")", "packed_hdr", "+=", "struct", ".", "pack", "(", "\"!B\"", ",", "radi...
Pack RADIUS data prior computing the authentication MAC
[ "Pack", "RADIUS", "data", "prior", "computing", "the", "authentication", "MAC" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/radius.py#L534-L547
train
secdev/scapy
scapy/layers/radius.py
RadiusAttribute.register_variant
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
python
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", ")", ":", "if", "hasattr", "(", "cls", ",", "\"val\"", ")", ":", "cls", ".", "registered_attributes", "[", "cls", ".", "val", "]", "=", "cls", "else", ":", "cls", ".", "registered_attributes", "[", "cls", ".", "ty...
Registers the RADIUS attributes defined in this module.
[ "Registers", "the", "RADIUS", "attributes", "defined", "in", "this", "module", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/radius.py#L239-L247
train
secdev/scapy
scapy/layers/radius.py
RadiusAttribute.dispatch_hook
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
python
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", ")", ":", "if", "_pkt", ":", "attr_type", "=", "orb", "(", "_pkt", "[", "0", "]", ")", "return", "cls", ".", "registered_attributes", ".", "get"...
Returns the right RadiusAttribute class for the given data.
[ "Returns", "the", "right", "RadiusAttribute", "class", "for", "the", "given", "data", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/radius.py#L250-L258
train
secdev/scapy
scapy/layers/radius.py
RadiusAttr_Message_Authenticator.compute_message_authenticator
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...
python
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", ")", ":", "data", "=", "prepare_packed_data", "(", "radius_packet", ",", "packed_req_authenticator", ")", "radius_hmac", "=", "hmac", ".", "new", "(", ...
Computes the "Message-Authenticator" of a given RADIUS packet.
[ "Computes", "the", "Message", "-", "Authenticator", "of", "a", "given", "RADIUS", "packet", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/radius.py#L566-L575
train
secdev/scapy
scapy/layers/radius.py
Radius.compute_authenticator
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()
python
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", ")", ":", "data", "=", "prepare_packed_data", "(", "self", ",", "packed_request_auth", ")", "radius_mac", "=", "hashlib", ".", "md5", "(", "data", "+", "shared_secret", ...
Computes the authenticator field (RFC 2865 - Section 3)
[ "Computes", "the", "authenticator", "field", "(", "RFC", "2865", "-", "Section", "3", ")" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/radius.py#L1132-L1139
train
secdev/scapy
scapy/layers/tls/keyexchange_tls13.py
KeyShareEntry.do_build
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
python
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", ")", ":", "tmp", "=", "self", ".", "explicit", "self", ".", "explicit", "=", "True", "b", "=", "super", "(", "KeyShareEntry", ",", "self", ")", ".", "do_build", "(", ")", "self", ".", "explicit", "=", "tmp", "return", ...
We need this hack, else 'self' would be replaced by __iter__.next().
[ "We", "need", "this", "hack", "else", "self", "would", "be", "replaced", "by", "__iter__", ".", "next", "()", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/keyexchange_tls13.py#L48-L56
train
secdev/scapy
scapy/layers/tls/keyexchange_tls13.py
KeyShareEntry.create_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 ...
python
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", ")", ":", "if", "self", ".", "group", "in", "_tls_named_ffdh_groups", ":", "params", "=", "_ffdh_groups", "[", "_tls_named_ffdh_groups", "[", "self", ".", "group", "]", "]", "[", "0", "]", "privkey", "=", "params", "."...
This is called by post_build() for key creation.
[ "This", "is", "called", "by", "post_build", "()", "for", "key", "creation", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/keyexchange_tls13.py#L59-L89
train
secdev/scapy
scapy/arch/unix.py
_guess_iface_name
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'...
python
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", ")", ":", "with", "os", ".", "popen", "(", "'%s -l'", "%", "conf", ".", "prog", ".", "ifconfig", ")", "as", "fdesc", ":", "ifaces", "=", "fdesc", ".", "readline", "(", ")", ".", "strip", "(", ")", ".", "spl...
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.
[ "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...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/unix.py#L28-L41
train
secdev/scapy
scapy/arch/unix.py
_in6_getifaddr
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 [...
python
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", ")", ":", "# Get the output of ifconfig", "try", ":", "f", "=", "os", ".", "popen", "(", "\"%s %s\"", "%", "(", "conf", ".", "prog", ".", "ifconfig", ",", "ifname", ")", ")", "except", "OSError", ":", "log_interactiv...
Returns a list of IPv6 addresses configured on the interface ifname.
[ "Returns", "a", "list", "of", "IPv6", "addresses", "configured", "on", "the", "interface", "ifname", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/unix.py#L149-L181
train
secdev/scapy
scapy/arch/unix.py
in6_getifaddr
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...
python
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", "(", ")", ":", "# List all network interfaces", "if", "OPENBSD", ":", "try", ":", "f", "=", "os", ".", "popen", "(", "\"%s\"", "%", "conf", ".", "prog", ".", "ifconfig", ")", "except", "OSError", ":", "log_interactive", ".", "warnin...
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.
[ "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", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/unix.py#L184-L222
train
secdev/scapy
scapy/arch/unix.py
read_routes6
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 ...
python
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", "(", ")", ":", "# 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...
Return a list of IPv6 routes than can be used by Scapy.
[ "Return", "a", "list", "of", "IPv6", "routes", "than", "can", "be", "used", "by", "Scapy", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/unix.py#L225-L339
train
secdev/scapy
scapy/main.py
_read_config_file
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...
python
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", "log_loading", ".", "debug", "(", "\"Loading config file [%s]\"", ",", "cf",...
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 #...
[ "Read", "a", "config", "file", ":", "execute", "a", "python", "file", "while", "loading", "scapy", "that", "may", "contain", "#", "noqa", ":", "E501", "some", "pre", "-", "configured", "values", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/main.py#L64-L95
train
secdev/scapy
scapy/main.py
_load
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...
python
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", ")", ":", "if", "globals_dict", "is", "None", ":", "globals_dict", "=", "six", ".", "moves", ".", "builtins", ".", "__dict__", "try", ":", "mod", "=", "impo...
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.
[ "Loads", "a", "Python", "module", "to", "make", "variables", "objects", "and", "functions", "available", "globally", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/main.py#L123-L149
train
secdev/scapy
scapy/main.py
load_module
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)
python
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", ")", ":", "_load", "(", "\"scapy.modules.\"", "+", "name", ",", "globals_dict", "=", "globals_dict", ",", "symb_list", "=", "symb_list", ")" ]
Loads a Scapy module to make variables, objects and functions available globally.
[ "Loads", "a", "Scapy", "module", "to", "make", "variables", "objects", "and", "functions", "available", "globally", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/main.py#L152-L158
train
secdev/scapy
scapy/main.py
load_layer
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)
python
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", ")", ":", "_load", "(", "\"scapy.layers.\"", "+", "LAYER_ALIASES", ".", "get", "(", "name", ",", "name", ")", ",", "globals_dict", "=", "globals_dict", ",", ...
Loads a Scapy layer module to make variables, objects and functions available globally.
[ "Loads", "a", "Scapy", "layer", "module", "to", "make", "variables", "objects", "and", "functions", "available", "globally", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/main.py#L161-L167
train
secdev/scapy
scapy/main.py
load_contrib
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: ...
python
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", ")", ":", "try", ":", "importlib", ".", "import_module", "(", "\"scapy.contrib.\"", "+", "name", ")", "_load", "(", "\"scapy.contrib.\"", "+", "name", ",", ...
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.
[ "Loads", "a", "Scapy", "contrib", "module", "to", "make", "variables", "objects", "and", "functions", "available", "globally", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/main.py#L170-L188
train
secdev/scapy
scapy/main.py
list_contrib
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...
python
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", ")", ":", "# _debug: checks that all contrib modules have correctly defined:", "# # scapy.contrib.description = [...]", "# # scapy.contrib.status = [...]", "# # scapy.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
[ "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...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/main.py#L191-L249
train
secdev/scapy
scapy/main.py
save_session
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...
python
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", ")", ":", "from", "scapy", "import", "utils", "if", "fname", "is", "None", ":", "fname", "=", "conf", ".", "session", "if", "not", "fnam...
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)
[ "Save", "current", "Scapy", "session", "to", "the", "file", "specified", "in", "the", "fname", "arg", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/main.py#L265-L308
train
secdev/scapy
scapy/main.py
load_session
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...
python
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", ")", ":", "if", "fname", "is", "None", ":", "fname", "=", "conf", ".", "session", "try", ":", "s", "=", "six", ".", "moves", ".", "cPickle", ".", "load", "(", "gzip", ".", "open", "(", "fname", ",...
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
[ "Load", "current", "Scapy", "session", "from", "the", "file", "specified", "in", "the", "fname", "arg", ".", "This", "will", "erase", "any", "existing", "session", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/main.py#L311-L333
train
secdev/scapy
scapy/main.py
update_session
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: ...
python
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", ")", ":", "if", "fname", "is", "None", ":", "fname", "=", "conf", ".", "session", "try", ":", "s", "=", "six", ".", "moves", ".", "cPickle", ".", "load", "(", "gzip", ".", "open", "(", "fname", ...
Update current Scapy session from the file specified in the fname arg. params: - fname: file to load the scapy session from
[ "Update", "current", "Scapy", "session", "from", "the", "file", "specified", "in", "the", "fname", "arg", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/main.py#L336-L349
train
secdev/scapy
scapy/main.py
_prepare_quote
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) -...
python
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", ")", ":", "quote", "=", "quote", ".", "split", "(", "' '", ")", "max_len", "-=", "6", "lines", "=", "[", "]", "cur_line", "=", "[", "]", "def", "_len", "(", "line", ...
This function processes a quote and returns a string that is ready to be used in the fancy prompt.
[ "This", "function", "processes", "a", "quote", "and", "returns", "a", "string", "that", "is", "ready", "to", "be", "used", "in", "the", "fancy", "prompt", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/main.py#L413-L435
train
secdev/scapy
scapy/autorun.py
autorun_get_interactive_session
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...
python
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", ")", ":", "sstdout", ",", "sstderr", "=", "sys", ".", "stdout", ",", "sys", ".", "stderr", "sw", "=", "StringWriter", "(", ")", "try", ":", "try", ":", "sys", ".", "stdout",...
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
[ "Create", "an", "interactive", "session", "and", "execute", "the", "commands", "passed", "as", "cmds", "and", "return", "all", "output" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/autorun.py#L103-L123
train
secdev/scapy
scapy/contrib/ethercat.py
LEBitField._check_field_type
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...
python
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", ")", ":", "my_idx", "=", "pkt", ".", "fields_desc", ".", "index", "(", "self", ")", "try", ":", "next_field", "=", "pkt", ".", "fields_desc", "[", "my_idx", "+", "index", "]", "if", "...
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
[ "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" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/ethercat.py#L78-L96
train
secdev/scapy
scapy/contrib/ethercat.py
LEBitField.getfield
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 ...
python
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", ")", ":", "if", "type", "(", "s", ")", "is", "tuple", "and", "len", "(", "s", ")", "==", "3", ":", "s", ",", "bits_in_set", ",", "fields", "=", "s", "else", ":", "bits_in_set", "=", "0", "...
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...
[ "extract", "data", "from", "raw", "str" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/ethercat.py#L160-L251
train
secdev/scapy
scapy/contrib/ethercat.py
EtherCat.post_build
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 ...
python
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", ")", ":", "class", "_EtherCatLengthCalc", "(", "Packet", ")", ":", "\"\"\"\n dummy class used to generate str representation easily\n \"\"\"", "fields_desc", "=", "[", "LEBitField", "(", "'len...
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...
[ "need", "to", "set", "the", "length", "of", "the", "whole", "PDU", "manually", "to", "avoid", "any", "bit", "fiddling", "use", "a", "dummy", "class", "to", "build", "the", "layer", "content" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/ethercat.py#L561-L619
train
secdev/scapy
scapy/utils6.py
get_source_addr_from_candidate_set
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 ...
python
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", ")", ":", "def", "scope_cmp", "(", "a", ",", "b", ")", ":", "\"\"\"\n Given two addresses, returns -1, 0 or 1 based on comparison of\n their scope\n \"\"\"", "scope_mapper", "=", ...
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.
[ "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", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L86-L165
train
secdev/scapy
scapy/utils6.py
in6_mactoifaceid
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...
python
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", ")", ":", "if", "len", "(", "mac", ")", "!=", "17", ":", "return", "None", "m", "=", "\"\"", ".", "join", "(", "mac", ".", "split", "(", "':'", ")", ")", "if", "len", "(", "m", ...
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.
[ "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",...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L203-L222
train
secdev/scapy
scapy/utils6.py
in6_ifaceidtomac
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, "::"...
python
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", ")", ":", "try", ":", "# Set ifaceid to a binary form", "ifaceid", "=", "inet_pton", "(", "socket", ".", "AF_INET6", ",", "\"::\"", "+", "ifaceid", ")", "[", "8", ":", "16", "]", "except", "Exception", ":", "return"...
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.
[ "Extract", "the", "mac", "address", "from", "provided", "iface", "ID", ".", "Iface", "ID", "is", "provided", "in", "printable", "format", "(", "XXXX", ":", "XXFF", ":", "FEXX", ":", "XXXX", "eventually", "compressed", ")", ".", "None", "is", "returned", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L225-L248
train
secdev/scapy
scapy/utils6.py
in6_addrtomac
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...
python
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", ")", ":", "mask", "=", "inet_pton", "(", "socket", ".", "AF_INET6", ",", "\"::ffff:ffff:ffff:ffff\"", ")", "x", "=", "in6_and", "(", "mask", ",", "inet_pton", "(", "socket", ".", "AF_INET6", ",", "addr", ")", ")", "if...
Extract the mac address from provided address. None is returned on error.
[ "Extract", "the", "mac", "address", "from", "provided", "address", ".", "None", "is", "returned", "on", "error", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L251-L259
train
secdev/scapy
scapy/utils6.py
in6_addrtovendor
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. ...
python
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", ")", ":", "mac", "=", "in6_addrtomac", "(", "addr", ")", "if", "mac", "is", "None", "or", "conf", ".", "manufdb", "is", "None", ":", "return", "None", "res", "=", "conf", ".", "manufdb", ".", "_get_manuf", "(", ...
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 ...
[ "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...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L262-L279
train
secdev/scapy
scapy/utils6.py
in6_getLinkScopedMcastAddr
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 ...
python
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", ")", ":", "if", "scope", "not", "in", "[", "0", ",", "1", ",", "2", "]", ":", "return", "None", "try", ":", "if", "not", "in6_islladdr", "(", "addr...
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...
[ "Generate", "a", "Link", "-", "Scoped", "Multicast", "Address", "as", "described", "in", "RFC", "4489", ".", "Returned", "value", "is", "in", "printable", "notation", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L282-L338
train
secdev/scapy
scapy/utils6.py
in6_getLocalUniquePrefix
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, ...
python
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", "(", ")", ":", "# 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....
Returns a pseudo-randomly generated Local Unique prefix. Function follows recommendation of Section 3.2.2 of RFC 4193 for prefix generation.
[ "Returns", "a", "pseudo", "-", "randomly", "generated", "Local", "Unique", "prefix", ".", "Function", "follows", "recommendation", "of", "Section", "3", ".", "2", ".", "2", "of", "RFC", "4193", "for", "prefix", "generation", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L369-L395
train
secdev/scapy
scapy/utils6.py
in6_getRandomizedIfaceId
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 ...
python
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", ")", ":", "s", "=", "b\"\"", "if", "previous", "is", "None", ":", "d", "=", "b\"\"", ".", "join", "(", "chb", "(", "x", ")", "for", "x", "in", "range", "(", "256", ")"...
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...
[ "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...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L398-L430
train
secdev/scapy
scapy/utils6.py
in6_ptoc
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*...
python
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", ")", ":", "try", ":", "d", "=", "struct", ".", "unpack", "(", "\"!IIII\"", ",", "inet_pton", "(", "socket", ".", "AF_INET6", ",", "addr", ")", ")", "except", "Exception", ":", "return", "None", "res", "=", "0", "m", ...
Converts an IPv6 address in printable representation to RFC 1924 Compact Representation ;-) Returns None on error.
[ "Converts", "an", "IPv6", "address", "in", "printable", "representation", "to", "RFC", "1924", "Compact", "Representation", ";", "-", ")", "Returns", "None", "on", "error", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L462-L482
train
secdev/scapy
scapy/utils6.py
in6_isaddrTeredo
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 =...
python
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", ")", ":", "our", "=", "inet_pton", "(", "socket", ".", "AF_INET6", ",", "x", ")", "[", "0", ":", "4", "]", "teredoPrefix", "=", "inet_pton", "(", "socket", ".", "AF_INET6", ",", "conf", ".", "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. Address must be passed in printable format.
[ "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", "....
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L498-L507
train
secdev/scapy
scapy/utils6.py
teredoAddrExtractInfo
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...
python
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", ")", ":", "addr", "=", "inet_pton", "(", "socket", ".", "AF_INET6", ",", "x", ")", "server", "=", "inet_ntop", "(", "socket", ".", "AF_INET", ",", "addr", "[", "4", ":", "8", "]", ")", "flag", "=", "struct", ...
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.
[ "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", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L510-L522
train
secdev/scapy
scapy/utils6.py
in6_iseui64
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') ...
python
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", ")", ":", "eui64", "=", "inet_pton", "(", "socket", ".", "AF_INET6", ",", "'::ff:fe00:0'", ")", "x", "=", "in6_and", "(", "inet_pton", "(", "socket", ".", "AF_INET6", ",", "x", ")", ",", "eui64", ")", "return", "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.
[ "Return", "True", "if", "provided", "address", "has", "an", "interface", "identifier", "part", "created", "in", "modified", "EUI", "-", "64", "format", "(", "meaning", "it", "matches", "*", "::", "*", ":", "*", "ff", ":", "fe", "*", ":", "*", ")", "....
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L525-L534
train
secdev/scapy
scapy/utils6.py
in6_getnsma
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:...
python
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", ")", ":", "r", "=", "in6_and", "(", "a", ",", "inet_pton", "(", "socket", ".", "AF_INET6", ",", "'::ff:ffff'", ")", ")", "r", "=", "in6_or", "(", "inet_pton", "(", "socket", ".", "AF_INET6", ",", "'ff02::1:ff00:0'", ")",...
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.
[ "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", "."...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L611-L620
train
secdev/scapy
scapy/utils6.py
in6_getha
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)
python
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", ")", ":", "r", "=", "in6_and", "(", "inet_pton", "(", "socket", ".", "AF_INET6", ",", "prefix", ")", ",", "in6_cidr2mask", "(", "64", ")", ")", "r", "=", "in6_or", "(", "r", ",", "inet_pton", "(", "socket", ".", "...
Return the anycast address associated with all home agents on a given subnet.
[ "Return", "the", "anycast", "address", "associated", "with", "all", "home", "agents", "on", "a", "given", "subnet", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L635-L642
train
secdev/scapy
scapy/utils6.py
in6_isincluded
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)
python
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", ")", ":", "temp", "=", "inet_pton", "(", "socket", ".", "AF_INET6", ",", "addr", ")", "pref", "=", "in6_cidr2mask", "(", "plen", ")", "zero", "=", "inet_pton", "(", "socket", ".", "AF_IN...
Returns True when 'addr' belongs to prefix/plen. False otherwise.
[ "Returns", "True", "when", "addr", "belongs", "to", "prefix", "/", "plen", ".", "False", "otherwise", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L653-L660
train
secdev/scapy
scapy/utils6.py
in6_isllsnmaddr
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\...
python
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", ")", ":", "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...
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.
[ "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...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L663-L671
train
secdev/scapy
scapy/utils6.py
in6_getscope
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): ...
python
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", ")", ":", "if", "in6_isgladdr", "(", "addr", ")", "or", "in6_isuladdr", "(", "addr", ")", ":", "scope", "=", "IPV6_ADDR_GLOBAL", "elif", "in6_islladdr", "(", "addr", ")", ":", "scope", "=", "IPV6_ADDR_LINKLOCAL", "elif", ...
Returns the scope of the address.
[ "Returns", "the", "scope", "of", "the", "address", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L783-L808
train
secdev/scapy
scapy/utils6.py
in6_get_common_plen
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...
python
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", ")", ":", "def", "matching_bits", "(", "byte1", ",", "byte2", ")", ":", "for", "i", "in", "range", "(", "8", ")", ":", "cur_mask", "=", "0x80", ">>", "i", "if", "(", "byte1", "&", "cur_mask", ")", ...
Return common prefix length of IPv6 addresses a and b.
[ "Return", "common", "prefix", "length", "of", "IPv6", "addresses", "a", "and", "b", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L811-L828
train
secdev/scapy
scapy/utils6.py
in6_isvalid
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
python
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", ")", ":", "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.
[ "Return", "True", "if", "address", "is", "a", "valid", "IPv6", "address", "string", "False", "otherwise", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils6.py#L831-L839
train
secdev/scapy
scapy/arch/bpf/core.py
get_if_raw_addr
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...
python
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", ")", ":", "# noqa: E501", "# Get ifconfig output", "try", ":", "fd", "=", "os", ".", "popen", "(", "\"%s %s\"", "%", "(", "conf", ".", "prog", ".", "ifconfig", ",", "ifname", ")", ")", "except", "OSError", "as", "...
Returns the IPv4 address configured on 'ifname', packed with inet_pton.
[ "Returns", "the", "IPv4", "address", "configured", "on", "ifname", "packed", "with", "inet_pton", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/core.py#L36-L56
train
secdev/scapy
scapy/arch/bpf/core.py
get_if_raw_hwaddr
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...
python
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", ")", ":", "NULL_MAC_ADDRESS", "=", "b'\\x00'", "*", "6", "# Handle the loopback interface separately", "if", "ifname", "==", "LOOPBACK_NAME", ":", "return", "(", "ARPHDR_LOOPBACK", ",", "NULL_MAC_ADDRESS", ")", "# Get ifconfig ...
Returns the packed MAC address configured on 'ifname'.
[ "Returns", "the", "packed", "MAC", "address", "configured", "on", "ifname", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/core.py#L59-L84
train
secdev/scapy
scapy/arch/bpf/core.py
get_dev_bpf
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...
python
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", "(", ")", ":", "# Get the first available BPF handle", "for", "bpf", "in", "range", "(", "256", ")", ":", "try", ":", "fd", "=", "os", ".", "open", "(", "\"/dev/bpf%i\"", "%", "bpf", ",", "os", ".", "O_RDWR", ")", "return", "(", "...
Returns an opened BPF file object
[ "Returns", "an", "opened", "BPF", "file", "object" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/core.py#L89-L100
train
secdev/scapy
scapy/arch/bpf/core.py
attach_filter
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...
python
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", ")", ":", "bp", "=", "compile_filter", "(", "bpf_filter", ",", "iface", ")", "# Assign the BPF program to the interface", "ret", "=", "LIBC", ".", "ioctl", "(", "c_int", "(", "fd", ")", ",",...
Attach a BPF filter to the BPF file descriptor
[ "Attach", "a", "BPF", "filter", "to", "the", "BPF", "file", "descriptor" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/core.py#L103-L109
train
secdev/scapy
scapy/arch/bpf/core.py
get_if_list
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...
python
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", "(", ")", ":", "# Get ifconfig output", "try", ":", "fd", "=", "os", ".", "popen", "(", "\"%s -a\"", "%", "conf", ".", "prog", ".", "ifconfig", ")", "except", "OSError", "as", "msg", ":", "raise", "Scapy_Exception", "(", "\"Failed to ...
Returns a list containing all network interfaces.
[ "Returns", "a", "list", "containing", "all", "network", "interfaces", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/core.py#L114-L126
train
secdev/scapy
scapy/arch/bpf/core.py
get_working_ifaces
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...
python
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", "(", ")", ":", "# Only root is allowed to perform the following ioctl() call", "if", "os", ".", "getuid", "(", ")", "!=", "0", ":", "return", "[", "]", "# Test all network interfaces", "interfaces", "=", "[", "]", "for", "ifname", "in", ...
Returns an ordered list of interfaces that could be used with BPF. Note: the order mimics pcap_findalldevs() behavior
[ "Returns", "an", "ordered", "list", "of", "interfaces", "that", "could", "be", "used", "with", "BPF", ".", "Note", ":", "the", "order", "mimics", "pcap_findalldevs", "()", "behavior" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/core.py#L132-L182
train