KUNAI Static Analyzer
Kunai is a library for doing static binary analysis of Dalvik.
Loading...
Searching...
No Matches
dex.hpp
1//--------------------------------------------------------------------*- C++ -*-
2// Kunai-static-analyzer: library for doing analysis of dalvik files
3// @author Farenain <kunai.static.analysis@gmail.com>
4// @author Ernesto Java <javaernesto@gmail.com>
5//
6// @file dex.hpp
7// @brief Managing of DEX files, the DEX files are managed by a generic class
8// this will check the DEX file is correct, will parse and optionally will
9// analyze the DEX.
10#ifndef KUNAI_DEX_DEX_HPP
11#define KUNAI_DEX_DEX_HPP
12
14#include "Kunai/Utils/logger.hpp"
15#include "Kunai/Utils/kunaistream.hpp"
16#include "Kunai/DEX/parser/parser.hpp"
17#include "Kunai/DEX/DVM/dex_disassembler.hpp"
18#include "Kunai/DEX/analysis/dex_analysis.hpp"
19
20#include <memory>
21
22namespace KUNAI
23{
24namespace DEX
25{
28 class Dex
29 {
30 public:
34 static std::unique_ptr<Dex> parse_dex_file(std::string& dex_file_path);
35
36 static std::unique_ptr<Dex> parse_dex_file(char * dex_file_path);
37
38 static std::unique_ptr<Dex> parse_dex_file(const char * dex_file_path);
39
40 private:
42 std::unique_ptr<stream::KunaiStream> kunai_stream;
44 std::ifstream dex_file;
45
47 std::unique_ptr<Parser> parser;
48
50 std::unique_ptr<DexDisassembler> dex_disassembler;
51
53 std::unique_ptr<Analysis> analysis;
54
56 bool parsing_correct = false;
57
61 void initialization(std::string& dex_file_path);
62
63 public:
64
68 Dex(std::string& dex_file_path)
69 {
70 initialization(dex_file_path);
71 }
72
76 {
77 if (dex_file.is_open())
78 dex_file.close();
79 }
80
84 {
85 return parsing_correct;
86 }
87
91 {
92 return parser.get();
93 }
94
98 {
99 return dex_disassembler.get();
100 }
101
109 Analysis * get_analysis(bool create_xrefs);
110 };
111
112} // namespace DEX
113} // namespace KUNAI
114
115
116#endif // KUNAI_DEX_DEX_HPP
Definition dex_analysis.hpp:21
Disassembler for DEX data.
Definition dex_disassembler.hpp:27
Abstraction of a DEX object, the class offers the analyst a parser, a disassembler and an analysis ob...
Definition dex.hpp:29
Analysis * get_analysis(bool create_xrefs)
Get the analysis object this needs the disassembly and the parser, the dex will be disassembled in ca...
Dex(std::string &dex_file_path)
Constructor of the Dex object, we obtain a path to the DEX file to analyze.
Definition dex.hpp:68
bool get_parsing_correct() const
Was parsing process correct?
Definition dex.hpp:83
static std::unique_ptr< Dex > parse_dex_file(std::string &dex_file_path)
Parse a given dex file, return a Dex object as a unique pointer.
Parser * get_parser()
get a pointer to the DEX parser with all the headers
Definition dex.hpp:90
DexDisassembler * get_dex_disassembler()
Get the disassembler of the DEX file.
Definition dex.hpp:97
~Dex()
Destructor of the Dex object, release any memory or files here in case it is needed.
Definition dex.hpp:75
Definition parser.hpp:29
utilities
Definition analysis.hpp:23