String 用于字符串的IDA Pro脚本

String 用于字符串的IDA Pro脚本,string,disassembly,ida,String,Disassembly,Ida,我想知道是否有可能通过idc脚本将字符串从可执行文件中列出到文件中?我还没有找到任何好的函数。 或者使用IDA Pro还有其他方法可以做到这一点吗?我有一个IDA python代码片段: import idautils string_type_map = { 0 : "ASCSTR_C", # C-string, zero terminated 1 : "ASCSTR_PASCAL", # Pascal-styl

我想知道是否有可能通过idc脚本将字符串从可执行文件中列出到文件中?我还没有找到任何好的函数。
或者使用IDA Pro还有其他方法可以做到这一点吗?

我有一个IDA python代码片段:

import idautils

string_type_map = {
    0 : "ASCSTR_C",       #              C-string, zero terminated
    1 : "ASCSTR_PASCAL",  #              Pascal-style ASCII string (length byte)
    2 : "ASCSTR_LEN2",    #              Pascal-style, length is 2 bytes
    3 : "ASCSTR_UNICODE", #              Unicode string
    4 : "ASCSTR_LEN4",    #              Delphi string, length is 4 bytes
    5 : "ASCSTR_ULEN2",   #              Pascal-style Unicode, length is 2 bytes
    6 : "ASCSTR_ULEN4",   #              Pascal-style Unicode, length is 4 bytes
}

def main():
    #Do not use default set up, we'll call setup().
    s = idautils.Strings(default_setup = False)
    # we want C & Unicode strings, and *only* existing strings.
    s.setup(strtypes=Strings.STR_C | Strings.STR_UNICODE, ignore_instructions = True, display_only_existing_strings = True)

    #loop through strings
    for i, v in enumerate(s):                
        if not v:
            print("Failed to retrieve string at index {}".format(i))
        else:
            print("[{}] ea: {:#x} ; length: {}; type: {}; '{}'".format(i, v.ea, v.length, string_type_map.get(v.type, None), str(v)))

if __name__ == "__main__":
    main()

这样做怎么样?谢谢,但对我来说最好的解决方案是使用IDA Pro!或者,如果有人可以肯定地告诉我,用脚本/命令行参数/补丁等从IDA以自动方式将字符串收集到文件中是不可能的……您知道如何让IDA(shift+F12)中的字符串窗口显示C样式和UNICODE字符串吗?我只能让它显示一个或另一个,这是恼人的切换。