发信人: Reinhard.bbs@bbs.sjtu.edu.cn (摘星的人), 信区: cnhacker
标  题: Soft-Ice 修改密技 -2 by 软蛀 -- Alex 整理(转寄)
发信站: 饮水思源站 (Fri Apr 25 19:07:32 1997)
转信站: Lilac!ustcnews!ustcnews!sjtunews!sjtubbs
出  处: bbs.sjtu.edu.cn



【 S-ICE 修改密技二 】                                            - 软蛀 -
==========================================================================
    当应用程式触动 INT_1 的指令时 ,有时候 S-ICE 会发出 BEEP 声 ,并因此延迟
了一秒左右 ,这个问题将会造成使用者除错时的困扰 ,虽然可以使用 "Break ON" 的
命令来克服此问题 ,但是遇到 "DB  F1" 的指令时 ,一定会哔哔叫 ,没有办法解决 ,
除非修改指令码....嘿嘿嘿...不信可写个小程式试试看 !!

    本例是使用 386DEBUG 与 S-ICE v2.64 为例..


C:\>DXDEBUG S-ICE.EXE
-u DS:4377
382D:00004377 6A00                     PUSH     Word Ptr 0
382D:00004379 E9F4D6                   JMP      1A70
382D:0000437C 6A01                     PUSH     Word Ptr 1
382D:0000437E E9C7D8                   JMP      1C48
382D:00004381 6A02                     PUSH     Word Ptr 2
382D:00004383 E98ADC                   JMP      2010
382D:00004386 6A03                     PUSH     Word Ptr 3
382D:00004388 E9D6DC                   JMP      2061
382D:0000438B 6A04                     PUSH     Word Ptr 4
382D:0000438D E9E0D6                   JMP      1A70
382D:00004392 E9DBD6                   JMP      1A70
382D:00004395 6A06                     PUSH     Word Ptr 6
382D:00004397 E943DF                   JMP      22DD

