首页
社区
课程
招聘
更改pCode代码地址的一点分析和疑惑
发表于: 2004-10-9 19:12 6749

更改pCode代码地址的一点分析和疑惑

2004-10-9 19:12
6749
拿到pCode的程序首先想到的就是用exec、VBExplorer静态反汇编,以备心中有数
之后WKTVVBdebug跟踪,详析。

我的目的:更改事件代码的位置从而有效Anti静态反汇编,什么?用WKTVVBdebug跟踪?
     看着大篇幅的代码又不能复制,跳来跳去,烦死你......呵呵
     如果找到规律再写个混乱器之类的东西就更好了!
代码:
***********************************************************
Private Sub Command1_Click()
Dim a, b As Integer
there:
a = 1
b = 5
If a + b = 3 Then
    GoTo there: '死循环,是为了看 jmp 向上跳的机器码
End If
End Sub

Private Sub Timer1_Timer()
    If Label1.ForeColor = &HCC Then
        Label1.ForeColor = &HFF0000
    Else
        Label1.ForeColor = &HCC
    End If
End Sub
***********************************************************

VbExplorer V1.01反汇编后的代码
[Timer1.Timer]
:00401A98  0474FF                          FLdRfVar                   ;Push LOCAL_008C
1A98是事件的起始代码

:00401A9B  21                              FLdPrThis                  ;[SR]=[stack2]
:00401A9C  0F0403                          VCallAd                    ;Return the control index 03
:00401A9F  1978FF                          FStAdFunc                  ;
:00401AA2  0878FF                          FLdPr                      ;[SR]=[LOCAL_0088]
***********Reference To:[propget]Label.ForeColor
                              |
:00401AA5  0D68000000                      VCallHresult               ;Call ptr_00401474
:00401AAA  6C74FF                          ILdRf                      ;Push DWORD [LOCAL_008C]
:00401AAD  F5CC000000                      LitI4                      ;Push 000000CC
:00401AB2  C7                              EqI4                       ;Push (Pop1 == Pop2)
:00401AB3  1A78FF                          FFree1Ad                   ;Push [LOCAL_0088]; Call [[[LOCAL_0088]]+8]; [[LOCAL_0088]]=0
:00401AB6  1C3B00                          BranchF                    ;If Pop=0 then ESI=00401AD3
:00401AB9  F50000FF00                      LitI4                      ;Push 00FF0000
:00401ABE  21                              FLdPrThis                  ;[SR]=[stack2]
:00401ABF  0F0403                          VCallAd                    ;Return the control index 03
:00401AC2  1978FF                          FStAdFunc                  ;
:00401AC5  0878FF                          FLdPr                      ;[SR]=[LOCAL_0088]
***********Reference To:[propput]Label.ForeColor
                              |
:00401AC8  0D6C000000                      VCallHresult               ;Call ptr_00401474
:00401ACD  1A78FF                          FFree1Ad                   ;Push [LOCAL_0088]; Call [[[LOCAL_0088]]+8]; [[LOCAL_0088]]=0
:00401AD0  1E5200                          Branch                     ;ESI=00401AEA
:00401AD3  F5CC000000                      LitI4                      ;Push 000000CC
:00401AD8  21                              FLdPrThis                  ;[SR]=[stack2]
:00401AD9  0F0403                          VCallAd                    ;Return the control index 03
:00401ADC  1978FF                          FStAdFunc                  ;
:00401ADF  0878FF                          FLdPr                      ;[SR]=[LOCAL_0088]
***********Reference To:[propput]Label.ForeColor
                              |
:00401AE2  0D6C000000                      VCallHresult               ;Call ptr_00401474
:00401AE7  1A78FF                          FFree1Ad                   ;Push [LOCAL_0088]; Call [[[LOCAL_0088]]+8]; [[LOCAL_0088]]=0
:00401AEA  13                              ExitProcHresult            ;

在1C10处找到一大块空地(导入表后面)
1C10-1A98=178

Branch机器码1EXXXX(低位在前)

