贴出qc9.0的注册码的判断的那个方法 大家写注册机吧

上一篇 / 下一篇  2007-08-19 20:23:12 / 个人分类:测试

查看( 2598 ) / 评论( 12 )
贴出qc9.0的注册码的判断的那个方法 大家写注册机吧


今天装了一个qc 9.0的试用版 随便输入了一个注册码之后 居然抛出了一堆的异常 (证明qc的测试人员不怎么的呀 这个应该有个 同一的返回值来封装的嘛 怎么能随便暴露出来呢)

异常抛出的为

Messages:
Failed to Set Admin Params;
Failed to set Site Admin Parameters;
Failed to update from frec;
Invalid license key - 'NPPPF-WGGGG-RPHWS-UH330';
Failed to initialize license service;
Invalid license key;
Stack Trace:
com.mercury.optane.core.CTdException: Invalid license key
at com.mercury.td.saserver.tools.license.CLicenseEngine.init(CLicenseEngine.java:90)
at com.mercury.td.saserver.directory.CAdminDataDirectory.initLicenses(CAdminDataDirectory.java:177)
wrapped in com.mercury.optane.core.CTdException: Failed to initialize license service
at com.mercury.td.saserver.directory.CAdminDataDirectory.initLicenses(CAdminDataDirectory.java:202)
at com.mercury.td.saserver.directory.CAdminDataDirectory.updateFromFrec(CAdminDataDirectory.java:221)
wrapped in com.mercury.optane.core.CTdException: Invalid license key - 'NPPPF-WGGGG-RPHWS-UH330'
at com.mercury.td.saserver.directory.CAdminDataDirectory.updateFromFrec(CAdminDataDirectory.java:224)
wrapped in com.mercury.optane.core.CTdException: Failed to update from frec
at com.mercury.td.saserver.directory.CAdminDataDirectory.updateFromFrec(CAdminDataDirectory.java:249)
at com.mercury.td.saserver.api.logics.CAdminLogic.setAdminParams(CAdminLogic.java:309)
wrapped in com.mercury.optane.core.CTdException: Failed to set Site Admin Parameters
at com.mercury.td.saserver.api.logics.CAdminLogic.setAdminParams(CAdminLogic.java:333)
at com.mercury.td.saserver.web.CTdSiteAdminServlet.redirectSetAdminParams(CTdSiteAdminServlet.java:739)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.mercury.optane.core.web.CAbsServlet.executeFunction(CAbsServlet.java:554)
wrapped in com.mercury.optane.core.CTdException: Failed to Set Admin Params
at com.mercury.optane.core.web.CAbsServlet.executeFunction(CAbsServlet.java:560)
at com.mercury.optane.core.web.CAbsServlet.processRequest(CAbsServlet.java:535)
at com.mercury.optane.core.web.CAbsServlet.doPost(CAbsServlet.java:418)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:153)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.valves.FastCommonAccessLogValve.invoke(FastCommonAccessLogValve.java:481)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:307)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:385)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:748)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:678)
at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:871)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:534)



看了下qc9.0的模式 用的是war包来部署在jboss下面的 app下面的  于是我就在下面找上面的校验抛出的那个类
但是我找了半天 还是没有那个类  
这时候我想到可能是封装在其他的jar包里面
于是 开始一个一个看 终于在 一个saproxy.jar\com\mercury\td\saserver\tools 的包里面找出了这个文件

用反编译工具看了下 还可以反编译出来 (好像没有加密) 源码如下 (那个大大要是猛给大家写个注册机什么的就好了)



这里 我本来想 反编译了后改下 在扔回去  但是 引用的包实在是太多了
我想这里可以派生个类出来

本人编程能力不行 在这里抛砖引玉 还是那个大大 看看写个注册机

代码太长了 文章发不出来 放在二楼

TAG: 测试

