IDA脚本——输出所有函数名称和地址

本博客由闲散白帽子胖胖鹏鹏胖胖鹏潜力所写,仅仅作为个人技术交流分享,不得用做商业用途。转载请注明出处,未经许可禁止将本博客内所有内容转载、商用。      

我们在使用IDA的时候,经常要对分析好的函数结果进行导出,结合其他软件比如OD或者其他二进制分析工具使用,这里我提供一个python脚本,能够将IDA中所有的函数名称和地址提取出来,并且输出成sqlite3数据库,这样即使是函数数量比较多的情况下,也能够轻松导入。

# -*- coding: utf-8 -*-
"""
Transfer ida function name text file to database.
We can use this to store our function name information.
So we can save time when we recogenize function in Angr.
"""
import os
import sqlite3

from idaapi import *
from idautils import *
from idc import *

def main(filename):
    if os.path.exists(filename):
        try :
            os.remove(filename)
            Message("Previous Database %s has removed\n" % filename)
        except:
            Message("Error! Can not remove file.")
    
    # create new database
    db = sqlite3.connect(filename)
    cur = db.cursor()
    sql_create = """create table if not exists functions(
                            id integer primary key,
                            address text unique,
                            name varchar(255))"""
    cur.execute(sql_create)
    
    sql_insert = "insert into functions (address, name) values (?, ?)"
    # enum functions
    func_list = Functions()
    
    for func in func_list:
        name = GetFunctionName(func)
        cur.execute(sql_insert,(func,name))
    Message("We have handled %d functions. " % len(list(Functions())))
    db.commit()
    db.close()

if __name__=="__main__":
    f = AskFile(1,"*.sqlite","Select the output file")
    if BADADDR == f :
        Warning("AskFile Failed!")
    else:
        main(f)

 

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值