-u DS:1c48 (观看 INT_1 的程式码)
382D:00001C48 6655                     PUSH     EBP
382D:00001C4A 06                       PUSH     ES
382D:00001C4B 06                       PUSH     ES
382D:00001C4C 1E                       PUSH     DS
382D:00001C4D 1E                       PUSH     DS
382D:00001C4E 6650                     PUSH     EAX
382D:00001C50 6653                     PUSH     EBX
382D:00001C52 6651                     PUSH     ECX
382D:00001C54 6652                     PUSH     EDX
382D:00001C56 6656                     PUSH     ESI
382D:00001C58 6657                     PUSH     EDI
382D:00001C5A 668BEC                   MOV      EBP,ESP
382D:00001C5D B80800                   MOV      AX,0008
382D:00001C60 8ED8                     MOV      DS,AX
382D:00001C62 8B462A                   MOV      AX,[BP+2A]
382D:00001C65 A33F02                   MOV      [023F],AX
382D:00001C68 8B4626                   MOV      AX,[BP+26]
382D:00001C6B A34102                   MOV      [0241],AX
382D:00001C6E 8B462E                   MOV      AX,[BP+2E]
382D:00001C71 A34302                   MOV      [0243],AX
382D:00001C74 B82000                   MOV      AX,0020
382D:00001C77 8EC0                     MOV      ES,AX
382D:00001C79 F746300200               TEST     Word Ptr [BP+30],0002
382D:00001C7E 0F850000                 JNE      1C82
382D:00001C82 0F21F0                   MOV      EAX,DR6             ;
382D:00001C85 6650                     PUSH     EAX                 ;
382D:00001C87 6633C0                   XOR      EAX,EAX             ;将DR6清0
382D:00001C8A 0F23F0                   MOV      DR6,EAX             ;
382D:00001C8D 6658                     POP      EAX                 ;
382D:00001C8F A26401                   MOV      [0164],AL
382D:00001C92 A90040                   TEST     AX,4000     ;是否因'T'产生中断
382D:00001C95 0F859700                 JNE      1D30        ;是则 JMP
382D:00001C99 A80F                     TEST     AL,0F      ;是否因DRx产生中断
382D:00001C9B 0F852B02                 JNE      1ECA       ;是则 JMP
382D:00001C9F 8D1EC20A                 LEA      BX,[0AC2]
382D:00001CA3 B90400                   MOV      CX,0004             ;四个断点
382D:00001CA6 807F1100                 CMP      Byte Ptr [BX+11],00 ;比较程式
382D:00001CAA 0F840800                 JE       1CB6                ;
382D:00001CAE 807F1104                 CMP      Byte Ptr [BX+11],04 ;
382D:00001CB2 0F851C00                 JNE      1CD2                ;
382D:00001CB6 668B7F05                 MOV      EDI,[BX+5]          ;
382D:00001CBA 660FB7462A               MOVZX    EAX,Word Ptr [BP+2A];
382D:00001CBF 66C1E004                 SHL      EAX,04              ;
382D:00001CC3 660FB77626               MOVZX    ESI,Word Ptr [BP+26];
382D:00001CC8 6603C6                   ADD      EAX,ESI             ;
382D:00001CCB 663BC7                   CMP      EAX,EDI             ;
382D:00001CCE 0F840503                 JE       1FD7                ;
382D:00001CD2 83C316                   ADD      BX,16               ;
382D:00001CD5 E2CF                     LOOP     1CA6                ;
382D:00001CD7 50                       PUSH     AX              ;都不是上面的
382D:00001CD8 51                       PUSH     CX              ;原因 ,就打开
382D:00001CD9 B90300                   MOV      CX,0003         ;喇叭叫几声
382D:00001CDC B003                     MOV      AL,03           ;
382D:00001CDE E661                     OUT      61,AL (喇叭ON)  ;
382D:00001CE0 51                       PUSH     CX              ;
382D:00001CE1 33C9                     XOR      CX,CX           ;
382D:00001CE3 E2FE                     LOOP     1CE3  (DELAY)   ;
382D:00001CE5 E2FE                     LOOP     1CE5            ;
382D:00001CE7 E2FE                     LOOP     1CE7            ;
382D:00001CE9 E2FE                     LOOP     1CE9            ;
382D:00001CEB E2FE                     LOOP     1CEB            ;
382D:00001CED E2FE                     LOOP     1CED            ;
382D:00001CEF E2FE                     LOOP     1CEF            ;
382D:00001CF1 E2FE                     LOOP     1CF1            ;
382D:00001CF3 E2FE                     LOOP     1CF3            ;
382D:00001CF5 E2FE                     LOOP     1CF5            ;
382D:00001CF7 E2FE                     LOOP     1CF7            ;
382D:00001CF9 E2FE                     LOOP     1CF9            ;
382D:00001CFB E2FE                     LOOP     1CFB            ;
382D:00001CFD E2FE                     LOOP     1CFD            ;
382D:00001CFF E2FE                     LOOP     1CFF            ;
382D:00001D01 B000                     MOV      AL,00           ;
382D:00001D03 E661                     OUT      61,AL (喇叭OFF) ;
382D:00001D05 E2FE                     LOOP     1D05            ;
382D:00001D07 E2FE                     LOOP     1D07  (DELAY)   ;
382D:00001D09 E2FE                     LOOP     1D09            ;
382D:00001D0B E2FE                     LOOP     1D0B            ;
382D:00001D0D E2FE                     LOOP     1D0D            ;
382D:00001D0F E2FE                     LOOP     1D0F            ;
382D:00001D11 E2FE                     LOOP     1D11            ;
382D:00001D13 E2FE                     LOOP     1D13            ;
382D:00001D15 E2FE                     LOOP     1D15            ;
382D:00001D17 59                       POP      CX              ;
382D:00001D18 E2C2                     LOOP     1CDC            ;
382D:00001D1A B80200                   MOV      AX,0002         ;
382D:00001D1D E2FE                     LOOP     1D1D            ;
382D:00001D1F 48                       DEC      AX              ;
382D:00001D20 75FB                     JNE      1D1D            ;
382D:00001D22 59                       POP      CX              ;
382D:00001D23 58                       POP      AX              ;
382D:00001D24 EB13                     JMP      1D39            ;

