乐易论坛-乐易网易语言培训教程火山PC视窗中文编程交流论坛

 找回密码
 立即注册

手机号登录

用手机号号登陆

微信登录

微信扫码,快速开始

QQ登录

用QQ账号登陆

办理VIP,定制软件,报名培训联系QQ请牢记揰掵佲的QQ号1615457736 1615457734 其他都是骗子易语言0基础入门课程
易语言汇编快速入门课程《64位某信Hook技术实战基础教程》【投稿课程】百日Js加密分析实战课程(无密下载)
【强烈推荐】《火山视窗0基础入门系列课程》《64位某信Hook技术实战进阶教程》【投稿课程】《0基础x64位游戏内存辅助开发教程 》
《火山视窗POST基础入门课程》《64位某信数据库操作课程》【投稿课程】广告位招租联系QQ1615457736
查看: 7649|回复: 5

[调试工具] IDA任意语言自动翻译脚本

[复制链接]

[调试工具] IDA任意语言自动翻译脚本

[复制链接]
已绑定手机
已实名认证
揰掵佲
等级头衔

等級:乐易运营组

Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20

积分成就
易币
贡献
主题
精华
金钱
积分
24315
注册时间
2014-8-2
最后登录
1970-1-1

勋章墙

2014-11-19 09:17:34 | 显示全部楼层 |阅读模式
用IDA逆向时,有时会碰到外文或者Unicode中文甚至UTF-8编码的中文,但IDA无法显示这2种中文,更不用说碰到比如韩语、日语等他国语言,想要弄懂字符串的意思,要复制出来->转码->翻译,相当之麻烦。

是否碰到过这种情况
[/url]

