java 驗證license 破解手記

1 第一步要先找出vendor ID,並計算出安裝序列號
2 破解wlscgen.exe文件,使之不受狗的控制
3 找出加密文件中feature,製作license


java 驗證license 破解手記:
Parasoft C++ Test Pro v6.5.8.1

C++Test    64.5 MB    (last update 2005-Oct-27)  
http://www.parasoft.com/jsp/downloads/cpptest/cpptest_win32_6.5.8.1_pro.exe

Parasoft.C.Plus.Plus.Test.Pro.v6.5.8.1-SHOCK
這個是有問題的,他只是破解了Toolkit.dll,可以運行C++TestW.exe進行GUI測試的。
可是強大的comandline沒有破解到。這樣你要套用makefile對整個工程進行test就不可能了。

G:\editg\CPPTest65\bin>cpptest t.c
There is no license to run command line.
Please launch C++Test GUI to enter license details.

用c32asm反編譯可以得看到他導入alex.dll的幾個函數驗證license:
ALEX.DLL:??0RegistryKey@@QAE@W4PredefinedKey@0@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@W4Mode@0@W4Access@0@@Z
ALEX.DLL:?isValid@RegistryKey@@QBE_NXZ
......

反編譯ALEX.DLL,分析這些函數,太多,太複雜,找不到關鍵點。
從error message 入手,用winhex搜索ALEX.DLL,包括ansi/unicode,並未發現“There is no license to run command line”字符串。
用uedit對整個bin目錄下所有文件搜索,也未發現。那麼,這一句license error message從那裏冒出來得?

G:\editg\CPPTest65\bin>cpptest t.c之後,
在系統temp目錄下發現一個文件Toolkit16970.log,主要內容如下。
[INFO] Checking main feature...
[INFO] Version: Application: C++Test 6.5
[INFO] License configured
[INFO] Final status: 0
[INFO] checkConfiguration(t):finish
[INFO] cancelOtherThreads:begin
[INFO] cancelOtherThreads:finish
[INFO] checkConfiguration:finish
[INFO] isFeatureConfigurated returned ErrorCode:  -3
[toolkit.modules.common.license.LicenseConfigurationException: isFeatureConfigurated returned ErrorCode:  -3
[  at toolkit.modules.common.license.LicenseUtils.isFeatureConfigurated(LicenseUtils.java:177)
[  at toolkit.modules.common.license.LicenseModule.getFeatureStatus(LicenseModule.java:392)
[  at com.parasoft.cpptest.app.LicenseManager.printErrorMessage(LicenseManager.java:814)
[  at com.parasoft.cpptest.app.LicenseManager.checkLicense(LicenseManager.java:424)
[  at com.parasoft.cpptest.app.ModuleTest.mainSlave(ModuleTest.java:1539)
[  at com.parasoft.cpptest.app.ModuleTest.main(ModuleTest.java:1376)

這時想到這個東西有很大一部分是java寫的。發現bin\jars有一堆.jar文件。
其中有一個license.jar.因爲.jar文件就是zip壓縮的一堆.class文件,
於是用winrar解壓了這個.jar。
可見,LicenseUtils.java的isFeatureConfigurated返回-3,(引起一系列後續處理),表示沒有license。

去下了個Jad - the fast JAva Decompiler,和它的GUI前端FrontEnd Plus v1.04:
http://www.kpdus.com/jad.html#download
順便分析了FrontEnd的註冊碼:
--------------cut--------------------
REGEDIT4

[HKEY_CURRENT_USER\Software\FrontEnd Plus]
"First Name"="readyu"
"Last Name"="#newsmth"
"Serial No"="22249790-678B4188-06D766F0"
--------------end---------------------
反編譯LicenseUtils.class,看函數,我考,是boolean,太爽了,從這裏看,直接return true應該表示成功:
public static synchronized boolean isFeatureConfigurated(LicenseFeature testedLicensefeature, Hashtable featuresStates)
        throws LicenseConfigurationException
    {
        int dfeaturesStatus = getFeatureFailReasonInt(testedLicensefeature, featuresStates);
        if(dfeaturesStatus == 0)
            return true;
        if(dfeaturesStatus == 7 || dfeaturesStatus == 9)
            return false;
        else
            throw new LicenseConfigurationException("isFeatureConfigurated returned ErrorCode: ", dfeaturesStatus);
    }
     
修改思路:     
        if(dfeaturesStatus == 0)
            return true;
直接改爲:
       return true;                  
     
LicenseUtils.class就是JVM的機器碼了,沒法直接改。反編譯出來的LicenseUtils.java也只有閱讀價值,
根本編譯不過。

去下了一個jclasslib,開源的jvm bytecode反彙編工具,看class的JVM彙編指令。
http://puzzle.dl.sourceforge.net/sourceforge/jclasslib/jclasslib_windows_3_0.zip

用jclasslib打開LicenseUtils.class, isFeatureConfigurated的JVM彙編代碼如下:
0 aload_0
1 aload_1
2 invokestatic #15 <toolkit/modules/common/license/LicenseUtils.getFeatureFailReasonInt>
5 istore_2
6 iload_2
7 ifne 12 (+5)
10 iconst_1
11 ireturn
12 iload_2
13 bipush 7
15 if_icmpeq 24 (+9)
18 iload_2
19 bipush 9
21 if_icmpne 26 (+5)
24 iconst_0
25 ireturn
26 new #16 <toolkit/modules/common/license/LicenseConfigurationException>
29 dup
30 ldc #17 <isFeatureConfigurated returned ErrorCode: >
32 iload_2
33 invokespecial #18 <toolkit/modules/common/license/LicenseConfigurationException.<init>>
36 athrow

思路:只要把條件語句
7 ifne 12 (+5)
NOP調即可,不讓它判斷非0跳轉,乖乖的return 1.

可是我不認識java的機器碼,怎麼改呢?不急,去sun公司的網站下一本手冊JVM Specification。
The JavaTM Virtual Machine Specification, Second Edition.  
http://java.sun.com/docs/books/vmspec/  
http://java.sun.com/docs/books/vmspec/download/vmspec.2nded.html.zip

找到CHAPTER 9 Opcode Mnemonics by Opcode,我們要用到的機器碼如下:
00 (0x00) nop
03 (0x03) iconst_0
04 (0x04) iconst_1
28 (0x1c) iload_2
61 (0x3d) istore_2
172 (0xac) ireturn
154 (0x9a) ifne

按照我在前面的分析,只要把  
ifne 12 這一句的三個字節nop掉即可。
用uedit打開LicenseUtils.class,搜索
3d1c9a0005,即以下3句。改爲3d1c000000,後面的用3個NOP.只要改動2個字節就夠了。
5 istore_2
6 iload_2
7 ifne 12 (+5)

把改好的LicenseUtils.class加到license.jar(zip壓縮文件),替換原來的。

測試:
G:\editg\CPPTest65\bin>cpptest t.c

Creating project configuration based on: builtin://VC++6.0
Using project configuration: project://VC++6.0


一是出錯值與程序的關係,比如12被
應用到後的校驗,如果你僅僅改後面的跳轉就不行了,因爲錯誤的值被做成標誌,在後面只要拿來校驗就
麻煩了。所以必須分析出程序對它的操作,是比較還是拿來計算?二是系統出錯不一定是程序本身的問題。
加密公司完全有能力把系統出錯和加密代碼返回的值結何起來,從而讓系統出錯,這樣做的目的是讓破解
者把注意力放到調試系統出錯的問題上,而忽略了程序本身。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章