viPlugin插件破解程序

dev
lixiangrong 2016-02-02 15:15:26 +08:00
parent 368a94cc4f
commit 54167ec2b9
5 changed files with 135 additions and 32 deletions

View File

@ -1,32 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.7.0_60">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@ -0,0 +1,5 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding/<project>=UTF-8

View File

@ -76,6 +76,11 @@
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.6</version>
</dependency>
</dependencies>
<build>
<finalName>useful-code</finalName>

View File

@ -0,0 +1,82 @@
package osc.git.eh3.viplugin;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import org.apache.commons.codec.binary.Base64;
public class CheckLicenseFile {
private static final String publicKey = "308201b83082012d";
private static SecretKeySpec key;
private static Cipher cipher;
private static byte[] linebreak = new byte[0];
private static Base64 coder;
static {
try {
key = new SecretKeySpec("308201b83082012d".getBytes(), "AES");
cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
coder = new Base64(32, linebreak, true);
} catch (Throwable t) {
t.printStackTrace();
}
}
public static boolean checkLicenseLocations(String[] paths) throws Exception {
String path = "";
boolean found = false;
for (int i = 0; i < paths.length; i++) {
path = paths[i] + "viPlugin2.lic";
if (new File(path).exists()) {
found = true;
break;
}
path = paths[i] + "viplugin2.lic";
if (new File(path).exists()) {
found = true;
break;
}
}
if (!found) {
throw new Exception("License should be in one of the following locations:\n" + paths[0] + "\n" + paths[1]);
}
return checkLicenseFile(path);
}
private static boolean checkLicenseFile(String fileName) throws Exception {
char[] buffer = new char[(int) new File(fileName).length()];
try {
FileReader fileReader = new FileReader(fileName);
fileReader.read(buffer);
fileReader.close();
} catch (FileNotFoundException e) {
throw new Exception("License file not found: " + fileName);
} catch (IOException e) {
throw new Exception("Can't read license file: " + fileName);
}
FileReader fileReader;
String license = new String(buffer);
if (!decrypt(license)) {
throw new Exception("Invalid license found: " + fileName);
}
return true;
}
public static synchronized String encrypt(String name, String email) throws Exception {
String plainText = name + "viPlugin 2.0" + email;
cipher.init(1, key);
byte[] cipherText = cipher.doFinal(plainText.getBytes());
return new String(coder.encode(cipherText));
}
public static synchronized boolean decrypt(String codedText) throws Exception {
byte[] encypted = coder.decode(codedText.getBytes());
cipher.init(2, key);
byte[] decrypted = cipher.doFinal(encypted);
String decoded = new String(decrypted);
return decoded.contains("viPlugin 2.0");
}
}

View File

@ -0,0 +1,11 @@
package osc.git.eh3.viplugin;
public class CreateLicense {
@SuppressWarnings("static-access")
public static void main(String[] args) throws Exception {
CheckLicenseFile licenseFile = new CheckLicenseFile();
String valueString = licenseFile.encrypt("elvin_lee", "elvin_lee@126.com");
System.out.println("viPlugin2.lic:" + valueString);
}
}