quark.utils package

Submodules

quark.utils.colors module

quark.utils.colors.black(text)
quark.utils.colors.blue(text)
quark.utils.colors.bold(text)
quark.utils.colors.color(text, color_code)

Colorize text. @param text: text. @param color_code: color. @return: colorized text.

quark.utils.colors.colorful_report(arg0)
quark.utils.colors.cyan(text)
quark.utils.colors.green(text)
quark.utils.colors.lightblue(text)
quark.utils.colors.lightyellow(text)
quark.utils.colors.magenta(text)
quark.utils.colors.red(text)
quark.utils.colors.white(text)
quark.utils.colors.yellow(text)

quark.utils.graph module

quark.utils.output module

quark.utils.pprint module

quark.utils.regex module

quark.utils.regex.extract_content(string)
quark.utils.regex.extract_file(string)
quark.utils.regex.extract_ip(string)
quark.utils.regex.extract_url(string)
quark.utils.regex.validate_base64(sb)
quark.utils.regex.validate_ip_address(ip)
quark.utils.regex.validate_url(url)

quark.utils.tools module

quark.utils.tools.contains(subset_to_check, target_list)

Check the sequence pattern within two list.

subset_to_check = [“getCellLocation”, “sendTextMessage”] target_list = [“put”, “getCellLocation”, “query”, “sendTextMessage”] then it will return true. —————————————————————– subset_to_check = [“getCellLocation”, “sendTextMessage”] target_list = [“sendTextMessage”, “put”, “getCellLocation”, “query”] then it will return False.

quark.utils.tools.descriptor_to_androguard_format(descriptor)
quark.utils.tools.filter_api_by_usage_count(data, api_pool, percentile_rank=0.2)

Sorting APIs by the number of APIs used in APK, and split APIs into P_set (less used number) and S_set (more used number) by percentile_rank (default 20%).

Parameters:
  • data – the object of apkinfo.

  • api_pool – the APIs list for rule generation.

  • percentile_rank – the int for rank of percentile.

Return P_set:

a set of APIs that less used.

Return S_set:

a set of APIs that more used.

quark.utils.tools.get_arguments_from_argument_str(argument_str: str, descriptor: str) List[Any]

Get arguments from an argument string.

Parameters:
  • argument_str – string that holds multiple arguments and uses commas as separators

  • descriptor – string that holds a descriptor for type inference

Returns:

python list that holds the arguments

quark.utils.tools.get_parenthetic_contents(string: str, start_index: int) str

Get the content between a pair of parentheses.

Parameters:
  • string – string to be parsed

  • start_index – index to specify the parenthesis

Returns:

string holding the content

quark.utils.tools.remove_dup_list(element)

Remove the duplicate elements in given list.

quark.utils.weight module

class quark.utils.weight.LEVEL_INFO(value)

Bases: Enum

An enumeration.

High = 'High Risk'
LOW = 'Low Risk'
Moderate = 'Moderate Risk'
class quark.utils.weight.Weight(score_sum, weight_sum)

Bases: object

calculate()

Module contents