Skip to content

Commit

Permalink
DbVisualizer 11.0.5, 20200924 update
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaguliuxiang committed Sep 24, 2020
1 parent 13a5229 commit dea8a84
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 26 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# DbVisualizer Pro Agent

#### Support (more version need your feedback):
DbVisualizer 10.0.26, 20200224 update
DbVisualizer 11.0.5, 20200924 update

## 使用说明

Expand All @@ -13,12 +13,13 @@ DbVisualizer 10.0.26, 20200224 update
* 直接下载本项目[release](https://github.com/xiaguliuxiang/dbvisualizer-agent/releases)包。

### 自行编译
* Clone本项目源码,pom.xml同级目录执行`mvn package`后即可进行编译。
* 使用`target`目录产出的`dbvisualizer-agent-1.0-SNAPSHOT-jar-with-dependencies.jar`,而非`dbvisualizer-agent-1.0-SNAPSHOT.jar`
* Clone本项目源码,pom.xml同级目录执行`mvn clean package`后即可进行编译。
* 使用`target`目录产出的`dbvisualizer-agent-1.0.3-jar-with-dependencies.jar`,而非`dbvisualizer-agent-1.0.3.jar`
* *如果你不知道我在说什么,最好还是直接下载我编译好的包。*

### 使用帮助
* 如果你已经获得`dbvisualizer-agent.jar`,可以试着执行`java -jar dbvisualizer-agent.jar -h`看看输出的帮助。
* 默认的`License id`已经进入软件服务商的黑名单,建议使用自定义的`License id`,具体参考上一步的帮助输出。

### 配置Agent
1.`dbvisualizer-agent.jar`放在一个你不会随便删除的位置。
Expand All @@ -41,7 +42,7 @@ DbVisualizer 10.0.26, 20200224 update
### 使用KeyGen
* 你得确认已经配置好agent,参考上面说明。
* 当你试着执行`java -jar dbvisualizer-agent.jar -h`时应该可以看到输出的KeyGen参数帮助。
* 请仔细看看每个参数的作用。
* 请仔细看看每个参数的作用,建议使用自定义的`License id`
* 提供了正确的参数运行KeyGen会在终端输出计算好的激活码。
* 将生成的激活码复制出来去激活你的DbVisualizer。
* 举个栗子:`java -jar dbvisualizer-agent.jar -i xiaguliuxiang -n xiaguliuxiang -o https://github.com/xiaguliuxiang/dbvisualizer-agent`
Expand All @@ -51,6 +52,7 @@ DbVisualizer 10.0.26, 20200224 update
* 商业使用请向 [DbVisualizer](https://www.dbvis.com) 购买正版,谢谢合作!
* 本项目使用`GNU General Public License v3.0`开源许可!
* 不允许说我代码写的糟糕。
* 此工具并不太适合我的应用场景早已卸载,这里也就懒得更新了,商业使用的记得支持正版哦!

### 交流
* 给本项目发issue。
Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>site.xiaguliuxiang.crack.dbvisualizer</groupId>
<groupId>com.xiaguliuxiang.crack.dbvisualizer</groupId>
<artifactId>dbvisualizer-agent</artifactId>
<version>1.0.2-SNAPSHOT</version>
<version>1.0.3</version>

<name>DbVisualizer Pro Agent</name>
<url>https://github.com/xiaguliuxiang/dbvisualizer-agent</url>
Expand Down Expand Up @@ -81,8 +81,8 @@
<addClasspath>false</addClasspath>
</manifest>
<manifestEntries>
<Premain-Class>site.xiaguliuxiang.crack.dbvisualizer.agent.Agent</Premain-Class>
<Main-Class>site.xiaguliuxiang.crack.dbvisualizer.Usage</Main-Class>
<Premain-Class>com.xiaguliuxiang.crack.dbvisualizer.agent.Agent</Premain-Class>
<Main-Class>com.xiaguliuxiang.crack.dbvisualizer.Usage</Main-Class>
<Can-Redefine-Classes>true</Can-Redefine-Classes>
<Built-By>[email protected]</Built-By>
<Created-By>[email protected]</Created-By>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package site.xiaguliuxiang.crack.dbvisualizer;
package com.xiaguliuxiang.crack.dbvisualizer;

import com.xiaguliuxiang.crack.dbvisualizer.keygen.KeyGen;
import org.apache.commons.cli.*;
import site.xiaguliuxiang.crack.dbvisualizer.keygen.KeyGen;

/**
* @author [email protected]
Expand Down Expand Up @@ -79,4 +79,5 @@ private static void runCommand(CommandLine commandLine) {

System.out.flush();
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package site.xiaguliuxiang.crack.dbvisualizer.agent;
package com.xiaguliuxiang.crack.dbvisualizer.agent;

import java.lang.instrument.Instrumentation;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package site.xiaguliuxiang.crack.dbvisualizer.agent;
package com.xiaguliuxiang.crack.dbvisualizer.agent;

import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtConstructor;
import javassist.CtField;
import javassist.*;

import java.io.ByteArrayInputStream;
import java.lang.instrument.ClassFileTransformer;
Expand All @@ -16,13 +13,16 @@
*/
public class KeyTransformer implements ClassFileTransformer {
private static final String ENCODED_KEY_SPEC = "sun/security/provider/DSAPublicKeyImpl";
private static final String JAVA_NET_URI = "java/net/URI";
private static final String JAVA_NET_URL = "java/net/URL";
private static final String BLACKLIST_CLASS = "com/onseven/dbvis(/n/h)";

private static final String RAW_KEY = "MIIBtzCCASwGByqGSM44BAEwggEfAoGBAP1/U4EddRIpUt9KnC7s5Of2EbdSPO9EAMMeP4C2USZpRV1AIlH7WT2NWPq/xfW6MPbLm1Vs14E7gB00b/JmYLdrmVClpJ+f6AR7ECLCT7up1/63xhv4O1fnxqimFQ8E+4P208UewwI1VBNaFpEy9nXzrith1yrv8iIDGZ3RSAHHAhUAl2BQjxUjC8yykrmCouuEC/BYHPUCgYEA9+GghdabPd7LvKtcNrhXuXmUr7v6OuqC+VdMCz0HgmdRWVeOutRZT+ZxBxCBgLRJFnEj6EwoFhO3zwkyjMim4TwWeotUfI0o4KOuHiuzpnWRbqN/C/ohNWLx+2J6ASQ7zKTxvqhRkImog9/hWuWfBpKLZl6Ae1UlZAFMO/7PSSoDgYQAAoGAJzCKYi3W8LGq0Dw10OB1H/ICqJ6MKs4KJYABa/rWus1wy4umHQn0s6Il764yTyFi34ft+kJau5NmG0pYw2hfCMS94TXnoruoxnovjstnpabpb9GIDOppAa7YxCxU5qZXW8gbrTz2EnTHXXv00WbYbClpOfda3T7rXlRlENqPtVo=";
private static final String XIAGULIUXIANG_KEY = "MIIBtzCCASwGByqGSM44BAEwggEfAoGBAP1/U4EddRIpUt9KnC7s5Of2EbdSPO9EAMMeP4C2USZpRV1AIlH7WT2NWPq/xfW6MPbLm1Vs14E7gB00b/JmYLdrmVClpJ+f6AR7ECLCT7up1/63xhv4O1fnxqimFQ8E+4P208UewwI1VBNaFpEy9nXzrith1yrv8iIDGZ3RSAHHAhUAl2BQjxUjC8yykrmCouuEC/BYHPUCgYEA9+GghdabPd7LvKtcNrhXuXmUr7v6OuqC+VdMCz0HgmdRWVeOutRZT+ZxBxCBgLRJFnEj6EwoFhO3zwkyjMim4TwWeotUfI0o4KOuHiuzpnWRbqN/C/ohNWLx+2J6ASQ7zKTxvqhRkImog9/hWuWfBpKLZl6Ae1UlZAFMO/7PSSoDgYQAAoGAZkR/ADfOBvyfKSmpiMnjzd2xeSSIy5lUVp6DU5UPmdOJejc8wHsS8lBW2fBN5mJHxXDVI3DHe0WEyK7C3iqwNp13+NiXSJyTE1Ek5IuaQ7QjUd8oQ+epZ6HjgTmwaC5pePlDxDxDjsvcsPy32IzV2Nm7DHH03asV0lF0gqI+Ees=";

@Override
public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined,
ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException {
ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException {
if (className == null) {
return classfileBuffer;
}
Expand All @@ -31,6 +31,18 @@ public byte[] transform(ClassLoader loader, String className, Class<?> classBein
return handleKeySpec(classfileBuffer);
}

if (className.equals(JAVA_NET_URI)) {
return handleNetwork(classfileBuffer);
}

if (className.equals(JAVA_NET_URL)) {
return handleNetwork(classfileBuffer);
}

if (className.matches(BLACKLIST_CLASS)) {
return handleBlacklist(classfileBuffer);
}

return classfileBuffer;
}

Expand All @@ -55,11 +67,8 @@ private byte[] handleKeySpec(byte[] classfileBuffer) throws IllegalClassFormatEx
}
}

ctClass.addField(
CtField.make("private static final byte[] __h_ok=" + b64f + "(\"" + RAW_KEY + "\");", ctClass));
ctClass.addField(
CtField.make("private static final byte[] __h_nk=" + b64f + "(\"" + XIAGULIUXIANG_KEY + "\");",
ctClass));
ctClass.addField(CtField.make("private static final byte[] __h_ok=" + b64f + "(\"" + RAW_KEY + "\");", ctClass));
ctClass.addField(CtField.make("private static final byte[] __h_nk=" + b64f + "(\"" + XIAGULIUXIANG_KEY + "\");", ctClass));
CtConstructor ctConstructor = ctClass.getConstructor("([B)V");
ctConstructor.insertBefore("if(Arrays.equals($1,__h_ok)){$1=__h_nk;}");

Expand All @@ -68,4 +77,42 @@ private byte[] handleKeySpec(byte[] classfileBuffer) throws IllegalClassFormatEx
throw new IllegalClassFormatException(e.getMessage());
}
}

