IDA Pro Python plugin to analyze and annotate Linux kernel alternatives

Overview

About

This is an IDA Pro (Interactive Disassembler) plugin allowing to automatically analyze and annotate Linux kernel alternatives (content of .altinstructions and .altinstr_replacement sections).

Requirements

This is an IDAPython-based plugin supporting IDA Pro 7.x with Python 3.

Currently only x86/x86_64 architecture is supported.

Installation

System-wide installation:

Copy linux_alternatives.py file into your IDADIR/plugins directory:

OS Typical global plugins directory path
Windows %ProgramFiles%\IDA Pro 7.x\plugins
macOS /Applications/IDA Pro 7.x/idabin/plugins
Linux /opt/idapro-7.x/plugins

Where x should be the actual version number installed.

User installation:

Copy linux_alternatives.py file into your local user IDA plugins directory:

OS Typical user plugins directory path
Windows %AppData%\Hex-Rays\IDA Pro\plugins
Linux/macOS ~/.idapro/plugins

Usage

To use the plugin click Linux Alternatives entry from the Edit / Plugins menu bar. Alternatively, invoke the plugin with a shortcut Alt + F9.

The plugin also registers three additional options (available from Edit / Linux Alternatives menu bar):

  • Import cpufeatures.h file - This option opens up a file chooser allowing to specify a cpufeatures.h file corresponding to the kernel being analyzed.

  • Remove alternative comments - This option closes the Alternatives window and removes all annotations from the database. Note: This option appears only after the annotations are applied.

  • Patch selected alternatives - This option allows to specify a comma-separated list of CPU feature flags and patch into binary corresponding alternatives. Note: after providing the list of feature flags, the corresponding alternatives are automatically patched in. No need to re-run the plugin.

What does it do?

The plugin performs the following steps upon invocation:

1. Obtain the memory layout of struct alt_instr:

  • If DWARF-based definition of the structure is available, it is used directly.
  • Otherwise, the plugin heuristically determines:
    • type (and size) of the first two structure members (address or relative offset of instruction and replacement).
    • size of the structure
    • offset of the length field members

      struct alt_instr

2. Obtain available CPUFEATURE and X86_BUGS flag names

  • Analyze string references in: x86_cap_flags and x86_bug_flags array symbols.
  • If cpufeatures.h file has been loaded, the plugin parses it and uses CPUFEATURE and X86_BUGS flags from it.

3. Analyze and annotate content of .altinstructions and .altinstr_replacement sections

.altinstructions .altinstr_replacement
.altinstructions .altinstr_replacement

4. Apply alternatives comments in the disassembly for all alternative entries found

without opcodes with opcodes
alternative comment alternative comment with opcodes

5. Open a new window with a tabular listing of the alternatives

  • columns are sortable and addresses clickable

    alternatives window

Patching alternatives

Main purpose of this feature is to simulate presence of specified CPU feature flags and update binary with their corresponding alternatives for static analysis purposes. This feature might be helpful for inspecting alternative entries for correctness and security, without the need to run the Linux kernel binary.

Upon clicking the Patch selected alternatives option in Edit / Linux Alternatives menu bar, the following prompt is displayed:

patching prompt

User can specify comma-separated list of feature flags either by their name (case insensitive) or by their integer value as calculated in typical cpufeatures.h file:

patching prompt

Clicking OK will automatically patch and re-analyze the entire database with alternatives selected with the feature flags:

Before After
before after
You might also like...
IDA scripts for hypervisor (Hyper-v) analysis and reverse engineering automation
IDA scripts for hypervisor (Hyper-v) analysis and reverse engineering automation

Re-Scripts IA32-VMX-Helper (IDA-Script) IA32-MSR-Decoder (IDA-Script) IA32 VMX Helper It's an IDA script (Updated IA32 MSR Decoder) which helps you to

Local server for IDA Lumina feature

About POC of an offline server for IDA Lumina feature.

Tools for converting Nintendo DS binaries to an ELF file for Ghidra/IDA

nds2elf Requirements nds2elf.py uses LIEF and template.elf to form a new binary. LIEF is available via pip: pip3 install lief Usage DSi and DSi-enhan

