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
Owner
Open Source Security, Inc.
Open Source Security, Inc.
ORector - A Fast Python tool designed to detect open redirects vulnerabilities on websites

ORector is a Fast Python tool designed to detect open redirects vulnerabilities

11 Apr 02, 2022
Cookiecutter for creating open source Python packages

Cookiecutter for rapidly developing new open source Python packages. Best practices with all the modern bells and whistles included.

Wolt 177 Dec 22, 2022
Lnkbomb - Malicious shortcut generator for collecting NTLM hashes from insecure file shares

Lnkbomb Lnkbomb is used for uploading malicious shortcut files to insecure file

Joe Helle 216 Jan 08, 2023
IDA2Obj is a tool to implement SBI (Static Binary Instrumentation).

IDA2Obj IDA2Obj is a tool to implement SBI (Static Binary Instrumentation). The working flow is simple: Dump object files (COFF) directly from one exe

Mickey 94 Dec 13, 2022
👑 Discovery Header DoD Bug-Bounty

👑 Discovery Header DoD Bug-Bounty Did you know that DoD accepts server headers? 😲 (example: apache"version" , php"version") ? In this code it is pos

KingOfTips 38 Aug 09, 2022
Exploiting CVE-2021-44228 in vCenter for remote code execution and more

Log4jCenter Exploiting CVE-2021-44228 in vCenter for remote code execution and more. Blog post detailing exploitation linked below: COMING SOON Why? P

81 Dec 20, 2022
AutoScan 有多个目标时,调用xray+rad进行自动扫描

Usage: 在高级版Xray和rad同目录下运行 python3 X-AutoXray.py xxxx.txt 写的蛮人性化的哦,os,linux,windows通用 生成的xray报告会在当前目录的/result下面 Ctrl+c 打断脚本运行时还可以结算扫描进度,生成已扫描和未扫描的进度文件,

斯文 73 Jan 01, 2023
DomainMonitor is a web project that has a RESTful API to get a domain's subdomains and whois data.

DomainMonitor is a web project that has a RESTful API to get a domain's subdomains and whois data.

2 Feb 05, 2022
Having a weak password is not good for a system that demands high confidentiality and security of user credentials

Having a weak password is not good for a system that demands high confidentiality and security of user credentials. It turns out that people find it difficult to make up a strong password that is str

PyLaboratory 0 Feb 07, 2022
Simple yara rule manager

Yara Manager A simple program to manage your yara ruleset in a (sqlite) database. Todos Search rules and descriptions Cluster rules in rulesets Enforc

Nils Kuhnert 65 Nov 17, 2022
A tool for making python source difficult to read.

obscurepy Description A tool for obscuring, or making python source code difficult to read. Table of Contents Installation Limitations Usage Disclaime

Andrew Christiansen 10 Jul 31, 2022
CVE-2021-22005 - VMWare vCenter Server File Upload to RCE

CVE-2021-22005 - VMWare vCenter Server File Upload to RCE Analyze Usage ------------------------------------------------------------- [*] CVE-2021-220

r0cky 224 Aug 05, 2022
xray多线程批量扫描工具

Auto_xray xray多线程批量扫描工具 简介 xray社区版貌似没有批量扫描,这就让安服仔使用起来很不方便,扫站得一个个手动添加,非常难受 Auto_xray目录下记得放xray,就跟平时一样的。 选项1:oneforall+xray 输入一个主域名,自动采集子域名然后添加到xray任务列表

1frame 13 Nov 09, 2022
CVE-2022-22963 PoC

CVE-2022-22963 CVE-2022-22963 PoC Slight modified for English translation and detection of https://github.com/chaosec2021/Spring-cloud-function-SpEL-R

Nicolas Krassas 104 Dec 08, 2022
😭 WSOB is a python tool created to exploit the new vulnerability on WSO2 assigned as CVE-2022-29464.

😭 WSOB (CVE-2022-29464) 😭 WSOB is a python tool created to exploit the new vulnerability on WSO2 assigned as CVE-2022-29464. CVE-2022-29464 details:

0p 25 Oct 14, 2022
MTBLLS Ethical Hacking Tool Announcement of v2.0

MTBLLS Ethical Hacking Tool Announcement of v2.0 MTBLLS is a Free and Open-Source Ethical Hacking Tool developed by GhostTD (SkyWtkh) The tool can onl

Ghost 2 Mar 19, 2022
Threat Intel Platform for T-POTs

GreedyBear The project goal is to extract data of the attacks detected by a TPOT or a cluster of them and to generate some feeds that can be used to p

The Honeynet Project 72 Jan 01, 2023
Get important strings inside [Info.plist] & and Binary file also all output of result it will be saved in [app_binary].json , [app_plist_file].json file

Get important strings inside [Info.plist] & and Binary file also all output of result it will be saved in [app_binary].json , [app_plist_file].json file

12 Sep 28, 2022
Scans for Log4j versions effected by CVE-2021-44228

check_mkExtension to check for log4j2 CVE-2021-44228 This Plugin wraps around logpresso/CVE-2021-44228-Scanner (Apache License 2.0) How it works Run i

inett GmbH 4 Jun 30, 2022
vulnerable APIs

vulnerable-apis vulnerable APIs inspired by https://github.com/mattvaldes/vulnerable-api Setup Docker If, Out of the box docker pull kmmanoj/vulnerabl

9 Jun 01, 2022