protected void R() {
txtName = new E(10); // JTextField
txtName.setName("name");
txtCompany = new E(10); // JTextField
txtCompany.setName("company");
txtKey = new E(10); // JTextField
txtKey.setName("key");
txtFloatName = new E(txtName.getDocument(), null, 10);
txtFloatCompany = new E(txtCompany.getDocument(), null, 10);
txtFloatLicense = new E(10);
btnPaste = new JButton("Paste From Clipboard");
btnClear = new JButton("Clear");
radioSingleLicense = new JRadioButton("Single or evaluation license", true);
radioFloatingLicense = new JRadioButton("Floating license");
radioGroup = new ButtonGroup();
radioGroup.add(radioSingleLicense);
radioGroup.add(radioFloatingLicense);
}
public abstract com.A.A.E.B U();
protected abstract void d();
protected abstract void K();
protected abstract void B();
protected abstract void _();
protected abstract void V();
protected abstract void W(String s);
protected void T() {
com.A.A.A.K().J(parent, "<html>The license key you have entered is intended for a <b>floating license server</b>.<br>Please consult your licensing email for download details of the floating license server.<br><br>If you already have an installation of the floating license server, please add this key<br>to the file <tt>license.txt</tt> in your floating license server installation.", 0);
}
protected boolean alwaysFalse() {
return false;
}
protected void I() {
setLayout(new MigLayout("insets 0", "[grow]", (new StringBuilder()).append(S() ? "[]unrel" : "").append("[grow]").toString()));
if (S()) {
add(radioSingleLicense, "split");
add(radioFloatingLicense, "wrap");
}
B = new CardLayout();
A = new JPanel(B);
A.add(G(), "single");
A.add(A(), "floating");
B.show(A, "single");
add(A, "grow");
a();
}
private JPanel G() {
JPanel jpanel = new JPanel(new MigLayout("insets 0, wmin 350px", "[][grow]", "[][]para[][]para[]"));
jpanel.add(new JLabel("Name: "));
jpanel.add(txtName, "growx, wrap");
jpanel.add(new JLabel("Company: "));
jpanel.add(txtCompany, "growx, wrap");
jpanel.add(new JLabel("License key: "));
jpanel.add(txtKey, "growx, wrap");
jpanel.add(F(), "alignx 100%, span, wrap");
jpanel.add(new e("If you have received the license key by e-mail, you can copy the entire e-mail to the clipboard and use the \"Paste from clipboard\" button to extract the license key."), "growx, span");
return jpanel;
}
private JPanel A() {
JPanel jpanel = new JPanel(new MigLayout("insets 0, wrap", "[][grow]", (new StringBuilder()).append("[][]para[][]").append(O()).toString()));
jpanel.add(new JLabel("Name: "));
jpanel.add(txtFloatName, "growx");
jpanel.add(new JLabel("Company: "));
jpanel.add(txtFloatCompany, "growx");
jpanel.add(new JLabel("License server: "));
jpanel.add(txtFloatLicense, "growx");
jpanel.add(new JLabel("(host name or IP address)"), "skip");
D(jpanel);
return jpanel;
}
private boolean validInput() {
if (txtName.getText().trim().length() == 0) {
W("Please enter a name.");
if (radioSingleLicense.isSelected())
txtName.requestFocus();
else
txtFloatName.requestFocus();
return false;
}
if (radioSingleLicense.isSelected() && L().length() == 0) {
W("Please enter a license key.");
txtKey.requestFocus();
return false;
}
if (radioFloatingLicense.isSelected() && c().length() == 0) {
W("Please enter a license server.");
txtFloatLicense.requestFocus();
return false;
} else {
return true;
}
}
private void b() {
Transferable transferable = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
if (transferable != null)
try {
Reader reader = DataFlavor.getTextPlainUnicodeFlavor().getReaderForText(transferable);
BufferedReader bufferedreader = new BufferedReader(reader);
String s;
String s1;
for (s = null; (s1 = bufferedreader.readLine()) != null && (s = Q(s1)) == null;) ;
if (s != null)
txtKey.setText(s);
else
N();
} catch (UnsupportedFlavorException unsupportedflavorexception) {
N();
} catch (IOException ioexception) {
N();
}
}
private String Q(String s) {
int i = s.indexOf("E-");
if (i == -1)
i = s.indexOf("T-");
if (i == -1)
i = s.indexOf("L-");
if (i == -1)
i = s.indexOf("A-");
if (i == -1)
i = s.indexOf("S-");
if (i == -1)
return null;
int j = s.indexOf('"', i);
if (j == -1)
j = s.indexOf(' ', i);
if (j == -1)
return s.substring(i);
else
return s.substring(i, j);
}
private void N() {
W("No license key was found on the clipboard.");
}
public boolean C() {
int i = U().F0();
if (i != -1 && i < 0) {
if (com.A.A.A.K().B(this, "No valid license has been entered. Would you like to quit the application?", com.A.A.B.B.D, com.A.A.B.B.D, 2) == com.A.A.B.B.C) {
try {
System.exit(1);
} catch (Throwable throwable) {
}
return false;
} else {
return false;
}
} else {
return true;
}
}
}
int i = b1.F3(strKey, strName, strCompany); 这个方法的代码实现是
那个这个B类中的F3方法是切入点,代码如下:
/**
* Check License status<br/>
* return values:<br/>
* 0 OK
* -1 OK
* -2
* -3
* -4 Server invalid
* -5 communicating error
* -6
* -8
* -9
* -10
* -11
* @param key
* @param name
* @param company
* @return status
*/
public int F3(String key, String name, String company) {
if (key == null)
key = l;
if (key.startsWith("FLOAT:")) { // Check float
String s4 = key.substring("FLOAT:".length());
int i1 = -1;
int j1 = s4.lastIndexOf(':');
if (j1 > -1) {
try {
i1 = Integer.parseInt(s4.substring(j1 + 1));
} catch (NumberFormatException numberformatexception) {
}
s4 = s4.substring(0, j1);
}
int k1 = E9();
int l1 = com.A.A.E.F.C(s4, i1, k1, name, company, F1(), E6() != null ? this : null);
u = com.A.A.E.F.L();
EC(l1 > 0 || l1 == -1);
return l1;
} else {
// Check License only
return E0(key);
}
}
包含两个部分,一个是针对 FLOAT license的,另外一个是针对 普通授权的 E0 这个方法
protected abstract int E0(String s1); 这个E0是抽象的,需要在类库中,搜索,
//public class D extends F
//{
//
// public D()
// {
// }
//
// protected int K()
// {
// return 6; // JProfiler 版本好
// }
//
// protected char[] A()
// {
// return (new char[] {
// 'J' // J 代表 JProfiler
// });
// }
//
// public int M(String licenseKey)
// {
// if(licenseKey.startsWith("F-"))
// return -11;
// A a = new A(licenseKey); // 生成授权对象
// int i = a.M(); // 计算授权状态,同时也代表了 试用版本的过期时间
// if(i == -3 || i == -2)
// return i;
// String s1 = a.C();
// String s2 = a.K();
// if(s1 == null || s2 == null)
// return -3;
// if(!H(s2, s1, 7, 38, 11)) // 这个地方是关键点
// return J(licenseKey);
// else
// return a.M();
// }
//}
Java部分校验的最终处理部分
protected static boolean H(String s, String s1, int i, int j, int k) {
if (s1 == null)
return false;
char ac[] = s1.toCharArray();
int l = 0;
char ac1[] = ac;
int i1 = ac1.length;
for (int j1 = 0; j1 < i1; j1++) {
char c = ac1[j1];
l += c;
}
public String C()
{
int i = E.indexOf('#');
if(i > -1)
return E.substring(0, i);
else
return E;
}
public String K()
{
int i = E.indexOf('#');
if(i > -1)
return E.substring(i + 1);
else
return null;
}
private static int A(String s, int i, int j)
{
int k = i;
for(int l = 0; l < j; l++)
{
k = s.indexOf('-', k);
if(k == -1)
return -1;
k++;
if(s.length() <= k)
return -1;
}
//
// main.m
// jprofiler
//
// Created by on 12-1-4.
// Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//
#include <mach-o/dyld.h>
#import <Foundation/Foundation.h>
char *getHash(char *hash, char *buf, int len, int key1, int key2, int key3) {
int sum = 0;
int i = 0;
for (; i < len; i++) {
sum += (hash[i]);
}
int l1, l2, l3;
l1 = sum % key1;
l2 = sum % key2;
l3 = sum % key3;
sprintf(buf, "%d%d%d", l1, l2, l3);
return buf;
}
// Name: checkLicenseKey__14LicenseCheckerPCcb Linux
// Name: __ZN14LicenseChecker15checkLicenseKeyEPKcb Mac OS X
// Type: int checkLicenseKey(char const *,bool)
typedef int (*CheckFunc)(char const *str, int b);
// Name: isChecksumValid__14LicenseCheckerPCc Linux
// Name: __ZN14LicenseChecker15isChecksumValidEPKc Mac OS X
// Type: int isChecksumValid(char *s)
typedef int (*IsChecksumValid)(char *s);
// Name: clearCRC32__FPUi Linux
// Name: __Z10clearCRC32Pj Mac OS X
// Type: int clearCRC32(char *s)
typedef int (*ClearCRC32)(unsigned int *crcValue);
// Name: addCrc32b__FPUiPCci Linux
// Name: __Z9addCrc32bPjPKci Mac OS X
// Type: int addCrc32b(unsigned int *, char const *, int)
typedef int (*AddCrc32b)(unsigned int * crcValue, char const *str, int len);
// Name: getCRC32__FPUiPCUi Linux
// Name: __Z8getCRC32PjPKj Mac OS X
// Type: int getCRC32(unsigned int *, unsigned int const *)
typedef int (*GetCRC32)(unsigned int *crcValue,
unsigned int const *oldCRCValue);
// Name: calculateChecksum__14LicenseCheckerUiPcb Linux
// Name: __ZN14LicenseChecker17calculateChecksumEjPcb Mac OS X
// Type: int calculateChecksum(unsigned int, char *, bool)
typedef int (*CalculateChecksum)(unsigned int crcValue, char *content, int b);
char *nl = (char*)(malloc(totalLen));
sprintf(nl,"%s-J%s-%s#%s-",licType,version,user,userID);
if(isTrail){
// TODO Get Current time and add expired days and gen yyyy.mm.dd-days
sprintf(nl,"%s-J%s-%s#%s-",licType,version,user,userID);
}
lic = nl;
bool b = NSAddLibrary("./jprofiler.dylib");
if(b){