User-friendly reference finder in IDA
User-friendly reference finder in IDA

IDARefHunter Updated: This project's been introduced on IDA Plugin Contest 2021! Why do we need RefHunter? Getting reference information in one specif

Better-rtti-parser - IDA script to parse RTTI information in executable
Better-rtti-parser - IDA script to parse RTTI information in executable

RTTI parser Parses RTTI information from executable. Example HexRays decompiler view Before: After: Functions window Before: After: Structs window Ins

The Linux defender anti-virus software ported to work on CentOS Linux.

By: Seanpm2001, Et; Al. Top README.md Read this article in a different language Sorted by: A-Z Sorting options unavailable ( af Afrikaans Afrikaans |

Directory Traversal in Afterlogic webmail aurora and pro

CVE-2021-26294 Exploit Directory Traversal in Afterlogic webmail aurora and pro . Description: AfterLogic Aurora and WebMail Pro products with 7.7.9 a

BuddyPress is an open source WordPress plugin to build a community site. In releases of BuddyPress from 5.0.0 before 7.2.1 it's possible for a non-privileged, regular user to obtain administrator rights by exploiting an issue in the REST API members endpoint. The vulnerability has been fixed in BuddyPress 7.2.1. Existing installations of the plugin should be updated to this version to mitigate the issue.
A Burp Pro extension that adds log4shell checks to Burp Scanner

scan4log4shell A Burp Pro extension that adds log4shell checks to Burp Scanner, written by Daniel Crowley of IBM X-Force Red. Installation To install

Owner
Open Source Security, Inc.
Open Source Security, Inc.
Driver Buddy Reloaded is an IDA Pro Python plugin that helps automate some tedious Windows Kernel Drivers reverse engineering tasks.

Driver Buddy Reloaded Quickstart Table of Contents Installation Usage About Driver Buddy Reloaded Finding DispatchDeviceControl Labelling WDM & WDF St

Paolo 'VoidSec' Stagno 199 Jan 4, 2023
A small POC plugin for launching dumpulator emulation within IDA, passing it addresses from your IDA view using the context menu.

Dumpulator-IDA Currently proof-of-concept This project is a small POC plugin for launching dumpulator emulation within IDA, passing it addresses from

Michael 9 Sep 21, 2022
HashDB API hash lookup plugin for IDA Pro

HashDB IDA Plugin Malware string hash lookup plugin for IDA Pro. This plugin connects to the OALABS HashDB Lookup Service. Adding New Hash Algorithms

OALabs 237 Dec 21, 2022
An IDA pro python script to decrypt Qbot malware string

Qbot-Strings-Decrypter An IDA pro python script to decrypt Qbot malware strings.

stuckinvim 6 Sep 1, 2022
IDAPatternSearch adds a capability of finding functions according to bit-patterns into the well-known IDA Pro disassembler based on Ghidra’s function patterns format.

IDA Pattern Search by Argus Cyber Security Ltd. The IDA Pattern Search plugin adds a capability of finding functions according to bit-patterns into th

David Lazar 48 Dec 29, 2022
Patching - Interactive Binary Patching for IDA Pro

Patching - Interactive Binary Patching for IDA Pro Overview Patching assembly code to change the behavior of an existing program is not uncommon in ma

null 589 Dec 30, 2022
IDA plugin for quickly copying disassembly as encoded hex bytes

HexCopy IDA plugin for quickly copying disassembly as encoded hex bytes. This whole plugin just saves you two extra clicks... but if you are frequentl

OALabs 46 Oct 30, 2022
IDA Frida Plugin for tracing something interesting.

IDAFrida A simple IDA plugin to generate FRIDA script. Edit template for functions or you can use the default template. Select functions you want to t

PandaOS 133 Dec 24, 2022
IDA Python Script for anti ollvm

IDA Python Script for anti ollvm

Shocker 62 Dec 23, 2022
IDA loader for Apple's iBoot, SecureROM and AVPBooter

IDA iBoot Loader IDA loader for Apple's iBoot, SecureROM and AVPBooter Installation Copy iboot-loader.py to the loaders folder in IDA directory. Credi

matteyeux 74 Dec 23, 2022