KUNAI Static Analyzer
Kunai is a library for doing static binary analysis of Dalvik.
Loading...
Searching...
No Matches
Public Member Functions | List of all members
KUNAI::DEX::Analysis Class Reference

Public Member Functions

 Analysis (Parser *parser, DexDisassembler *disassembler, bool create_xrefs)
 
void add (Parser *parser)
 Add all the classes and methods from a parser to the analysis class.
 
void create_xrefs ()
 Create class, method, string and field cross references if you are using multiple DEX files, this function must be called when all DEX files are added. If you call the function after every DEX file, it will only work for the first time. ADD ALL DEX FIRST.
 
ClassAnalysisget_class_analysis (std::string &class_name)
 Get a ClassAnalysis object by the class name.
 
const std::unordered_map< std::string, std::unique_ptr< ClassAnalysis > > & get_classes () const
 Get a constant reference to the classes.
 
std::unordered_map< std::string, std::unique_ptr< ClassAnalysis > > & get_classes ()
 Get a reference to the classes.
 
const std::unordered_map< std::string, std::unique_ptr< ExternalClass > > & get_external_classes () const
 Get a constant reference to external classes.
 
std::unordered_map< std::string, std::unique_ptr< ExternalClass > > & get_external_classes ()
 Get a reference to external classes.
 
MethodAnalysisget_method (std::variant< EncodedMethod *, ExternalMethod * > method)
 Get a MethodAnalysis pointer given an Encoded or External Method.
 
MethodAnalysisget_method_analysis_by_name (std::string &class_name, std::string &method_name, std::string &method_descriptor)
 Obtain a method anaylsis by different values.
 
MethodIDget_method_id_by_name (std::string &class_name, std::string &method_name, std::string &method_descriptor)
 Obtain a MethodID by different values.
 
const std::unordered_map< std::string, std::unique_ptr< MethodAnalysis > > & get_methods () const
 Return a constant reference to the method analysis.
 
std::unordered_map< std::string, std::unique_ptr< MethodAnalysis > > & get_methods ()
 Return a reference to the method analysis.
 
const std::unordered_map< std::string, std::unique_ptr< ExternalMethod > > & get_external_methods () const
 Return a constant reference to the ExternalMethods.
 
std::unordered_map< std::string, std::unique_ptr< ExternalMethod > > & get_external_methods ()
 Return a reference to the ExternalMethods.
 
FieldAnalysisget_field_analysis (EncodedField *field)
 Get a field given an encoded field.
 
std::vector< FieldAnalysis * > & get_fields ()
 Get all the fields from all the classes.
 
const std::unordered_map< std::string, std::unique_ptr< StringAnalysis > > & get_string_analysis () const
 Get a constant reference to the StringAnalysis objects.
 
std::unordered_map< std::string, std::unique_ptr< StringAnalysis > > & get_string_analysis ()
 Get a reference to the StringAnalysis map.
 
std::vector< ClassAnalysis * > find_classes (std::string &name, bool no_external)
 Find classes by name with regular expression, the method returns a list of ClassAnalysis object that match the regex.
 
std::vector< MethodAnalysis * > find_methods (std::string &class_name, std::string &method_name, std::string &descriptor, std::string &accessflags, bool no_external)
 Find MethodAnalysis object by name with regular expression. This time is necessary to specify more values for the method.
 
std::vector< StringAnalysis * > find_strings (std::string &str)
 Find the strings that match a provided regular expression.
 
std::vector< FieldAnalysis * > find_fields (std::string &class_name, std::string &field_name, std::string &field_type, std::string &accessflags)
 Find FieldAnalysis objects using regular expressions find those that are in classes.
 

Member Function Documentation

◆ add()

void KUNAI::DEX::Analysis::add ( Parser parser)

Add all the classes and methods from a parser to the analysis class.

Parameters
parserparser to extract the information

◆ find_classes()

std::vector< ClassAnalysis * > KUNAI::DEX::Analysis::find_classes ( std::string &  name,
bool  no_external 
)

Find classes by name with regular expression, the method returns a list of ClassAnalysis object that match the regex.

Parameters
nameregex of name class to find
no_externalwant external classes too?
Returns
vector with all ClassAnalysis objects

◆ find_fields()

std::vector< FieldAnalysis * > KUNAI::DEX::Analysis::find_fields ( std::string &  class_name,
std::string &  field_name,
std::string &  field_type,
std::string &  accessflags 
)

Find FieldAnalysis objects using regular expressions find those that are in classes.

Parameters
class_namename of the class where field is
field_namename of the field
field_typetype of the field
accessflagsaccess flags of the field
Returns
vector with all the fields that match the regex

◆ find_methods()

std::vector< MethodAnalysis * > KUNAI::DEX::Analysis::find_methods ( std::string &  class_name,
std::string &  method_name,
std::string &  descriptor,
std::string &  accessflags,
bool  no_external 
)

Find MethodAnalysis object by name with regular expression. This time is necessary to specify more values for the method.

