èªåã®ãœãããŠã§ã¢ããªããŒã¹ãšã³ãžãã¢ãªã³ã°ããä¿è·ããããšã¯ããªãå€ãåé¡ã§ããããã€ãŠå€ãã®ã·ã§ã¢ãŠã§ã¢éçºè ã®å¿ãèŠãããã ãã§ãªãããããèŠãããŸããã éåžžããã®ãããªç®çã«ã¯ãã¬ããã䜿çšãããŸããããã¬ãããã©ããªã«æ¥åŸé ã§ãã£ââãŠããåžžã«ãã¬ãããåæããŠã¯ã©ãã¯ãã人ãããŸãã ãããæè¿ããããã¯ã¿ãŒã¯ã³ãŒãå€æŽæè¡ïŒçªç¶å€ç°ãšä»®æ³åïŒã®äœ¿çšãéå§ããŸãããããã«ãããå ã®ã¢ã«ãŽãªãºã ã®ãã©ãã¯ããã¯ã¹ã®ãããªæ··ä¹±ãäœãããšãã§ããŸãã å®éãçŸä»£ã®åçšãããã¯ã¿ãŒã«ããå®è¡å¯èœã³ãŒãã®ä»®æ³åãšçªç¶å€ç°ã¯äžèœè¬ã§ãããšç¢ºä¿¡ããŠãã人ã ãããŸãã ã»ãã¥ãªãã£ã®èŠãäŸ¡æ Œãç¥ã£ãŠãã人ã¯ãå®å šãªä¿è·ã®ãã³ããç¥è©±ãããŒã±ãã£ã³ã°ã®ããšã話ãšããŠæããå¯èœæ§ãé«ããããã»ãã¥ãªãã£ã¬ãŒãããã®ãããªå£°æã«ããªãç¬ããå察ããããšã¯æããã§ãã ãã®èšäºã§ã¯ãåçšãããã¯ã¿ãŒã®ãã©ãã¯ããã¯ã¹ãšãã®æ»æã®å¯èœæ§ãæ¢ããšããç§èªèº«ã®çµéšãšããžã§ã³ã«ã€ããŠã話ããŸãã ãã®ãããªæè¡ã®äžå©ãªç¹ãç解ããããšã§ãå®éã«ããããããåççãã€å¹æçã«é©çšãããããŸã£ããé©çšããªãããé¡ã£ãŠããŸãã
0x00ã ã³ãŒãä¿è·ã¡ã«ããºã ã®åæ
ãŸãã調æ»ãããã¯ãããžãŒãå®çŸ©ããŸãããã
1.ãã¥ãŒããŒã·ã§ã³ã¯ããªãªãžãã«ã®ããã°ã©ã ã¢ã«ãŽãªãºã ã«éåããããšãªããå¶åŸ¡ãããŒã®å ã®ã°ã©ããè¿œå ã®é ç¹ãåå²ãã¬ããŒãžåœä»€ããµã€ã¯ã«ã«ãã£ãŠè£å®ãããã³ãŒãé£èªåæ¹æ³ã§ãã å€ãã®å ŽåããœãŒã¹åœä»€ã¯åããžã§ããå®è¡ããä»ã®åœä»€ã®ãµãã»ããã«å€æãããŸãã
2.ä»®æ³åã¯ãã¢ã«ãŽãªãºã ã®å ã®åœä»€ããããã¯ã¿ãŒã«ãã£ãŠçæãããä»®æ³ãã·ã³ã®åœä»€ã«å€æãããã³ãŒãé£èªåæ¹æ³ã§ãã å ã®ã¢ã«ãŽãªãºã ã®ä»£ããã«ãå®è¡æã«äžéåœä»€ãæž¡ããŠãããã解éããä»®æ³ãã·ã³ã«å ¥ãã³ãŒããåã蟌ãŸããŠããŸãã
äž¡æ¹ã®æ¹æ³ã¯ãå®è¡å¯èœã³ãŒãã®éçããã³åçåæã®äž¡æ¹ãè€éã«ããå€ãã®å Žåããããã¯ã¿ãŒã¯æ¹æ³ã®çµã¿åãããèš±å¯ããŸãã
èšäºã®åŸåã§ã VMProtectãšSafengineã® 2ã€ã®ãããã¯ã¿ãŒã®ç¡æãã¢ããŒãžã§ã³ãæ€èšããŸãããããã¯ãé£èªåã®äž¡æ¹ã®æ¹æ³ãå€æŽãä»®æ³åãããã³çµã¿åãããããšãå¯èœã«ããŸãã
ãã¥ãŒããŒã·ã§ã³ããã³ã³ãŒãä»®æ³åãã¯ãããžãŒãé©çšããããã«ããããã¯ã¿ãŒã¯æ¬¡ã®æ¹æ³ãæäŸããŸãã
1.éçºæ®µéã§ãç¹å¥ãªããŒã«ãŒïŒSDKïŒã䜿çš
ãœãããŠã§ã¢éçºè ã¯ããœãŒã¹ã³ãŒãã§ãã¬ããSDKã®ç¹å¥ãªæ©èœã䜿çšããŠä¿è·ãããã³ãŒãã®ãã©ã°ã¡ã³ããããŒã¯ããã³ã³ãã€ã«åŸããã¬ããã®ã€ã³ã¹ããŒã«æ®µéã§ãããã®ã»ã¯ã·ã§ã³ãæ€åºãåãåããé£èªåããŸãã
int main () { VMProtectMutate("Critical_code_mut"); ... // critical code here VMProtectEnd(); return 0; }
VMProtectããŒã«ãŒã§ãœãŒã¹ã³ãŒããããŒã¯ããäŸ
2.ä¿è·ã®æ®µéã§ããããã°ãã¡ã€ã«ã䜿çš
ãã¬ããã®ã€ã³ã¹ããŒã«äžã«çŽæ¥ããããã°ãã¡ã€ã«ïŒpdbãmapïŒãèªã¿åãããããã«åºã¥ããŠã¢ããªã±ãŒã·ã§ã³ãªããžã§ã¯ãã®ãããã決å®ãããŸãã 次ã«ãéçºè ã¯ãä¿è·ããæ©èœãšãã®æ¹æ³ãéžæããŸãããã®åŸããããã¯å®å šã«ã³ãŒãããåãé¢ãããŠåŠçãããŸãã
ä¿è·ãããã³ãŒããåæãããã®ã¯ãªãã§ããïŒ å®éãã³ãŒããåžéããããšããã®ãµã€ãºãå€§å¹ ã«å¢å ãããããå ã®ã»ã°ã¡ã³ãã«æ°ããåœä»€ãåããããšãã§ããªããããã³ãŒãã¯ãã¬ããã¡ã¢ãªã®ç¬èªã®ã»ã¯ã·ã§ã³ã«ã«ãããããŸãã
å®è¡å¯èœé¢æ°ã³ãŒãã®ç°¡ç¥åãããçªç¶å€ç°ã¹ããŒã void TestïŒïŒ{printfïŒ "Hello"ïŒ; }
0x01ã ãããã¯ã¿ãŒã®é·æãšçæ
ãã¡ãããçªç¶å€ç°ã®æãããªå©ç¹ã¯ãã¢ã«ãŽãªãºã ã®èŠèŠç調æ»ãäžå¯èœã§ããããšã§ãã ç 究è ã®åã«ãäžèŠãããšãã¹ãã²ããã£ã®å±±ãä»ãããã¬ãŒãããããŸããããã¯æã§å解ããããšã¯éåžžã«é£ããããŸãã«çŸä»£ã®ä¿è·è ãè³ããŠãããã®ã§ãã
åæ§ã«éèŠãªã®ã¯ããããã°å¯Ÿçããããé©çšå¯Ÿçãããã¯å¯Ÿçãçªç¶å€ç°ãªã©ã®ããŸããŸãªææ³ã®çµã¿åããã§ãã äžç·ã«ãããã¯ãã¹ãŠåæããã»ã¹ã®è€éåã«ã€ãªãããŸãããããããåæ¢ããŸããã
ãã®ãããªæè¡ã®æ¬ ç¹ãååã§ãã 1ã€ç®ã¯ããã©ãŒãã³ã¹ã®äœäžã§ããããã¯ãå€æŽãããã³ãŒããæ°çŸãŸãã¯æ°ååãå¢å ããããã§ãã ããã¯ä»®æ³åã«ãé©çšãããŸããååãšããŠãä»®æ³ãã·ã³ã¯å€æŽãããã³ãŒããããã¯ããã«éãã§ãã äž¡æ¹ã®ã¢ãããŒããçµã¿åããããšãã³ãŒããè¥å€§åããŸãã ããã«ããªãŒããŒãããã³ã¹ãã¯åžžã«ãã®ãããªé£èªåãæ£åœåãããã®ã§ã¯ãããŸãããå€ç°æè¡ã®äœ¿çšã¯ãããã°ã©ã å®è¡ã®å ã®ã°ã©ãã®åŸ©å ãè€éã«ããããšãç®çãšããŠããŸãã
ããªããã£ãé¢æ°ããã¬ãŒã¹ããäŸã次ã«ç€ºããŸãã
void test() { printf("This is protected message #1\n"); printf("This is protected message #2\n"); }
çªç¶å€ç°åïŒ
ãã¬ãŒã¹ãã°
ã¡ã€ã³00405A2A CALL 004059F0 ESP = 0018FEE0 ã¡ã€ã³004059F0 PUSH EBP ESP = 0018FEDC ã¡ã€ã³004059F1 MOV EBPãESP EBP = 0018FEDC ã¡ã€ã³004059F3 SUB ESPã40 ESP = 0018FE9C ã¡ã€ã³004059F6 PUSH EBX ESP = 0018FE98 ã¡ã€ã³004059F7 PUSH ESI ESP = 0018FE94 ã¡ã€ã³004059F8 PUSH EDI ESP = 0018FE90 ã¡ã€ã³004059F9ããã·ã¥ãªãã»ãã0040ED10 ESP = 0018FE8C ã¡ã€ã³004059FE CALL DWORD PTR DSïŒ[<ïŒMSVCR100D.printf>] EAX = 00000012ãECX = 84CB6CA9ãEDX = 7418F4B8 ã¡ã€ã³00405A04 ESPã®è¿œå ã4 ESP = 0018FE90 ã¡ã€ã³00405A07ããã·ã¥ãªãã»ãã0040ECF8 ESP = 0018FE8C main 00405A0C CALL DWORD PTR DSïŒ[<ïŒMSVCR100D.printf>] EAX = 00000014 ã¡ã€ã³00405A12 ADD ESPã4 ESP = 0018FE90 ã¡ã€ã³00405A15 POP EDI ESP = 0018FE94 ã¡ã€ã³00405A16 POP ESI ESP = 0018FE98 ã¡ã€ã³00405A17 POP EBX ESP = 0018FE9C ã¡ã€ã³00405A18 MOV ESPãEBP ESP = 0018FEDC ã¡ã€ã³00405A1A POP EBP ESP = 0018FEE0ãEBP = 0018FF30 ã¡ã€ã³00405A1B RETN ESP = 0018FEE4
Safengineãããã¯ã¿ãŒã«ããçªç¶å€ç°åŸïŒ
ãã¬ãŒã¹ãã°
ã¡ã€ã³00405A2A CALL 004059F0 ESP = 0018FEE0 ã¡ã€ã³004059F0 JMP 004C9C6A ã¡ã€ã³004C9C6A JMP 004C8391 ã¡ã€ã³004C8391 CALL 004C82D6 ESP = 0018FEDC ã¡ã€ã³004C82D6 LEA ESPã[ESP + 2] ESP = 0018FEDE ã¡ã€ã³004C82DA LEA ESPã[ESP + 2] ESP = 0018FEE0 ã¡ã€ã³004C82DE PUSH EBP ESP = 0018FEDC ã¡ã€ã³004C82DF NEG BP EBP = 001800D0 ã¡ã€ã³004C82E2 JMP 004C812E ã¡ã€ã³004C812E MOV EBPãESP EBP = 0018FEDC ã¡ã€ã³004C8130 STC ã¡ã€ã³004C8131 SUB ESPã40 ESP = 0018FE9C ã¡ã€ã³004C8134 CALL 004C8006 ESP = 0018FE98 ã¡ã€ã³004C8006 JMPã·ã§ãŒã004C7F96 ã¡ã€ã³004C7F96 LEA ESPã[ESP + 4] ESP = 0018FE9C ã¡ã€ã³004C7F9A PUSH EBX ESP = 0018FE98 ã¡ã€ã³004C7F9B CALL 004C7F80 ESP = 0018FE94 ã¡ã€ã³004C7F80 LEA ESPã[ESP + 4] ESP = 0018FE98 ã¡ã€ã³004C7F84 PUSH ESI ESP = 0018FE94 ã¡ã€ã³004C7F85 JMP SHORT 004C7FB6 ã¡ã€ã³004C7FB6 PUSH EDI ESP = 0018FE90 ã¡ã€ã³004C7FB7 PUSH 0040ED10 ESP = 0018FE8C main 004C7FBC CALL DWORD PTR DSïŒ[40E19C] EAX = 00000012ãECX = 93D2AD8FãEDX = 7418F4B8 ã¡ã€ã³004C7FC2 JMP SHORT 004C7FA0 ã¡ã€ã³004C7FA0 STC ã¡ã€ã³004C7FA1 JMP SHORT 004C7FDA ã¡ã€ã³004C7FDA ADD ESPã4 ESP = 0018FE90 ã¡ã€ã³004C7FDD CALL 004C7FC4 ESP = 0018FE8C ã¡ã€ã³004C7FC4 LEA ESPã[ESP + 4] ESP = 0018FE90 ã¡ã€ã³004C7FC8 PUSH 0040ECF8 ESP = 0018FE8C main 004C7FCD CALL 004C7FE2 ESP = 0018FE88 ã¡ã€ã³004C7FE2 MOV BYTE PTR SSïŒ[ESP]ãCH ã¡ã€ã³004C7FE5 JMP SHORT 004C7FEB ã¡ã€ã³004C7FEB LEA ESPã[ESP + 4] ESP = 0018FE8C main 004C7FEF CALL DWORD PTR DSïŒ[40E19C] EAX = 00000014 ã¡ã€ã³004C7FF5 SETPE BH EBX = 7EFD0100 ã¡ã€ã³004C7FF8 XCHG BLãBH EBX = 7EFD0001 ã¡ã€ã³004C7FFA INC EBX EBX = 7EFD0002 ã¡ã€ã³004C7FFB JMPã·ã§ãŒã004C805A ã¡ã€ã³004C805A ESPã®è¿œå ã4 ESP = 0018FE90 ã¡ã€ã³004C805D POP EDI ESP = 0018FE94 ã¡ã€ã³004C805E MOV ESIã4B536EDD ESI = 4B536EDD ã¡ã€ã³004C8063 MOV SIãWORD PTR SSïŒ[ESP] ESI = 4B530000 ã¡ã€ã³004C8067 JMPã·ã§ãŒã004C801E ã¡ã€ã³004C801E LEA EBXã[CDDFCA2F] EBX = CDDFCA2F ã¡ã€ã³004C8024 POP ESI ESP = 0018FE98ãESI = 00000000 ã¡ã€ã³004C8025 CALL 004C8008 ESP = 0018FE94 main 004C8008 POP WORD PTR SSïŒ[ESP] ESP = 0018FE96 ã¡ã€ã³004C800C MOV BXãWORD PTR SSïŒ[ESP + 1] EBX = CDDF0000 ã¡ã€ã³004C8011 XCHG BYTE PTR SSïŒ[ESP]ãBL EBX = CDDF004C ã¡ã€ã³004C8014 JMPã·ã§ãŒã004C8040 ã¡ã€ã³004C8040 LEA ESPã[ESP + 2] ESP = 0018FE98 ã¡ã€ã³004C8044 POP EBX EBX = 7EFDE000ãESP = 0018FE9C ã¡ã€ã³004C8045 JMPã·ã§ãŒã004C802A ã¡ã€ã³004C802A MOV ESPãEBP ESP = 0018FEDC ã¡ã€ã³004C802C LEA EBPã[EDI + EAX] EBP = 00000014 ã¡ã€ã³004C802F MOV BPã3200 EBP = 00003200 ã¡ã€ã³004C8033 MOV EBPãCEF73787 EBP = CEF73787 ã¡ã€ã³004C8038 JMP 004C80ED ã¡ã€ã³004C80ED POP EBP ESP = 0018FEE0ãEBP = 0018FF30 ã¡ã€ã³004C80EE RETN ESP = 0018FEE4 --------ãã®ã³ã°ãåæ¢ããŸãã
äžèšã®äŸã§ã¯ãã³ãŒãã®å€æŽã¯æå°ã¬ãã«ã®è€éãã§å®è¡ãããŸãã Safengineã䜿çšãããšããã®è€éããæ倧254åã«å¢ããããšãã§ããŸããããã«ãããã³ãŒãã10åœä»€ãããœãŒã¹ããã°ã©ã ã®ãµã€ãºãæ°åè¶ ããã¬ããŒãžã»ããã«èšããããšãã§ããŸããããã¯éåžžã«åé·ã§ãã
ãŸããäžå¹žãªããšã«ç§ã®èšæ¶ã§èµ·ãã£ãããã°ã©ã ã®ç Žæã®ã±ãŒã¹ã«èµ·å ãããã¡ãªããããããŸãã ãã®ãããªé害ãéåžžã®ããã°ã©ã ã§çºçããå Žåãããã¯ã¯ã©ãã·ã¥ã«ã€ãªããããã©ã€ããŒã§ã¯ã©ãã·ã¥ãçºçããå Žåã¯ãŸã£ããç°ãªãããŸã£ããåãå ¥ããããŸããã ãåç¥ã®ããã«ããããã¯ã¿ãŒã¯ããŸããŸãªå®è¡å¯èœãã¡ã€ã«ïŒexeãdllãocxãsysïŒãåŠçââã§ããŸãã
ãŸããããŒã±ãã£ã³ã°ããªã·ãŒã«ã¯ãå€ãã®ããšãæãŸããå ŽåããããŸãã ã»ãã¥ãªãã£ã®é¯èŠãäœãåºã顧客ã®è³ã«ããæè¡çãªãŽãã¯è¯ããããŸããã 確ãã«ããã¬ããéçºè ã¯è£œåã®èª¬æã«ãã®æè¡ãåªããŠãããšã¯æžããŠããŸãããããã®ãããªæ¬ é¥ããããŸãã
0x02ã äžå®å šãªã³ãŒãä¿è·ã®åé¡
æåŸã«ãä¿è·è ã®éçºè ãããã«è€éã§æ°žç¶çãªä¿è·ãèšè¿°ã§ããªãããã«ããã«ã¯ãã©ãããã°ããã®ã§ããããïŒ çãã¯éåžžã«ç°¡åã§ã-äžå®å šãªæ å ±ã ãããã°æ å ±ãããå Žåã§ãããã€ããªãã¡ã€ã«ãå ¥åãšããŠåãåããšãããã€ãã®å¶éããããéåãããšãã¬ãããéãŠãããŒãµã«ã«ãªã£ãããä¿è·ãããã¢ããªã±ãŒã·ã§ã³ãç ŽæãããããŸãã ãã®ãããªå¶éã®äŸã«ã€ããŠã¯ãéåžžã®PEã¢ããªã±ãŒã·ã§ã³ã®æ§é ãèŠãŠã¿ãŸãããã
çã®ä»®æ³å ------------------------------------ 00000000 00400000 PEããã㌠00000200 00401000ã³ãŒãã»ã¯ã¿ãŒ 00000400 00402000ããŒã¿ã»ã¯ã¿ãŒ 00000600 00403000ãªãœãŒã¹ã»ã¯ã¿ãŒ
ã¢ããªã±ãŒã·ã§ã³ã®ã³ãŒããšããŒã¿ã¯ããŸããŸãªã»ã¯ã·ã§ã³ã«é 眮ãããŸããããããã®éã«ã¯æ確ãªãªã³ã¯ããããŸãã ãããã£ãŠãããã€ãã®ç°ãªãé¢æ°ã¯åãããŒã¿ãããã¯ãåç §ã§ããããŒã¿ã¯ä»ã®ããŒã¿ãšé¢æ°ãåç §ã§ããŸãã ããã«ããã®æ¥ç¶ã¯åžžã«æããã§ã¯ãããŸããã ããã«åºã¥ããŠããããã¯ã¿ãŒã¯å®è¡å¯èœãã¡ã€ã«ã®æ§é ãèªç±ã«æäœã§ããŸããïŒããŒã¿ã®ç§»åãå±éããœãŒã¹ã»ã°ã¡ã³ãã®æ©èœã®ç§»åãªã©ã äžåºŠå®è¡å¯èœãã¡ã€ã«ã®ã»ã¯ã·ã§ã³ãå±éããããšããŸããã ãããã¯ç¹æ®ãªã±ãŒã¹ã§ãããæ®éçã§ã¯ãããŸããã ãããã£ãŠããããã¯ã¿ãŒã¯æ¬¡ã®ããã«ããŒã¿ãã¹ã¿ãã¯ããŸãã
çã®ä»®æ³å ------------------------------------ 00000000 00400000 PEããã㌠00000200 00401000ã³ãŒãã»ã¯ã¿ãŒ 00000400 00402000ããŒã¿ã»ã¯ã¿ãŒ 00000600 00403000ãããã¯ã¿ãŒã»ã¯ã¿ãŒ 00000800 00404000ãªãœãŒã¹ã»ã¯ã¿ãŒ
ã³ãŒããšããŒã¿ã®å ã®å Žæã¯å€æŽãããŸããããä»ã®äžéšã®ã»ã¯ã¿ãŒã®ç§»åã¯å¯èœã§ãïŒãªãœãŒã¹ãåé 眮ãªã©ïŒã ä¿è·ãããã³ãŒãã¯åãåãããã¬ããŒãžåœä»€ããã®å Žæã«é 眮ãããŸããã»ãšãã©ã®å Žåããããã®åœä»€ã¯å€æŽãããå®è¡ã°ã©ãã®äžéšã§ãã å€æãããã°ã©ããšä»®æ³ãã·ã³ã¯ããã¬ããã»ã¯ã¿ãŒã«é 眮ãããŸãã
ãŸããã³ã³ãã¥ãŒãã£ã³ã°ã®è² è·ãå¢å ããããããããã¯ã¿ãŒã¯ã¢ããªã±ãŒã·ã§ã³ã³ãŒãå šäœãå€æŽã§ããŸããã ãããã£ãŠãã³ãŒãã®ä¿è·ãããã»ã¯ã·ã§ã³ã®éžæã¯ããã°ã©ããŒã«ããã£ãŠããŸãã ããããããã°ã©ããŒã¯åžžã«ãã®ãªãŒããŒã¬ã€ãã€ã³ããªãžã§ã³ãã«é©çšã§ãããšã¯éããŸããã ããšãã°ãäžéšã®æå·åã¢ã«ãŽãªãºã ãçªç¶å€ç°ã§ã«ããŒããå Žåãããã°ã©ããŒã¯ãã®æå·ã®ãã¹ãŠã®åŒã³åºããçªç¶å€ç°ã§ã«ããŒããããšãå¿ããç 究è ããã®ã¢ã«ãŽãªãºã ã®å ¥åããŒã¿ãååŸãããããã䜿çšããŠæå·ã®æ§é ã«é¢ããä»®å®ãæ§ç¯ããå Žåã«ãã£ãŠã¯åé¡ãŸãã¯åçŸããããšããã§ããããšãçºèŠããŸã
ããã¯ãã¹ãŠãå€ç°/ä»®æ³åã³ãŒãããã®æ å ±æŒæŽ©ã«ã€ãªããããã®äžã§ã®æ»æãèš±å¯ããŸãã ããŒã¿ãŸãã¯ããã€ãã®é¢æ°ã®ããããã®äœçœ®ãããã£ãŠããã®ã§ããã©ãã¯ããã¯ã¹ããããããžã®ã¢ã¯ã»ã¹ã远跡ã§ããŸããããã«ããããã€ãã解ã代ããã«ãã¢ã«ãŽãªãºã ã®ãã¡ã³ãã ã¢ãã«ãäœæããŸãã ãã¡ããããã®ã¢ãããŒãã¯ããã°ã©ã ã¢ã«ãŽãªãºã ã®å šäœåã瀺ããµããããŸããããå Žåã«ãã£ãŠã¯ããã§ååã§ãã
0x03ã ãã©ãã¯ããã¯ã¹æŒåž«
ãã©ãã¯ããã¯ã¹ãæ¢çŽ¢ããããã®å žåçãªããŒã«ã¯ãã¬ãŒãµãŒã§ãã ãã ããé£èªåãããã³ãŒãã®ãã¹ã¯80ã99ïŒ ã®ãŽãã§ãããããäœããã®æ¹æ³ã§ãã®ãŽãããæçšãªæ å ±ã®ã¿ãååŸããå¿ èŠããããŸãã ãã®ããã»ã¹ã¯é£ããé£æ³ãããŸãã ã«ãŒããæ¹ã§ããããã¬ãŒãµãŒãé£ãç«¿ã§ããããã®é€ã远跡ããããã®æ¡ä»¶ãæ³åããŠãã ããã ãããã¯ã¿ãŒã®äžèšã®æ¬ ç¹ã䜿çšããŠãé©åãªé€ãéžæããé©åãªæ å ±ãååŸã§ããŸãã å®éã«ã©ã®ããã«èŠãããèŠãŠã¿ãŸãããã
次ã®ããã°ã©ã ããããšããŸãïŒ
void array_fill(unsigned char *buf, size_t size) { for (int i = 0; i < size; i++) { buf[i] = i; if (i > 0) { buf[i] ^= buf[i - 1]; } } } int main() { unsigned char buf[10]; array_fill(buf, sizeof(buf)); return 0; }
çªç¶å€ç°ãšä»®æ³åã®äž¡æ¹ãarray_fillïŒïŒé¢æ°ã«éãåãããŸãã array_fillïŒïŒé¢æ°ã®åŒã³åºãããã¬ãŒã¹ããŠã¿ãŸãããã
æåã®ã¹ãããæ°ïŒ 230
VMProtectã®é£èªååŸã®ã¹ãããæ°ïŒ 83924
é£èªååŸã®ã¹ãããæ°SafengineïŒ 250382
æ°åãããããããã«ãã«ãŒããæåã§è§£æããã®ã¯éçŸå®çã§ãã ãã®ãããé£ãã®æ¹æ³ã䜿çšããŸãã
array_fillïŒïŒé¢æ°ã«ã€ããŠäœãç¥ããªããšæ³åããŠãã ããã mainïŒïŒã調ã¹ãŠããã®ãµãã³ãŒã«ãå ¥åã§ãããã¡ã¢ãã¬ã¹ãšãã®ãµã€ãºãåä¿¡ããããšã確èªã§ããŸãããã®åŸãäœããã®ã¢ã«ãŽãªãºã ã«åŸã£ãŠããããã¡ã¯æ å ±ã§æºããããŸãã ãããã£ãŠããã¬ãŒãµãŒã«ã«ãŒã«ãèšå®ããããã«åºã¥ããŠãé¢æ°ã«æž¡ããããããã¡ãŒãžã®èªã¿åã/æžã蟌ã¿åŒã³åºãã®ã¿ãèšé²ããŸãã 3ã€ã®ã¢ããªã±ãŒã·ã§ã³ãªãã·ã§ã³ãã¹ãŠã®çµæã¯åãã«ãªããŸãã
ãã¬ãŒã¹ãã°
ã¡ã€ã³004B7898 MOV BYTE PTR DSïŒ[ECX]ãAL EAX = 004B7700ãECX = 0018FF34 ã¡ã€ã³004B7898 MOV BYTE PTR DSïŒ[ECX]ãAL EAX = 004B7701ãECX = 0018FF35 ã¡ã€ã³004B7A8E MOV ALãBYTE PTR DSïŒ[ECX] EAX = 004B7A89ãECX = 0018FF34 ã¡ã€ã³004B7A8E MOV ALãBYTE PTR DSïŒ[ECX] EAX = 004B7A89ãECX = 0018FF35 ã¡ã€ã³004B7898 MOV BYTE PTR DSïŒ[ECX]ãAL EAX = 004B7701ãECX = 0018FF35 ã¡ã€ã³004B7898 MOV BYTE PTR DSïŒ[ECX]ãAL EAX = 004B7702ãECX = 0018FF36 ã¡ã€ã³004B7A8E MOV ALãBYTE PTR DSïŒ[ECX] EAX = 004B7A89ãECX = 0018FF35 ã¡ã€ã³004B7A8E MOV ALãBYTE PTR DSïŒ[ECX] EAX = 004B7A89ãECX = 0018FF36 ã¡ã€ã³004B7898 MOV BYTE PTR DSïŒ[ECX]ãAL EAX = 004B7703ãECX = 0018FF36 ã¡ã€ã³004B7898 MOV BYTE PTR DSïŒ[ECX]ãAL EAX = 004B7703ãECX = 0018FF37 ã¡ã€ã³004B7A8E MOV ALãBYTE PTR DSïŒ[ECX] EAX = 004B7A89ãECX = 0018FF36 ã¡ã€ã³004B7A8E MOV ALãBYTE PTR DSïŒ[ECX] EAX = 004B7A89ãECX = 0018FF37 ã¡ã€ã³004B7898 MOV BYTE PTR DSïŒ[ECX]ãAL EAX = 004B7700ãECX = 0018FF37 ã¡ã€ã³004B7898 MOV BYTE PTR DSïŒ[ECX]ãAL EAX = 004B7704ãECX = 0018FF38 ã¡ã€ã³004B7A8E MOV ALãBYTE PTR DSïŒ[ECX] EAX = 004B7A89ãECX = 0018FF37 ã¡ã€ã³004B7A8E MOV ALãBYTE PTR DSïŒ[ECX] EAX = 004B7A89ãECX = 0018FF38 ã¡ã€ã³004B7898 MOV BYTE PTR DSïŒ[ECX]ãAL EAX = 004B7704ãECX = 0018FF38 ã¡ã€ã³004B7898 MOV BYTE PTR DSïŒ[ECX]ãAL EAX = 004B7705ãECX = 0018FF39 ã¡ã€ã³004B7A8E MOV ALãBYTE PTR DSïŒ[ECX] EAX = 004B7A89ãECX = 0018FF38 ã¡ã€ã³004B7A8E MOV ALãBYTE PTR DSïŒ[ECX] EAX = 004B7A89ãECX = 0018FF39 ã¡ã€ã³004B7898 MOV BYTE PTR DSïŒ[ECX]ãAL EAX = 004B7701ãECX = 0018FF39 ã¡ã€ã³004B7898 MOV BYTE PTR DSïŒ[ECX]ãAL EAX = 004B7706ãECX = 0018FF3A ã¡ã€ã³004B7A8E MOV ALãBYTE PTR DSïŒ[ECX] EAX = 004B7A89ãECX = 0018FF39 ã¡ã€ã³004B7A8E MOV ALãBYTE PTR DSïŒ[ECX] EAX = 004B7A89ãECX = 0018FF3A ã¡ã€ã³004B7898 MOV BYTE PTR DSïŒ[ECX]ãAL EAX = 004B7707ãECX = 0018FF3A ã¡ã€ã³004B7898 MOV BYTE PTR DSïŒ[ECX]ãAL EAX = 004B7707ãECX = 0018FF3B ã¡ã€ã³004B7A8E MOV ALãBYTE PTR DSïŒ[ECX] EAX = 004B7A89ãECX = 0018FF3A ã¡ã€ã³004B7A8E MOV ALãBYTE PTR DSïŒ[ECX] EAX = 004B7A89ãECX = 0018FF3B ã¡ã€ã³004B7898 MOV BYTE PTR DSïŒ[ECX]ãAL EAX = 004B7700ãECX = 0018FF3B ã¡ã€ã³004B7898 MOV BYTE PTR DSïŒ[ECX]ãAL EAX = 004B7708ãECX = 0018FF3C ã¡ã€ã³004B7A8E MOV ALãBYTE PTR DSïŒ[ECX] EAX = 004B7A89ãECX = 0018FF3B ã¡ã€ã³004B7A8E MOV ALãBYTE PTR DSïŒ[ECX] EAX = 004B7A89ãECX = 0018FF3C ã¡ã€ã³004B7898 MOV BYTE PTR DSïŒ[ECX]ãAL EAX = 004B7708ãECX = 0018FF3C ã¡ã€ã³004B7898 MOV BYTE PTR DSïŒ[ECX]ãAL EAX = 004B7709ãECX = 0018FF3D ã¡ã€ã³004B7A8E MOV ALãBYTE PTR DSïŒ[ECX] EAX = 004B7A89ãECX = 0018FF3C ã¡ã€ã³004B7A8E MOV ALãBYTE PTR DSïŒ[ECX] EAX = 004B7A89ãECX = 0018FF3D
ã芧ã®ããã«ãã³ãŒãã®å€æŽã®çšåºŠãã¬ããŒãžã®æ°ã«é¢ä¿ãªãããããã¡ãžã®ãã¹ãŠã®åŒã³åºãã説æããããããªãã¬ãŒã¹ãååŸã§ããŸããã ããããå ã®ã¢ã«ãŽãªãºã ããããã埩å ã§ããŸããïŒ ãã£ãŠã¿ãŸãããã
ãã®ããããã©ãã¯ãããèŠããšããµã€ã¯ã«ãèŠããããã«ãªããŸãïŒããã¯ã004B7898ã§ã³ãŒããç¹°ãè¿ãåŒã³åºããŠããããšããæããã§ãïŒã
; 1ã¹ããã ã¡ã€ã³004B7898 MOV BYTE PTR DSïŒ[ECX]ãAL EAX = 004B7700ãECX = 0018FF34 ; 2段é ã¡ã€ã³004B7898 MOV BYTE PTR DSïŒ[ECX]ãAL EAX = 004B7701ãECX = 0018FF35 ã¡ã€ã³004B7A8E MOV ALãBYTE PTR DSïŒ[ECX] EAX = 004B7A89ãECX = 0018FF34 ã¡ã€ã³004B7A8E MOV ALãBYTE PTR DSïŒ[ECX] EAX = 004B7A89ãECX = 0018FF35 ã¡ã€ã³004B7898 MOV BYTE PTR DSïŒ[ECX]ãAL EAX = 004B7701ãECX = 0018FF35 ; 3ã¹ããã ã¡ã€ã³004B7898 MOV BYTE PTR DSïŒ[ECX]ãAL EAX = 004B7702ãECX = 0018FF36 ã¡ã€ã³004B7A8E MOV ALãBYTE PTR DSïŒ[ECX] EAX = 004B7A89ãECX = 0018FF35 ã¡ã€ã³004B7A8E MOV ALãBYTE PTR DSïŒ[ECX] EAX = 004B7A89ãECX = 0018FF36 ã¡ã€ã³004B7898 MOV BYTE PTR DSïŒ[ECX]ãAL EAX = 004B7703ãECX = 0018FF36 ...
ãããã¡ã®ãµã€ãºã«å¯Ÿå¿ãããã®ãããªã¹ãããã¯10åãããããŸããã ããã«ããã¹ãŠãéåžžã«åçŽã§ãããã©ã®å€ãååŸãããã©ã®å€ãæ»ãããããç¥ã£ãŠãããããäœæ¥ã®ã¢ã«ãŽãªãºã ã¯æã®ã²ãã«ãããŸãã ããã§æšæž¬ããå¯äžã®ããšã¯ãXORæŒç®ã®äœ¿çšã§ããããã®å Žåã絶察ã«é£ãããããŸããã
ãã¡ããããã®äŸã¯äººçºçãªãã®ã§ãããå®éã«ã¯ããã¹ããããåŒã³åºããšæé»ã®ããžãã¯ãåããããè€éãªã¢ã«ãŽãªãºã ãåŠçããå¿ èŠããããŸãã ãã®ãããªç¶æ³ã§ã¯ãããè€éãªãã¬ãŒãµãŒãé£èªå解é€ããŒã«ãDBIãªã©ã䜿çšãããŸãã ããã«ããããããããã¹ãŠã¯ãã¬ãŒãµãŒã«ããæ å ±ã®åŒãæããšåæã«åž°çããŸãã ã¢ã«ãŽãªãºã ãã¢ã¯ã»ã¹ã§ããã¢ãã¬ã¹ãç¥ã£ãŠããã°ãããã«é¢ããååãªæçšãªæ å ±ãåéããŸãã
0x04ã ãã¹ããããã³ãŒã«åæ
ãã©ãã¯ããã¯ã¹ããåŒãåºãããšãã§ããéèŠãªæ å ±ã¯ããã¹ããããåŒã³åºãã«é¢ããæ å ±ã§ãã ãããã¯ãWinAPIåŒã³åºããã©ã€ãã©ãªé¢æ°ãã¢ããªã±ãŒã·ã§ã³èªäœã®é¢æ°ã§ãã ãã®ãããªæ å ±ã¯ãä¿è·ãããã¢ã«ãŽãªãºã ã®å éšæ§é ãšäŸåé¢ä¿ããã詳现ã«èª¿æ»ããã®ã«åœ¹ç«ã¡ãŸãã
æãåçŽãªã±ãŒã¹ã§ã¯ããã¹ããããåŒã³åºããåæããããã«ãå®è¡å¯èœãã¡ã€ã«ã®æ§é ã«é¢ããæ¢ç¥ã®æ å ±ã䜿çšã§ããŸãã ã€ãŸããå€æŽãããã³ãŒããã©ã®ã»ã°ã¡ã³ãã«ããããç¥ããšãå€éšé¢æ°ã®åŒã³åºãã«å¯Ÿå¿ãããã®ã»ã°ã¡ã³ãããã®ãã¹ãŠã®åºå£ã远跡ã§ããŸãã ãããŠãããã¯å®éã«ã¯ã©ã€ãã©ãªé¢æ°ã«å¯ŸããŠã¯æ©èœããŸãããããã°ã©ã èªèº«ã®é¢æ°ãåŒã³åºããšåé¡ãçºçããå¯èœæ§ããããŸãã äžèšã®ã©ããã§è¿°ã¹ãããã«ãä¿è·ãããã³ãŒããåãåãããã®ä»£ããã«ãããã¯ã¿ãŒã¯ç¬èªã®ã³ãŒãã®äžéšïŒå€æŽãããã°ã©ããä»®æ³ãã·ã³ïŒã眮ãããšãã§ããŸãã ãããã£ãŠãã³ãŒãã®å®è¡ããã¬ããã»ã¯ã·ã§ã³ããã¢ããªã±ãŒã·ã§ã³ã³ãŒãã»ã¯ã·ã§ã³ã«ç§»ã£ãå Žåããããåã蟌ã¿é¢æ°ã®åŒã³åºãã§ãããå€æŽãããã°ã©ãã®äžéšã®å®è¡ã§ã¯ãªããšããä¿èšŒã¯ãããŸããã
ãã®åé¡ã®è§£æ±ºçããŸãããªã確ççã§ãã ãŸããæè»ãªãã¬ãŒãµãŒãå¿ èŠã§ããããšãã°ãæåŸã«OllyDbgã«çµã¿èŸŒãŸãããã¬ãŒãµãŒã䜿çšãããšãã«ã Intel Pinãã¬ãŒã ã¯ãŒã¯ã䜿çšã§ããŸãã 第äºã«ãã³ãŒãã»ã¯ã·ã§ã³ã«ããã¬ããŒãžãé€ããŠããã¹ããããåŒã³åºãã®ã¿ããã°ã«èšé²ã§ãããé©åãªãã¬ãŒã¹ã«ãŒã«ãäœæããå¿ èŠããããŸãã ã©ã€ãã©ãªé¢æ°åŒã³åºããå®çŸ©ããå Žåã¯ã調æ»äžã®ã¢ãžã¥ãŒã«ã«å±ããã¡ã¢ãªé åå€ãžã®å¶åŸ¡ã®ç§»åãä¿®æ£ããã«ãŒã«ãäœæããã ãã§ååã§ãã ã»ãšãã©ã®å Žåãããã¯äžéšã®ã©ã€ãã©ãªãžã®å¶åŸ¡ã®ç§»è¡ã«ãªããŸãããäžéšã®éæšæºçãªç¶æ³ã§ã¯ãäžéšã®ããŒã¹ã«äŸåããªããã¬ããã³ãŒãã§å¶åŸ¡ã®ç§»è¡ãå®è¡ã§ããŸãã ãã ãããã®ãããªç¹æ®ãªã±ãŒã¹ã¯èæ ®ããŸããã ãã ããããã°ã©ã èªäœã®ãã¹ããããåŒã³åºããã©ãããã°ããã§ããïŒ
ãããã¯ãããããŒã°çœ²åã«ãã£ãŠãã¹ããããé¢æ°ãå®çŸ©ã§ããŸãã ã³ã³ãã€ã©ãŒã¯éåžžãé¢æ°ã«ããªãäžè¬çãªå€èŠ³ãäžããŸãã
ãã³ãã¬ãŒãããããŒã°é¢æ°
ã€ãŸããé£èªåãããã³ãŒãïŒãã¬ããã»ã¯ã·ã§ã³ïŒããã¢ããªã±ãŒã·ã§ã³ã³ãŒãã»ã¯ã·ã§ã³ã«å¶åŸ¡ãæ»ãå Žåãææ¡ãããããããŒã°ã®åã«ããInt3ãRetnåœä»€ã確èªããäºåæºåããã眲åã§ããããŒã°ãæ€èšŒããããšãã§ããŸãã ã³ã³ãã€ã©ãŒã¯ãç¹ã«æé©ååŸã«ãã³ãŒãã«äœã§ãè©°ã蟌ãããšãã§ããã®ã§ãããã¯åžžã«å©ãã«ãªããšã¯éããŸããããããã¯äœãããŸããã
ãŸããSafengineã®ãã¬ããã®é£èªåã«1ã€ã®å°ããªæ¬ é¥ãããããšã«æ°ä»ããŸãããããã¯ä»ã®ãã¬ããã«ã¯ååšããå¯èœæ§ããããŸãããVMProtectã«ã¯ãããŸããã æ¬ ç¹ã¯ããããã¯ã¿ãŒãäžéšã®é¢æ°ãå€æŽãããã®äžã«å¥ã®å€æŽãããé¢æ°ãžã®åŒã³åºããããå Žåããã¹ããããé¢æ°ã¯ãå€æŽãããã³ãŒãã§ã¯ãªããå ã®ã¢ãã¬ã¹ã«ããã¢ããã¿ãŒïŒjmpåœä»€ïŒããåŒã³åºãããããšã§ãã ãŸããå€æŽãããã³ãŒãããã®æ å ±ã®æŒæŽ©ã§ãããããã¬ãŒãµãŒã«ãŒã«ã®äœæã«äœ¿çšã§ããŸãã ããšãã°ãVMProtectã§ã¯ããã¹ããããå€æé¢æ°ã¯ãã¬ããã»ã°ã¡ã³ãã§ããã«åŒã³åºãããŸããããã®æ¹æ³ã§ãã¹ããããåŒã³åºããå®çŸ©ããããšã¯ã§ããŸããã ããããããã®æ¬ é¥ã¯Safengineã®ãã¢çã«ã®ã¿ååšããŸãã
Intel Pinã®ãã¬ãŒãµãŒã®ãœãŒã¹ã³ãŒãã§èšäºãè©°ãŸãããããã§ã¯ãããŸããããèšäºãæ°ã«å ¥ã£ããããã¬ãŒãµãŒã«é¢ããèšäºãå¥ã«æžãããšãã§ããŸãã
0x05ã ã°ã©ãå埩ãå®è¡ãã
ç§ãã¡ã¯ã¿ãªãããŸããŸãªæ¹æ³ã§ããããæ¹æ³ãè©Šããå€ç°ã³ãŒãã®å®å šãªåæãåé¿ããããšããŸããããé£èªå解é€ãšä»®æ³åã¯ç¥è©±ããã¯ã»ã©é ããã®ã§ãã çŸå®ã«ã¯ããã®ãããªæè¡ã¯éåžžã«è€éã§ãã²ããŸãããŠæžãããŠããªãã ãã§ãã 倧åŠããŠã€ã«ã¹å¯Ÿçç 究æã®å°é家ã¯ããã§ã«ãã®åéã匷åãã€ã¡ã€ã³ã§ç¿åŸããŠãããå®è£ ã®ããã®è±å¯ãªããŒã«ã»ãããæã£ãŠãããšæããŸãã æ®å¿µãªãããç§ã¯ãã®ãããªæè¡ã䜿çšããæ £ç¿ã«ããŸã粟éããŠãããããããã«ã€ããŠäœãèšãããšã¯ãããŸããããããããããã§ããããããã¯ãŒã«ã§ããããšãé€ããŠ:)
ãã®åé¡ã«é¢ããç¥èãšçµéšãããã°ãã³ã¡ã³ãã«ãªã³ã¯ãããã€ãå ¥ããŠããã ããã°å¹žãã§ãã
0x06ã ãããã«
ã芧ã®ãšããããã©ãã¯ããã¯ã¹ã¯å®éã«ã¯ããã»ã©é»ã§ã¯ãããŸããã åéãããæ å ±ã«åºã¥ããŠãä¿è·ãããã¢ã«ãŽãªãºã ã®ããžãã¯ãéšåçã«åŸ©å ããå Žåã«ãã£ãŠã¯ååãªéã«ããããšãã§ããŸãã
äžè¬çã«ãä»®æ³åãšçªç¶å€ç°ã®ãã¯ãããžãŒã䜿çšããå¯èœæ§ããå°çšã®ã³ã³ãã€ã©ãŒã«ãã£ãŠã®ã¿çºæ®ãããããšãæåã ãšæããŸãã çµå±ã®ãšãããã³ã³ãã€ã©ã¯ãããã¯ã¿ãŒãšã¯ç°ãªããä¿è·ãããã³ãŒãã«é¢ããã»ãŒå®å šãªæ å ±ãæã¡ãä¿è·ãããã³ãŒãã®å Žæãšå€èŠ³ãç°¡åã«æäœã§ããŸãã ã³ã³ãã€ã©ãŒã«ããã€ãã®ãã³ããå®è£ ãããšãããã°ã©ããŒãç¹å®ã®é¢æ°ããã³ã¡ãœããã®é£èªåã®è€éãã®åºŠåããç¬ç«ããŠéžæã§ããããã«ãªããä¿è·ã®å¹ççãªåæ£ããããã£ãŠè² è·ãæäŸãããŸãã
æåŸã«ãé£èªåãããã³ãŒããéã«ããã¹ãã«ããã¹ãããå Žåã¯ã ãã®crackmeã解決ããããšãææ¡ããŸãã
ãæž èŽããããšãããããŸããã