| 25 | } |
| 26 | |
| 27 | int main(int argc, char* argv[]) |
| 28 | { |
| 29 | if (argc != 2) |
| 30 | { |
| 31 | cerr << "USAGE: " << argv[0] << " <file_name>" << endl; |
| 32 | exit(-1); |
| 33 | } |
| 34 | |
| 35 | char* fname = argv[1]; |
| 36 | if (!is_file(fname)) |
| 37 | { |
| 38 | cerr << "Error: " << fname << " is not a regular file" << endl; |
| 39 | exit(-1); |
| 40 | } |
| 41 | |
| 42 | /* In order to initiate the bundled plugins properly, the location |
| 43 | * of where bundled plugins directory is must be set. */ |
| 44 | SetBundledPluginDirectory(GetBundledPluginDirectory()); |
| 45 | InitPlugins(); |
| 46 | |
| 47 | Ref<BinaryView> bv = BinaryNinja::Load(fname); |
| 48 | if (!bv || bv->GetTypeName() == "Raw") |
| 49 | { |
| 50 | fprintf(stderr, "Input file does not appear to be an executable\n"); |
| 51 | return -1; |
| 52 | } |
| 53 | |
| 54 | cout << "Target: " << fname << endl << endl; |
| 55 | cout << "TYPE: " << bv->GetTypeName() << endl; |
| 56 | cout << "START: 0x" << hex << bv->GetStart() << endl; |
| 57 | cout << "ENTRY: 0x" << hex << bv->GetEntryPoint() << endl; |
| 58 | cout << "PLATFORM: " << bv->GetDefaultPlatform()->GetName() << endl; |
| 59 | cout << endl; |
| 60 | |
| 61 | cout << "------ALL ENTRY FUNCTIONS---------" << endl; |
| 62 | for (auto func : bv->GetAllEntryFunctions()) |
| 63 | { |
| 64 | cout << hex << func->GetStart() << " " << func->GetSymbol()->GetFullName() << endl; |
| 65 | } |
| 66 | cout << endl; |
| 67 | |
| 68 | cout << "---------- 10 Functions ----------" << endl; |
| 69 | int x = 0; |
| 70 | for (auto func : bv->GetAnalysisFunctionList()) |
| 71 | { |
| 72 | cout << hex << func->GetStart() << " " << func->GetSymbol()->GetFullName() << endl; |
| 73 | if (++x >= 10) |
| 74 | break; |
| 75 | } |
| 76 | cout << endl; |
| 77 | |
| 78 | cout << "---------- 10 Strings ----------" << endl; |
| 79 | x = 0; |
| 80 | for (auto str_ref : bv->GetStrings()) |
| 81 | { |
| 82 | char* str = (char*)malloc(str_ref.length + 1); |
| 83 | bv->Read(str, str_ref.start, str_ref.length); |
| 84 | str[str_ref.length] = 0; |
nothing calls this directly
no test coverage detected