private byte[] handleNetwork(byte[] classfileBuffer) throws IllegalClassFormatException {
try {
ClassPool classPool = ClassPool.getDefault();
CtClass ctClass = classPool.makeClass(new ByteArrayInputStream(classfileBuffer));

CtConstructor ctConstructor = ctClass.getConstructor("(Ljava/lang/String;)V");
ctConstructor.insertBefore("if($1.contains(\"dbvis.com\")){$1=$1.replaceAll(\"(www.)dbvis.com\",\"127.0.0.1\");}");

return ctClass.toBytecode();
} catch (Exception e) {
throw new IllegalClassFormatException(e.getMessage());
}
}

private byte[] handleBlacklist(byte[] classfileBuffer) throws IllegalClassFormatException {
try {
ClassPool classPool = ClassPool.getDefault();
CtClass ctClass = classPool.makeClass(new ByteArrayInputStream(classfileBuffer));

CtMethod[] declaredMethods = ctClass.getDeclaredMethods();
CtClass propertiesClass = classPool.get("java.util.Properties");
for (CtMethod ctMethod : declaredMethods) {
CtClass[] parameterTypes = ctMethod.getParameterTypes();
String returnTypeName = ctMethod.getReturnType().getName();
boolean isBlacklistMethod = (null != parameterTypes) && (parameterTypes.length == 1) && (parameterTypes[0] == propertiesClass);
isBlacklistMethod = isBlacklistMethod && ("boolean".equals(returnTypeName));
if (isBlacklistMethod) {
ctMethod.setBody("{return false;}");
}
}

return ctClass.toBytecode();
} catch (Exception e) {
throw new IllegalClassFormatException(e.getMessage());
}
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package site.xiaguliuxiang.crack.dbvisualizer.keygen;
package com.xiaguliuxiang.crack.dbvisualizer.keygen;

import site.xiaguliuxiang.crack.dbvisualizer.util.Base64;
import com.xiaguliuxiang.crack.dbvisualizer.util.Base64;

import java.nio.charset.StandardCharsets;
import java.security.*;
Expand Down Expand Up @@ -66,12 +66,13 @@ private static String signLicense(Map<String, String> map)

private static String license2String(Map<String, String> map) {
StringBuilder licenseBuilder = new StringBuilder("# DbVisualizer Pro License - 侠骨留香/ChinaPYG 2019\n");
map.forEach((k, v) -> licenseBuilder.append(k + "=" + v).append("\n"));
map.forEach((k, v) -> licenseBuilder.append(k).append("=").append(v).append("\n"));
return licenseBuilder.toString();
}

public static void main(String[] args) throws NoSuchAlgorithmException, InvalidKeyException, SignatureException {
String license = generateLicense("侠骨留香/Www.ChinaPYG.CoM", "侠骨留香", "ChinaPYG");
System.out.println(license);
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package site.xiaguliuxiang.crack.dbvisualizer.util;
package com.xiaguliuxiang.crack.dbvisualizer.util;

import javax.xml.bind.DatatypeConverter;

Expand Down

0 comments on commit dea8a84

Please sign in to comment.