因此你必需想办法让 S-ICE 认识发生此中断的原因 ,或是叫它闭嘴...真残忍
---------------------------------------------------------------------------
有些烂程式会故意用一些 CPU 不认识的指令来产生 INT_6 ,例如 FFFF.FEF4 之类的
指令码 ,此时 S-ICE 会秀出 Gxxxxxx Pxxxxxx Exxxxx
                          (R)eturn (C)ountinue
万一程式大量使用此指令 ,你岂不是要按键按到爽 ,追究原因是 S-ICE 不认识它 ,
所以才会停下来让使用者确定是否写错程式啦 ,可惜就有保护故意使用它 ,使得它
反而是除错过程的困扰 ,因此我们得想办法让 S-ICE 认识它 ,或是让它的眼睛瞎掉
(让它没看到)....毒瞎它的眼睛啦....


-U DS:23F4
382D:000023F4 80FBF0                   CMP      BL,F0
382D:000023F7 0F841300                 JE       240E
382D:000023FB 26678B5FFE               MOV      BX,ES:[EDI-2] ;
382D:00002400 81FBCD06                 CMP      BX,06CD       ;是否因为INT_6
382D:00002404 0F840600                 JE       240E          ;产生中断
382D:00002408 B80006                   MOV      AX,0600       ;
382D:0000240B E8D712                   CALL     36E5          ;秀出视窗并请按
382D:0000240E B80600                   MOV      AX,0006       ;C.R.键
382D:00002411 E98DF6                   JMP      1AA1          ;
382D:00002414 6655                     PUSH     EBP           ;

-U DS:36E5
382D:000036E5 50                       PUSH     AX            ;打开视窗的副程式
382D:000036E6 56                       PUSH     SI            ;
382D:000036E7 51                       PUSH     CX            ;※注一
382D:000036E8 33C0                     XOR      AX,AX         ;
382D:000036EA B9AA00                   MOV      CX,00AA       ;
382D:000036ED 8D364A01                 LEA      SI,[014A]     ;
382D:000036F1 2E1304                   ADC      AX,CS:[SI]    ;
382D:000036F4 46                       INC      SI            ;
382D:000036F5 E2FA                     LOOP     36F1          ;
382D:000036F7 150000                   ADC      AX,0000       ;
382D:000036FA 2E3B06F501               CMP      AX,CS:[01F5]  ;
382D:000036FF 0F840200                 JE       3705          ;
382D:00003703 EBFE                     JMP      3703          ;
382D:00003705 59                       POP      CX            ;

注一: 打开视窗的程式开头刚好就是 S-ICE 检查序号是否被篡改的保护程式.
      若序号被篡改 ,则会当在 3703 的地方.

---------------------------------------------------------------------------
追踪程式後 ,发现应用程式也会使用除错暂存器来解码....怎麽办 ?
或许各位有听过在V86下的应用程式是无权读写系统暂存器(CRx.DRx) ,所以当V86下
的程式尝试读写这些暂存器 ,会被 S-ICE 拦下 ,经由内部指令翻译的方式 ,让使用者
能够改到系统暂存器 ,不过万一 S-ICE 不做此命令翻译 ,则 V86 下的程式就取不到
控制权 ,因此首先你要知道被除错的程式用了那些除错暂存器 ,或是你打算开放那些
给使用者 ,那些不开放...甚至做出适当回应..

底下是 S-ICE 对於指令翻译的程式码..

