When we select open with Options in Binary Ninja - netajinet/Reverse-Engineering-using-Binary-Ninja GitHub Wiki

Key Options in "Open with Options" for .bin files:

Architecture:

Purpose: This is arguably the most critical setting. Binary Ninja needs to know what CPU architecture the code is compiled for (e.g., x86, x64, ARM, MIPS, PowerPC, etc.). Without the correct architecture, the disassembly will be gibberish, and no meaningful analysis can occur. How to Choose: Know your target: If you're analyzing firmware, you often know the microcontroller or CPU it runs on. Educated Guess/Trial and Error: If you don't know, look for clues: String data: Readable strings can sometimes hint at the platform (e.g., "Windows", "Linux", "ARM"). Common instruction patterns: If you have some familiarity with different assembly languages, try loading it with a few common architectures and see if any patterns emerge (e.g., common prologue/epilogue sequences for functions). External resources: Datasheets, project documentation, or even a quick search for the device model might reveal the architecture. Endianness: Some architectures (like ARM) can operate in both little-endian and big-endian modes. Binary Ninja will often have architecture options like "ARMV7 (Little Endian)" or "ARMV7 (Big Endian)". Make sure to select the correct one. Base Address (Load Address / Virtual Address):

Purpose: Raw binaries, especially firmware, often don't have a defined load address within the file itself. Binary Ninja needs to know where in memory this binary is expected to be loaded and executed. This is vital for correct address calculations, cross-references, and function identification. How to Choose: Datasheets/Memory Maps: For firmware, the microcontroller's datasheet or memory map is your best friend. It will specify where flash memory, RAM, and memory-mapped peripherals are located. The code usually resides in flash. Vector Table/Reset Vector: Embedded systems often start execution at a specific "reset vector" address. This address might be listed in the device's documentation, and if you find the corresponding code in your binary, that's a strong candidate for the base address. Pointers/Addresses: Look for absolute addresses within the binary itself. If you see a lot of addresses pointing to a specific range (e.g., 0x8000000), that range might be the base address. Binary Ninja's "BASE" feature: Recent versions of Binary Ninja (as seen in the search results) have a "Base Address Scan Engine" (BASE) that can automatically suggest candidate base addresses by analyzing pointers and points-of-interest within the binary. This is a very powerful feature for raw binaries. You might see a "Triage View" that presents these candidates. Trial and Error: If all else fails, you might try a common embedded base address like 0x0, 0x8000000, 0x10000000, or 0x08000000. Default Binary View:

Purpose: This determines how Binary Ninja initially processes and displays the file. Common Options: "Executable" or "Default": For most standard executables (PE, ELF, Mach-O), this is the default and uses the file's header information. For .bin files, you often won't have a header. "Raw Binary": This is typically what you'll use for .bin files. It tells Binary Ninja to treat the file as a raw block of bytes and rely on your manual configuration (architecture, base address). "Firmware Ninja" (if installed): If you have the Firmware Ninja plugin, this might appear as an option and can provide specialized handling for firmware. Analysis Mode:

Purpose: Controls the depth and aggressiveness of Binary Ninja's automated analysis. Options: "Full": (Recommended for most cases) Performs the most extensive analysis, including type propagation, data flow, value set analysis, and jump table resolution. This is generally what you want for in-depth reverse engineering. "Intermediate": A less aggressive analysis. Can be useful if "Full" analysis gets stuck on very complex or obfuscated code, or if you just want a quicker initial pass. "Control Flow": Focuses primarily on identifying basic blocks and function boundaries. "Disassembly Only": Performs minimal analysis, essentially just disassembling the bytes. Useful for extremely malformed binaries or quick looks. Considerations: For highly obfuscated or packed binaries, you might start with "Intermediate" or "Control Flow" if "Full" struggles, then iteratively refine the analysis once you've handled unpacking/deobfuscation. Initial Analysis Hold (checkbox):

Purpose: If checked, Binary Ninja will load the file but pause its automatic analysis. This allows you to define sections, segments, or other critical information before the full analysis runs, which can be crucial for raw binaries. When to use: This is highly recommended for .bin files where you need to manually define segments (code, data, BSS, memory-mapped I/O regions) and apply correct memory permissions. Once you've set up these initial structures, you can manually trigger analysis. Workflow for .bin files using "Open with Options": Select "File" -> "Open with Options..." Browse and Select your .bin file. In the "Open with Options" dialog: Choose the correct Architecture: This is paramount. Set the Base Address: Based on your knowledge of the target, documentation, or by letting Binary Ninja's BASE feature suggest candidates (if it prompts you after initial load). Select Raw Binary as the Binary View Type. Consider checking Initial Analysis Hold: This gives you control before full analysis runs. Set Analysis Mode to Full (unless you have a reason to start with less). Click "Open". Post-Load Steps (Especially if using "Initial Analysis Hold"): After loading, especially a raw binary with "Initial Analysis Hold" enabled:

Define Segments/Sections: Go to View -> Segments (or View -> Sections). Use the "Add Segment" or "Add Section" options (often a right-click or a menu option). Define regions for code, data, stack, and any memory-mapped I/O (if applicable for firmware). Crucially, set the correct permissions (Read, Write, Execute). Mark code segments as executable. Define Entry Point(s): Navigate to the known entry point address. Press P to define a function at that address. Run Analysis: If you had "Initial Analysis Hold" enabled, go to Analysis -> Reanalyze or click the "Play" button in the analysis progress bar to start the full analysis. Iterative Refinement: Binary Ninja will start identifying functions, data, and cross-references. Manually refine analysis by: Renaming functions (N) Defining structures and types (Y) Adding comments (;) Undefining incorrect code (U) and redefining as data (D, then choose size) Manually defining functions (P) where auto-analysis missed them.

### Configure these options, especially the architecture and base address, you provide Binary Ninja with the necessary context to perform accurate and effective reverse engineering on raw .bin files.