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
joke2k/faker
faker/providers/credit_card/__init__.py
Provider.credit_card_provider
def credit_card_provider(self, card_type=None): """ Returns the provider's name of the credit card. """ if card_type is None: card_type = self.random_element(self.credit_card_types.keys()) return self._credit_card_type(card_type).name
python
def credit_card_provider(self, card_type=None): """ Returns the provider's name of the credit card. """ if card_type is None: card_type = self.random_element(self.credit_card_types.keys()) return self._credit_card_type(card_type).name
[ "def", "credit_card_provider", "(", "self", ",", "card_type", "=", "None", ")", ":", "if", "card_type", "is", "None", ":", "card_type", "=", "self", ".", "random_element", "(", "self", ".", "credit_card_types", ".", "keys", "(", ")", ")", "return", "self",...
Returns the provider's name of the credit card.
[ "Returns", "the", "provider", "s", "name", "of", "the", "credit", "card", "." ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/credit_card/__init__.py#L61-L65
train
joke2k/faker
faker/providers/credit_card/__init__.py
Provider.credit_card_number
def credit_card_number(self, card_type=None): """ Returns a valid credit card number. """ card = self._credit_card_type(card_type) prefix = self.random_element(card.prefixes) number = self._generate_number(self.numerify(prefix), card.length) return number
python
def credit_card_number(self, card_type=None): """ Returns a valid credit card number. """ card = self._credit_card_type(card_type) prefix = self.random_element(card.prefixes) number = self._generate_number(self.numerify(prefix), card.length) return number
[ "def", "credit_card_number", "(", "self", ",", "card_type", "=", "None", ")", ":", "card", "=", "self", ".", "_credit_card_type", "(", "card_type", ")", "prefix", "=", "self", ".", "random_element", "(", "card", ".", "prefixes", ")", "number", "=", "self",...
Returns a valid credit card number.
[ "Returns", "a", "valid", "credit", "card", "number", "." ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/credit_card/__init__.py#L67-L72
train
joke2k/faker
faker/providers/credit_card/__init__.py
Provider.credit_card_security_code
def credit_card_security_code(self, card_type=None): """ Returns a security code string. """ sec_len = self._credit_card_type(card_type).security_code_length return self.numerify('#' * sec_len)
python
def credit_card_security_code(self, card_type=None): """ Returns a security code string. """ sec_len = self._credit_card_type(card_type).security_code_length return self.numerify('#' * sec_len)
[ "def", "credit_card_security_code", "(", "self", ",", "card_type", "=", "None", ")", ":", "sec_len", "=", "self", ".", "_credit_card_type", "(", "card_type", ")", ".", "security_code_length", "return", "self", ".", "numerify", "(", "'#'", "*", "sec_len", ")" ]
Returns a security code string.
[ "Returns", "a", "security", "code", "string", "." ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/credit_card/__init__.py#L96-L99
train
joke2k/faker
faker/providers/credit_card/__init__.py
Provider._credit_card_type
def _credit_card_type(self, card_type=None): """ Returns a random credit card type instance. """ if card_type is None: card_type = self.random_element(self.credit_card_types.keys()) elif isinstance(card_type, CreditCard): return card_type return self.credit_card_t...
python
def _credit_card_type(self, card_type=None): """ Returns a random credit card type instance. """ if card_type is None: card_type = self.random_element(self.credit_card_types.keys()) elif isinstance(card_type, CreditCard): return card_type return self.credit_card_t...
[ "def", "_credit_card_type", "(", "self", ",", "card_type", "=", "None", ")", ":", "if", "card_type", "is", "None", ":", "card_type", "=", "self", ".", "random_element", "(", "self", ".", "credit_card_types", ".", "keys", "(", ")", ")", "elif", "isinstance"...
Returns a random credit card type instance.
[ "Returns", "a", "random", "credit", "card", "type", "instance", "." ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/credit_card/__init__.py#L101-L107
train
joke2k/faker
faker/providers/credit_card/__init__.py
Provider._generate_number
def _generate_number(self, prefix, length): """ 'prefix' is the start of the CC number as a string, any number of digits. 'length' is the length of the CC number to generate. Typically 13 or 16 """ number = prefix # Generate random char digits number += '#' * (len...
python
def _generate_number(self, prefix, length): """ 'prefix' is the start of the CC number as a string, any number of digits. 'length' is the length of the CC number to generate. Typically 13 or 16 """ number = prefix # Generate random char digits number += '#' * (len...
[ "def", "_generate_number", "(", "self", ",", "prefix", ",", "length", ")", ":", "number", "=", "prefix", "# Generate random char digits", "number", "+=", "'#'", "*", "(", "length", "-", "len", "(", "prefix", ")", "-", "1", ")", "number", "=", "self", "."...
'prefix' is the start of the CC number as a string, any number of digits. 'length' is the length of the CC number to generate. Typically 13 or 16
[ "prefix", "is", "the", "start", "of", "the", "CC", "number", "as", "a", "string", "any", "number", "of", "digits", ".", "length", "is", "the", "length", "of", "the", "CC", "number", "to", "generate", ".", "Typically", "13", "or", "16" ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/credit_card/__init__.py#L109-L130
train
joke2k/faker
faker/providers/company/fi_FI/__init__.py
Provider.company_business_id
def company_business_id(self): """ Returns Finnish company Business Identity Code (y-tunnus). Format is 8 digits - e.g. FI99999999,[8] last digit is a check digit utilizing MOD 11-2. The first digit is zero for some old organizations. This function provides current codes starting...
python
def company_business_id(self): """ Returns Finnish company Business Identity Code (y-tunnus). Format is 8 digits - e.g. FI99999999,[8] last digit is a check digit utilizing MOD 11-2. The first digit is zero for some old organizations. This function provides current codes starting...
[ "def", "company_business_id", "(", "self", ")", ":", "def", "calculate_checksum", "(", "number", ")", ":", "\"\"\"Calculate the checksum using mod 11,2 method\"\"\"", "factors", "=", "[", "7", ",", "9", ",", "10", ",", "5", ",", "8", ",", "4", ",", "2", "]",...
Returns Finnish company Business Identity Code (y-tunnus). Format is 8 digits - e.g. FI99999999,[8] last digit is a check digit utilizing MOD 11-2. The first digit is zero for some old organizations. This function provides current codes starting with non-zero.
[ "Returns", "Finnish", "company", "Business", "Identity", "Code", "(", "y", "-", "tunnus", ")", ".", "Format", "is", "8", "digits", "-", "e", ".", "g", ".", "FI99999999", "[", "8", "]", "last", "digit", "is", "a", "check", "digit", "utilizing", "MOD", ...
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/company/fi_FI/__init__.py#L17-L39
train
joke2k/faker
faker/providers/ssn/nl_BE/__init__.py
Provider.ssn
def ssn(self): """ Returns a 11 digits Belgian SSN called "rijksregisternummer" as a string The first 6 digits represent the birthdate with (in order) year, month and day. The second group of 3 digits is represents a sequence number (order of birth). It is even for women and odd...
python
def ssn(self): """ Returns a 11 digits Belgian SSN called "rijksregisternummer" as a string The first 6 digits represent the birthdate with (in order) year, month and day. The second group of 3 digits is represents a sequence number (order of birth). It is even for women and odd...
[ "def", "ssn", "(", "self", ")", ":", "# see http://nl.wikipedia.org/wiki/Burgerservicenummer (in Dutch)", "def", "_checksum", "(", "digits", ")", ":", "res", "=", "97", "-", "(", "digits", "%", "97", ")", "return", "res", "# Generate a date (random)", "mydate", "=...
Returns a 11 digits Belgian SSN called "rijksregisternummer" as a string The first 6 digits represent the birthdate with (in order) year, month and day. The second group of 3 digits is represents a sequence number (order of birth). It is even for women and odd for men. For men the range...
[ "Returns", "a", "11", "digits", "Belgian", "SSN", "called", "rijksregisternummer", "as", "a", "string" ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/ssn/nl_BE/__init__.py#L14-L58
train
joke2k/faker
faker/providers/address/ko_KR/__init__.py
Provider.land_address
def land_address(self): """ :example 세종특별자치시 어진동 507 """ pattern = self.random_element(self.land_address_formats) return self.generator.parse(pattern)
python
def land_address(self): """ :example 세종특별자치시 어진동 507 """ pattern = self.random_element(self.land_address_formats) return self.generator.parse(pattern)
[ "def", "land_address", "(", "self", ")", ":", "pattern", "=", "self", ".", "random_element", "(", "self", ".", "land_address_formats", ")", "return", "self", ".", "generator", ".", "parse", "(", "pattern", ")" ]
:example 세종특별자치시 어진동 507
[ ":", "example", "세종특별자치시", "어진동", "507" ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/address/ko_KR/__init__.py#L274-L279
train
joke2k/faker
faker/providers/address/ko_KR/__init__.py
Provider.road_address
def road_address(self): """ :example 세종특별자치시 도움5로 19 (어진동) """ pattern = self.random_element(self.road_address_formats) return self.generator.parse(pattern)
python
def road_address(self): """ :example 세종특별자치시 도움5로 19 (어진동) """ pattern = self.random_element(self.road_address_formats) return self.generator.parse(pattern)
[ "def", "road_address", "(", "self", ")", ":", "pattern", "=", "self", ".", "random_element", "(", "self", ".", "road_address_formats", ")", "return", "self", ".", "generator", ".", "parse", "(", "pattern", ")" ]
:example 세종특별자치시 도움5로 19 (어진동)
[ ":", "example", "세종특별자치시", "도움5로", "19", "(", "어진동", ")" ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/address/ko_KR/__init__.py#L287-L292
train
joke2k/faker
faker/providers/address/ko_KR/__init__.py
Provider.address_detail
def address_detail(self): """ :example 가나아파트 가동 102호 """ pattern = self.bothify(self.random_element( self.address_detail_formats)) return self.generator.parse(pattern)
python
def address_detail(self): """ :example 가나아파트 가동 102호 """ pattern = self.bothify(self.random_element( self.address_detail_formats)) return self.generator.parse(pattern)
[ "def", "address_detail", "(", "self", ")", ":", "pattern", "=", "self", ".", "bothify", "(", "self", ".", "random_element", "(", "self", ".", "address_detail_formats", ")", ")", "return", "self", ".", "generator", ".", "parse", "(", "pattern", ")" ]
:example 가나아파트 가동 102호
[ ":", "example", "가나아파트", "가동", "102호" ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/address/ko_KR/__init__.py#L294-L300
train
joke2k/faker
faker/providers/address/ko_KR/__init__.py
Provider.road
def road(self): """ :example 도움5로 """ pattern = self.random_element(self.road_formats) return self.generator.parse(pattern)
python
def road(self): """ :example 도움5로 """ pattern = self.random_element(self.road_formats) return self.generator.parse(pattern)
[ "def", "road", "(", "self", ")", ":", "pattern", "=", "self", ".", "random_element", "(", "self", ".", "road_formats", ")", "return", "self", ".", "generator", ".", "parse", "(", "pattern", ")" ]
:example 도움5로
[ ":", "example", "도움5로" ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/address/ko_KR/__init__.py#L302-L307
train
joke2k/faker
faker/providers/address/ko_KR/__init__.py
Provider.city
def city(self): """ :example 고양시 """ pattern = self.random_element(self.cities) return self.generator.parse(pattern)
python
def city(self): """ :example 고양시 """ pattern = self.random_element(self.cities) return self.generator.parse(pattern)
[ "def", "city", "(", "self", ")", ":", "pattern", "=", "self", ".", "random_element", "(", "self", ".", "cities", ")", "return", "self", ".", "generator", ".", "parse", "(", "pattern", ")" ]
:example 고양시
[ ":", "example", "고양시" ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/address/ko_KR/__init__.py#L333-L338
train
joke2k/faker
faker/providers/address/ko_KR/__init__.py
Provider.town
def town(self): """ :example 가나동 """ pattern = self.random_element(self.town_formats) return self.generator.parse(pattern)
python
def town(self): """ :example 가나동 """ pattern = self.random_element(self.town_formats) return self.generator.parse(pattern)
[ "def", "town", "(", "self", ")", ":", "pattern", "=", "self", ".", "random_element", "(", "self", ".", "town_formats", ")", "return", "self", ".", "generator", ".", "parse", "(", "pattern", ")" ]
:example 가나동
[ ":", "example", "가나동" ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/address/ko_KR/__init__.py#L346-L351
train
joke2k/faker
faker/providers/address/ko_KR/__init__.py
Provider.building_name
def building_name(self): """ :example 김구아파트 """ pattern = self.random_element(self.building_name_formats) return self.generator.parse(pattern)
python
def building_name(self): """ :example 김구아파트 """ pattern = self.random_element(self.building_name_formats) return self.generator.parse(pattern)
[ "def", "building_name", "(", "self", ")", ":", "pattern", "=", "self", ".", "random_element", "(", "self", ".", "building_name_formats", ")", "return", "self", ".", "generator", ".", "parse", "(", "pattern", ")" ]
:example 김구아파트
[ ":", "example", "김구아파트" ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/address/ko_KR/__init__.py#L359-L364
train
joke2k/faker
faker/providers/ssn/en_CA/__init__.py
checksum
def checksum(sin): """ Determine validity of a Canadian Social Insurance Number. Validation is performed using a modified Luhn Algorithm. To check the Every second digit of the SIN is doubled and the result is summed. If the result is a multiple of ten, the Social Insurance Number is considere...
python
def checksum(sin): """ Determine validity of a Canadian Social Insurance Number. Validation is performed using a modified Luhn Algorithm. To check the Every second digit of the SIN is doubled and the result is summed. If the result is a multiple of ten, the Social Insurance Number is considere...
[ "def", "checksum", "(", "sin", ")", ":", "# Remove spaces and create a list of digits.", "checksumCollection", "=", "list", "(", "sin", ".", "replace", "(", "' '", ",", "''", ")", ")", "checksumCollection", "=", "[", "int", "(", "i", ")", "for", "i", "in", ...
Determine validity of a Canadian Social Insurance Number. Validation is performed using a modified Luhn Algorithm. To check the Every second digit of the SIN is doubled and the result is summed. If the result is a multiple of ten, the Social Insurance Number is considered valid. https://en.wikipe...
[ "Determine", "validity", "of", "a", "Canadian", "Social", "Insurance", "Number", ".", "Validation", "is", "performed", "using", "a", "modified", "Luhn", "Algorithm", ".", "To", "check", "the", "Every", "second", "digit", "of", "the", "SIN", "is", "doubled", ...
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/ssn/en_CA/__init__.py#L6-L41
train
joke2k/faker
faker/providers/internet/__init__.py
Provider.hostname
def hostname(self, levels=1): """ Produce a hostname with specified number of subdomain levels. >>> hostname() db-01.nichols-phillips.com >>> hostname(0) laptop-56 >>> hostname(2) web-12.williamson-hopkins.jackson.com """ if levels < 1: ...
python
def hostname(self, levels=1): """ Produce a hostname with specified number of subdomain levels. >>> hostname() db-01.nichols-phillips.com >>> hostname(0) laptop-56 >>> hostname(2) web-12.williamson-hopkins.jackson.com """ if levels < 1: ...
[ "def", "hostname", "(", "self", ",", "levels", "=", "1", ")", ":", "if", "levels", "<", "1", ":", "return", "self", ".", "random_element", "(", "self", ".", "hostname_prefixes", ")", "+", "'-'", "+", "self", ".", "numerify", "(", "'##'", ")", "return...
Produce a hostname with specified number of subdomain levels. >>> hostname() db-01.nichols-phillips.com >>> hostname(0) laptop-56 >>> hostname(2) web-12.williamson-hopkins.jackson.com
[ "Produce", "a", "hostname", "with", "specified", "number", "of", "subdomain", "levels", "." ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/internet/__init__.py#L192-L205
train
joke2k/faker
faker/providers/internet/__init__.py
Provider.domain_name
def domain_name(self, levels=1): """ Produce an Internet domain name with the specified number of subdomain levels. >>> domain_name() nichols-phillips.com >>> domain_name(2) williamson-hopkins.jackson.com """ if levels < 1: raise Value...
python
def domain_name(self, levels=1): """ Produce an Internet domain name with the specified number of subdomain levels. >>> domain_name() nichols-phillips.com >>> domain_name(2) williamson-hopkins.jackson.com """ if levels < 1: raise Value...
[ "def", "domain_name", "(", "self", ",", "levels", "=", "1", ")", ":", "if", "levels", "<", "1", ":", "raise", "ValueError", "(", "\"levels must be greater than or equal to 1\"", ")", "if", "levels", "==", "1", ":", "return", "self", ".", "domain_word", "(", ...
Produce an Internet domain name with the specified number of subdomain levels. >>> domain_name() nichols-phillips.com >>> domain_name(2) williamson-hopkins.jackson.com
[ "Produce", "an", "Internet", "domain", "name", "with", "the", "specified", "number", "of", "subdomain", "levels", "." ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/internet/__init__.py#L208-L223
train
joke2k/faker
faker/providers/internet/__init__.py
Provider.url
def url(self, schemes=None): """ :param schemes: a list of strings to use as schemes, one will chosen randomly. If None, it will generate http and https urls. Passing an empty list will result in schemeless url generation like "://domain.com". :returns: a random url string. ...
python
def url(self, schemes=None): """ :param schemes: a list of strings to use as schemes, one will chosen randomly. If None, it will generate http and https urls. Passing an empty list will result in schemeless url generation like "://domain.com". :returns: a random url string. ...
[ "def", "url", "(", "self", ",", "schemes", "=", "None", ")", ":", "if", "schemes", "is", "None", ":", "schemes", "=", "[", "'http'", ",", "'https'", "]", "pattern", "=", "'{}://{}'", ".", "format", "(", "self", ".", "random_element", "(", "schemes", ...
:param schemes: a list of strings to use as schemes, one will chosen randomly. If None, it will generate http and https urls. Passing an empty list will result in schemeless url generation like "://domain.com". :returns: a random url string.
[ ":", "param", "schemes", ":", "a", "list", "of", "strings", "to", "use", "as", "schemes", "one", "will", "chosen", "randomly", ".", "If", "None", "it", "will", "generate", "http", "and", "https", "urls", ".", "Passing", "an", "empty", "list", "will", "...
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/internet/__init__.py#L236-L252
train
joke2k/faker
faker/providers/internet/__init__.py
Provider._random_ipv4_address_from_subnet
def _random_ipv4_address_from_subnet(self, subnet, network=False): """ Produces a random IPv4 address or network with a valid CIDR from within a given subnet. :param subnet: IPv4Network to choose from within :param network: Return a network address, and not an IP address ...
python
def _random_ipv4_address_from_subnet(self, subnet, network=False): """ Produces a random IPv4 address or network with a valid CIDR from within a given subnet. :param subnet: IPv4Network to choose from within :param network: Return a network address, and not an IP address ...
[ "def", "_random_ipv4_address_from_subnet", "(", "self", ",", "subnet", ",", "network", "=", "False", ")", ":", "address", "=", "str", "(", "subnet", "[", "self", ".", "generator", ".", "random", ".", "randint", "(", "0", ",", "subnet", ".", "num_addresses"...
Produces a random IPv4 address or network with a valid CIDR from within a given subnet. :param subnet: IPv4Network to choose from within :param network: Return a network address, and not an IP address
[ "Produces", "a", "random", "IPv4", "address", "or", "network", "with", "a", "valid", "CIDR", "from", "within", "a", "given", "subnet", "." ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/internet/__init__.py#L254-L275
train
joke2k/faker
faker/providers/internet/__init__.py
Provider._exclude_ipv4_networks
def _exclude_ipv4_networks(self, networks, networks_to_exclude): """ Exclude the list of networks from another list of networks and return a flat list of new networks. :param networks: List of IPv4 networks to exclude from :param networks_to_exclude: List of IPv4 networks to exc...
python
def _exclude_ipv4_networks(self, networks, networks_to_exclude): """ Exclude the list of networks from another list of networks and return a flat list of new networks. :param networks: List of IPv4 networks to exclude from :param networks_to_exclude: List of IPv4 networks to exc...
[ "def", "_exclude_ipv4_networks", "(", "self", ",", "networks", ",", "networks_to_exclude", ")", ":", "for", "network_to_exclude", "in", "networks_to_exclude", ":", "def", "_exclude_ipv4_network", "(", "network", ")", ":", "\"\"\"\n Exclude a single network fr...
Exclude the list of networks from another list of networks and return a flat list of new networks. :param networks: List of IPv4 networks to exclude from :param networks_to_exclude: List of IPv4 networks to exclude :returns: Flat list of IPv4 networks
[ "Exclude", "the", "list", "of", "networks", "from", "another", "list", "of", "networks", "and", "return", "a", "flat", "list", "of", "new", "networks", "." ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/internet/__init__.py#L277-L318
train
joke2k/faker
faker/providers/internet/__init__.py
Provider.ipv4
def ipv4(self, network=False, address_class=None, private=None): """ Produce a random IPv4 address or network with a valid CIDR. :param network: Network address :param address_class: IPv4 address class (a, b, or c) :param private: Public or private :returns: IPv4 ...
python
def ipv4(self, network=False, address_class=None, private=None): """ Produce a random IPv4 address or network with a valid CIDR. :param network: Network address :param address_class: IPv4 address class (a, b, or c) :param private: Public or private :returns: IPv4 ...
[ "def", "ipv4", "(", "self", ",", "network", "=", "False", ",", "address_class", "=", "None", ",", "private", "=", "None", ")", ":", "if", "private", "is", "True", ":", "return", "self", ".", "ipv4_private", "(", "address_class", "=", "address_class", ","...
Produce a random IPv4 address or network with a valid CIDR. :param network: Network address :param address_class: IPv4 address class (a, b, or c) :param private: Public or private :returns: IPv4
[ "Produce", "a", "random", "IPv4", "address", "or", "network", "with", "a", "valid", "CIDR", "." ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/internet/__init__.py#L328-L361
train
joke2k/faker
faker/providers/internet/__init__.py
Provider.ipv4_private
def ipv4_private(self, network=False, address_class=None): """ Returns a private IPv4. :param network: Network address :param address_class: IPv4 address class (a, b, or c) :returns: Private IPv4 """ # compute private networks from given class supernet = ...
python
def ipv4_private(self, network=False, address_class=None): """ Returns a private IPv4. :param network: Network address :param address_class: IPv4 address class (a, b, or c) :returns: Private IPv4 """ # compute private networks from given class supernet = ...
[ "def", "ipv4_private", "(", "self", ",", "network", "=", "False", ",", "address_class", "=", "None", ")", ":", "# compute private networks from given class", "supernet", "=", "_IPv4Constants", ".", "_network_classes", "[", "address_class", "or", "self", ".", "ipv4_n...
Returns a private IPv4. :param network: Network address :param address_class: IPv4 address class (a, b, or c) :returns: Private IPv4
[ "Returns", "a", "private", "IPv4", "." ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/internet/__init__.py#L363-L390
train
joke2k/faker
faker/providers/internet/__init__.py
Provider.ipv4_public
def ipv4_public(self, network=False, address_class=None): """ Returns a public IPv4 excluding private blocks. :param network: Network address :param address_class: IPv4 address class (a, b, or c) :returns: Public IPv4 """ # compute public networks public_...
python
def ipv4_public(self, network=False, address_class=None): """ Returns a public IPv4 excluding private blocks. :param network: Network address :param address_class: IPv4 address class (a, b, or c) :returns: Public IPv4 """ # compute public networks public_...
[ "def", "ipv4_public", "(", "self", ",", "network", "=", "False", ",", "address_class", "=", "None", ")", ":", "# compute public networks", "public_networks", "=", "[", "_IPv4Constants", ".", "_network_classes", "[", "address_class", "or", "self", ".", "ipv4_networ...
Returns a public IPv4 excluding private blocks. :param network: Network address :param address_class: IPv4 address class (a, b, or c) :returns: Public IPv4
[ "Returns", "a", "public", "IPv4", "excluding", "private", "blocks", "." ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/internet/__init__.py#L392-L415
train
joke2k/faker
faker/providers/internet/__init__.py
Provider.ipv6
def ipv6(self, network=False): """Produce a random IPv6 address or network with a valid CIDR""" address = str(ip_address(self.generator.random.randint( 2 ** IPV4LENGTH, (2 ** IPV6LENGTH) - 1))) if network: address += '/' + str(self.generator.random.randint(0, IPV6LENGTH))...
python
def ipv6(self, network=False): """Produce a random IPv6 address or network with a valid CIDR""" address = str(ip_address(self.generator.random.randint( 2 ** IPV4LENGTH, (2 ** IPV6LENGTH) - 1))) if network: address += '/' + str(self.generator.random.randint(0, IPV6LENGTH))...
[ "def", "ipv6", "(", "self", ",", "network", "=", "False", ")", ":", "address", "=", "str", "(", "ip_address", "(", "self", ".", "generator", ".", "random", ".", "randint", "(", "2", "**", "IPV4LENGTH", ",", "(", "2", "**", "IPV6LENGTH", ")", "-", "...
Produce a random IPv6 address or network with a valid CIDR
[ "Produce", "a", "random", "IPv6", "address", "or", "network", "with", "a", "valid", "CIDR" ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/internet/__init__.py#L417-L424
train
joke2k/faker
faker/providers/internet/__init__.py
Provider.image_url
def image_url(self, width=None, height=None): """ Returns URL to placeholder image Example: http://placehold.it/640x480 """ width_ = width or self.random_int(max=1024) height_ = height or self.random_int(max=1024) placeholder_url = self.random_element(self.image_p...
python
def image_url(self, width=None, height=None): """ Returns URL to placeholder image Example: http://placehold.it/640x480 """ width_ = width or self.random_int(max=1024) height_ = height or self.random_int(max=1024) placeholder_url = self.random_element(self.image_p...
[ "def", "image_url", "(", "self", ",", "width", "=", "None", ",", "height", "=", "None", ")", ":", "width_", "=", "width", "or", "self", ".", "random_int", "(", "max", "=", "1024", ")", "height_", "=", "height", "or", "self", ".", "random_int", "(", ...
Returns URL to placeholder image Example: http://placehold.it/640x480
[ "Returns", "URL", "to", "placeholder", "image", "Example", ":", "http", ":", "//", "placehold", ".", "it", "/", "640x480" ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/internet/__init__.py#L453-L461
train
joke2k/faker
faker/generator.py
Generator.seed_instance
def seed_instance(self, seed=None): """Calls random.seed""" if self.__random == random: # create per-instance random obj when first time seed_instance() is # called self.__random = random_module.Random() self.__random.seed(seed) return self
python
def seed_instance(self, seed=None): """Calls random.seed""" if self.__random == random: # create per-instance random obj when first time seed_instance() is # called self.__random = random_module.Random() self.__random.seed(seed) return self
[ "def", "seed_instance", "(", "self", ",", "seed", "=", "None", ")", ":", "if", "self", ".", "__random", "==", "random", ":", "# create per-instance random obj when first time seed_instance() is", "# called", "self", ".", "__random", "=", "random_module", ".", "Rando...
Calls random.seed
[ "Calls", "random", ".", "seed" ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/generator.py#L61-L68
train
joke2k/faker
faker/generator.py
Generator.format
def format(self, formatter, *args, **kwargs): """ This is a secure way to make a fake from another Provider. """ # TODO: data export? return self.get_formatter(formatter)(*args, **kwargs)
python
def format(self, formatter, *args, **kwargs): """ This is a secure way to make a fake from another Provider. """ # TODO: data export? return self.get_formatter(formatter)(*args, **kwargs)
[ "def", "format", "(", "self", ",", "formatter", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# TODO: data export?", "return", "self", ".", "get_formatter", "(", "formatter", ")", "(", "*", "args", ",", "*", "*", "kwargs", ")" ]
This is a secure way to make a fake from another Provider.
[ "This", "is", "a", "secure", "way", "to", "make", "a", "fake", "from", "another", "Provider", "." ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/generator.py#L74-L79
train
angr/angr
angr/slicer.py
SimSlicer._alias_analysis
def _alias_analysis(self, mock_sp=True, mock_bp=True): """ Perform a forward execution and perform alias analysis. Note that this analysis is fast, light-weight, and by no means complete. For instance, most arithmetic operations are not supported. - Depending on user settings, stack poi...
python
def _alias_analysis(self, mock_sp=True, mock_bp=True): """ Perform a forward execution and perform alias analysis. Note that this analysis is fast, light-weight, and by no means complete. For instance, most arithmetic operations are not supported. - Depending on user settings, stack poi...
[ "def", "_alias_analysis", "(", "self", ",", "mock_sp", "=", "True", ",", "mock_bp", "=", "True", ")", ":", "state", "=", "SimLightState", "(", "regs", "=", "{", "self", ".", "_arch", ".", "sp_offset", ":", "self", ".", "_arch", ".", "initial_sp", ",", ...
Perform a forward execution and perform alias analysis. Note that this analysis is fast, light-weight, and by no means complete. For instance, most arithmetic operations are not supported. - Depending on user settings, stack pointer and stack base pointer will be mocked and propagated to individual ...
[ "Perform", "a", "forward", "execution", "and", "perform", "alias", "analysis", ".", "Note", "that", "this", "analysis", "is", "fast", "light", "-", "weight", "and", "by", "no", "means", "complete", ".", "For", "instance", "most", "arithmetic", "operations", ...
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/slicer.py#L56-L82
train
angr/angr
angr/slicer.py
SimSlicer._slice
def _slice(self): """ Slice it! """ regs = set(self._target_regs) tmps = set(self._target_tmps) stack_offsets = set(self._target_stack_offsets) state = SimLightState(regs=regs, temps=tmps, stack_offsets=stack_offsets) for stmt_idx, stmt in reversed(list...
python
def _slice(self): """ Slice it! """ regs = set(self._target_regs) tmps = set(self._target_tmps) stack_offsets = set(self._target_stack_offsets) state = SimLightState(regs=regs, temps=tmps, stack_offsets=stack_offsets) for stmt_idx, stmt in reversed(list...
[ "def", "_slice", "(", "self", ")", ":", "regs", "=", "set", "(", "self", ".", "_target_regs", ")", "tmps", "=", "set", "(", "self", ".", "_target_tmps", ")", "stack_offsets", "=", "set", "(", "self", ".", "_target_stack_offsets", ")", "state", "=", "Si...
Slice it!
[ "Slice", "it!" ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/slicer.py#L176-L199
train
angr/angr
angr/simos/linux.py
SimLinux.prepare_function_symbol
def prepare_function_symbol(self, symbol_name, basic_addr=None): """ Prepare the address space with the data necessary to perform relocations pointing to the given symbol. Returns a 2-tuple. The first item is the address of the function code, the second is the address of the relocation ...
python
def prepare_function_symbol(self, symbol_name, basic_addr=None): """ Prepare the address space with the data necessary to perform relocations pointing to the given symbol. Returns a 2-tuple. The first item is the address of the function code, the second is the address of the relocation ...
[ "def", "prepare_function_symbol", "(", "self", ",", "symbol_name", ",", "basic_addr", "=", "None", ")", ":", "if", "self", ".", "project", ".", "loader", ".", "main_object", ".", "is_ppc64_abiv1", ":", "if", "basic_addr", "is", "not", "None", ":", "pointer",...
Prepare the address space with the data necessary to perform relocations pointing to the given symbol. Returns a 2-tuple. The first item is the address of the function code, the second is the address of the relocation target.
[ "Prepare", "the", "address", "space", "with", "the", "data", "necessary", "to", "perform", "relocations", "pointing", "to", "the", "given", "symbol", "." ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/simos/linux.py#L326-L346
train
angr/angr
angr/simos/linux.py
SimLinux.initialize_segment_register_x64
def initialize_segment_register_x64(self, state, concrete_target): """ Set the fs register in the angr to the value of the fs register in the concrete process :param state: state which will be modified :param concrete_target: concrete target that will be used to read t...
python
def initialize_segment_register_x64(self, state, concrete_target): """ Set the fs register in the angr to the value of the fs register in the concrete process :param state: state which will be modified :param concrete_target: concrete target that will be used to read t...
[ "def", "initialize_segment_register_x64", "(", "self", ",", "state", ",", "concrete_target", ")", ":", "_l", ".", "debug", "(", "\"Synchronizing fs segment register\"", ")", "state", ".", "regs", ".", "fs", "=", "self", ".", "_read_fs_register_x64", "(", "concrete...
Set the fs register in the angr to the value of the fs register in the concrete process :param state: state which will be modified :param concrete_target: concrete target that will be used to read the fs register :return: None
[ "Set", "the", "fs", "register", "in", "the", "angr", "to", "the", "value", "of", "the", "fs", "register", "in", "the", "concrete", "process" ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/simos/linux.py#L348-L357
train
angr/angr
angr/simos/linux.py
SimLinux.initialize_gdt_x86
def initialize_gdt_x86(self,state,concrete_target): """ Create a GDT in the state memory and populate the segment registers. Rehook the vsyscall address using the real value in the concrete process memory :param state: state which will be modified :param concrete_t...
python
def initialize_gdt_x86(self,state,concrete_target): """ Create a GDT in the state memory and populate the segment registers. Rehook the vsyscall address using the real value in the concrete process memory :param state: state which will be modified :param concrete_t...
[ "def", "initialize_gdt_x86", "(", "self", ",", "state", ",", "concrete_target", ")", ":", "_l", ".", "debug", "(", "\"Creating fake Global Descriptor Table and synchronizing gs segment register\"", ")", "gs", "=", "self", ".", "_read_gs_register_x86", "(", "concrete_targe...
Create a GDT in the state memory and populate the segment registers. Rehook the vsyscall address using the real value in the concrete process memory :param state: state which will be modified :param concrete_target: concrete target that will be used to read the fs register ...
[ "Create", "a", "GDT", "in", "the", "state", "memory", "and", "populate", "the", "segment", "registers", ".", "Rehook", "the", "vsyscall", "address", "using", "the", "real", "value", "in", "the", "concrete", "process", "memory" ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/simos/linux.py#L359-L378
train
angr/angr
angr/knowledge_plugins/cfg/cfg_node.py
CFGNode.merge
def merge(self, other): """ Merges this node with the other, returning a new node that spans the both. """ new_node = self.copy() new_node.size += other.size new_node.instruction_addrs += other.instruction_addrs # FIXME: byte_string should never be none, but it is...
python
def merge(self, other): """ Merges this node with the other, returning a new node that spans the both. """ new_node = self.copy() new_node.size += other.size new_node.instruction_addrs += other.instruction_addrs # FIXME: byte_string should never be none, but it is...
[ "def", "merge", "(", "self", ",", "other", ")", ":", "new_node", "=", "self", ".", "copy", "(", ")", "new_node", ".", "size", "+=", "other", ".", "size", "new_node", ".", "instruction_addrs", "+=", "other", ".", "instruction_addrs", "# FIXME: byte_string sho...
Merges this node with the other, returning a new node that spans the both.
[ "Merges", "this", "node", "with", "the", "other", "returning", "a", "new", "node", "that", "spans", "the", "both", "." ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/knowledge_plugins/cfg/cfg_node.py#L246-L259
train
angr/angr
angr/engines/soot/expressions/newArray.py
SimSootExpr_NewArray.new_array
def new_array(state, element_type, size): """ Allocates a new array in memory and returns the reference to the base. """ size_bounded = SimSootExpr_NewArray._bound_array_size(state, size) # return the reference of the array base # => elements getting lazy initialized in t...
python
def new_array(state, element_type, size): """ Allocates a new array in memory and returns the reference to the base. """ size_bounded = SimSootExpr_NewArray._bound_array_size(state, size) # return the reference of the array base # => elements getting lazy initialized in t...
[ "def", "new_array", "(", "state", ",", "element_type", ",", "size", ")", ":", "size_bounded", "=", "SimSootExpr_NewArray", ".", "_bound_array_size", "(", "state", ",", "size", ")", "# return the reference of the array base", "# => elements getting lazy initialized in the ja...
Allocates a new array in memory and returns the reference to the base.
[ "Allocates", "a", "new", "array", "in", "memory", "and", "returns", "the", "reference", "to", "the", "base", "." ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/engines/soot/expressions/newArray.py#L17-L26
train
angr/angr
angr/analyses/decompiler/structurer.py
Structurer._convert_claripy_bool_ast
def _convert_claripy_bool_ast(self, cond): """ Convert recovered reaching conditions from claripy ASTs to ailment Expressions :return: None """ if isinstance(cond, ailment.Expr.Expression): return cond if cond.op == "BoolS" and claripy.is_true(cond): ...
python
def _convert_claripy_bool_ast(self, cond): """ Convert recovered reaching conditions from claripy ASTs to ailment Expressions :return: None """ if isinstance(cond, ailment.Expr.Expression): return cond if cond.op == "BoolS" and claripy.is_true(cond): ...
[ "def", "_convert_claripy_bool_ast", "(", "self", ",", "cond", ")", ":", "if", "isinstance", "(", "cond", ",", "ailment", ".", "Expr", ".", "Expression", ")", ":", "return", "cond", "if", "cond", ".", "op", "==", "\"BoolS\"", "and", "claripy", ".", "is_tr...
Convert recovered reaching conditions from claripy ASTs to ailment Expressions :return: None
[ "Convert", "recovered", "reaching", "conditions", "from", "claripy", "ASTs", "to", "ailment", "Expressions" ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/decompiler/structurer.py#L552-L606
train
angr/angr
angr/analyses/decompiler/structurer.py
Structurer._extract_jump_targets
def _extract_jump_targets(stmt): """ Extract goto targets from a Jump or a ConditionalJump statement. :param stmt: The statement to analyze. :return: A list of known concrete jump targets. :rtype: list """ targets = [ ] # FIXME: We are...
python
def _extract_jump_targets(stmt): """ Extract goto targets from a Jump or a ConditionalJump statement. :param stmt: The statement to analyze. :return: A list of known concrete jump targets. :rtype: list """ targets = [ ] # FIXME: We are...
[ "def", "_extract_jump_targets", "(", "stmt", ")", ":", "targets", "=", "[", "]", "# FIXME: We are assuming all jump targets are concrete targets. They may not be.", "if", "isinstance", "(", "stmt", ",", "ailment", ".", "Stmt", ".", "Jump", ")", ":", "targets", ".", ...
Extract goto targets from a Jump or a ConditionalJump statement. :param stmt: The statement to analyze. :return: A list of known concrete jump targets. :rtype: list
[ "Extract", "goto", "targets", "from", "a", "Jump", "or", "a", "ConditionalJump", "statement", "." ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/decompiler/structurer.py#L838-L857
train
angr/angr
angr/state_plugins/heap/heap_libc.py
SimHeapLibc.malloc
def malloc(self, sim_size): """ A somewhat faithful implementation of libc `malloc`. :param sim_size: the amount of memory (in bytes) to be allocated :returns: the address of the allocation, or a NULL pointer if the allocation failed """ raise NotImplementedError(...
python
def malloc(self, sim_size): """ A somewhat faithful implementation of libc `malloc`. :param sim_size: the amount of memory (in bytes) to be allocated :returns: the address of the allocation, or a NULL pointer if the allocation failed """ raise NotImplementedError(...
[ "def", "malloc", "(", "self", ",", "sim_size", ")", ":", "raise", "NotImplementedError", "(", "\"%s not implemented for %s\"", "%", "(", "self", ".", "malloc", ".", "__func__", ".", "__name__", ",", "self", ".", "__class__", ".", "__name__", ")", ")" ]
A somewhat faithful implementation of libc `malloc`. :param sim_size: the amount of memory (in bytes) to be allocated :returns: the address of the allocation, or a NULL pointer if the allocation failed
[ "A", "somewhat", "faithful", "implementation", "of", "libc", "malloc", "." ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/state_plugins/heap/heap_libc.py#L8-L16
train
angr/angr
angr/state_plugins/heap/heap_libc.py
SimHeapLibc.free
def free(self, ptr): #pylint:disable=unused-argument """ A somewhat faithful implementation of libc `free`. :param ptr: the location in memory to be freed """ raise NotImplementedError("%s not implemented for %s" % (self.free.__func__.__name__, ...
python
def free(self, ptr): #pylint:disable=unused-argument """ A somewhat faithful implementation of libc `free`. :param ptr: the location in memory to be freed """ raise NotImplementedError("%s not implemented for %s" % (self.free.__func__.__name__, ...
[ "def", "free", "(", "self", ",", "ptr", ")", ":", "#pylint:disable=unused-argument", "raise", "NotImplementedError", "(", "\"%s not implemented for %s\"", "%", "(", "self", ".", "free", ".", "__func__", ".", "__name__", ",", "self", ".", "__class__", ".", "__nam...
A somewhat faithful implementation of libc `free`. :param ptr: the location in memory to be freed
[ "A", "somewhat", "faithful", "implementation", "of", "libc", "free", "." ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/state_plugins/heap/heap_libc.py#L18-L25
train
angr/angr
angr/state_plugins/heap/heap_libc.py
SimHeapLibc.calloc
def calloc(self, sim_nmemb, sim_size): """ A somewhat faithful implementation of libc `calloc`. :param sim_nmemb: the number of elements to allocated :param sim_size: the size of each element (in bytes) :returns: the address of the allocation, or a NULL pointer if the a...
python
def calloc(self, sim_nmemb, sim_size): """ A somewhat faithful implementation of libc `calloc`. :param sim_nmemb: the number of elements to allocated :param sim_size: the size of each element (in bytes) :returns: the address of the allocation, or a NULL pointer if the a...
[ "def", "calloc", "(", "self", ",", "sim_nmemb", ",", "sim_size", ")", ":", "raise", "NotImplementedError", "(", "\"%s not implemented for %s\"", "%", "(", "self", ".", "calloc", ".", "__func__", ".", "__name__", ",", "self", ".", "__class__", ".", "__name__", ...
A somewhat faithful implementation of libc `calloc`. :param sim_nmemb: the number of elements to allocated :param sim_size: the size of each element (in bytes) :returns: the address of the allocation, or a NULL pointer if the allocation failed
[ "A", "somewhat", "faithful", "implementation", "of", "libc", "calloc", "." ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/state_plugins/heap/heap_libc.py#L27-L36
train
angr/angr
angr/state_plugins/heap/heap_libc.py
SimHeapLibc.realloc
def realloc(self, ptr, size): """ A somewhat faithful implementation of libc `realloc`. :param ptr: the location in memory to be reallocated :param size: the new size desired for the allocation :returns: the address of the allocation, or a NULL pointer if the allocation was ...
python
def realloc(self, ptr, size): """ A somewhat faithful implementation of libc `realloc`. :param ptr: the location in memory to be reallocated :param size: the new size desired for the allocation :returns: the address of the allocation, or a NULL pointer if the allocation was ...
[ "def", "realloc", "(", "self", ",", "ptr", ",", "size", ")", ":", "raise", "NotImplementedError", "(", "\"%s not implemented for %s\"", "%", "(", "self", ".", "realloc", ".", "__func__", ".", "__name__", ",", "self", ".", "__class__", ".", "__name__", ")", ...
A somewhat faithful implementation of libc `realloc`. :param ptr: the location in memory to be reallocated :param size: the new size desired for the allocation :returns: the address of the allocation, or a NULL pointer if the allocation was freed or if no new allocation ...
[ "A", "somewhat", "faithful", "implementation", "of", "libc", "realloc", "." ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/state_plugins/heap/heap_libc.py#L38-L48
train
angr/angr
angr/state_plugins/gdb.py
GDB.set_stack
def set_stack(self, stack_dump, stack_top): """ Stack dump is a dump of the stack from gdb, i.e. the result of the following gdb command : ``dump binary memory [stack_dump] [begin_addr] [end_addr]`` We set the stack to the same addresses as the gdb session to avoid pointers corruption....
python
def set_stack(self, stack_dump, stack_top): """ Stack dump is a dump of the stack from gdb, i.e. the result of the following gdb command : ``dump binary memory [stack_dump] [begin_addr] [end_addr]`` We set the stack to the same addresses as the gdb session to avoid pointers corruption....
[ "def", "set_stack", "(", "self", ",", "stack_dump", ",", "stack_top", ")", ":", "data", "=", "self", ".", "_read_data", "(", "stack_dump", ")", "self", ".", "real_stack_top", "=", "stack_top", "addr", "=", "stack_top", "-", "len", "(", "data", ")", "# Ad...
Stack dump is a dump of the stack from gdb, i.e. the result of the following gdb command : ``dump binary memory [stack_dump] [begin_addr] [end_addr]`` We set the stack to the same addresses as the gdb session to avoid pointers corruption. :param stack_dump: The dump file. :param stac...
[ "Stack", "dump", "is", "a", "dump", "of", "the", "stack", "from", "gdb", "i", ".", "e", ".", "the", "result", "of", "the", "following", "gdb", "command", ":" ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/state_plugins/gdb.py#L33-L49
train
angr/angr
angr/state_plugins/gdb.py
GDB.set_heap
def set_heap(self, heap_dump, heap_base): """ Heap dump is a dump of the heap from gdb, i.e. the result of the following gdb command: ``dump binary memory [stack_dump] [begin] [end]`` :param heap_dump: The dump file. :param heap_base: The start address of the heap i...
python
def set_heap(self, heap_dump, heap_base): """ Heap dump is a dump of the heap from gdb, i.e. the result of the following gdb command: ``dump binary memory [stack_dump] [begin] [end]`` :param heap_dump: The dump file. :param heap_base: The start address of the heap i...
[ "def", "set_heap", "(", "self", ",", "heap_dump", ",", "heap_base", ")", ":", "# We set the heap at the same addresses as the gdb session to avoid pointer corruption.", "data", "=", "self", ".", "_read_data", "(", "heap_dump", ")", "self", ".", "state", ".", "heap", "...
Heap dump is a dump of the heap from gdb, i.e. the result of the following gdb command: ``dump binary memory [stack_dump] [begin] [end]`` :param heap_dump: The dump file. :param heap_base: The start address of the heap in the gdb session.
[ "Heap", "dump", "is", "a", "dump", "of", "the", "heap", "from", "gdb", "i", ".", "e", ".", "the", "result", "of", "the", "following", "gdb", "command", ":" ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/state_plugins/gdb.py#L51-L67
train
angr/angr
angr/state_plugins/gdb.py
GDB.set_data
def set_data(self, addr, data_dump): """ Update any data range (most likely use is the data segments of loaded objects) """ data = self._read_data(data_dump) l.info("Set data from 0x%x to %#x", addr, addr+len(data)) self._write(addr, data)
python
def set_data(self, addr, data_dump): """ Update any data range (most likely use is the data segments of loaded objects) """ data = self._read_data(data_dump) l.info("Set data from 0x%x to %#x", addr, addr+len(data)) self._write(addr, data)
[ "def", "set_data", "(", "self", ",", "addr", ",", "data_dump", ")", ":", "data", "=", "self", ".", "_read_data", "(", "data_dump", ")", "l", ".", "info", "(", "\"Set data from 0x%x to %#x\"", ",", "addr", ",", "addr", "+", "len", "(", "data", ")", ")",...
Update any data range (most likely use is the data segments of loaded objects)
[ "Update", "any", "data", "range", "(", "most", "likely", "use", "is", "the", "data", "segments", "of", "loaded", "objects", ")" ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/state_plugins/gdb.py#L69-L75
train
angr/angr
angr/state_plugins/gdb.py
GDB.set_regs
def set_regs(self, regs_dump): """ Initialize register values within the state :param regs_dump: The output of ``info registers`` in gdb. """ if self.real_stack_top == 0 and self.adjust_stack is True: raise SimStateError("You need to set the stack first, or set" ...
python
def set_regs(self, regs_dump): """ Initialize register values within the state :param regs_dump: The output of ``info registers`` in gdb. """ if self.real_stack_top == 0 and self.adjust_stack is True: raise SimStateError("You need to set the stack first, or set" ...
[ "def", "set_regs", "(", "self", ",", "regs_dump", ")", ":", "if", "self", ".", "real_stack_top", "==", "0", "and", "self", ".", "adjust_stack", "is", "True", ":", "raise", "SimStateError", "(", "\"You need to set the stack first, or set\"", "\"adjust_stack to False....
Initialize register values within the state :param regs_dump: The output of ``info registers`` in gdb.
[ "Initialize", "register", "values", "within", "the", "state" ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/state_plugins/gdb.py#L77-L101
train
angr/angr
angr/state_plugins/gdb.py
GDB._adjust_regs
def _adjust_regs(self): """ Adjust bp and sp w.r.t. stack difference between GDB session and angr. This matches sp and bp registers, but there is a high risk of pointers inconsistencies. """ if not self.adjust_stack: return bp = self.state.arch.register_names...
python
def _adjust_regs(self): """ Adjust bp and sp w.r.t. stack difference between GDB session and angr. This matches sp and bp registers, but there is a high risk of pointers inconsistencies. """ if not self.adjust_stack: return bp = self.state.arch.register_names...
[ "def", "_adjust_regs", "(", "self", ")", ":", "if", "not", "self", ".", "adjust_stack", ":", "return", "bp", "=", "self", ".", "state", ".", "arch", ".", "register_names", "[", "self", ".", "state", ".", "arch", ".", "bp_offset", "]", "sp", "=", "sel...
Adjust bp and sp w.r.t. stack difference between GDB session and angr. This matches sp and bp registers, but there is a high risk of pointers inconsistencies.
[ "Adjust", "bp", "and", "sp", "w", ".", "r", ".", "t", ".", "stack", "difference", "between", "GDB", "session", "and", "angr", ".", "This", "matches", "sp", "and", "bp", "registers", "but", "there", "is", "a", "high", "risk", "of", "pointers", "inconsis...
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/state_plugins/gdb.py#L103-L118
train
angr/angr
angr/analyses/loopfinder.py
LoopFinder._parse_loop_graph
def _parse_loop_graph(self, subg, bigg): """ Create a Loop object for a strongly connected graph, and any strongly connected subgraphs, if possible. :param subg: A strongly connected subgraph. :param bigg: The graph which subg is a subgraph of. :return: A l...
python
def _parse_loop_graph(self, subg, bigg): """ Create a Loop object for a strongly connected graph, and any strongly connected subgraphs, if possible. :param subg: A strongly connected subgraph. :param bigg: The graph which subg is a subgraph of. :return: A l...
[ "def", "_parse_loop_graph", "(", "self", ",", "subg", ",", "bigg", ")", ":", "loop_body_nodes", "=", "list", "(", "subg", ".", "nodes", "(", ")", ")", "[", ":", "]", "entry_edges", "=", "[", "]", "break_edges", "=", "[", "]", "continue_edges", "=", "...
Create a Loop object for a strongly connected graph, and any strongly connected subgraphs, if possible. :param subg: A strongly connected subgraph. :param bigg: The graph which subg is a subgraph of. :return: A list of Loop objects, some of which may be inside others, ...
[ "Create", "a", "Loop", "object", "for", "a", "strongly", "connected", "graph", "and", "any", "strongly", "connected", "subgraphs", "if", "possible", "." ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/loopfinder.py#L61-L150
train
angr/angr
angr/analyses/loopfinder.py
LoopFinder._parse_loops_from_graph
def _parse_loops_from_graph(self, graph): """ Return all Loop instances that can be extracted from a graph. :param graph: The graph to analyze. :return: A list of all the Loop instances that were found in the graph. """ outtop = [] outall = [] f...
python
def _parse_loops_from_graph(self, graph): """ Return all Loop instances that can be extracted from a graph. :param graph: The graph to analyze. :return: A list of all the Loop instances that were found in the graph. """ outtop = [] outall = [] f...
[ "def", "_parse_loops_from_graph", "(", "self", ",", "graph", ")", ":", "outtop", "=", "[", "]", "outall", "=", "[", "]", "for", "subg", "in", "networkx", ".", "strongly_connected_component_subgraphs", "(", "graph", ")", ":", "if", "len", "(", "subg", ".", ...
Return all Loop instances that can be extracted from a graph. :param graph: The graph to analyze. :return: A list of all the Loop instances that were found in the graph.
[ "Return", "all", "Loop", "instances", "that", "can", "be", "extracted", "from", "a", "graph", "." ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/loopfinder.py#L152-L170
train
angr/angr
angr/engines/soot/values/instancefieldref.py
SimSootValue_InstanceFieldRef.get_ref
def get_ref(cls, state, obj_alloc_id, field_class_name, field_name, field_type): """ Resolve the field within the given state. """ # resolve field field_class = state.javavm_classloader.get_class(field_class_name) field_id = resolve_field(state, field_class, field_name, f...
python
def get_ref(cls, state, obj_alloc_id, field_class_name, field_name, field_type): """ Resolve the field within the given state. """ # resolve field field_class = state.javavm_classloader.get_class(field_class_name) field_id = resolve_field(state, field_class, field_name, f...
[ "def", "get_ref", "(", "cls", ",", "state", ",", "obj_alloc_id", ",", "field_class_name", ",", "field_name", ",", "field_type", ")", ":", "# resolve field", "field_class", "=", "state", ".", "javavm_classloader", ".", "get_class", "(", "field_class_name", ")", "...
Resolve the field within the given state.
[ "Resolve", "the", "field", "within", "the", "given", "state", "." ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/engines/soot/values/instancefieldref.py#L36-L44
train
angr/angr
angr/analyses/bindiff.py
_euclidean_dist
def _euclidean_dist(vector_a, vector_b): """ :param vector_a: A list of numbers. :param vector_b: A list of numbers. :returns: The euclidean distance between the two vectors. """ dist = 0 for (x, y) in zip(vector_a, vector_b): dist += (x-y)*(x-y) return math.sqrt(...
python
def _euclidean_dist(vector_a, vector_b): """ :param vector_a: A list of numbers. :param vector_b: A list of numbers. :returns: The euclidean distance between the two vectors. """ dist = 0 for (x, y) in zip(vector_a, vector_b): dist += (x-y)*(x-y) return math.sqrt(...
[ "def", "_euclidean_dist", "(", "vector_a", ",", "vector_b", ")", ":", "dist", "=", "0", "for", "(", "x", ",", "y", ")", "in", "zip", "(", "vector_a", ",", "vector_b", ")", ":", "dist", "+=", "(", "x", "-", "y", ")", "*", "(", "x", "-", "y", "...
:param vector_a: A list of numbers. :param vector_b: A list of numbers. :returns: The euclidean distance between the two vectors.
[ ":", "param", "vector_a", ":", "A", "list", "of", "numbers", ".", ":", "param", "vector_b", ":", "A", "list", "of", "numbers", ".", ":", "returns", ":", "The", "euclidean", "distance", "between", "the", "two", "vectors", "." ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/bindiff.py#L44-L53
train
angr/angr
angr/analyses/bindiff.py
_get_closest_matches
def _get_closest_matches(input_attributes, target_attributes): """ :param input_attributes: First dictionary of objects to attribute tuples. :param target_attributes: Second dictionary of blocks to attribute tuples. :returns: A dictionary of objects in the input_attributes to the ...
python
def _get_closest_matches(input_attributes, target_attributes): """ :param input_attributes: First dictionary of objects to attribute tuples. :param target_attributes: Second dictionary of blocks to attribute tuples. :returns: A dictionary of objects in the input_attributes to the ...
[ "def", "_get_closest_matches", "(", "input_attributes", ",", "target_attributes", ")", ":", "closest_matches", "=", "{", "}", "# for each object in the first set find the objects with the closest target attributes", "for", "a", "in", "input_attributes", ":", "best_dist", "=", ...
:param input_attributes: First dictionary of objects to attribute tuples. :param target_attributes: Second dictionary of blocks to attribute tuples. :returns: A dictionary of objects in the input_attributes to the closest objects in the target_attributes.
[ ":", "param", "input_attributes", ":", "First", "dictionary", "of", "objects", "to", "attribute", "tuples", ".", ":", "param", "target_attributes", ":", "Second", "dictionary", "of", "blocks", "to", "attribute", "tuples", ".", ":", "returns", ":", "A", "dictio...
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/bindiff.py#L56-L78
train
angr/angr
angr/analyses/bindiff.py
_levenshtein_distance
def _levenshtein_distance(s1, s2): """ :param s1: A list or string :param s2: Another list or string :returns: The levenshtein distance between the two """ if len(s1) > len(s2): s1, s2 = s2, s1 distances = range(len(s1) + 1) for index2, num2 in enumerate(s2): new_dis...
python
def _levenshtein_distance(s1, s2): """ :param s1: A list or string :param s2: Another list or string :returns: The levenshtein distance between the two """ if len(s1) > len(s2): s1, s2 = s2, s1 distances = range(len(s1) + 1) for index2, num2 in enumerate(s2): new_dis...
[ "def", "_levenshtein_distance", "(", "s1", ",", "s2", ")", ":", "if", "len", "(", "s1", ")", ">", "len", "(", "s2", ")", ":", "s1", ",", "s2", "=", "s2", ",", "s1", "distances", "=", "range", "(", "len", "(", "s1", ")", "+", "1", ")", "for", ...
:param s1: A list or string :param s2: Another list or string :returns: The levenshtein distance between the two
[ ":", "param", "s1", ":", "A", "list", "or", "string", ":", "param", "s2", ":", "Another", "list", "or", "string", ":", "returns", ":", "The", "levenshtein", "distance", "between", "the", "two" ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/bindiff.py#L82-L101
train
angr/angr
angr/analyses/bindiff.py
_normalized_levenshtein_distance
def _normalized_levenshtein_distance(s1, s2, acceptable_differences): """ This function calculates the levenshtein distance but allows for elements in the lists to be different by any number in the set acceptable_differences. :param s1: A list. :param s2: A...
python
def _normalized_levenshtein_distance(s1, s2, acceptable_differences): """ This function calculates the levenshtein distance but allows for elements in the lists to be different by any number in the set acceptable_differences. :param s1: A list. :param s2: A...
[ "def", "_normalized_levenshtein_distance", "(", "s1", ",", "s2", ",", "acceptable_differences", ")", ":", "if", "len", "(", "s1", ")", ">", "len", "(", "s2", ")", ":", "s1", ",", "s2", "=", "s2", ",", "s1", "acceptable_differences", "=", "set", "(", "-...
This function calculates the levenshtein distance but allows for elements in the lists to be different by any number in the set acceptable_differences. :param s1: A list. :param s2: Another list. :param acceptable_differences: A set of numbers. If (s2[i]-s1[i]...
[ "This", "function", "calculates", "the", "levenshtein", "distance", "but", "allows", "for", "elements", "in", "the", "lists", "to", "be", "different", "by", "any", "number", "in", "the", "set", "acceptable_differences", "." ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/bindiff.py#L104-L128
train
angr/angr
angr/analyses/bindiff.py
_is_better_match
def _is_better_match(x, y, matched_a, matched_b, attributes_dict_a, attributes_dict_b): """ :param x: The first element of a possible match. :param y: The second element of a possible match. :param matched_a: The current matches for the first set. :param...
python
def _is_better_match(x, y, matched_a, matched_b, attributes_dict_a, attributes_dict_b): """ :param x: The first element of a possible match. :param y: The second element of a possible match. :param matched_a: The current matches for the first set. :param...
[ "def", "_is_better_match", "(", "x", ",", "y", ",", "matched_a", ",", "matched_b", ",", "attributes_dict_a", ",", "attributes_dict_b", ")", ":", "attributes_x", "=", "attributes_dict_a", "[", "x", "]", "attributes_y", "=", "attributes_dict_b", "[", "y", "]", "...
:param x: The first element of a possible match. :param y: The second element of a possible match. :param matched_a: The current matches for the first set. :param matched_b: The current matches for the second set. :param attributes_dict_a: The at...
[ ":", "param", "x", ":", "The", "first", "element", "of", "a", "possible", "match", ".", ":", "param", "y", ":", "The", "second", "element", "of", "a", "possible", "match", ".", ":", "param", "matched_a", ":", "The", "current", "matches", "for", "the", ...
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/bindiff.py#L131-L151
train
angr/angr
angr/analyses/bindiff.py
differing_constants
def differing_constants(block_a, block_b): """ Compares two basic blocks and finds all the constants that differ from the first block to the second. :param block_a: The first block to compare. :param block_b: The second block to compare. :returns: Returns a list of differing constants in the ...
python
def differing_constants(block_a, block_b): """ Compares two basic blocks and finds all the constants that differ from the first block to the second. :param block_a: The first block to compare. :param block_b: The second block to compare. :returns: Returns a list of differing constants in the ...
[ "def", "differing_constants", "(", "block_a", ",", "block_b", ")", ":", "statements_a", "=", "[", "s", "for", "s", "in", "block_a", ".", "vex", ".", "statements", "if", "s", ".", "tag", "!=", "\"Ist_IMark\"", "]", "+", "[", "block_a", ".", "vex", ".", ...
Compares two basic blocks and finds all the constants that differ from the first block to the second. :param block_a: The first block to compare. :param block_b: The second block to compare. :returns: Returns a list of differing constants in the form of ConstantChange, which has the offset in the ...
[ "Compares", "two", "basic", "blocks", "and", "finds", "all", "the", "constants", "that", "differ", "from", "the", "first", "block", "to", "the", "second", "." ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/bindiff.py#L154-L193
train
angr/angr
angr/analyses/bindiff.py
FunctionDiff.probably_identical
def probably_identical(self): """ :returns: Whether or not these two functions are identical. """ if len(self._unmatched_blocks_from_a | self._unmatched_blocks_from_b) > 0: return False for (a, b) in self._block_matches: if not self.blocks_probably_identic...
python
def probably_identical(self): """ :returns: Whether or not these two functions are identical. """ if len(self._unmatched_blocks_from_a | self._unmatched_blocks_from_b) > 0: return False for (a, b) in self._block_matches: if not self.blocks_probably_identic...
[ "def", "probably_identical", "(", "self", ")", ":", "if", "len", "(", "self", ".", "_unmatched_blocks_from_a", "|", "self", ".", "_unmatched_blocks_from_b", ")", ">", "0", ":", "return", "False", "for", "(", "a", ",", "b", ")", "in", "self", ".", "_block...
:returns: Whether or not these two functions are identical.
[ ":", "returns", ":", "Whether", "or", "not", "these", "two", "functions", "are", "identical", "." ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/bindiff.py#L368-L377
train
angr/angr
angr/analyses/bindiff.py
FunctionDiff.identical_blocks
def identical_blocks(self): """ :returns: A list of block matches which appear to be identical """ identical_blocks = [] for (block_a, block_b) in self._block_matches: if self.blocks_probably_identical(block_a, block_b): identical_blocks.append((block_...
python
def identical_blocks(self): """ :returns: A list of block matches which appear to be identical """ identical_blocks = [] for (block_a, block_b) in self._block_matches: if self.blocks_probably_identical(block_a, block_b): identical_blocks.append((block_...
[ "def", "identical_blocks", "(", "self", ")", ":", "identical_blocks", "=", "[", "]", "for", "(", "block_a", ",", "block_b", ")", "in", "self", ".", "_block_matches", ":", "if", "self", ".", "blocks_probably_identical", "(", "block_a", ",", "block_b", ")", ...
:returns: A list of block matches which appear to be identical
[ ":", "returns", ":", "A", "list", "of", "block", "matches", "which", "appear", "to", "be", "identical" ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/bindiff.py#L380-L388
train
angr/angr
angr/analyses/bindiff.py
FunctionDiff.differing_blocks
def differing_blocks(self): """ :returns: A list of block matches which appear to differ """ differing_blocks = [] for (block_a, block_b) in self._block_matches: if not self.blocks_probably_identical(block_a, block_b): differing_blocks.append((block_a,...
python
def differing_blocks(self): """ :returns: A list of block matches which appear to differ """ differing_blocks = [] for (block_a, block_b) in self._block_matches: if not self.blocks_probably_identical(block_a, block_b): differing_blocks.append((block_a,...
[ "def", "differing_blocks", "(", "self", ")", ":", "differing_blocks", "=", "[", "]", "for", "(", "block_a", ",", "block_b", ")", "in", "self", ".", "_block_matches", ":", "if", "not", "self", ".", "blocks_probably_identical", "(", "block_a", ",", "block_b", ...
:returns: A list of block matches which appear to differ
[ ":", "returns", ":", "A", "list", "of", "block", "matches", "which", "appear", "to", "differ" ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/bindiff.py#L391-L399
train
angr/angr
angr/analyses/bindiff.py
FunctionDiff.blocks_with_differing_constants
def blocks_with_differing_constants(self): """ :return: A list of block matches which appear to differ """ differing_blocks = [] diffs = dict() for (block_a, block_b) in self._block_matches: if self.blocks_probably_identical(block_a, block_b) and \ ...
python
def blocks_with_differing_constants(self): """ :return: A list of block matches which appear to differ """ differing_blocks = [] diffs = dict() for (block_a, block_b) in self._block_matches: if self.blocks_probably_identical(block_a, block_b) and \ ...
[ "def", "blocks_with_differing_constants", "(", "self", ")", ":", "differing_blocks", "=", "[", "]", "diffs", "=", "dict", "(", ")", "for", "(", "block_a", ",", "block_b", ")", "in", "self", ".", "_block_matches", ":", "if", "self", ".", "blocks_probably_iden...
:return: A list of block matches which appear to differ
[ ":", "return", ":", "A", "list", "of", "block", "matches", "which", "appear", "to", "differ" ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/bindiff.py#L402-L416
train
angr/angr
angr/analyses/bindiff.py
FunctionDiff.block_similarity
def block_similarity(self, block_a, block_b): """ :param block_a: The first block address. :param block_b: The second block address. :returns: The similarity of the basic blocks, normalized for the base address of the block and function call addresses. ...
python
def block_similarity(self, block_a, block_b): """ :param block_a: The first block address. :param block_b: The second block address. :returns: The similarity of the basic blocks, normalized for the base address of the block and function call addresses. ...
[ "def", "block_similarity", "(", "self", ",", "block_a", ",", "block_b", ")", ":", "# handle sim procedure blocks", "if", "self", ".", "_project_a", ".", "is_hooked", "(", "block_a", ")", "and", "self", ".", "_project_b", ".", "is_hooked", "(", "block_b", ")", ...
:param block_a: The first block address. :param block_b: The second block address. :returns: The similarity of the basic blocks, normalized for the base address of the block and function call addresses.
[ ":", "param", "block_a", ":", "The", "first", "block", "address", ".", ":", "param", "block_b", ":", "The", "second", "block", "address", ".", ":", "returns", ":", "The", "similarity", "of", "the", "basic", "blocks", "normalized", "for", "the", "base", "...
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/bindiff.py#L435-L492
train
angr/angr
angr/analyses/bindiff.py
FunctionDiff.blocks_probably_identical
def blocks_probably_identical(self, block_a, block_b, check_constants=False): """ :param block_a: The first block address. :param block_b: The second block address. :param check_constants: Whether or not to require matching constants in blocks. :returns: ...
python
def blocks_probably_identical(self, block_a, block_b, check_constants=False): """ :param block_a: The first block address. :param block_b: The second block address. :param check_constants: Whether or not to require matching constants in blocks. :returns: ...
[ "def", "blocks_probably_identical", "(", "self", ",", "block_a", ",", "block_b", ",", "check_constants", "=", "False", ")", ":", "# handle sim procedure blocks", "if", "self", ".", "_project_a", ".", "is_hooked", "(", "block_a", ")", "and", "self", ".", "_projec...
:param block_a: The first block address. :param block_b: The second block address. :param check_constants: Whether or not to require matching constants in blocks. :returns: Whether or not the blocks appear to be identical.
[ ":", "param", "block_a", ":", "The", "first", "block", "address", ".", ":", "param", "block_b", ":", "The", "second", "block", "address", ".", ":", "param", "check_constants", ":", "Whether", "or", "not", "to", "require", "matching", "constants", "in", "bl...
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/bindiff.py#L494-L557
train
angr/angr
angr/analyses/bindiff.py
FunctionDiff._compute_block_attributes
def _compute_block_attributes(function): """ :param function: A normalized function object. :returns: A dictionary of basic block addresses to tuples of attributes. """ # The attributes we use are the distance form function start, distance from function exit and whet...
python
def _compute_block_attributes(function): """ :param function: A normalized function object. :returns: A dictionary of basic block addresses to tuples of attributes. """ # The attributes we use are the distance form function start, distance from function exit and whet...
[ "def", "_compute_block_attributes", "(", "function", ")", ":", "# The attributes we use are the distance form function start, distance from function exit and whether", "# or not it has a subfunction call", "distances_from_start", "=", "FunctionDiff", ".", "_distances_from_function_start", ...
:param function: A normalized function object. :returns: A dictionary of basic block addresses to tuples of attributes.
[ ":", "param", "function", ":", "A", "normalized", "function", "object", ".", ":", "returns", ":", "A", "dictionary", "of", "basic", "block", "addresses", "to", "tuples", "of", "attributes", "." ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/bindiff.py#L567-L590
train
angr/angr
angr/analyses/bindiff.py
FunctionDiff._distances_from_function_exit
def _distances_from_function_exit(function): """ :param function: A normalized Function object. :returns: A dictionary of basic block addresses and their distance to the exit of the function. """ reverse_graph = function.graph.reverse() # we aren't guaranteed...
python
def _distances_from_function_exit(function): """ :param function: A normalized Function object. :returns: A dictionary of basic block addresses and their distance to the exit of the function. """ reverse_graph = function.graph.reverse() # we aren't guaranteed...
[ "def", "_distances_from_function_exit", "(", "function", ")", ":", "reverse_graph", "=", "function", ".", "graph", ".", "reverse", "(", ")", "# we aren't guaranteed to have an exit from the function so explicitly add the node", "reverse_graph", ".", "add_node", "(", "\"start\...
:param function: A normalized Function object. :returns: A dictionary of basic block addresses and their distance to the exit of the function.
[ ":", "param", "function", ":", "A", "normalized", "Function", "object", ".", ":", "returns", ":", "A", "dictionary", "of", "basic", "block", "addresses", "and", "their", "distance", "to", "the", "exit", "of", "the", "function", "." ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/bindiff.py#L602-L631
train
angr/angr
angr/analyses/bindiff.py
FunctionDiff._compute_diff
def _compute_diff(self): """ Computes the diff of the functions and saves the result. """ # get the attributes for all blocks l.debug("Computing diff of functions: %s, %s", ("%#x" % self._function_a.startpoint.addr) if self._function_a.startpoint is not None else ...
python
def _compute_diff(self): """ Computes the diff of the functions and saves the result. """ # get the attributes for all blocks l.debug("Computing diff of functions: %s, %s", ("%#x" % self._function_a.startpoint.addr) if self._function_a.startpoint is not None else ...
[ "def", "_compute_diff", "(", "self", ")", ":", "# get the attributes for all blocks", "l", ".", "debug", "(", "\"Computing diff of functions: %s, %s\"", ",", "(", "\"%#x\"", "%", "self", ".", "_function_a", ".", "startpoint", ".", "addr", ")", "if", "self", ".", ...
Computes the diff of the functions and saves the result.
[ "Computes", "the", "diff", "of", "the", "functions", "and", "saves", "the", "result", "." ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/bindiff.py#L633-L713
train
angr/angr
angr/analyses/bindiff.py
FunctionDiff._get_block_matches
def _get_block_matches(self, attributes_a, attributes_b, filter_set_a=None, filter_set_b=None, delta=(0, 0, 0), tiebreak_with_block_similarity=False): """ :param attributes_a: A dict of blocks to their attributes :param attributes_b: A dict of blocks to their att...
python
def _get_block_matches(self, attributes_a, attributes_b, filter_set_a=None, filter_set_b=None, delta=(0, 0, 0), tiebreak_with_block_similarity=False): """ :param attributes_a: A dict of blocks to their attributes :param attributes_b: A dict of blocks to their att...
[ "def", "_get_block_matches", "(", "self", ",", "attributes_a", ",", "attributes_b", ",", "filter_set_a", "=", "None", ",", "filter_set_b", "=", "None", ",", "delta", "=", "(", "0", ",", "0", ",", "0", ")", ",", "tiebreak_with_block_similarity", "=", "False",...
:param attributes_a: A dict of blocks to their attributes :param attributes_b: A dict of blocks to their attributes The following parameters are optional. :param filter_set_a: A set to limit attributes_a to the blocks in this set. :param filter_set_b: A set to limit attribu...
[ ":", "param", "attributes_a", ":", "A", "dict", "of", "blocks", "to", "their", "attributes", ":", "param", "attributes_b", ":", "A", "dict", "of", "blocks", "to", "their", "attributes" ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/bindiff.py#L734-L805
train
angr/angr
angr/analyses/bindiff.py
BinDiff.functions_probably_identical
def functions_probably_identical(self, func_a_addr, func_b_addr, check_consts=False): """ Compare two functions and return True if they appear identical. :param func_a_addr: The address of the first function (in the first binary). :param func_b_addr: The address of the second function (...
python
def functions_probably_identical(self, func_a_addr, func_b_addr, check_consts=False): """ Compare two functions and return True if they appear identical. :param func_a_addr: The address of the first function (in the first binary). :param func_b_addr: The address of the second function (...
[ "def", "functions_probably_identical", "(", "self", ",", "func_a_addr", ",", "func_b_addr", ",", "check_consts", "=", "False", ")", ":", "if", "self", ".", "cfg_a", ".", "project", ".", "is_hooked", "(", "func_a_addr", ")", "and", "self", ".", "cfg_b", ".", ...
Compare two functions and return True if they appear identical. :param func_a_addr: The address of the first function (in the first binary). :param func_b_addr: The address of the second function (in the second binary). :returns: Whether or not the functions appear to be identical.
[ "Compare", "two", "functions", "and", "return", "True", "if", "they", "appear", "identical", "." ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/bindiff.py#L878-L893
train
angr/angr
angr/analyses/bindiff.py
BinDiff.identical_functions
def identical_functions(self): """ :returns: A list of function matches that appear to be identical """ identical_funcs = [] for (func_a, func_b) in self.function_matches: if self.functions_probably_identical(func_a, func_b): identical_funcs.append((fu...
python
def identical_functions(self): """ :returns: A list of function matches that appear to be identical """ identical_funcs = [] for (func_a, func_b) in self.function_matches: if self.functions_probably_identical(func_a, func_b): identical_funcs.append((fu...
[ "def", "identical_functions", "(", "self", ")", ":", "identical_funcs", "=", "[", "]", "for", "(", "func_a", ",", "func_b", ")", "in", "self", ".", "function_matches", ":", "if", "self", ".", "functions_probably_identical", "(", "func_a", ",", "func_b", ")",...
:returns: A list of function matches that appear to be identical
[ ":", "returns", ":", "A", "list", "of", "function", "matches", "that", "appear", "to", "be", "identical" ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/bindiff.py#L896-L904
train
angr/angr
angr/analyses/bindiff.py
BinDiff.differing_functions
def differing_functions(self): """ :returns: A list of function matches that appear to differ """ different_funcs = [] for (func_a, func_b) in self.function_matches: if not self.functions_probably_identical(func_a, func_b): different_funcs.append((func...
python
def differing_functions(self): """ :returns: A list of function matches that appear to differ """ different_funcs = [] for (func_a, func_b) in self.function_matches: if not self.functions_probably_identical(func_a, func_b): different_funcs.append((func...
[ "def", "differing_functions", "(", "self", ")", ":", "different_funcs", "=", "[", "]", "for", "(", "func_a", ",", "func_b", ")", "in", "self", ".", "function_matches", ":", "if", "not", "self", ".", "functions_probably_identical", "(", "func_a", ",", "func_b...
:returns: A list of function matches that appear to differ
[ ":", "returns", ":", "A", "list", "of", "function", "matches", "that", "appear", "to", "differ" ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/bindiff.py#L907-L915
train
angr/angr
angr/analyses/bindiff.py
BinDiff.differing_functions_with_consts
def differing_functions_with_consts(self): """ :return: A list of function matches that appear to differ including just by constants """ different_funcs = [] for (func_a, func_b) in self.function_matches: if not self.functions_probably_identical(func_a, func_b, check_...
python
def differing_functions_with_consts(self): """ :return: A list of function matches that appear to differ including just by constants """ different_funcs = [] for (func_a, func_b) in self.function_matches: if not self.functions_probably_identical(func_a, func_b, check_...
[ "def", "differing_functions_with_consts", "(", "self", ")", ":", "different_funcs", "=", "[", "]", "for", "(", "func_a", ",", "func_b", ")", "in", "self", ".", "function_matches", ":", "if", "not", "self", ".", "functions_probably_identical", "(", "func_a", ",...
:return: A list of function matches that appear to differ including just by constants
[ ":", "return", ":", "A", "list", "of", "function", "matches", "that", "appear", "to", "differ", "including", "just", "by", "constants" ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/bindiff.py#L917-L925
train
angr/angr
angr/analyses/bindiff.py
BinDiff.differing_blocks
def differing_blocks(self): """ :returns: A list of block matches that appear to differ """ differing_blocks = [] for (func_a, func_b) in self.function_matches: differing_blocks.extend(self.get_function_diff(func_a, func_b).differing_blocks) return differing_b...
python
def differing_blocks(self): """ :returns: A list of block matches that appear to differ """ differing_blocks = [] for (func_a, func_b) in self.function_matches: differing_blocks.extend(self.get_function_diff(func_a, func_b).differing_blocks) return differing_b...
[ "def", "differing_blocks", "(", "self", ")", ":", "differing_blocks", "=", "[", "]", "for", "(", "func_a", ",", "func_b", ")", "in", "self", ".", "function_matches", ":", "differing_blocks", ".", "extend", "(", "self", ".", "get_function_diff", "(", "func_a"...
:returns: A list of block matches that appear to differ
[ ":", "returns", ":", "A", "list", "of", "block", "matches", "that", "appear", "to", "differ" ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/bindiff.py#L928-L935
train
angr/angr
angr/analyses/bindiff.py
BinDiff.identical_blocks
def identical_blocks(self): """ :return A list of all block matches that appear to be identical """ identical_blocks = [] for (func_a, func_b) in self.function_matches: identical_blocks.extend(self.get_function_diff(func_a, func_b).identical_blocks) return ide...
python
def identical_blocks(self): """ :return A list of all block matches that appear to be identical """ identical_blocks = [] for (func_a, func_b) in self.function_matches: identical_blocks.extend(self.get_function_diff(func_a, func_b).identical_blocks) return ide...
[ "def", "identical_blocks", "(", "self", ")", ":", "identical_blocks", "=", "[", "]", "for", "(", "func_a", ",", "func_b", ")", "in", "self", ".", "function_matches", ":", "identical_blocks", ".", "extend", "(", "self", ".", "get_function_diff", "(", "func_a"...
:return A list of all block matches that appear to be identical
[ ":", "return", "A", "list", "of", "all", "block", "matches", "that", "appear", "to", "be", "identical" ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/bindiff.py#L938-L945
train
angr/angr
angr/analyses/bindiff.py
BinDiff.blocks_with_differing_constants
def blocks_with_differing_constants(self): """ :return: A dict of block matches with differing constants to the tuple of constants """ diffs = dict() for (func_a, func_b) in self.function_matches: diffs.update(self.get_function_diff(func_a, func_b).blocks_with_differi...
python
def blocks_with_differing_constants(self): """ :return: A dict of block matches with differing constants to the tuple of constants """ diffs = dict() for (func_a, func_b) in self.function_matches: diffs.update(self.get_function_diff(func_a, func_b).blocks_with_differi...
[ "def", "blocks_with_differing_constants", "(", "self", ")", ":", "diffs", "=", "dict", "(", ")", "for", "(", "func_a", ",", "func_b", ")", "in", "self", ".", "function_matches", ":", "diffs", ".", "update", "(", "self", ".", "get_function_diff", "(", "func...
:return: A dict of block matches with differing constants to the tuple of constants
[ ":", "return", ":", "A", "dict", "of", "block", "matches", "with", "differing", "constants", "to", "the", "tuple", "of", "constants" ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/bindiff.py#L948-L955
train
angr/angr
angr/analyses/bindiff.py
BinDiff.get_function_diff
def get_function_diff(self, function_addr_a, function_addr_b): """ :param function_addr_a: The address of the first function (in the first binary) :param function_addr_b: The address of the second function (in the second binary) :returns: the FunctionDiff of the two functions """...
python
def get_function_diff(self, function_addr_a, function_addr_b): """ :param function_addr_a: The address of the first function (in the first binary) :param function_addr_b: The address of the second function (in the second binary) :returns: the FunctionDiff of the two functions """...
[ "def", "get_function_diff", "(", "self", ",", "function_addr_a", ",", "function_addr_b", ")", ":", "pair", "=", "(", "function_addr_a", ",", "function_addr_b", ")", "if", "pair", "not", "in", "self", ".", "_function_diffs", ":", "function_a", "=", "self", ".",...
:param function_addr_a: The address of the first function (in the first binary) :param function_addr_b: The address of the second function (in the second binary) :returns: the FunctionDiff of the two functions
[ ":", "param", "function_addr_a", ":", "The", "address", "of", "the", "first", "function", "(", "in", "the", "first", "binary", ")", ":", "param", "function_addr_b", ":", "The", "address", "of", "the", "second", "function", "(", "in", "the", "second", "bina...
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/bindiff.py#L962-L973
train
angr/angr
angr/analyses/bindiff.py
BinDiff._compute_function_attributes
def _compute_function_attributes(cfg): """ :param cfg: An angr CFG object :returns: a dictionary of function addresses to tuples of attributes """ # the attributes we use are the number of basic blocks, number of edges, and number of subfunction calls attributes = dict...
python
def _compute_function_attributes(cfg): """ :param cfg: An angr CFG object :returns: a dictionary of function addresses to tuples of attributes """ # the attributes we use are the number of basic blocks, number of edges, and number of subfunction calls attributes = dict...
[ "def", "_compute_function_attributes", "(", "cfg", ")", ":", "# the attributes we use are the number of basic blocks, number of edges, and number of subfunction calls", "attributes", "=", "dict", "(", ")", "all_funcs", "=", "set", "(", "cfg", ".", "kb", ".", "callgraph", "....
:param cfg: An angr CFG object :returns: a dictionary of function addresses to tuples of attributes
[ ":", "param", "cfg", ":", "An", "angr", "CFG", "object", ":", "returns", ":", "a", "dictionary", "of", "function", "addresses", "to", "tuples", "of", "attributes" ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/bindiff.py#L976-L1001
train
angr/angr
angr/analyses/bindiff.py
BinDiff._get_function_matches
def _get_function_matches(attributes_a, attributes_b, filter_set_a=None, filter_set_b=None): """ :param attributes_a: A dict of functions to their attributes :param attributes_b: A dict of functions to their attributes The following parameters are optional. :param filter_...
python
def _get_function_matches(attributes_a, attributes_b, filter_set_a=None, filter_set_b=None): """ :param attributes_a: A dict of functions to their attributes :param attributes_b: A dict of functions to their attributes The following parameters are optional. :param filter_...
[ "def", "_get_function_matches", "(", "attributes_a", ",", "attributes_b", ",", "filter_set_a", "=", "None", ",", "filter_set_b", "=", "None", ")", ":", "# get the attributes that are in the sets", "if", "filter_set_a", "is", "None", ":", "filtered_attributes_a", "=", ...
:param attributes_a: A dict of functions to their attributes :param attributes_b: A dict of functions to their attributes The following parameters are optional. :param filter_set_a: A set to limit attributes_a to the functions in this set. :param filter_set_b: A set to limi...
[ ":", "param", "attributes_a", ":", "A", "dict", "of", "functions", "to", "their", "attributes", ":", "param", "attributes_b", ":", "A", "dict", "of", "functions", "to", "their", "attributes" ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/bindiff.py#L1171-L1205
train
angr/angr
angr/project.py
load_shellcode
def load_shellcode(shellcode, arch, start_offset=0, load_address=0): """ Load a new project based on a string of raw bytecode. :param shellcode: The data to load :param arch: The name of the arch to use, or an archinfo class :param start_offset: The offset into the data to start...
python
def load_shellcode(shellcode, arch, start_offset=0, load_address=0): """ Load a new project based on a string of raw bytecode. :param shellcode: The data to load :param arch: The name of the arch to use, or an archinfo class :param start_offset: The offset into the data to start...
[ "def", "load_shellcode", "(", "shellcode", ",", "arch", ",", "start_offset", "=", "0", ",", "load_address", "=", "0", ")", ":", "return", "Project", "(", "BytesIO", "(", "shellcode", ")", ",", "main_opts", "=", "{", "'backend'", ":", "'blob'", ",", "'arc...
Load a new project based on a string of raw bytecode. :param shellcode: The data to load :param arch: The name of the arch to use, or an archinfo class :param start_offset: The offset into the data to start analysis (default 0) :param load_address: The address to place the data i...
[ "Load", "a", "new", "project", "based", "on", "a", "string", "of", "raw", "bytecode", "." ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/project.py#L17-L34
train
angr/angr
angr/project.py
Project._register_object
def _register_object(self, obj, sim_proc_arch): """ This scans through an objects imports and hooks them with simprocedures from our library whenever possible """ # Step 1: get the set of libraries we are allowed to use to resolve unresolved symbols missing_libs = [] for...
python
def _register_object(self, obj, sim_proc_arch): """ This scans through an objects imports and hooks them with simprocedures from our library whenever possible """ # Step 1: get the set of libraries we are allowed to use to resolve unresolved symbols missing_libs = [] for...
[ "def", "_register_object", "(", "self", ",", "obj", ",", "sim_proc_arch", ")", ":", "# Step 1: get the set of libraries we are allowed to use to resolve unresolved symbols", "missing_libs", "=", "[", "]", "for", "lib_name", "in", "self", ".", "loader", ".", "missing_depen...
This scans through an objects imports and hooks them with simprocedures from our library whenever possible
[ "This", "scans", "through", "an", "objects", "imports", "and", "hooks", "them", "with", "simprocedures", "from", "our", "library", "whenever", "possible" ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/project.py#L231-L340
train
angr/angr
angr/project.py
Project._guess_simprocedure
def _guess_simprocedure(self, f, hint): """ Does symbol name `f` exist as a SIM_PROCEDURE? If so, return it, else return None. Narrows down the set of libraries to search based on hint. Part of the hack to enable Binary Ninja support. Remove if _register_objects() stops using it. ...
python
def _guess_simprocedure(self, f, hint): """ Does symbol name `f` exist as a SIM_PROCEDURE? If so, return it, else return None. Narrows down the set of libraries to search based on hint. Part of the hack to enable Binary Ninja support. Remove if _register_objects() stops using it. ...
[ "def", "_guess_simprocedure", "(", "self", ",", "f", ",", "hint", ")", ":", "# First, filter the SIM_LIBRARIES to a reasonable subset based on the hint", "hinted_libs", "=", "[", "]", "if", "hint", "==", "\"win\"", ":", "hinted_libs", "=", "filter", "(", "lambda", "...
Does symbol name `f` exist as a SIM_PROCEDURE? If so, return it, else return None. Narrows down the set of libraries to search based on hint. Part of the hack to enable Binary Ninja support. Remove if _register_objects() stops using it.
[ "Does", "symbol", "name", "f", "exist", "as", "a", "SIM_PROCEDURE?", "If", "so", "return", "it", "else", "return", "None", ".", "Narrows", "down", "the", "set", "of", "libraries", "to", "search", "based", "on", "hint", ".", "Part", "of", "the", "hack", ...
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/project.py#L342-L361
train
angr/angr
angr/project.py
Project._check_user_blacklists
def _check_user_blacklists(self, f): """ Has symbol name `f` been marked for exclusion by any of the user parameters? """ return not self._should_use_sim_procedures or \ f in self._exclude_sim_procedures_list or \ f in self._ignore_functions or \ ...
python
def _check_user_blacklists(self, f): """ Has symbol name `f` been marked for exclusion by any of the user parameters? """ return not self._should_use_sim_procedures or \ f in self._exclude_sim_procedures_list or \ f in self._ignore_functions or \ ...
[ "def", "_check_user_blacklists", "(", "self", ",", "f", ")", ":", "return", "not", "self", ".", "_should_use_sim_procedures", "or", "f", "in", "self", ".", "_exclude_sim_procedures_list", "or", "f", "in", "self", ".", "_ignore_functions", "or", "(", "self", "....
Has symbol name `f` been marked for exclusion by any of the user parameters?
[ "Has", "symbol", "name", "f", "been", "marked", "for", "exclusion", "by", "any", "of", "the", "user", "parameters?" ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/project.py#L363-L371
train
angr/angr
angr/project.py
Project.hook
def hook(self, addr, hook=None, length=0, kwargs=None, replace=False): """ Hook a section of code with a custom function. This is used internally to provide symbolic summaries of library functions, and can be used to instrument execution or to modify control flow. When hook is n...
python
def hook(self, addr, hook=None, length=0, kwargs=None, replace=False): """ Hook a section of code with a custom function. This is used internally to provide symbolic summaries of library functions, and can be used to instrument execution or to modify control flow. When hook is n...
[ "def", "hook", "(", "self", ",", "addr", ",", "hook", "=", "None", ",", "length", "=", "0", ",", "kwargs", "=", "None", ",", "replace", "=", "False", ")", ":", "if", "hook", "is", "None", ":", "# if we haven't been passed a thing to hook with, assume we're b...
Hook a section of code with a custom function. This is used internally to provide symbolic summaries of library functions, and can be used to instrument execution or to modify control flow. When hook is not specified, it returns a function decorator that allows easy hooking. Usage:: ...
[ "Hook", "a", "section", "of", "code", "with", "a", "custom", "function", ".", "This", "is", "used", "internally", "to", "provide", "symbolic", "summaries", "of", "library", "functions", "and", "can", "be", "used", "to", "instrument", "execution", "or", "to",...
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/project.py#L385-L436
train
angr/angr
angr/project.py
Project.hooked_by
def hooked_by(self, addr): """ Returns the current hook for `addr`. :param addr: An address. :returns: None if the address is not hooked. """ if not self.is_hooked(addr): l.warning("Address %s is not hooked", self._addr_to_str(addr)) return N...
python
def hooked_by(self, addr): """ Returns the current hook for `addr`. :param addr: An address. :returns: None if the address is not hooked. """ if not self.is_hooked(addr): l.warning("Address %s is not hooked", self._addr_to_str(addr)) return N...
[ "def", "hooked_by", "(", "self", ",", "addr", ")", ":", "if", "not", "self", ".", "is_hooked", "(", "addr", ")", ":", "l", ".", "warning", "(", "\"Address %s is not hooked\"", ",", "self", ".", "_addr_to_str", "(", "addr", ")", ")", "return", "None", "...
Returns the current hook for `addr`. :param addr: An address. :returns: None if the address is not hooked.
[ "Returns", "the", "current", "hook", "for", "addr", "." ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/project.py#L447-L460
train
angr/angr
angr/project.py
Project.unhook
def unhook(self, addr): """ Remove a hook. :param addr: The address of the hook. """ if not self.is_hooked(addr): l.warning("Address %s not hooked", self._addr_to_str(addr)) return del self._sim_procedures[addr]
python
def unhook(self, addr): """ Remove a hook. :param addr: The address of the hook. """ if not self.is_hooked(addr): l.warning("Address %s not hooked", self._addr_to_str(addr)) return del self._sim_procedures[addr]
[ "def", "unhook", "(", "self", ",", "addr", ")", ":", "if", "not", "self", ".", "is_hooked", "(", "addr", ")", ":", "l", ".", "warning", "(", "\"Address %s not hooked\"", ",", "self", ".", "_addr_to_str", "(", "addr", ")", ")", "return", "del", "self", ...
Remove a hook. :param addr: The address of the hook.
[ "Remove", "a", "hook", "." ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/project.py#L462-L472
train
angr/angr
angr/project.py
Project.hook_symbol
def hook_symbol(self, symbol_name, simproc, kwargs=None, replace=None): """ Resolve a dependency in a binary. Looks up the address of the given symbol, and then hooks that address. If the symbol was not available in the loaded libraries, this address may be provided by the CLE externs ob...
python
def hook_symbol(self, symbol_name, simproc, kwargs=None, replace=None): """ Resolve a dependency in a binary. Looks up the address of the given symbol, and then hooks that address. If the symbol was not available in the loaded libraries, this address may be provided by the CLE externs ob...
[ "def", "hook_symbol", "(", "self", ",", "symbol_name", ",", "simproc", ",", "kwargs", "=", "None", ",", "replace", "=", "None", ")", ":", "if", "type", "(", "symbol_name", ")", "is", "not", "int", ":", "sym", "=", "self", ".", "loader", ".", "find_sy...
Resolve a dependency in a binary. Looks up the address of the given symbol, and then hooks that address. If the symbol was not available in the loaded libraries, this address may be provided by the CLE externs object. Additionally, if instead of a symbol name you provide an address, some secret...
[ "Resolve", "a", "dependency", "in", "a", "binary", ".", "Looks", "up", "the", "address", "of", "the", "given", "symbol", "and", "then", "hooks", "that", "address", ".", "If", "the", "symbol", "was", "not", "available", "in", "the", "loaded", "libraries", ...
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/project.py#L474-L522
train
angr/angr
angr/project.py
Project.is_symbol_hooked
def is_symbol_hooked(self, symbol_name): """ Check if a symbol is already hooked. :param str symbol_name: Name of the symbol. :return: True if the symbol can be resolved and is hooked, False otherwise. :rtype: bool """ sym = self.loader.find_symbol(symbol_name) ...
python
def is_symbol_hooked(self, symbol_name): """ Check if a symbol is already hooked. :param str symbol_name: Name of the symbol. :return: True if the symbol can be resolved and is hooked, False otherwise. :rtype: bool """ sym = self.loader.find_symbol(symbol_name) ...
[ "def", "is_symbol_hooked", "(", "self", ",", "symbol_name", ")", ":", "sym", "=", "self", ".", "loader", ".", "find_symbol", "(", "symbol_name", ")", "if", "sym", "is", "None", ":", "l", ".", "warning", "(", "\"Could not find symbol %s\"", ",", "symbol_name"...
Check if a symbol is already hooked. :param str symbol_name: Name of the symbol. :return: True if the symbol can be resolved and is hooked, False otherwise. :rtype: bool
[ "Check", "if", "a", "symbol", "is", "already", "hooked", "." ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/project.py#L524-L537
train
angr/angr
angr/project.py
Project.unhook_symbol
def unhook_symbol(self, symbol_name): """ Remove the hook on a symbol. This function will fail if the symbol is provided by the extern object, as that would result in a state where analysis would be unable to cope with a call to this symbol. """ sym = self.loader.find_sym...
python
def unhook_symbol(self, symbol_name): """ Remove the hook on a symbol. This function will fail if the symbol is provided by the extern object, as that would result in a state where analysis would be unable to cope with a call to this symbol. """ sym = self.loader.find_sym...
[ "def", "unhook_symbol", "(", "self", ",", "symbol_name", ")", ":", "sym", "=", "self", ".", "loader", ".", "find_symbol", "(", "symbol_name", ")", "if", "sym", "is", "None", ":", "l", ".", "warning", "(", "\"Could not find symbol %s\"", ",", "symbol_name", ...
Remove the hook on a symbol. This function will fail if the symbol is provided by the extern object, as that would result in a state where analysis would be unable to cope with a call to this symbol.
[ "Remove", "the", "hook", "on", "a", "symbol", ".", "This", "function", "will", "fail", "if", "the", "symbol", "is", "provided", "by", "the", "extern", "object", "as", "that", "would", "result", "in", "a", "state", "where", "analysis", "would", "be", "una...
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/project.py#L539-L556
train
angr/angr
angr/project.py
Project.rehook_symbol
def rehook_symbol(self, new_address, symbol_name): """ Move the hook for a symbol to a specific address :param new_address: the new address that will trigger the SimProc execution :param symbol_name: the name of the symbol (f.i. strcmp ) :return: None """ new_sim_...
python
def rehook_symbol(self, new_address, symbol_name): """ Move the hook for a symbol to a specific address :param new_address: the new address that will trigger the SimProc execution :param symbol_name: the name of the symbol (f.i. strcmp ) :return: None """ new_sim_...
[ "def", "rehook_symbol", "(", "self", ",", "new_address", ",", "symbol_name", ")", ":", "new_sim_procedures", "=", "{", "}", "for", "key_address", ",", "simproc_obj", "in", "self", ".", "_sim_procedures", ".", "items", "(", ")", ":", "if", "simproc_obj", ".",...
Move the hook for a symbol to a specific address :param new_address: the new address that will trigger the SimProc execution :param symbol_name: the name of the symbol (f.i. strcmp ) :return: None
[ "Move", "the", "hook", "for", "a", "symbol", "to", "a", "specific", "address", ":", "param", "new_address", ":", "the", "new", "address", "that", "will", "trigger", "the", "SimProc", "execution", ":", "param", "symbol_name", ":", "the", "name", "of", "the"...
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/project.py#L558-L572
train
angr/angr
angr/project.py
Project.execute
def execute(self, *args, **kwargs): """ This function is a symbolic execution helper in the simple style supported by triton and manticore. It designed to be run after setting up hooks (see Project.hook), in which the symbolic state can be checked. This function can be r...
python
def execute(self, *args, **kwargs): """ This function is a symbolic execution helper in the simple style supported by triton and manticore. It designed to be run after setting up hooks (see Project.hook), in which the symbolic state can be checked. This function can be r...
[ "def", "execute", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "args", ":", "state", "=", "args", "[", "0", "]", "else", ":", "state", "=", "self", ".", "factory", ".", "full_init_state", "(", "*", "*", "kwargs", ")", ...
This function is a symbolic execution helper in the simple style supported by triton and manticore. It designed to be run after setting up hooks (see Project.hook), in which the symbolic state can be checked. This function can be run in three different ways: - When run with...
[ "This", "function", "is", "a", "symbolic", "execution", "helper", "in", "the", "simple", "style", "supported", "by", "triton", "and", "manticore", ".", "It", "designed", "to", "be", "run", "after", "setting", "up", "hooks", "(", "see", "Project", ".", "hoo...
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/project.py#L578-L605
train
angr/angr
angr/project.py
Project._hook_decorator
def _hook_decorator(self, addr, length=0, kwargs=None): """ Return a function decorator that allows easy hooking. Please refer to hook() for its usage. :return: The function decorator. """ def hook_decorator(func): self.hook(addr, func, length=length, kwargs=kwargs)...
python
def _hook_decorator(self, addr, length=0, kwargs=None): """ Return a function decorator that allows easy hooking. Please refer to hook() for its usage. :return: The function decorator. """ def hook_decorator(func): self.hook(addr, func, length=length, kwargs=kwargs)...
[ "def", "_hook_decorator", "(", "self", ",", "addr", ",", "length", "=", "0", ",", "kwargs", "=", "None", ")", ":", "def", "hook_decorator", "(", "func", ")", ":", "self", ".", "hook", "(", "addr", ",", "func", ",", "length", "=", "length", ",", "kw...
Return a function decorator that allows easy hooking. Please refer to hook() for its usage. :return: The function decorator.
[ "Return", "a", "function", "decorator", "that", "allows", "easy", "hooking", ".", "Please", "refer", "to", "hook", "()", "for", "its", "usage", "." ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/project.py#L617-L628
train
angr/angr
angr/project.py
Project.is_java_project
def is_java_project(self): """ Indicates if the project's main binary is a Java Archive. """ if self._is_java_project is None: self._is_java_project = isinstance(self.arch, ArchSoot) return self._is_java_project
python
def is_java_project(self): """ Indicates if the project's main binary is a Java Archive. """ if self._is_java_project is None: self._is_java_project = isinstance(self.arch, ArchSoot) return self._is_java_project
[ "def", "is_java_project", "(", "self", ")", ":", "if", "self", ".", "_is_java_project", "is", "None", ":", "self", ".", "_is_java_project", "=", "isinstance", "(", "self", ".", "arch", ",", "ArchSoot", ")", "return", "self", ".", "_is_java_project" ]
Indicates if the project's main binary is a Java Archive.
[ "Indicates", "if", "the", "project", "s", "main", "binary", "is", "a", "Java", "Archive", "." ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/project.py#L701-L707
train
angr/angr
angr/project.py
Project.is_java_jni_project
def is_java_jni_project(self): """ Indicates if the project's main binary is a Java Archive, which interacts during its execution with native libraries (via JNI). """ if self._is_java_jni_project is None: self._is_java_jni_project = isinstance(self.arch, ArchSoot) and...
python
def is_java_jni_project(self): """ Indicates if the project's main binary is a Java Archive, which interacts during its execution with native libraries (via JNI). """ if self._is_java_jni_project is None: self._is_java_jni_project = isinstance(self.arch, ArchSoot) and...
[ "def", "is_java_jni_project", "(", "self", ")", ":", "if", "self", ".", "_is_java_jni_project", "is", "None", ":", "self", ".", "_is_java_jni_project", "=", "isinstance", "(", "self", ".", "arch", ",", "ArchSoot", ")", "and", "self", ".", "simos", ".", "is...
Indicates if the project's main binary is a Java Archive, which interacts during its execution with native libraries (via JNI).
[ "Indicates", "if", "the", "project", "s", "main", "binary", "is", "a", "Java", "Archive", "which", "interacts", "during", "its", "execution", "with", "native", "libraries", "(", "via", "JNI", ")", "." ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/project.py#L710-L717
train
angr/angr
angr/misc/plugins.py
PluginHub.register_preset
def register_preset(cls, name, preset): """ Register a preset instance with the class of the hub it corresponds to. This allows individual plugin objects to automatically register themselves with a preset by using a classmethod of their own with only the name of the preset to register wi...
python
def register_preset(cls, name, preset): """ Register a preset instance with the class of the hub it corresponds to. This allows individual plugin objects to automatically register themselves with a preset by using a classmethod of their own with only the name of the preset to register wi...
[ "def", "register_preset", "(", "cls", ",", "name", ",", "preset", ")", ":", "if", "cls", ".", "_presets", "is", "None", ":", "cls", ".", "_presets", "=", "{", "}", "cls", ".", "_presets", "[", "name", "]", "=", "preset" ]
Register a preset instance with the class of the hub it corresponds to. This allows individual plugin objects to automatically register themselves with a preset by using a classmethod of their own with only the name of the preset to register with.
[ "Register", "a", "preset", "instance", "with", "the", "class", "of", "the", "hub", "it", "corresponds", "to", ".", "This", "allows", "individual", "plugin", "objects", "to", "automatically", "register", "themselves", "with", "a", "preset", "by", "using", "a", ...
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/misc/plugins.py#L42-L50
train
angr/angr
angr/misc/plugins.py
PluginHub.use_plugin_preset
def use_plugin_preset(self, preset): """ Apply a preset to the hub. If there was a previously active preset, discard it. Preset can be either the string name of a preset or a PluginPreset instance. """ if isinstance(preset, str): try: preset = self._p...
python
def use_plugin_preset(self, preset): """ Apply a preset to the hub. If there was a previously active preset, discard it. Preset can be either the string name of a preset or a PluginPreset instance. """ if isinstance(preset, str): try: preset = self._p...
[ "def", "use_plugin_preset", "(", "self", ",", "preset", ")", ":", "if", "isinstance", "(", "preset", ",", "str", ")", ":", "try", ":", "preset", "=", "self", ".", "_presets", "[", "preset", "]", "except", "(", "AttributeError", ",", "KeyError", ")", ":...
Apply a preset to the hub. If there was a previously active preset, discard it. Preset can be either the string name of a preset or a PluginPreset instance.
[ "Apply", "a", "preset", "to", "the", "hub", ".", "If", "there", "was", "a", "previously", "active", "preset", "discard", "it", "." ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/misc/plugins.py#L109-L129
train
angr/angr
angr/misc/plugins.py
PluginHub.discard_plugin_preset
def discard_plugin_preset(self): """ Discard the current active preset. Will release any active plugins that could have come from the old preset. """ if self.has_plugin_preset: for name, plugin in list(self._active_plugins.items()): if id(plugin) in self._prov...
python
def discard_plugin_preset(self): """ Discard the current active preset. Will release any active plugins that could have come from the old preset. """ if self.has_plugin_preset: for name, plugin in list(self._active_plugins.items()): if id(plugin) in self._prov...
[ "def", "discard_plugin_preset", "(", "self", ")", ":", "if", "self", ".", "has_plugin_preset", ":", "for", "name", ",", "plugin", "in", "list", "(", "self", ".", "_active_plugins", ".", "items", "(", ")", ")", ":", "if", "id", "(", "plugin", ")", "in",...
Discard the current active preset. Will release any active plugins that could have come from the old preset.
[ "Discard", "the", "current", "active", "preset", ".", "Will", "release", "any", "active", "plugins", "that", "could", "have", "come", "from", "the", "old", "preset", "." ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/misc/plugins.py#L131-L140
train
angr/angr
angr/misc/plugins.py
PluginHub.get_plugin
def get_plugin(self, name): """ Get the plugin named ``name``. If no such plugin is currently active, try to activate a new one using the current preset. """ if name in self._active_plugins: return self._active_plugins[name] elif self.has_plugin_preset: ...
python
def get_plugin(self, name): """ Get the plugin named ``name``. If no such plugin is currently active, try to activate a new one using the current preset. """ if name in self._active_plugins: return self._active_plugins[name] elif self.has_plugin_preset: ...
[ "def", "get_plugin", "(", "self", ",", "name", ")", ":", "if", "name", "in", "self", ".", "_active_plugins", ":", "return", "self", ".", "_active_plugins", "[", "name", "]", "elif", "self", ".", "has_plugin_preset", ":", "plugin_cls", "=", "self", ".", "...
Get the plugin named ``name``. If no such plugin is currently active, try to activate a new one using the current preset.
[ "Get", "the", "plugin", "named", "name", ".", "If", "no", "such", "plugin", "is", "currently", "active", "try", "to", "activate", "a", "new", "one", "using", "the", "current", "preset", "." ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/misc/plugins.py#L146-L165
train
angr/angr
angr/misc/plugins.py
PluginHub.register_plugin
def register_plugin(self, name, plugin): """ Add a new plugin ``plugin`` with name ``name`` to the active plugins. """ if self.has_plugin(name): self.release_plugin(name) self._active_plugins[name] = plugin setattr(self, name, plugin) return plugin
python
def register_plugin(self, name, plugin): """ Add a new plugin ``plugin`` with name ``name`` to the active plugins. """ if self.has_plugin(name): self.release_plugin(name) self._active_plugins[name] = plugin setattr(self, name, plugin) return plugin
[ "def", "register_plugin", "(", "self", ",", "name", ",", "plugin", ")", ":", "if", "self", ".", "has_plugin", "(", "name", ")", ":", "self", ".", "release_plugin", "(", "name", ")", "self", ".", "_active_plugins", "[", "name", "]", "=", "plugin", "seta...
Add a new plugin ``plugin`` with name ``name`` to the active plugins.
[ "Add", "a", "new", "plugin", "plugin", "with", "name", "name", "to", "the", "active", "plugins", "." ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/misc/plugins.py#L181-L189
train
angr/angr
angr/misc/plugins.py
PluginHub.release_plugin
def release_plugin(self, name): """ Deactivate and remove the plugin with name ``name``. """ plugin = self._active_plugins[name] if id(plugin) in self._provided_by_preset: self._provided_by_preset.remove(id(plugin)) del self._active_plugins[name] dela...
python
def release_plugin(self, name): """ Deactivate and remove the plugin with name ``name``. """ plugin = self._active_plugins[name] if id(plugin) in self._provided_by_preset: self._provided_by_preset.remove(id(plugin)) del self._active_plugins[name] dela...
[ "def", "release_plugin", "(", "self", ",", "name", ")", ":", "plugin", "=", "self", ".", "_active_plugins", "[", "name", "]", "if", "id", "(", "plugin", ")", "in", "self", ".", "_provided_by_preset", ":", "self", ".", "_provided_by_preset", ".", "remove", ...
Deactivate and remove the plugin with name ``name``.
[ "Deactivate", "and", "remove", "the", "plugin", "with", "name", "name", "." ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/misc/plugins.py#L191-L200
train
angr/angr
angr/misc/plugins.py
PluginPreset.copy
def copy(self): """ Return a copy of self. """ cls = self.__class__ result = cls.__new__(cls) result._default_plugins = dict(self._default_plugins) # pylint:disable=protected-access return result
python
def copy(self): """ Return a copy of self. """ cls = self.__class__ result = cls.__new__(cls) result._default_plugins = dict(self._default_plugins) # pylint:disable=protected-access return result
[ "def", "copy", "(", "self", ")", ":", "cls", "=", "self", ".", "__class__", "result", "=", "cls", ".", "__new__", "(", "cls", ")", "result", ".", "_default_plugins", "=", "dict", "(", "self", ".", "_default_plugins", ")", "# pylint:disable=protected-access",...
Return a copy of self.
[ "Return", "a", "copy", "of", "self", "." ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/misc/plugins.py#L249-L256
train
angr/angr
angr/exploration_techniques/tracer.py
Tracer._grab_concretization_results
def _grab_concretization_results(cls, state): """ Grabs the concretized result so we can add the constraint ourselves. """ # only grab ones that match the constrained addrs if cls._should_add_constraints(state): addr = state.inspect.address_concretization_expr ...
python
def _grab_concretization_results(cls, state): """ Grabs the concretized result so we can add the constraint ourselves. """ # only grab ones that match the constrained addrs if cls._should_add_constraints(state): addr = state.inspect.address_concretization_expr ...
[ "def", "_grab_concretization_results", "(", "cls", ",", "state", ")", ":", "# only grab ones that match the constrained addrs", "if", "cls", ".", "_should_add_constraints", "(", "state", ")", ":", "addr", "=", "state", ".", "inspect", ".", "address_concretization_expr",...
Grabs the concretized result so we can add the constraint ourselves.
[ "Grabs", "the", "concretized", "result", "so", "we", "can", "add", "the", "constraint", "ourselves", "." ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/exploration_techniques/tracer.py#L459-L470
train
angr/angr
angr/exploration_techniques/tracer.py
Tracer._should_add_constraints
def _should_add_constraints(cls, state): """ Check to see if the current address concretization variable is any of the registered constrained_addrs we want to allow concretization for """ expr = state.inspect.address_concretization_expr hit_indices = cls._to_indices(state...
python
def _should_add_constraints(cls, state): """ Check to see if the current address concretization variable is any of the registered constrained_addrs we want to allow concretization for """ expr = state.inspect.address_concretization_expr hit_indices = cls._to_indices(state...
[ "def", "_should_add_constraints", "(", "cls", ",", "state", ")", ":", "expr", "=", "state", ".", "inspect", ".", "address_concretization_expr", "hit_indices", "=", "cls", ".", "_to_indices", "(", "state", ",", "expr", ")", "for", "action", "in", "state", "."...
Check to see if the current address concretization variable is any of the registered constrained_addrs we want to allow concretization for
[ "Check", "to", "see", "if", "the", "current", "address", "concretization", "variable", "is", "any", "of", "the", "registered", "constrained_addrs", "we", "want", "to", "allow", "concretization", "for" ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/exploration_techniques/tracer.py#L482-L494
train
angr/angr
angr/state_plugins/heap/heap_brk.py
SimHeapBrk.allocate
def allocate(self, sim_size): """ The actual allocation primitive for this heap implementation. Increases the position of the break to allocate space. Has no guards against the heap growing too large. :param sim_size: a size specifying how much to increase the break pointer by :...
python
def allocate(self, sim_size): """ The actual allocation primitive for this heap implementation. Increases the position of the break to allocate space. Has no guards against the heap growing too large. :param sim_size: a size specifying how much to increase the break pointer by :...
[ "def", "allocate", "(", "self", ",", "sim_size", ")", ":", "size", "=", "self", ".", "_conc_alloc_size", "(", "sim_size", ")", "addr", "=", "self", ".", "state", ".", "heap", ".", "heap_location", "self", ".", "state", ".", "heap", ".", "heap_location", ...
The actual allocation primitive for this heap implementation. Increases the position of the break to allocate space. Has no guards against the heap growing too large. :param sim_size: a size specifying how much to increase the break pointer by :returns: a pointer to the previous break position,...
[ "The", "actual", "allocation", "primitive", "for", "this", "heap", "implementation", ".", "Increases", "the", "position", "of", "the", "break", "to", "allocate", "space", ".", "Has", "no", "guards", "against", "the", "heap", "growing", "too", "large", "." ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/state_plugins/heap/heap_brk.py#L31-L43
train
angr/angr
angr/state_plugins/heap/heap_brk.py
SimHeapBrk.release
def release(self, sim_size): """ The memory release primitive for this heap implementation. Decreases the position of the break to deallocate space. Guards against releasing beyond the initial heap base. :param sim_size: a size specifying how much to decrease the break pointer by (may b...
python
def release(self, sim_size): """ The memory release primitive for this heap implementation. Decreases the position of the break to deallocate space. Guards against releasing beyond the initial heap base. :param sim_size: a size specifying how much to decrease the break pointer by (may b...
[ "def", "release", "(", "self", ",", "sim_size", ")", ":", "requested", "=", "self", ".", "_conc_alloc_size", "(", "sim_size", ")", "used", "=", "self", ".", "heap_location", "-", "self", ".", "heap_base", "released", "=", "requested", "if", "requested", "<...
The memory release primitive for this heap implementation. Decreases the position of the break to deallocate space. Guards against releasing beyond the initial heap base. :param sim_size: a size specifying how much to decrease the break pointer by (may be symbolic or not)
[ "The", "memory", "release", "primitive", "for", "this", "heap", "implementation", ".", "Decreases", "the", "position", "of", "the", "break", "to", "deallocate", "space", ".", "Guards", "against", "releasing", "beyond", "the", "initial", "heap", "base", "." ]
4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/state_plugins/heap/heap_brk.py#L45-L56
train