amirfly的个人空间 amirfly 发布于2007-08-18 15:10:48
package com.mercury.td.saserver.tools.license;
import com.mercury.optane.EnLicenseStatus;
import com.mercury.optane.EnLicenseType;
import com.mercury.optane.core.CTdException;
import com.mercury.optane.core.CTdGeneralFunctions;
import com.mercury.optane.core.crypto.license.CLicenseSigner;
import com.mercury.optane.core.frec.CFileRec;
import com.mercury.optane.core.frec.IFileRec;
import java.io.ByteArrayInputStream;
import java.util.*;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;
public class CLicenseEngine
{
    static interface ILicenseConsts
    {
        public static final String UNLIMITED = "unlimited";
        public static final String TERMS = "terms";
        public static final String ISSUED_TO = "issued_to";
        public static final String LICENSE_IDENTIFIER = "license_identifier";
        public static final String EVALUATION = "evaluation";
        public static final String EXPIRATION = "expiration";
        public static final String START_DATE = "start_date";
        public static final String FULL_TEST_DIRECTOR = "full_test_director";
        public static final String ADDITIONAL_DEFECTS = "additional_defects";
        public static final String TOLERANCE = "tolerance";
        public static final String REQUIREMENTS = "requirements";
        public static final String ADVANCED_REPORTS = "advanced_reports";
        public static final String VERSION_C;
        public static final String BUSINESS_PROCESS_TESTING = "business_process_testing";
        public static final String DASHBOARD = "dashboard";
    }

