吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 6435|回复: 9
收起左侧

[IDA Plugin] IDA Deobfuscator plugin 0.76b

  [复制链接]
iawen 发表于 2009-2-23 14:04
作者:mpompeo
转载自:http://www.woodmann.com/forum/showthread.php?t=12342

介绍:
basic deobfuscator plugin for IDA.
Go to an obfuscated code sequence, start it (ALT+O), enter the end address (start address is already filled) and go.
I wont push much this POC version as it needs a full rewrite -it is a quick&dirt tool-, but I am curious to know 'how it works' for you, and where it mainly fails.


(didnt test it on 5.3, drop me a line if it doesnt work and I'll update)
edit--- 0.2 which fixexs checkboxes (made confusion with some flag :P )
edit--- 0.3 which add some basic constants accumulation.
edit--- 0.5, minor constant accumulation, minor push/pop folding
edit--- 0.51, fixed a bug introduced in 0.5 (an "IF" code flow): now it remove the junk and keep the good instruction (+fixed table-mode, now it works)
edit-- 0.6 few bugfixes, added layout in the stack for registers at end of deobfuscated block.
edit-- 0.7 common indirect register tracking of values (experimental)
edit-- 0.71 removed a debug check left for error, that caused frequent crashes...
edit-- 0.76b fixed a bunch of deadly errors, added 'selection' to be taken as start-end and few other changes

本地备份一个:

IDA_Deob_076b.rar

43.22 KB, 下载次数: 19, 下载积分: 吾爱币 -1 CB

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

 楼主| iawen 发表于 2009-2-23 14:08
hi, here the sample of usage, + 0.75 which hopefully fixes all the ugly bugs I introduced when I had extended the constant folding in 0.6x-0.7x...
1.jpg
it deobfuscates the following code (cut&paste from IDA)
                 sar     dx, cl
                 inc     ah
                 add     dh, 6Eh
                 mov     eax, [ebp+0]
                 neg     dl
                 shl     dx, 9
                 mov     dx, [ebp+4]
                 cmp     cl, al
                 pushf
                 clc
                 cmp     cx, di
                 add     ebp, 6
                 jmp     loc_4250D1
                 [...]
loc_4250D1:                             
                 call    $+5
                 push    [dword ptr esp]
                 mov     [ss:eax], dx
                 pushf
                 pushf
                 lea     esp, [esp+14h]
                 jmp     common_end
2.jpg
this is another sample, used in IDA: I just fille dthe start and end of obfuscated code, which is
common_end:                           
                                       
                 lea     edx, [ebx+5FB827D6h]
                 btr     dx, 4
                 rol     al, cl
                 sal     dl, 1
                 mov     al, [esi-1]
                 cmp     ah, dh
                 clc
                 shrd    dx, bx, 1
                 xor     al, bl
                 btc     dx, 0Fh
                 movsx   edx, cl
                 pushf
                 rol     al, 3
                 sal     dx, 0Ah
                 inc     dx
                 add     dh, 0B7h
                 btr     edx, edx
                 xor     al, 1
                 cmp     esi, esi
                 adc     dh, 25h
                 btr     dx, cx
                 sub     dl, bl
                 sub     al, 37h
                 cmc
                 pop     edx
                 call    continue_1
continue_1:                            
                 neg     al
                 inc     dl
                 lea     esi, [esi-1]
                 bsr     dx, ax
                 dec     al
                 pop     edx
                 pusha
                 not     al
                 pop     edx
                 db      66h
                 bswap   edx
                 movzx   edx, bl
                 setnl   dl
                 inc     al
                 bts     dx, bx
                 xor     bl, al
                 cmc
                 clc
                 movzx   eax, al
                 adc     dl, al
                 db      66h
                 bswap   edx
                 jmp     continue_2
continue_2:                             
                 sbb     dl, 17h
                 mov     edx, [ds:Address_Table+eax*4]
                 mov     [esp], ch
                 jmp     continue_3
continue_3:                             
                 mov     [esp+8], di
                 clc
                 bswap   edx
                 call    continue_4
proc            continue_4 near         
                 cmc
                 stc
                 add     edx, 0D5B781C2h
                 push    eax
                 jmp     continue_5
continue_5:                
                 bswap   edx
                 cmc
                 cmp     bh, 49h
                 bt      sp, 1
                 pushf
                 sub     edx, 89010C55h
                 cmc
                 cmp     bh, 0BEh
                 jmp     continue_end
continue_end:                         
                 clc
                 bswap   edx
                 stc
                 add     edx, 0
                 mov     [byte ptr esp+0], 0Ch
                 mov     [esp+return_address_of_ret____CARE], edx
                 pushf
                 push    [esp+4+return_address_of_ret____CARE]
                 retn    2Ch
3.jpg

Basically, you set up a start/end, and then it provides to prune obfuscated code. Output is estabilished in the first 3 options, either notepad, IDB anterior comment (this EDIT your idb, care), or just in the IDA log window as messages. A little ida sdk note: call_system() wait the end of the called process, so until you close notepad you won't be able to click in IDA.

The 'table mode' just cycles thru a table of pointers deobfuscating all handles (useful for VM). When it fails, it stop, so you know the instruction that wasnt possible to deobfuscate (hopefully). To use the table mode, you need to position at start of table, fill 'pointers table end' and set table mode, of course. The 'max valid pointer address' is used to prevent invalid entries in handle table to cause problems.

The 'relative tracking' is explained in 1st sample: see the end layout line for EBP that says [EBP+0]=[EBP+4].

Stack constants moved back and forth the stack are tracked and sent to output, so you know how your stack will look like AFTER the deobfuscated sequence.

It can accumulate simple transformations whenever possible, and track down basic assignments.

Almost everywhere you will find an address before a line, as it allows a quick click-jump. Whenever you get to a Jcc or to a RET, it will ask you the address where it should jump to. Exiting there will 'stop' analysis there.

This is made to ease analysis, not to 'rewrite' code. I got an idea on a generic deobfuscation method and wanted to 'test it out'
estelle 发表于 2009-2-23 14:16
Hmily 发表于 2009-2-23 17:01
随便不知道他是干啥的,但是我还是把这东西扔我IDA里面,好歹东西多没坏处~
ucantseeme 发表于 2009-2-23 17:09
谁能帮我简单介绍一下是干嘛用的
Hmily 发表于 2009-2-23 17:19
刚放进去发现我就有这个插件.....
 楼主| iawen 发表于 2009-2-23 17:21
原帖由 Hmily 于 2009-2-23 17:19 发表
刚放进去发现我就有这个插件.....


太自私了,有了也不分享出来!
给大家说说,这个插件的用途,
Hmily 发表于 2009-2-23 17:31
我这插件居多,不过都没用过.......IDA基本不用.......等待老鸭IDA语音分析教程~
xie83544109 发表于 2009-2-24 11:38
要是有个中文说明就好了
谢谢[s:367]
yishon 发表于 2010-6-29 10:33
呵呵,针对什么版的呢?
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-5-14 14:27

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

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