-U DS:2D42
3994:00002D42 668B4614                 MOV      EAX,[BP+14]
3994:00002D46 0F23C0                   MOV      DR0,EAX
3994:00002D49 E9D600                   JMP      2E22
3994:00002D4C 0F21C0                   MOV      EAX,DR0
3994:00002D4F 66894614                 MOV      [BP+14],EAX
3994:00002D53 E9CC00                   JMP      2E22
3994:00002D56 80FC23                   CMP      AH,23
3994:00002D59 0F850A00                 JNE      2D67
3994:00002D5D 668B4614                 MOV      EAX,[BP+14]
3994:00002D61 0F23C8                   MOV      DR1,EAX
3994:00002D64 E9BB00                   JMP      2E22
3994:00002D67 0F21C8                   MOV      EAX,DR1
3994:00002D6A 66894614                 MOV      [BP+14],EAX
3994:00002D6E E9B100                   JMP      2E22
3994:00002D71 80FC23                   CMP      AH,23
3994:00002D74 0F850A00                 JNE      2D82
3994:00002D78 668B4614                 MOV      EAX,[BP+14]
3994:00002D7C 0F23D0                   MOV      DR2,EAX
3994:00002D7F E9A000                   JMP      2E22
3994:00002D82 0F21D0                   MOV      EAX,DR2
3994:00002D85 66894614                 MOV      [BP+14],EAX
3994:00002D89 E99600                   JMP      2E22
3994:00002D8C 80FC23                   CMP      AH,23
3994:00002D8F 0F850A00                 JNE      2D9D
3994:00002D93 668B4614                 MOV      EAX,[BP+14]
3994:00002D97 0F23D8                   MOV      DR3,EAX
3994:00002D9A E98500                   JMP      2E22
3994:00002D9D 0F21D8                   MOV      EAX,DR3
3994:00002DA0 66894614                 MOV      [BP+14],EAX
3994:00002DA4 EB7C                     JMP      2E22
3994:00002DA6 90                       NOP
3994:00002DA7 80FC23                   CMP      AH,23
3994:00002DAA 0F850A00                 JNE      2DB8
3994:00002DAE 668B4614                 MOV      EAX,[BP+14]
3994:00002DB2 0F23F0                   MOV      DR6,EAX
3994:00002DB5 EB6B                     JMP      2E22
3994:00002DB7 90                       NOP
3994:00002DB8 0F21F0                   MOV      EAX,DR6
3994:00002DBB 66894614                 MOV      [BP+14],EAX
3994:00002DBF EB61                     JMP      2E22
3994:00002DC1 90                       NOP
3994:00002DC2 80FC23                   CMP      AH,23
3994:00002DC5 0F850A00                 JNE      2DD3
3994:00002DC9 668B4614                 MOV      EAX,[BP+14]
3994:00002DCD 0F23F8                   MOV      DR7,EAX
3994:00002DD0 EB50                     JMP      2E22
3994:00002DD2 90                       NOP
3994:00002DD3 0F21F8                   MOV      EAX,DR7
3994:00002DD6 66894614                 MOV      [BP+14],EAX
3994:00002DDA EB46                     JMP      2E22
3994:00002DDC 90                       NOP
3994:00002DDD 80FC22                   CMP      AH,22
3994:00002DE0 0F850700                 JNE      2DEB
3994:00002DE4 668B4614                 MOV      EAX,[BP+14]
3994:00002DE8 EB38                     JMP      2E22
3994:00002DEA 90                       NOP
3994:00002DEB 0F20C0                   MOV      EAX,CR0
3994:00002DEE 66894614                 MOV      [BP+14],EAX
3994:00002DF2 EB2E                     JMP      2E22
3994:00002DF4 90                       NOP
3994:00002DF5 80FC22                   CMP      AH,22
3994:00002DF8 0F850700                 JNE      2E03
3994:00002DFC 668B4614                 MOV      EAX,[BP+14]
3994:00002E00 EB20                     JMP      2E22
3994:00002E02 90                       NOP
3994:00002E03 0F20D0                   MOV      EAX,CR2
3994:00002E06 66894614                 MOV      [BP+14],EAX
3994:00002E0A EB16                     JMP      2E22
3994:00002E0C 90                       NOP
3994:00002E0D 80FC22                   CMP      AH,22
3994:00002E10 0F850700                 JNE      2E1B
3994:00002E14 668B4614                 MOV      EAX,[BP+14]
3994:00002E18 EB08                     JMP      2E22
3994:00002E1A 90                       NOP
3994:00002E1B 0F20D8                   MOV      EAX,CR3
3994:00002E1E 66894614                 MOV      [BP+14],EAX

