首页
社区
课程
招聘
[原创] IDA 7.0 IDAPython MakeStr Bug 修复
发表于: 2018-7-3 22:19 12277

[原创] IDA 7.0 IDAPython MakeStr Bug 修复

2018-7-3 22:19
12277

MakeStr 在7.0版本中使用会报错,6.8版本每问题,细究原因,属于脚本二次传参错误bug,

可以

D:\IDA 7.0\python\idc_bc695.py

中,113行的

def MakeStr(ea, endea): return create_strlit(ea, 0 if (endea) == ida_idaapi.BADADDR else endea-ea)

屏蔽掉,然后修正添加如下即可

def MakeStr(ea, endea): return create_strlit(ea, endea)

最后reload下idc模块即可



强迫症,将原来的屏蔽后,在原来行修正,避免万一以后还有bug修正某某行,与国际错误行信息不对接

def MakeStr(ea, endea): return create_strlit(ea, endea)  # def MakeStr(ea, endea): return create_strlit(ea, 0 if (endea) == ida_idaapi.BADADDR else endea-ea)



Python>idc.MakeStr(0x413000,BADADDR)

Traceback (most recent call last):

File "<string>", line 1, in <module>

File "C:\IDA 7.0\python\idc_bc695.py", line 113, in MakeStr

#def MakeStr(ea, endea): return create_strlit(ea, 0 if (endea) == ida_idaapi.BADADDR else endea-ea)

File "D:\IDA 7.0\python\idc.py", line 695, in create_strlit

return ida_bytes.create_strlit(ea, 0 if endea == BADADDR else endea - ea, get_inf_attr(INF_STRTYPE))

File "D:\IDA 7.0\python\ida_bytes.py", line 1618, in create_strlit

return _ida_bytes.create_strlit(*args)

OverflowError: in method 'create_strlit', argument 2 of type 'size_t'

Python>reload(idc)

<module 'idc' from 'D:\IDA 7.0\python\idc.pyc'>

Python>idc.MakeStr(0x413000,BADADDR)

True



[课程]Linux pwn 探索篇!

收藏
免费 0
支持
分享
最新回复 (7)
雪    币: 13713
活跃值: (2851)
能力值: ( LV15,RANK:2663 )
在线值:
发帖
回帖
粉丝
2

这个问题是由于cretate_strlit这个函数在idcida_bytes中都有定义,如下代码如示,idc中的定义实际上就是调用的ida_bytes中的定义函数。

#in idc.py file
def create_strlit(ea, endea):
    """
    Create a string.

    This function creates a string (the string type is determined by the
    value of get_inf_attr(INF_STRTYPE))

    @param ea: linear address
    @param endea: ending address of the string (excluded)
        if endea == BADADDR, then length of string will be calculated
        by the kernel

    @return: 1-ok, 0-failure

    @note: The type of an existing string is returned by get_str_type()
    """
    return ida_bytes.create_strlit(ea, 0 if endea == BADADDR else endea - ea, get_inf_attr(INF_STRTYPE))


#in ida_bytes file
def create_strlit(*args):
  """
  create_strlit(start, len, strtype) -> bool
  """
  return _ida_bytes.create_strlit(*args)

而在idc_bc695.py文件中,Makestr的定义如下:

def MakeStr(ea, endea): return create_strlit(ea, 0 if (endea) == ida_idaapi.BADADDR else endea-ea)

此函数中实际调用的是idc中的create_strlit,参数并不对应。所以可以将idc_bc695.py中的Makestr函数定义修改为:

def MakeStr(ea, endea): return create_strlit(ea, endea)
#or this
def MakeStr(ea, endea): return ida_bytes.create_strlit(ea, 0 if (endea) == ida_idaapi.BADADDR else endea-ea,get_inf_attr(INF_STRTYPE))
最后于 2018-7-3 22:44 被poyoten编辑 ,原因:
2018-7-3 22:43
0
雪    币: 5676
活跃值: (1303)
能力值: ( LV17,RANK:1185 )
在线值:
发帖
回帖
粉丝
3
大佬可以去pull request一波
2018-7-3 23:08
0
雪    币: 8149
活跃值: (1875)
能力值: ( LV8,RANK:122 )
在线值:
发帖
回帖
粉丝
4
刚好碰到这个问题, 没想到这里就有解决方案了, 谢谢
2018-7-5 21:15
0
雪    币: 264
活跃值: (184)
能力值: ( LV12,RANK:210 )
在线值:
发帖
回帖
粉丝
5
牛逼 不愧是po大叔
2020-1-16 23:29
0
雪    币: 8370
活跃值: (4926)
能力值: ( LV4,RANK:45 )
在线值:
发帖
回帖
粉丝
6
非常感谢,帮了我大忙
2020-5-3 11:19
0
雪    币: 109
活跃值: (289)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
7
感谢,找到解决方案了
2020-10-10 11:35
0
雪    币: 10
活跃值: (392)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
8
2021-1-11 13:54
0
游客
登录 | 注册 方可回帖
返回
//