    private String m_license;
    private boolean m_LicenseIsValid;
    private String m_expiration;
    private String m_edition;
    private int m_date;
    private int m_month;
    private int m_year;
    private GregorianCalendar m_expirationTime;
    private float m_tolerance;
    private int m_defects;
    private int m_reqs;
    private int m_tests;
    private int m_components;
    private boolean m_dashboard;
    private boolean m_advanced_reports;
    private boolean m_version_control;
    private String m_startdate;
    private GregorianCalendar m_startTime;
    public CLicenseEngine()
    {
        m_license = null;
        m_LicenseIsValid = false;
        m_expiration = "01/01/1970";
        m_date = 1;
        m_month = 1;
        m_year = 1970;
        m_expirationTime = null;
        m_tolerance = 0.0F;
        m_defects = 1;
        m_reqs = 1;
        m_tests = 1;
        m_components = 1;
        m_dashboard = false;
        m_advanced_reports = false;
        m_version_control = false;
        m_startdate = null;
        m_startTime = null;
    }
    public void init(String license)
    {
        m_license = license;
        m_LicenseIsValid = CLicenseSigner.checkLicense(license);
        if(!m_LicenseIsValid)
        {
            throw new CTdException("Invalid license key");
        } else
        {
            decrypt();
            return;
        }
    }
    private void decrypt()
    {
        Document doc = null;
        try
        {
            SAXBuilder builder = new SAXBuilder();
            doc = builder.build(new ByteArrayInputStream(m_license.getBytes()));
            Element termsEl = doc.getRootElement().getChild("terms");
            String vc = termsEl.getChildText("version_control");
            m_version_control = CTdGeneralFunctions.strToBoolean(vc);
            String reports = termsEl.getChildText("advanced_reports");
            m_advanced_reports = CTdGeneralFunctions.strToBoolean(reports);
            String defects = termsEl.getChildText("full_test_director");
            if(defects.equalsIgnoreCase("unlimited"))
            {
                m_defects = EnLicenseStatus.UNLIMITED.asInt();
                m_reqs = EnLicenseStatus.UNLIMITED.asInt();
                m_tests = EnLicenseStatus.UNLIMITED.asInt();
            } else
            {
                m_defects = Integer.parseInt(defects);
                m_reqs = m_defects;
                m_tests = m_defects;
                defects = termsEl.getChildText("additional_defects");
                if(defects.equalsIgnoreCase("unlimited"))
                {
                    m_defects = EnLicenseStatus.UNLIMITED.asInt();
                } else
                {
                    m_defects += Integer.parseInt(defects);
                }
            }
            String tolerance = termsEl.getChildText("tolerance");
            tolerance = tolerance.substring(0, tolerance.indexOf("%"));
            m_tolerance = 1.0F + Float.parseFloat(tolerance) / 100F;
            m_expiration = termsEl.getChildText("expiration");
            m_edition = termsEl.getChildText("edition");
            if(m_edition == null)
            {
                m_edition = "enterprise";
            }
            Element startEl = termsEl.getChild("start_date");
            if(startEl != null)
            {
                m_startdate = startEl.getText();
            }
            String sDashboard = termsEl.getChildText("dashboard");
            if(sDashboard == null || sDashboard.length() == 0)
            {
                m_dashboard = false;
            } else
            {
                m_dashboard = CTdGeneralFunctions.strToBoolean(sDashboard);
            }
            String sComponents = termsEl.getChildText("business_process_testing");
            if(sComponents == null || sComponents.length() == 0)
            {
                m_components = 0;
            } else
            if(sComponents.equalsIgnoreCase("unlimited"))
            {
                m_components = EnLicenseStatus.UNLIMITED.asInt();
            } else
            {
                m_components = Integer.parseInt(sComponents);
            }
        }
        catch(Exception e)
        {
            throw new CTdException("Unable to load data from license data", e);
        }
        buildExpiration();
    }
amirfly的个人空间 amirfly 发布于2007-08-18 15:12:05
private void buildExpiration()
    {
        if(m_expiration.equalsIgnoreCase("unlimited"))
        {
            return;
        }
        StringTokenizer st = new StringTokenizer(m_expiration, "/");
        m_month = Integer.parseInt(st.nextToken());
        m_date = Integer.parseInt(st.nextToken());
        m_year = Integer.parseInt(st.nextToken());
        m_expirationTime = new GregorianCalendar(m_year, m_month - 1, m_date, 23, 59, 59);
        if(m_startdate != null)
        {
            st = new StringTokenizer(m_startdate, "/");
            int month = Integer.parseInt(st.nextToken());
            int date = Integer.parseInt(st.nextToken());
            int year = Integer.parseInt(st.nextToken());
            m_startTime = new GregorianCalendar(year, month - 1, date, 0, 0, 1);
        }
    }
    public boolean isExpired()
    {
        if(m_expiration.equalsIgnoreCase("unlimited"))
        {
            return false;
        }
        GregorianCalendar now = new GregorianCalendar();
        if(now.after(m_expirationTime))
        {
            return true;
        }
        if(m_startTime != null)
        {
            return m_startTime.after(now);
        } else
        {
            return false;
        }
    }
    public String getEdition()
    {
        return m_edition;
    }
    private int getMaxAllocations(EnLicenseType licType)
    {
        int licTypeValue = licType.asInt();
        switch(licTypeValue)
        {
        case 1: // '\001'
            return m_defects;
        case 2: // '\002'
            return m_tests;
        case 3: // '\003'
            return m_reqs;
        case 13: // '\r'
            return m_components;
        }
        throw new CTdException("Max allocation for license type '" + licType.getName() + "' could not be retieved");
    }
    public boolean isLicenseTypeEnabled(EnLicenseType licType)
    {
        if(isExpired())
        {
            return false;
        }
        switch(licType.asInt())
        {
        case 1: // '\001'
        case 2: // '\002'
        case 3: // '\003'
        case 13: // '\r'
            int maxLicenseAllocations = 0;
            try
            {
                maxLicenseAllocations = getMaxAllocations(licType);
            }
            catch(CTdException e)
            {
                return false;
            }
            if(maxLicenseAllocations == EnLicenseStatus.UNLIMITED.asInt())
            {
                return true;
            }
            return maxLicenseAllocations > 0;
        case 12: // '\f'
            return m_dashboard;
        case 10: // '\n'
            return m_advanced_reports;
        case 9: // '\t'
            return m_version_control;
        case 4: // '\004'
        case 5: // '\005'
        case 6: // '\006'
        case 7: // '\007'
        case 8: // '\b'
        case 11: // '\013'
        default:
            return false;
        }
    }
    public EnLicenseStatus canAllocateLicense(EnLicenseType licType, int currentLicenseUsage)
    {
        if(isExpired())
        {
            return EnLicenseStatus.KEY_EXPIRED;
        }
        switch(licType.asInt())
        {
        case 1: // '\001'
        case 2: // '\002'
        case 3: // '\003'
        case 13: // '\r'
            int maxLicenseAllocations = 0;
            try
            {
                maxLicenseAllocations = getMaxAllocations(licType);
            }
            catch(CTdException e)
            {
                return EnLicenseStatus.DENIED;
            }
            if(maxLicenseAllocations == EnLicenseStatus.UNLIMITED.asInt())
            {
                return EnLicenseStatus.APPROVED;
            }
            if(currentLicenseUsage >= (int)((float)maxLicenseAllocations * m_tolerance))
            {
                return EnLicenseStatus.DENIED;
            }
            if(currentLicenseUsage >= maxLicenseAllocations)
            {
                return EnLicenseStatus.OVERFLOW_ALERT;
            } else
            {
                return EnLicenseStatus.APPROVED;
            }
        case 12: // '\f'
            return m_dashboard ? EnLicenseStatus.APPROVED : EnLicenseStatus.DENIED;
        case 4: // '\004'
        case 5: // '\005'
        case 6: // '\006'
        case 7: // '\007'
        case 8: // '\b'
        case 9: // '\t'
        case 10: // '\n'
        case 11: // '\013'
        default:
            return EnLicenseStatus.DENIED;
        }
    }
    public IFileRec getLicenseStatus(Map used)
    {
        StringBuffer expTime = null;
        expTime = new StringBuffer();
        IFileRec resultFrec = new CFileRec();
        if(m_expiration.equalsIgnoreCase("Unlimited"))
        {
            expTime.append("Unlimited");
        } else
        {
            expTime.append(m_month).append("/").append(m_date).append("/").append(m_year);
            long daysToExpiration = (m_expirationTime.getTime().getTime() - System.currentTimeMillis()) / 0x5265c00L;
            resultFrec.addItem("DaysToExpiration", daysToExpiration);
        }
        resultFrec.addItem("ExpirationDate", expTime.toString());
        int usedLicenses = 0;
        if(used.containsKey(EnLicenseType.BUG))
        {
            usedLicenses = ((Integer)used.get(EnLicenseType.BUG)).intValue();
        } else
        {
            usedLicenses = 0;
        }
        saveLicStatus(EnLicenseType.BUG.getName(), EnLicenseType.BUG.getStatusCaption(), EnLicenseType.BUG, usedLicenses, resultFrec);
        if(used.containsKey(EnLicenseType.LAB))
        {
            usedLicenses = ((Integer)used.get(EnLicenseType.LAB)).intValue();
        } else
        {
            usedLicenses = 0;
        }
        saveLicStatus(EnLicenseType.LAB.getName(), EnLicenseType.LAB.getStatusCaption(), EnLicenseType.LAB, usedLicenses, resultFrec);
        if(used.containsKey(EnLicenseType.REQUIREMENT))
        {
            usedLicenses = ((Integer)used.get(EnLicenseType.REQUIREMENT)).intValue();
        } else
        {
            usedLicenses = 0;
        }
        saveLicStatus(EnLicenseType.REQUIREMENT.getName(), EnLicenseType.REQUIREMENT.getStatusCaption(), EnLicenseType.REQUIREMENT, usedLicenses, resultFrec);
        if(used.containsKey(EnLicenseType.COMPONENTS))
        {
            usedLicenses = ((Integer)used.get(EnLicenseType.COMPONENTS)).intValue();
        } else
        {
            usedLicenses = 0;
        }
        saveLicStatus(EnLicenseType.COMPONENTS.getName(), EnLicenseType.COMPONENTS.getStatusCaption(), EnLicenseType.COMPONENTS, usedLicenses, resultFrec);
        resultFrec.addItem("Tolerance", Math.round((m_tolerance - 1.0F) * 100F));
        resultFrec.addItem(EnLicenseType.VC.getStatusCaption(), CTdGeneralFunctions.booleanToStr(m_version_control));
        resultFrec.addItem(EnLicenseType.ADVANCEDREPORTS.getStatusCaption(), CTdGeneralFunctions.booleanToStr(m_advanced_reports));
        resultFrec.addItem(EnLicenseType.DASHBOARD.getStatusCaption(), CTdGeneralFunctions.booleanToStr(m_dashboard));
        return resultFrec;
    }
    private void saveLicStatus(String name, String caption, EnLicenseType licType, int used, IFileRec outFrec)
    {
        IFileRec licStat = null;
        licStat = new CFileRec();
        licStat.addItem("inuse", used);
        licStat.addItem("max", getMaxAllocations(licType));
        licStat.addItem("name", caption);
        outFrec.addItem(name, licStat.toString());
    }
}
梦想流浪发布于2007-08-19 12:58:22
public void init(String license)
    {
        m_license = license;
        m_LicenseIsValid = CLicenseSigner.checkLicense(license);
        if(!m_LicenseIsValid)
        {
            throw new CTdException("Invalid license key");
        } else
        {
            decrypt();
            return;
        }
    }