Parameters
class_namename of the class to retrieve
method_namename of the method to retrieve
descriptordescriptor of this method
accessflags
no_external
Returns

◆ find_strings()

std::vector< StringAnalysis * > KUNAI::DEX::Analysis::find_strings ( std::string &  str)

Find the strings that match a provided regular expression.

Parameters
strregular expression to find as string
Returns
vector of StringAnalysis objects

◆ get_class_analysis()

ClassAnalysis * KUNAI::DEX::Analysis::get_class_analysis ( std::string &  class_name)
inline

Get a ClassAnalysis object by the class name.

Parameters
class_namename of the class to retrieve
Returns
pointer to ClassAnalysis*

◆ get_classes() [1/2]

std::unordered_map< std::string, std::unique_ptr< ClassAnalysis > > & KUNAI::DEX::Analysis::get_classes ( )
inline

Get a reference to the classes.

Returns
reference to map with classes

◆ get_classes() [2/2]

const std::unordered_map< std::string, std::unique_ptr< ClassAnalysis > > & KUNAI::DEX::Analysis::get_classes ( ) const
inline

Get a constant reference to the classes.

Returns
constant reference to map with classes

◆ get_external_classes() [1/2]

std::unordered_map< std::string, std::unique_ptr< ExternalClass > > & KUNAI::DEX::Analysis::get_external_classes ( )
inline

Get a reference to external classes.

Returns
reference to external classes

◆ get_external_classes() [2/2]

const std::unordered_map< std::string, std::unique_ptr< ExternalClass > > & KUNAI::DEX::Analysis::get_external_classes ( ) const
inline

Get a constant reference to external classes.

Returns
constant reference to external classes

◆ get_external_methods() [1/2]

std::unordered_map< std::string, std::unique_ptr< ExternalMethod > > & KUNAI::DEX::Analysis::get_external_methods ( )
inline

Return a reference to the ExternalMethods.

Returns
reference to map with ExternalMethod

◆ get_external_methods() [2/2]

const std::unordered_map< std::string, std::unique_ptr< ExternalMethod > > & KUNAI::DEX::Analysis::get_external_methods ( ) const
inline

Return a constant reference to the ExternalMethods.

Returns
constant reference to map with ExternalMethod

◆ get_field_analysis()

FieldAnalysis * KUNAI::DEX::Analysis::get_field_analysis ( EncodedField field)
inline

Get a field given an encoded field.

Parameters
fieldfield to obtain the FieldAnalysis
Returns
FieldAnalysis object

◆ get_fields()

std::vector< FieldAnalysis * > & KUNAI::DEX::Analysis::get_fields ( )

Get all the fields from all the classes.

Returns
reference to vector with all the fields

◆ get_method()

MethodAnalysis * KUNAI::DEX::Analysis::get_method ( std::variant< EncodedMethod *, ExternalMethod * >  method)
inline

Get a MethodAnalysis pointer given an Encoded or External Method.

Parameters
methodmethod to retrieve
Returns
MethodAnalysis from the given method

◆ get_method_analysis_by_name()

MethodAnalysis * KUNAI::DEX::Analysis::get_method_analysis_by_name ( std::string &  class_name,
std::string &  method_name,
std::string &  method_descriptor 
)
inline

Obtain a method anaylsis by different values.

Parameters
class_nameclass name of the method
method_namename of the method
method_descriptorprototype descriptor of the method
Returns
pointer to MethodAnalysis or nullptr

◆ get_method_id_by_name()

MethodID * KUNAI::DEX::Analysis::get_method_id_by_name ( std::string &  class_name,
std::string &  method_name,
std::string &  method_descriptor 
)
inline

Obtain a MethodID by different values.

Parameters
class_nameclass name of the method
method_namename of the method
method_descriptorprototype descriptor of the method
Returns
pointer to MethodID or nullptr

◆ get_methods() [1/2]

std::unordered_map< std::string, std::unique_ptr< MethodAnalysis > > & KUNAI::DEX::Analysis::get_methods ( )
inline

Return a reference to the method analysis.

Returns
reference to map woth MethodAnalysis

◆ get_methods() [2/2]

const std::unordered_map< std::string, std::unique_ptr< MethodAnalysis > > & KUNAI::DEX::Analysis::get_methods ( ) const
inline

Return a constant reference to the method analysis.

Returns
constant reference to map with MethodAnalysis

◆ get_string_analysis() [1/2]

std::unordered_map< std::string, std::unique_ptr< StringAnalysis > > & KUNAI::DEX::Analysis::get_string_analysis ( )
inline

Get a reference to the StringAnalysis map.

Returns
reference to StringAnalysis map

◆ get_string_analysis() [2/2]

const std::unordered_map< std::string, std::unique_ptr< StringAnalysis > > & KUNAI::DEX::Analysis::get_string_analysis ( ) const
inline

Get a constant reference to the StringAnalysis objects.

Returns
constant reference to StringAnalysis map

The documentation for this class was generated from the following file: