IDA c++分析辅助插件ida_medigate使用记录

news2024/11/15 12:26:17

1.下载插件

IDA_medigate

2.将medigate_cpp_plugin.py放到 ida的plugin文件夹中 plugins/ida-referee/referee.py 放置到plugin中

3.将下载的 ida_medigate 放到IDA 内置的python38的Lib\site-packages\目录下

如:D:\IDA_Pro_7.7\python38\Lib\site-packages

4.配置插件搜索路径

在 IDA中输入

import idaapi
idaapi.get_user_idadir() 

得到路径
‘C:\Users\XXX\AppData\Roaming\Hex-Rays\IDA Pro’

在路径下新建一个 idapythonrc.py

添加代码

import ida_idaapi
idaapi.require(‘ida_medigate’)

5.报错

D:\IDA_Pro_7.7\plugins\medigate_cpp_plugin.py: [Errno 2] No such file or directory: 'D:\\tmp\\cpp_plugin.log'
Traceback (most recent call last):
  File "D:\IDA_Pro_7.7\python\3\ida_idaapi.py", line 580, in IDAPython_ExecScript
    exec(code, g)
  File "D:/IDA_Pro_7.7/plugins/medigate_cpp_plugin.py", line 2, in <module>
    from ida_medigate.cpp_plugin.plugin import CPPPlugin
  File "D:\IDA_Pro_7.7\python38\lib\site-packages\ida_medigate\cpp_plugin\plugin.py", line 4, in <module>
    from .hooks import CPPHooks, CPPUIHooks, HexRaysHooks
  File "D:\IDA_Pro_7.7\python38\lib\site-packages\ida_medigate\cpp_plugin\hooks.py", line 16, in <module>
    logging.basicConfig(
  File "logging\__init__.py", line 1988, in basicConfig
  File "logging\__init__.py", line 1147, in __init__
  File "logging\__init__.py", line 1176, in _open
FileNotFoundError: [Errno 2] No such file or directory: 'D:\\tmp\\cpp_plugin.log'

新建 D:\tmp\cpp_plugin.log

6.使用

作者提供的demo


using namespace std;

class A {
	public:
	int x_a;
	virtual int f_a()=0;
};

class B : public A{ 
	public:
	int x_b;
	int f_a(){x_a = 0;}
	virtual int f_b(){this->f_a();}
};

class Z {
	public:
	virtual int f_z1(){cout << "f_z1";}
	virtual int f_z2(){cout << "f_z2";}
};

class C: public B, public Z{
	public:
    int f_a(){x_a = 5;}
	int x_c;
	int f_c(){x_c = 0;}
	virtual int f_z1(){cout << "f_z3";}
};


int main()
{
	C *c = new C();
    c->f_a();
    c->f_b();
    c->f_z1();
    c->f_z2();
    
	return 0;
}

7.自动构建类层次

IDA 命令窗口输入

from ida_medigate.rtti_parser import GccRTTIParser

GccRTTIParser.init_parser()

GccRTTIParser.build_all()

查看 D:\tmp\cpp_plugin.log 查看日志信息

2023-07-03 15:23:00,589 - DEBUG - Starting :12344 0x3038
2023-07-03 15:23:00,590 - INFO - C: Parsed typeinfo
2023-07-03 15:23:00,590 - INFO - B: Parsed typeinfo
2023-07-03 15:23:00,590 - INFO - A: Parsed typeinfo
2023-07-03 15:23:00,590 - DEBUG - A: Finish setup parents
2023-07-03 15:23:00,590 - DEBUG - create_vtable_struct(A, 0)
2023-07-03 15:23:00,590 - DEBUG - Couldn't found parent vtable A 0
2023-07-03 15:23:00,591 - ERROR - Couldn't decompile 0x3034
Traceback (most recent call last):
  File "D:\IDA_Pro_7.7\python38\lib\site-packages\ida_medigate\cpp_utils.py", line 293, in update_func_this
    func_details = utils.get_func_details(func_ea)
  File "D:\IDA_Pro_7.7\python38\lib\site-packages\ida_medigate\utils.py", line 101, in get_func_details
    xfunc = ida_hexrays.decompile(func_ea)
  File "D:\IDA_Pro_7.7\python\3\ida_hexrays.py", line 25850, in decompile
    raise DecompilationFailure(hf)
ida_hexrays.DecompilationFailure: Decompilation failed: 3034: special segments cannot be decompiled
2023-07-03 15:23:00,596 - DEBUG - B: Finish setup parents
2023-07-03 15:23:00,597 - DEBUG - Is struct!
2023-07-03 15:23:00,597 - DEBUG - Is struct: A/4278190317
2023-07-03 15:23:00,597 - DEBUG - create_vtable_struct(B, 0)
2023-07-03 15:23:00,597 - DEBUG - Found parent vtable B 0
2023-07-03 15:23:00,597 - DEBUG - add_child_vtable (A, B, 4278190323)
2023-07-03 15:23:00,598 - DEBUG - pointed_struct: <ida_struct.struc_t; proxy of <Swig Object of type 'struc_t *' at 0x0000012F07938450> >
2023-07-03 15:23:00,598 - DEBUG - A vtable isn't union -> unionize it!
2023-07-03 15:23:00,598 - DEBUG - install_vtables_union(A, <ida_struct.member_t; proxy of <Swig Object of type 'member_t *' at 0x0000012F07938210> >, A_vtbl *)
2023-07-03 15:23:00,598 - DEBUG - Is struct!
2023-07-03 15:23:00,598 - DEBUG - Is struct: A_vtbl_orig/4278190318
2023-07-03 15:23:00,599 - DEBUG - add_to_struct 4278190324 B_vtbl
2023-07-03 15:23:00,599 - DEBUG - Is struct!
2023-07-03 15:23:00,599 - DEBUG - Is struct: B_vtbl/4278190323
2023-07-03 15:23:00,602 - DEBUG - analyzing function at 0x98E
2023-07-03 15:23:00,602 - DEBUG - Cleared 0 xrefs
2023-07-03 15:23:00,603 - DEBUG - Overwriting!
2023-07-03 15:23:00,607 - DEBUG - analyzing function at 0x9A8
2023-07-03 15:23:00,607 - DEBUG - Cleared 0 xrefs
2023-07-03 15:23:00,609 - INFO - Z: Parsed typeinfo
2023-07-03 15:23:00,609 - DEBUG - Z: Finish setup parents
2023-07-03 15:23:00,609 - DEBUG - create_vtable_struct(Z, 0)
2023-07-03 15:23:00,609 - DEBUG - Couldn't found parent vtable Z 0
2023-07-03 15:23:00,618 - DEBUG - analyzing function at 0x9CE
2023-07-03 15:23:00,618 - DEBUG - Cleared 0 xrefs
2023-07-03 15:23:00,623 - DEBUG - analyzing function at 0xA00
2023-07-03 15:23:00,623 - DEBUG - Cleared 0 xrefs
2023-07-03 15:23:00,624 - DEBUG - C: Finish setup parents
2023-07-03 15:23:00,624 - DEBUG - Is struct!
2023-07-03 15:23:00,624 - DEBUG - Is struct: B/4278190321
2023-07-03 15:23:00,625 - DEBUG - Expanding struc B 0x4 -> 0xc
2023-07-03 15:23:00,625 - DEBUG - Delete member (0x4dfe0000-0x4dfe000b)
2023-07-03 15:23:00,625 - DEBUG - Now fix args:
2023-07-03 15:23:00,625 - DEBUG - [4278190334, 'baseclass_0', 0, 1610613760, 4278190321, 12] = -2
2023-07-03 15:23:00,625 - DEBUG - Is struct!
2023-07-03 15:23:00,626 - DEBUG - Is struct: Z/4278190329
2023-07-03 15:23:00,626 - DEBUG - create_vtable_struct(C, 0)
2023-07-03 15:23:00,626 - DEBUG - Found parent vtable C 0
2023-07-03 15:23:00,626 - DEBUG - add_child_vtable (B, C, 4278190338)
2023-07-03 15:23:00,626 - DEBUG - pointed_struct: <ida_struct.struc_t; proxy of <Swig Object of type 'struc_t *' at 0x0000012F07938030> >
2023-07-03 15:23:00,626 - DEBUG - Not a struct vtable: A
2023-07-03 15:23:00,626 - DEBUG - B vtable isn't union -> unionize it!
2023-07-03 15:23:00,627 - DEBUG - install_vtables_union(B, None, A)
2023-07-03 15:23:00,627 - DEBUG - Is struct!
2023-07-03 15:23:00,627 - DEBUG - Is struct: B_vtbl_orig/4278190323
2023-07-03 15:23:00,627 - DEBUG - add_to_struct 4278190339 C_vtbl
2023-07-03 15:23:00,627 - DEBUG - Is struct!
2023-07-03 15:23:00,627 - DEBUG - Is struct: C_vtbl/4278190338
2023-07-03 15:23:00,628 - DEBUG - add_child_vtable (A, C, 4278190338)
2023-07-03 15:23:00,628 - DEBUG - pointed_struct: <ida_struct.struc_t; proxy of <Swig Object of type 'struc_t *' at 0x0000012F07938330> >
2023-07-03 15:23:00,628 - DEBUG - add_to_struct 4278190324 C_vtbl
2023-07-03 15:23:00,628 - DEBUG - Is struct!
2023-07-03 15:23:00,628 - DEBUG - Is struct: C_vtbl/4278190338
2023-07-03 15:23:00,631 - DEBUG - analyzing function at 0xA32
2023-07-03 15:23:00,631 - DEBUG - Cleared 0 xrefs
2023-07-03 15:23:00,632 - DEBUG - Overwriting!
2023-07-03 15:23:00,635 - DEBUG - analyzing function at 0x9A8
2023-07-03 15:23:00,635 - DEBUG - Loaded 0 xrefs
2023-07-03 15:23:00,635 - DEBUG - Cleared 0 xrefs
2023-07-03 15:23:00,635 - DEBUG -  0x9BD 	struct B_vtbl_orig 	dr_R | XREF_USER
2023-07-03 15:23:00,635 - DEBUG -  0x9BD 	member B_vtbl_orig.B__sub_98E 	dr_R | XREF_USER
2023-07-03 15:23:00,635 - DEBUG -  0x9BD 	struct B_vtbl 	dr_R | XREF_USER
2023-07-03 15:23:00,636 - DEBUG -  0x9BD 	member B_vtbl.B 	dr_R | XREF_USER
2023-07-03 15:23:00,636 - DEBUG -  0x9BD 	struct B 	dr_R | XREF_USER
2023-07-03 15:23:00,636 - DEBUG -  0x9BD 	member B.baseclass_0 	dr_R | XREF_USER
2023-07-03 15:23:00,639 - DEBUG - analyzing function at 0x9A8
2023-07-03 15:23:00,639 - DEBUG - Loaded 6 xrefs
2023-07-03 15:23:00,639 - DEBUG - Cleared 6 xrefs
2023-07-03 15:23:00,639 - DEBUG -  0x9BD 	struct B_vtbl_orig 	dr_R | XREF_USER
2023-07-03 15:23:00,639 - DEBUG -  0x9BD 	member B_vtbl_orig.B__sub_98E 	dr_R | XREF_USER
2023-07-03 15:23:00,640 - DEBUG -  0x9BD 	struct B_vtbl 	dr_R | XREF_USER
2023-07-03 15:23:00,640 - DEBUG -  0x9BD 	member B_vtbl.B 	dr_R | XREF_USER
2023-07-03 15:23:00,640 - DEBUG -  0x9BD 	struct B 	dr_R | XREF_USER
2023-07-03 15:23:00,640 - DEBUG -  0x9BD 	member B.baseclass_0 	dr_R | XREF_USER
2023-07-03 15:23:00,644 - DEBUG - analyzing function at 0xA4C
2023-07-03 15:23:00,645 - DEBUG - Cleared 0 xrefs
2023-07-03 15:23:00,646 - DEBUG - create_vtable_struct(C, 12)
2023-07-03 15:23:00,646 - DEBUG - Found parent vtable C 12
2023-07-03 15:23:00,647 - DEBUG - add_child_vtable (Z, C, 4278190346)
2023-07-03 15:23:00,647 - DEBUG - pointed_struct: <ida_struct.struc_t; proxy of <Swig Object of type 'struc_t *' at 0x0000012F07938030> >
2023-07-03 15:23:00,647 - DEBUG - Z vtable isn't union -> unionize it!
2023-07-03 15:23:00,647 - DEBUG - install_vtables_union(Z, <ida_struct.member_t; proxy of <Swig Object of type 'member_t *' at 0x0000012F07938060> >, Z_vtbl *)
2023-07-03 15:23:00,647 - DEBUG - Is struct!
2023-07-03 15:23:00,647 - DEBUG - Is struct: Z_vtbl_orig/4278190330
2023-07-03 15:23:00,648 - DEBUG - add_to_struct 4278190347 C_000C_vtbl
2023-07-03 15:23:00,648 - DEBUG - Is struct!
2023-07-03 15:23:00,648 - DEBUG - Is struct: C_000C_vtbl/4278190346
2023-07-03 15:23:00,650 - DEBUG - analyzing function at 0xA7E
2023-07-03 15:23:00,650 - DEBUG - Cleared 0 xrefs
2023-07-03 15:23:00,651 - DEBUG - Overwriting!
2023-07-03 15:23:00,654 - DEBUG - analyzing function at 0xA00
2023-07-03 15:23:00,654 - DEBUG - Loaded 0 xrefs
2023-07-03 15:23:00,654 - DEBUG - Cleared 0 xrefs
2023-07-03 15:23:00,658 - DEBUG - analyzing function at 0xA00
2023-07-03 15:23:00,658 - DEBUG - Loaded 0 xrefs
2023-07-03 15:23:00,658 - DEBUG - Cleared 0 xrefs
2023-07-03 15:23:00,659 - INFO - Done 12344
2023-07-03 15:23:00,659 - DEBUG - Starting :12336 0x3030
2023-07-03 15:23:00,659 - INFO - Done 12336
2023-07-03 15:23:00,659 - DEBUG - Starting :12320 0x3020
2023-07-03 15:23:00,659 - INFO - Done 12320

查看IDA 结构体
新建了结构体类型

查找 sub_84A函数 快捷键Y 将v0类型改成C
在这里插入图片描述
类和虚函数的类型基本都能识别清楚
在这里插入图片描述

8.手动构建类层次

需要手动选择虚函数表 然后在命名行窗口输入指令

from ida_medigate import cpp_utils

cpp_utils.make_vtable("B")

在这里插入图片描述

9.设置继承

cpp_utils.add_baseclass("C", "B")

10.总结

插件使用 手动设置类有时候会导致IDA崩溃 没法恢复成跟作者demo一模一样的情况
对于分析cpp的程序 这个插件是非常有帮助的

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/714107.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

大厂面试官:软件测试员,你的简历,是如何石沉大海的?

引言 俗话说&#xff1a;知己知彼百战百胜&#xff0c;面试如打仗&#xff0c;不是面试官赢&#xff0c;就是求职者胜。站在面试官的维度来跟求职者聊天&#xff0c;让求职者知道面试官的心理。 因为我本身作为一面多年的大厂面试官&#xff0c;相对来说还是有一些面试经验&am…

股价在5年内暴涨了3000%后,Enphase Energy未来还会继续上涨吗?

来源&#xff1a;猛兽财经 作者&#xff1a;猛兽财经 Enphase Energy股票的关键指标 最近很多人都在关注Enphase Energy&#xff08;ENPH&#xff09;的关键指标&#xff0c;包括该公司第二季度的指引和最近的股价调整。 2023年4月25日收盘后&#xff0c;Enphase Energy公布了…

leetcode每日一题——80.删除有序数组中的重复项II(面试经典150题)

一、题目描述与要求 80. 删除有序数组中的重复项 II - 力扣&#xff08;LeetCode&#xff09; 题目描述 给你一个有序数组 nums &#xff0c;请你 原地 删除重复出现的元素&#xff0c;使得出现次数超过两次的元素只出现两次 &#xff0c;返回删除后数组的新长度。 不要使用…

NodeJS安装教程(详细)

系列文章 MySQL安装教程&#xff08;详细&#xff09; 本文链接&#xff1a;https://blog.csdn.net/youcheng_ge/article/details/126037520 MySQL卸载教程&#xff08;详细&#xff09; 本文链接&#xff1a;https://blog.csdn.net/youcheng_ge/article/details/129279265 …

Linux 内核源代码情景分析(一)

系列文章目录 Linux 内核设计与实现 深入理解 Linux 内核 Linux 设备驱动程序 Linux设备驱动开发详解 深入理解Linux虚拟内存管理 Linux 内核源代码情景分析&#xff08;一&#xff09; 文章目录 系列文章目录一、存储管理1、外部设备存储空间的地址映射&#xff08;1&#xff…

LinK3D论文详解

摘要 特征提取和匹配是许多计算机视觉任务的基本部分&#xff0c;例如二维或三维物体检测、识别和配准。众所周知&#xff0c;二维特征提取和匹配已经取得了很大的成功。遗憾的是&#xff0c;在3D领域&#xff0c;由于描述能力差和效率低&#xff0c;目前的方法无法支持3D激光雷…

uniapp在微信开放平台创建移动应用时,如何生成应用签名的问题

包名在打包的时候是必填项&#xff0c;就不多赘述了… 微信开放平台获取应用签名&#xff0c; 场景&#xff1a; 首先需要在手机或者模拟器上下载签名生成工具&#xff0c;下载地址&#xff1a;下载签名生成工具 然后手机打开&#xff0c; 在这里输入你的app打包时的包名&…

【雕爷学编程】Arduino动手做(148)---MD-PS002压力传感器模块

37款传感器与执行器的提法&#xff0c;在网络上广泛流传&#xff0c;其实Arduino能够兼容的传感器模块肯定是不止这37种的。鉴于本人手头积累了一些传感器和执行器模块&#xff0c;依照实践出真知&#xff08;一定要动手做&#xff09;的理念&#xff0c;以学习和交流为目的&am…

[解决方案] 在linux运行python代码报错(Illegal instruction (core dumped))

PVE修改CPU类型 在运行Python代码时遇到"Illegal instruction (core dumped)"错误时&#xff0c;意味着你的代码尝试在当前CPU架构不支持的指令上运行 1. 利用lscpu命令查看宿机和虚拟机CPU架构&#xff0c;确定宿机和虚拟机是否支持avx指令集 可以发现宿机是支持avx…

暑期学JavaScript【第四天】

日期对象 创建 //创建 const date new Date(); // 默认使用现在时间常用方法 时间戳的获取方式 date.getTime()new Date()Date.now() 倒计时案例 <!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><meta htt…

Redis初步认识

1、概述 redis是一款高性能的NOSQL系列的非关系型数据库&#xff1b; 2、什么是NOSQL&#xff1f; NOSQL(NoSQLNotOnlySQL)&#xff0c;意即“不仅仅是SQL”&#xff0c;是一项全新的数据库理念&#xff0c;泛指非关系型的数据库随着互联网web2.0网站的兴起&#xff0c;传统…

Java中常见的线程池以及ThreadPoolTaskExecutor和ThreadPoolExecutor

线程池的基本组成&#xff1a; 线程管理器&#xff1a;用于创建并管理线程池&#xff0c;负责线程池的创建、销毁以及任务的添加。 工作线程&#xff1a;线程池中的线程&#xff0c;负责执行任务&#xff0c;没有任务时处于等待状态。 任务接口&#xff1a;每个任务必须实现的…

gen1-视频生成论文阅读

文章目录 摘要贡献算法3.1 LDM3.2 时空隐空间扩散3.3表征内容及结构内容表征结构表征条件机制采样 3.4优化过程 实验结果结论 论文&#xff1a; 《Structure and Content-Guided Video Synthesis with Diffusion Models》 官网&#xff1a; https://research.runwayml.com/ge…

aliyun-oss-sdk阿里云OSS视频上传(断点续传)前端实现

问题背景 最近上传视频的功能&#xff0c;突然炸了&#xff0c;两年没动的代码&#xff0c;突然不行辽&#xff0c;首次上传成功&#xff0c;后面继续上传就可以&#xff0c;但凡有一次上传失败&#xff0c;再上传文件就不行。 这里博主使用的是凭证上传方式哈。 凭证上传 …

CMU 15-445 -- Hash Tables - 04

CMU 15-445 -- Hash Tables - 04 引言Hash TablesHash FunctionsHashing Scheme小结 Dynamic Hash TablesChained Hashing (链式哈希)Extendible Hashing(可扩展哈希)Linear Hashing(线性哈希) 总结 引言 本系列为 CMU 15-445 Fall 2022 Database Systems 数据库系统 [卡内基梅…

【IDA疑难杂症修复】

我们在使用IDA进行逆向分析的时候&#xff0c;会遇到一些问题&#xff0c;这篇文章来带领大家学习IDA中疑难杂症的修复&#xff1a;函数大小限制&#xff0c;栈不平衡&#xff0c;switch无法识别&#xff08;跳转表修复&#xff09;&#xff0c;ida Decompile as call。 一.函…

Redis学习(一)数据类型、Java中使用redis、缓存概念

文章目录 常用数据结构String类型Hash类型List类型Set类型SortedSet 类型 通用命令key的层级结构 Spring Data Redis快速入门RedisTemplate的序列化方式StringRedisTemplateRedisTemplate的Hash类型操作 实战操作短信登录发送验证码校验登录信息校验登录状态 商家查询缓存缓存更…

antdesignpro组件Upload传excel文件到后端flask的两种方案

&#xff08;特别提醒&#xff1a;后端xlrd新版本不支持xlsx文件&#xff0c;所以暂用xls文件进行上传&#xff09; 1.第一种方案&#xff1a;组件接收到excel文件,然后解析成list数据&#xff0c;解析是要用到XLSX&#xff08; 安装插件&#xff1a;npm i xlsx --save impor…

【Leetcode】21.合并两个有序链表

一、题目 1、题目描述 将两个升序链表合并为一个新的 升序 链表并返回。新链表是通过拼接给定的两个链表的所有节点组成的。 示例1: 输入:l1 = [1,2,4], l2 = [1,3,4] 输出:[1,1,2,3,4,4]示例2: 输入:l1 = [], l2 = [] 输出:[]示例3: 输入:l1 = [], l2 = [0] 输…

Cesium 常用标绘线、面、矩形、圆、曲面、曲线、攻击箭头、钳击箭头,标绘与修改。

前言&#xff1a;直接放效果图&#xff0c;符合就往下看&#xff0c;不符合出门右转。 由于篇幅有限&#xff0c;只贴出各个标绘的关键代码。 1、线段 基于坐标点&#xff0c;加载不同的材质。 //动态加载 const entity this._viewer.entities.add({polyline: {positions: …