• TextMate爆破手记 - [俺的专业]

    2008-01-12

    版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
    http://hlinzhou.blogbus.com/logs/13746756.html

    恩,这个传说中超级好用的TextMate是要注册的:

    俺们且利用考试与考试的间隙来尝试一下Mac OS X下程序的破解。
    首先找到TextMate主程序的所在:/Applications/TextMate.app/Contents/MacOS/TextMate,将其copy到Win下,万能的IDA Pro大神竟然无法识别:(。Google后被告知可用Mac OS X自带的otool -tV反汇编之。
    zhang-yingdediannao:~ cherry$ otool -tV /Applications/TextMate.app/Contents/MacOS/TextMate > dis.asm
    查找敏感关键字
    zhang-yingdediannao:~ cherry$ grep -i license dis.asm
    000071c6 movl _OakRegistrationLicenseKey,%esi
    -[OakRegistrationManager setLicenseKey:]:
    -[OakRegistrationManager lostLicense:]:
    -[OakRegistrationManager changeToLicenseInformationView:]:
    -[OakRegistrationManager changeLicense:]:
    00085aff cmpl $_LicenseTypes,%ebx
    -[OakRegistrationManager setLicenseInfo:]:
    00085bfc movl $_LicenseTypes,%esi
    恩,貌似都是OakRegistrationManager类的内容,看看这个类都有些什么方法
    zhang-yingdediannao:~ cherry$ grep -i OakRegistrationManager -A 1 dis.asm
    -[OakRegistrationManager resetTrialPeriod:]:
    000846b0 pushl %ebp
    --
    +[OakRegistrationManager sharedInstance]:
    00084728 pushl %ebp
    --
    -[OakRegistrationManager init]:
    00084754 pushl %ebp
    --
    -[OakRegistrationManager canRegister]:
    00084854 pushl %ebp
    --
    -[OakRegistrationManager ownerPortrait]:
    00084864 pushl %ebp
    --
    -[OakRegistrationManager setLicenseKey:]:
    000848d6 pushl %ebp
    --
    -[OakRegistrationManager orderFrontRegistrationPanel:]:
    00084912 pushl %ebp
    --
    -[OakRegistrationManager windowWillClose:]:
    00084b58 movl 0x0022b038,%eax
    --
    -[OakRegistrationManager ok:]:
    00084b74 pushl %ebp
    --
    -[OakRegistrationManager cancel:]:
    00084baa pushl %ebp
    --
    -[OakRegistrationManager continue:]:
    00084be4 pushl %ebp
    --
    -[OakRegistrationManager lostLicense:]:
    00084c1e pushl %ebp
    --
    -[OakRegistrationManager buyOnline:]:
    00084c90 pushl %ebp
    --
    -[OakRegistrationManager changeToLicenseInformationView:]:
    00084e0c pushl %ebp
    --
    +[OakRegistrationManager initialize]:
    000850f8 pushl %ebp
    --
    -[OakRegistrationManager changeLicense:]:
    000856dc pushl %ebp
    --
    -[OakRegistrationManager setOwner:]:
    000859c8 pushl %ebp
    --
    -[OakRegistrationManager setLicenseInfo:]:
    00085b0e pushl %ebp
    gdb调试,在最可疑的几个方法上下断点,发现canRegister方法中被调用的__Z13is_registeredv函数可能是关键:
    __Z13is_registeredv:

    0000715a pushl %ebp
    0000715b movl %esp,%ebp
    0000715d pushl %edi
    0000715e pushl %esi
    ...
    00007942 movl %ecx,%eax
    00007944 popl %ebx
    00007945 popl %esi
    00007946 popl %edi
    00007947 leave
    00007948 ret
    00007949 nop
    尝试让其总是返回1
    (gdb) b *0x00007944
    Breakpoint 1 at 0x7944
    (gdb) r
    ...
    Breakpoint 1, 0x00007944 in is_registered ()
    (gdb) set $eax = 1
    (gdb) c
    重复几次,启动完成后不跳出注册框,点TextMate/Registration显示已经注册。


    恩,那么现在就直接考虑将00007942处的movl %ecx,%eax替换为mov eax, 1,爆破之。
    用Win下的OllyICE试验了一下,mov eax, ecx机器码为89 C8 ,mov al, 1机器码为B0 01(mov eax, 1大于两个字节)。
    由于反汇编代码所显示的地址与文件实际偏移不同,首先需将0x00007942换算为文件实际偏移。
    以start为基准计算offset:
    zhang-yingdediannao:~ cherry$ head dis.asm
    /Applications/TextMate.app/Contents/MacOS/TextMate:
    (__TEXT,__text) section
    start:
    00002f90 pushl $0x00
    00002f92 movl %esp,%ebp
    00002f94 andl $0xf0,%esp
    00002f97 subl $0x10,%esp
    00002f9a movl 0x04(%ebp),%ebx
    00002f9d movl %ebx,0x00(%esp,1)
    00002fa1 leal 0x08(%ebp),%ecx
    zhang-yingdediannao:~ cherry$ otool -t /Applications/TextMate.app/Contents/MacOS/TextMate | grep 00002f90
    00002f90 6a 00 89 e5 83 e4 f0 83 ec 10 8b 5d 04 89 5c 24
    zhang-yingdediannao:~ cherry$ vim /Applications/TextMate.app/Contents/MacOS/TextMate
    %!xxd转换为十六进制,查找6a00 89e5有
    0314f90 6a 00 89 e5 83 e4 f0 83 ec 10 8b 5d 04 89 5c 24
    offset = 0x0314f90 - 0x2f90 = 0x312000
    所以movl %ecx,%eax在文件中的实际位置为:

    0x312000 + 0x7942 = 0x319942
    WinHex编辑,copy回Mac,重新运行TextMate,显示已注册。


    收藏到:Del.icio.us




    评论

  • 能把你已经破解好的textmate程序发给我吗?多谢了,你的方法我看不懂呀。我的邮箱是:hubo606@yahoo.com.cn
    hlinzhou回复lake606说:
    我用的PC,破解是在朋友电脑上做的,早就被她删了。你去pcbeta上看看吧,早有人放出破解版本了。
    2009-10-11 16:37:03
  • 不好意思,我不懂汇编,但是又想破了它,能不能够请你直接说说方法?
    先行谢过了!
    hlinzhou回复will说:
    嗯,我记得最简单的方法好像是把系统时间向后(向前?)调,启动TextMate,关了,然后再把系统时间调回来,TextMate就可以再用30天……
    2008-02-23 12:41:00
  • 写的不错,我都看懂了~