真想能这样
[url=http://bbs.pediy.com/attachment.php?attachmentid=93706&d=1416314679]


事实是这样的
[/url]

好了,有了Google Translate后一切都结束了,本脚本支持世界上一切语言(ANSI Code Page和Unicode)的自动识别和翻译(如果太短或者多语言混合识别率低要手动指定语言),支持Unicode中文(UTF-16/UTF-8)自动转GBK,IDA里从此再没有编码困扰。

使用需知:
本机需要装有python,安装[url=https://pip.pypa.io/en/latest/installing.html]pip
,并使用pip安装下面两个库
pip install goslate
pip install chardet

另外,由于Google服务经常被墙,建议开梯子使用本脚本,不然失败概率很高。
就算开了梯子,由于网络原因有时也会失败,可以多来几次。

跑起脚本后,会自动注册快捷键,默认支持以下几种模式,由于Fx和Shift+Fx都是自动识别编码,之所以分开是暂时无法自动识别ANSI/UTF-8类无'\0'编码和UTF-16LE编码的,这里需要人肉确认。Ctrl+Fx是翻译指定语言用的,可以任意修改。当字符串过短时语言识别会概率低,默认低于60%的可能性就要求人工指定源语言。

Use F3 translate ANSI/UTF-8 to Chinese
Use F4 translate ANSI/UTF-8 to English
Use Ctrl-F3 translate Korea to Chinese
Use Ctrl-F4 translate Korea to English
Use Shift-F3 translate Unicode to Chinese
Use Shift-F4 translate Unicode to English

-----------------放python---------------
# -*- coding: utf-8 -*-  
# Translate current string in IDA Pro
# author : fuyzen@gmail.com

# install:
# easy_install goslate
# easy_install chardet

import struct
import re

def read_string(ea, coding=''):
    bytes = []
    if coding == 'utf-16':
        # Read UCS-2LE in Windows
        while Word(ea) != 0:
            bytes.Append(struct.pack('H', Word(ea)))
            ea += 2
    else:
        # Read ANSI or UTF-8
        while Byte(ea) != 0:
            bytes.append(struct.pack('B', Byte(ea)))
            ea += 1
            
    s = ''.join(bytes)
    print 'processing:',
   
    # if codepage is not given manually, anto detect
    if coding == '':
        # detect codepage
        import chardet
        codepage = chardet.detect(s)
        print 'codepage may', codepage['encoding'], \
               'confidence', codepage['confidence']
        if codepage['confidence'] < 0.6:
            print 'Auto detect may not precise enough. Please give manually.'
            return
        coding = codepage['encoding']
        
    return s.decode(coding)
   
# call Google Translate
# sometime it would fail, try again
def google_trans(u, dstLan, dstCoding):
    s = ''
    if u:
        try:
            #call Google Translate
            import goslate
            gs = goslate.Goslate()
            s = gs.translate(u, dstLan).encode(dstCoding)
        except:
            print 'translate error, try again!'
    return s

def is_utf16_has_chinese(u):
    # have chinese?
    return re.match(u'[\u4e00-\u9fa5]+', u)
   
# arg0: current address in IDA
# arg1: soutce coding, can be auto detected. If detect result is wrong, can be set manually.
#       it can be utf-8/utf-16/gb2312/big5/euc-kr etc...
# arg2: dest language,default 'zh-cn'
# arg3: dest coding,default 'gbk'
def translate(ea, srcCoding='', dstLan='zh-cn', dstCoding='gbk'):
    u = read_string(ea, srcCoding)
    s = None
    if u:
        if is_utf16_has_chinese(u) and dstLan.lower() == 'zh-cn':
            # if the string contain Chinese, direct encode to gbk
            s = u.encode('gbk')
        else:
            s = google_trans(u, dstLan, dstCoding)
            
        if s:
            Message(dstLan + ' result: ' + s + '\n')
    return s

# ------------translate funcitons------------
# ANSI、UTF-8 to Chinese
def trans2cn():
    s = translate(ScreenEA())
    if s : MakeRptCmt(ScreenEA(), s)
   
# ANSI、UTF-8 to English
def trans2en():
    s = translate(ScreenEA(), dstLan='en', dstCoding='ascii')
    if s : MakeRptCmt(ScreenEA(), s)
   
# euc-kr to Chinese
def trans_kr2cn():
    s = translate(ScreenEA(), 'euc-kr')
    if s : MakeRptCmt(ScreenEA(), s)
   
# euc-kr to English
def trans_kr2en():
    s = translate(ScreenEA(), 'euc-kr', 'en', 'ascii')
    if s : MakeRptCmt(ScreenEA(), s)
   
# Windows Unicode(UTF-16LE) to Chinese
def trans2cn_u():
    s = translate(ScreenEA(), 'utf-16')
    if s : MakeRptCmt(ScreenEA(), s)
   
# Windows Unicode(UTF-16LE) to English
def trans2en_u():
    s = translate(ScreenEA(), 'utf-16', 'en', 'ascii')
    if s : MakeRptCmt(ScreenEA(), s)
#-------------------------------------

def add_hot_key(key, str_func):
    idaapi.CompileLine('static %s() { RunPythonStatement("%s()"); }'%(str_func, str_func))
    AddHotkey(key, str_func)
   
if __name__ == '__main__':
   
    # set hotkeys
    add_hot_key('F3', 'trans2cn');
    add_hot_key('F4', 'trans2en');
    add_hot_key('Ctrl-F3', 'trans_kr2cn');
    add_hot_key('Ctrl-F4', 'trans_kr2en');
    add_hot_key('Shift-F3', 'trans2cn_u');
    add_hot_key('Shift-F4', 'trans2en_u');
   
    print '-----------------------------------------'
    print 'Use F3 translate ANSI/UTF-8 to Chinese'
    print 'Use F4 translate ANSI/UTF-8 to English'
    print 'Use Ctrl-F3 translate Korea to Chinese'
    print 'Use Ctrl-F4 translate Korea to English'
    print 'Use Shift-F3 translate Unicode to Chinese'
    print 'Use Shift-F4 translate Unicode to English'
    print '-----------------------------------------'
   
    # if auto detect is wrong, temporary manually given here
    # s = translate(ScreenEA(), 'euc-kr')
    # if s : MakeRptCmt(ScreenEA(), s)

直接下载链接:
idaStrTrans.zip.



本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
回复

使用道具 举报

325019289
等级头衔

等級:程序制作者

Rank: 6Rank: 6

积分成就
易币
贡献
主题
精华
金钱
积分
4236
注册时间
2014-11-11
最后登录
1970-1-1

勋章墙

2014-11-19 09:42:20 | 显示全部楼层
很强的说,就是还不会用IDA
回复

使用道具 举报

携寒
等级头衔

等級:顶级Vip

Rank: 14Rank: 14Rank: 14Rank: 14

积分成就
易币
贡献
主题
精华
金钱
积分
416
注册时间
2014-11-10
最后登录
1970-1-1

勋章墙

2014-11-19 10:21:25 | 显示全部楼层
来看看楼主,天天好心情
(*^__^*)
回复

使用道具 举报

2991239158
等级头衔

等級:编程起步

Rank: 5Rank: 5

积分成就
易币
贡献
主题
精华
金钱
积分
1661
注册时间
2014-10-18
最后登录
1970-1-1

勋章墙

2014-11-19 20:34:55 | 显示全部楼层
这个很棒,真的很不错……
回复

使用道具 举报

已绑定手机
安。
等级头衔

等級:顶级Vip

Rank: 14Rank: 14Rank: 14Rank: 14

积分成就
易币
贡献
主题
精华
金钱
积分
420
注册时间
2014-10-29
最后登录
1970-1-1

勋章墙

2014-11-19 22:32:18 | 显示全部楼层
赞一个。
回复

使用道具 举报

最终的幻象
等级头衔

等級:编程起步

Rank: 5Rank: 5

积分成就
易币
贡献
主题
精华
金钱
积分
1067
注册时间
2014-9-10
最后登录
1970-1-1

勋章墙

2014-11-20 08:30:06 | 显示全部楼层
优秀文章!神马都是浮云,支持!
回复

使用道具 举报

如果懒得打字,请选择右侧内容快捷回复 提醒:以任何方式进行『恶意灌水』的行为,进行封号处理
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

热点推荐上一条 /5 下一条

QQ|网站地图|手机版|小黑屋|乐易论坛-乐易网 | 湘ICP备19007035号

拒绝任何人以任何形式在本论坛发表与中华人民共和国法律相抵触的言论,本站内容均为会员发表,并不代表乐易立场!

娄底市乐易网络科技有限公司声明:乐易原创培训课程版权均为我公司所有,未经许可,不得擅自翻录,盗版,破解本站课课程,我们将保留法律诉讼的权利

GMT+8, 2025-7-7 00:56 , Processed in 0.068545 second(s), 50 queries .

Powered by Discuz! X3.4

Copyright © Tencent Cloud.

快速回复 返回顶部 返回列表