梦想流浪发布于2007-08-19 12:59:17
public void init(String license)
    {
        m_license = license;
        m_LicenseIsValid = CLicenseSigner.checkLicense(license);
        if(!m_LicenseIsValid)
        {
            throw new CTdException("Invalid license key");
        } else
        {
            decrypt();
            return;
        }
    }
修改成
梦想流浪发布于2007-08-19 13:00:02
public void init(String license)
    {
        m_license = license;
        m_LicenseIsValid = CLicenseSigner.checkLicense(license);
        if(!m_LicenseIsValid)
        {
            throw new CTdException("Invalid license key");
        } else
        {
            decrypt();
            return;
        }
    }
修改成

public void init(String license)
    {
        m_license = license;
        m_LicenseIsValid = CLicenseSigner.checkLicense(license);
        if(!m_LicenseIsValid)
        {
            decrypt();
            return;
        } else
        {
            decrypt();
            return;
        }
    }
amirfly的个人空间 amirfly 发布于2007-08-19 20:26:06
呵呵 下面还有校验的  不只是这一段 不知道大家看了没有
*快乐的火柴*的个人空间 cooltianhai 发布于2007-09-03 12:00:59
哇!
影子的个人空间 juneyg 发布于2007-09-03 13:28:26
牛人啊
423799223发布于2007-09-03 14:24:10
确实较牛
会破解

太强啦
jxaa133720发布于2007-09-06 21:57:25
其实MERCURY的产品bug挺多的。。。
QC9.0的patch不是特别需要最好别打,打到patch16之后,bug修改历史记录居然没有了,什么玩意。。。
bill_hen发布于2007-09-07 06:02:08
Decompile and post the result publicly is very likely illegal ..........

-----------------------------------
For bug tracking, use BUGZERO, fully supported.
http://www.websina.com/bugzero/
RNB发布于2007-09-12 17:32:01
顶起,那些saproxy.jar等文件在停止QC服务时会被自动删除,启动后又会自动生成,不知道反编译修改后再编译的方法是否可行?
我来说两句

(可选)

我的栏目

日历

« 2024-05-08  
   1234
567891011
12131415161718
19202122232425
262728293031 

我的存档

数据统计

  • 访问量: 2516
  • 日志数: 1
  • 建立时间: 2007-08-19
  • 更新时间: 2007-08-19

RSS订阅

Open Toolbar