举例来说 ,如果你不想使用者的程式写入 DR2 ,但允许读取 ,那你就把写入 DR2 的
指令干掉就行了....又举例来说 ,有个GA的外壳会用 DR0 做解码 ,并涂掉其它 DRx
那麽我们就开放 DR0 ,其它的写入动作忽略 ,并於写入 DR7 时做适当回应 ,於是两
者皆可和平使用 DRx ,它用 DR0.DR7 ,S-ICE 用 DR3.DR7 ,还有一种情形是 PPIP
这套外壳只是涂掉 DRx ,因此你只要不要让 S-ICE 去翻译这些断手断脚的指令 ,追
起来形同没有防破能力哩......还有其它玩法吗 ,当然有...自己去找吧.

至於你要怎麽知道应用程式用了那些除错暂存器 ,那就得凭个人的功力了 ,笔者有自
己的「系统资源分析」程式 ,你呢....哈哈哈....自己想办法吧 ,我是不会流出来害
人的。又如果应用程式把所有的除错暂存器用完了呢 ,那麽你就只好放弃使用它 ,改
用其它类似的硬体中断能力 ,例如 BPX.BPINT.'T' 等等 ,或用P5新增加的 CR4.DR4.
DR5 暂存器啦 !!

有关於 V86 下读取系统暂存器的问题与技巧 ,请参阅笔者保护模式的电子刊物第三
集。
---------------------------------------------------------------------------
上次提到在倚天中文下叫出 S-ICE 的密技改法又有新版的改法了:
(因为我没有未改过的版本 ,所以列出改过的程式码给各为参"拷"一下吧)

-u DS:3127 (INT_10h 进入点)
3736:00003127 6655                     PUSH     EBP
3736:00003129 06                       PUSH     ES
3736:0000312A 06                       PUSH     ES
3736:0000312B 1E                       PUSH     DS
3736:0000312C 1E                       PUSH     DS
3736:0000312D 6650                     PUSH     EAX
3736:0000312F 6653                     PUSH     EBX
3736:00003131 6651                     PUSH     ECX
3736:00003133 6652                     PUSH     EDX
3736:00003135 6656                     PUSH     ESI
3736:00003137 6657                     PUSH     EDI
3736:00003139 668BEC                   MOV      EBP,ESP
3736:0000313C B80800                   MOV      AX,0008
3736:0000313F 8ED8                     MOV      DS,AX
3736:00003141 8B462A                   MOV      AX,[BP+2A]
3736:00003144 A33F02                   MOV      [023F],AX
3736:00003147 8B4626                   MOV      AX,[BP+26]
3736:0000314A A34102                   MOV      [0241],AX
3736:0000314D 8B462E                   MOV      AX,[BP+2E]
3736:00003150 A34302                   MOV      [0243],AX
3736:00003153 807E1500                 CMP      Byte Ptr [BP+15],00
3736:00003157 0F854D00                 JNE      31A8
3736:0000315B 8A4614                   MOV      AL,[BP+14]
3736:0000315E B012                     MOV      AL,12               ;改
3736:00003160 A2EE01                   MOV      [01EE],AL           ;的
3736:00003163 8026FB03FE               AND      Byte Ptr [03FB],FE  ;地
3736:00003168 EB3E                     JMP      31A8                ;方
3736:0000316A 90                       NOP
3736:0000316B 90                       NOP

本篇真的是便宜各位玩家啦(有得抄嘛) !!
---------------------------------------------------------------------------

--


                                                    沉默的人
                                                 Reinhard Young

※ 来源:·饮水思源站 bbs.sjtu.edu.cn·[FROM: 202.96.210.121]
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:208.096毫秒