将00401A98--00401AEA的代码贴到1C10处

将00401A98的机器码由0474FF改为1E7801(让她跳到新地址去运行)

现在将00401A9B--00401AEA的代码全码改乱,我改为00(好像是pCode的NOP)

再次运行发现程序运行异常(表现为只自动更改一次label1的颜色)

再次跟踪发现程序00401AB6跳到00401AD3运行,看来是又跳回来了

00401AD3--00401AEA都已改为00(NOP)所以最后只有执行ExitProcHresult

重新恢复00401AD3--00401AEA处的原始代码,这样程序又跑起来了

代码:
:00401A98  1E7801                          Branch                     ;ESI=00401C10
:00401A9B  0000                            LargeBos                   ;IDE beginning of line with 00 byte codes
:00401A9D  0000                            LargeBos                   ;IDE beginning of line with 00 byte codes
:00401A9F  0000                            LargeBos                   ;IDE beginning of line with 00 byte codes
......(这段nop可以改为其它pCode指令,反正也不走这,一眼看去,乱......呵呵)
:00401AD1  0000                            LargeBos                   ;IDE beginning of line with 00 byte codes
:00401AD3  F5CC000000                      LitI4                      ;Push 000000CC
:00401AD8  21                              FLdPrThis                  ;[SR]=[stack2]
:00401AD9  0F0403                          VCallAd                    ;Return the control index 03
:00401ADC  1978FF                          FStAdFunc                  ;
:00401ADF  0878FF                          FLdPr                      ;[SR]=[LOCAL_0088]
***********Reference To:[propput]Label.ForeColor
                              |
:00401AE2  0D6C000000                      VCallHresult               ;Call ptr_00401474
:00401AE7  1A78FF                          FFree1Ad                   ;Push [LOCAL_0088]; Call [[[LOCAL_0088]]+8]; [[LOCAL_0088]]=0
:00401AEA  13                              ExitProcHresult            ;

只有部分代码移植成功,我们的修改没完全达到目的

00401AB6  1C3B00  BranchF ;If Pop=0 then ESI=00401AD3

003B=59(Dec),正是Timer1.Timer起始地址00401A98-->00401AD3的距离+1

看来这个是相对跳转,我想可能是在Timer1.Timer事件执行前pCode引擎已经将Timer1.Timer的起始地址压入

堆栈了,是不是只有重定位才能搞定?pCode的重定位又该始何操作?附件:Project.rar 附件:Project.rar

[培训]科锐逆向工程师培训第53期2025年7月8日开班!

收藏
免费 1
支持
分享
最新回复 (3)
雪    币: 166
活跃值: (112)
能力值: ( LV4,RANK:50 )
在线值:
发帖
回帖
粉丝
2
pcode中跳转(Branch, BranchF, BranchT)的距离计算如下:
  目标地址 - 事件起始地址

这里,事件起始地址 = 00401A98
所以,你进行了代码段移位后,问题出现了
原先的   :00401AB6  1C3B00      BranchF  0001A98 + 003B = 00401AD3
修改后   :00401C2E  1C3B00      BranchF  0001A98 + 003B = 00401AD3
解决方法是修正所有的跳转长度,比如改 00401C2E 处 1C3B00 为 1CB301(003B + 迁移距离0178)
2004-10-9 20:08
0
雪    币: 253
活跃值: (27)
能力值: ( LV4,RANK:50 )
在线值:
发帖
回帖
粉丝
3
咋就没想到呢?
多谢谢小楼老师指点
重新改了一些无用的代码,这回出事了,呵呵。

ljtt->VBParser Ptr error 其它事件代码依然可以反汇编
CCG的兄弟就是强啊,虽然有时兼容性不佳

VBExplorer非法操作
直接B掉了,没想到

exec
这个就更离谱了,出错报告,点击则死机

以上测试为win98平台
2004-10-9 21:06
0
雪    币: 496
活跃值: (119)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
4
这帖子留脚印。
2009-8-30 23:35
0
游客
登录 | 注册 方可回帖
返回