Compare commits
10 Commits
9823d58d00
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| a3b68f7746 | |||
| 3e5cf0680d | |||
| b316de054e | |||
| 7a9f82629c | |||
| cca89ed597 | |||
| f69a459850 | |||
| 6da7112443 | |||
|
|
3388fad6fc | ||
|
|
73b82da0e6 | ||
|
|
2fe0791b46 |
45
privacy.conf.example
Normal file
45
privacy.conf.example
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
[Hide_Plugin]
|
||||||
|
EQUAL,io.zhile.research.ide-eval-resetter
|
||||||
|
EQUAL,Nasller.License
|
||||||
|
EQUAL,nasller
|
||||||
|
EQUAL,manifold.ij
|
||||||
|
|
||||||
|
[Hide_Package]
|
||||||
|
PREFIX,com.janetfilter
|
||||||
|
PREFIX,jdk.internal.org.objectweb.asm
|
||||||
|
|
||||||
|
[Hide_Resource]
|
||||||
|
# EQUAL,/6c81ec87e55d331c267262e892427a3d93d76683.txt
|
||||||
|
PREFIX,/com/janetfilter
|
||||||
|
PREFIX,/com/novitechie
|
||||||
|
|
||||||
|
[Hide_Env]
|
||||||
|
EQUAL,IDEA_VM_OPTIONS
|
||||||
|
EQUAL,CLION_VM_OPTIONS
|
||||||
|
EQUAL,PHPSTORM_VM_OPTIONS
|
||||||
|
EQUAL,GOLAND_VM_OPTIONS
|
||||||
|
EQUAL,PYCHARM_VM_OPTIONS
|
||||||
|
EQUAL,WEBSTORM_VM_OPTIONS
|
||||||
|
EQUAL,WEBIDE_VM_OPTIONS
|
||||||
|
EQUAL,RIDER_VM_OPTIONS
|
||||||
|
EQUAL,DATAGRIP_VM_OPTIONS
|
||||||
|
EQUAL,RUBYMINE_VM_OPTIONS
|
||||||
|
EQUAL,APPCODE_VM_OPTIONS
|
||||||
|
EQUAL,DATASPELL_VM_OPTIONS
|
||||||
|
EQUAL,GATEWAY_VM_OPTIONS
|
||||||
|
EQUAL,JETBRAINS_CLIENT_VM_OPTIONS
|
||||||
|
EQUAL,JETBRAINSCLIENT_VM_OPTIONS
|
||||||
|
EQUAL,JANF_DEBUG
|
||||||
|
EQUAL,JANF_OUTPUT
|
||||||
|
|
||||||
|
[Hide_Property]
|
||||||
|
EQUAL,janf.debug
|
||||||
|
EQUAL,janf.output
|
||||||
|
|
||||||
|
[Ignore_Class]
|
||||||
|
EQUAL,com.janetfilter.core.utils.StringUtils
|
||||||
|
# EQUAL,com.janetfilter.core.utils.DateUtils
|
||||||
|
|
||||||
|
[Ignore_Resource]
|
||||||
|
EQUAL,/com/janetfilter/core/utils/StringUtils.class
|
||||||
|
# EQUAL,/com/janetfilter/core/utils/DateUtils.class
|
||||||
41
src/main/java/com/novitechie/ClassLoaderTransformer.java
Normal file
41
src/main/java/com/novitechie/ClassLoaderTransformer.java
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
package com.novitechie;
|
||||||
|
|
||||||
|
import com.janetfilter.core.plugin.MyTransformer;
|
||||||
|
import jdk.internal.org.objectweb.asm.ClassReader;
|
||||||
|
import jdk.internal.org.objectweb.asm.ClassWriter;
|
||||||
|
import jdk.internal.org.objectweb.asm.tree.*;
|
||||||
|
|
||||||
|
import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author YeloChick
|
||||||
|
*/
|
||||||
|
public class ClassLoaderTransformer implements MyTransformer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHookClassName() {
|
||||||
|
return "java/lang/ClassLoader";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public byte[] transform(String className, byte[] classBytes, int order) throws Exception {
|
||||||
|
ClassReader reader = new ClassReader(classBytes);
|
||||||
|
ClassNode node = new ClassNode(ASM5);
|
||||||
|
reader.accept(node, 0);
|
||||||
|
for (MethodNode m : node.methods) {
|
||||||
|
if ("loadClass".equals(m.name)) {
|
||||||
|
InsnList list = new InsnList();
|
||||||
|
LabelNode L0 = new LabelNode();
|
||||||
|
list.add(new MethodInsnNode(INVOKESTATIC, "com/novitechie/rules/StackTraceRule", "check", "()Z", false));
|
||||||
|
list.add(new JumpInsnNode(IFEQ, L0));
|
||||||
|
list.add(new VarInsnNode(ALOAD, 1));
|
||||||
|
list.add(new MethodInsnNode(INVOKESTATIC, "com/novitechie/rules/LoadClassRule", "check", "(Ljava/lang/String;)V", false));
|
||||||
|
list.add(L0);
|
||||||
|
m.instructions.insert(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ClassWriter writer = new SafeClassWriter(null, null, ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
||||||
|
node.accept(writer);
|
||||||
|
return writer.toByteArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
52
src/main/java/com/novitechie/ClassTransformer.java
Normal file
52
src/main/java/com/novitechie/ClassTransformer.java
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
package com.novitechie;
|
||||||
|
|
||||||
|
import com.janetfilter.core.plugin.MyTransformer;
|
||||||
|
import jdk.internal.org.objectweb.asm.ClassReader;
|
||||||
|
import jdk.internal.org.objectweb.asm.ClassWriter;
|
||||||
|
import jdk.internal.org.objectweb.asm.tree.*;
|
||||||
|
|
||||||
|
import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author YeloChick
|
||||||
|
*/
|
||||||
|
public class ClassTransformer implements MyTransformer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHookClassName() {
|
||||||
|
return "java/lang/Class";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public byte[] transform(String className, byte[] classBytes, int order) throws Exception {
|
||||||
|
ClassReader reader = new ClassReader(classBytes);
|
||||||
|
ClassNode node = new ClassNode(ASM5);
|
||||||
|
reader.accept(node, 0);
|
||||||
|
for (MethodNode m : node.methods) {
|
||||||
|
if ("getResource".equals(m.name) && m.desc.equals("(Ljava/lang/String;)Ljava/net/URL;")) {
|
||||||
|
InsnList list = new InsnList();
|
||||||
|
LabelNode L0 = new LabelNode();
|
||||||
|
list.add(new VarInsnNode(ALOAD, 1));
|
||||||
|
list.add(new MethodInsnNode(INVOKESTATIC, "com/novitechie/rules/ResourceRule", "check", "(Ljava/lang/String;)Z", false));
|
||||||
|
list.add(new JumpInsnNode(IFEQ, L0));
|
||||||
|
list.add(new InsnNode(ACONST_NULL));
|
||||||
|
list.add(new InsnNode(ARETURN));
|
||||||
|
list.add(L0);
|
||||||
|
m.instructions.insert(list);
|
||||||
|
} else if ("getResourceAsStream".equals(m.name) && m.desc.equals("(Ljava/lang/String;)Ljava/io/InputStream;")) {
|
||||||
|
InsnList list = new InsnList();
|
||||||
|
LabelNode L0 = new LabelNode();
|
||||||
|
list.add(new VarInsnNode(ALOAD, 1));
|
||||||
|
list.add(new MethodInsnNode(INVOKESTATIC, "com/novitechie/rules/ResourceRule", "check", "(Ljava/lang/String;)Z", false));
|
||||||
|
list.add(new JumpInsnNode(IFEQ, L0));
|
||||||
|
list.add(new InsnNode(ACONST_NULL));
|
||||||
|
list.add(new InsnNode(ARETURN));
|
||||||
|
list.add(L0);
|
||||||
|
m.instructions.insert(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
||||||
|
node.accept(writer);
|
||||||
|
return writer.toByteArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
41
src/main/java/com/novitechie/CollectionsTransformer.java
Normal file
41
src/main/java/com/novitechie/CollectionsTransformer.java
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
package com.novitechie;
|
||||||
|
|
||||||
|
import com.janetfilter.core.plugin.MyTransformer;
|
||||||
|
import jdk.internal.org.objectweb.asm.ClassReader;
|
||||||
|
import jdk.internal.org.objectweb.asm.ClassWriter;
|
||||||
|
import jdk.internal.org.objectweb.asm.tree.*;
|
||||||
|
|
||||||
|
import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author YeloChick
|
||||||
|
*/
|
||||||
|
public class CollectionsTransformer implements MyTransformer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHookClassName() {
|
||||||
|
return "java/util/Collections";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public byte[] transform(String className, byte[] classBytes, int order) throws Exception {
|
||||||
|
ClassReader reader = new ClassReader(classBytes);
|
||||||
|
ClassNode node = new ClassNode(ASM5);
|
||||||
|
reader.accept(node, 0);
|
||||||
|
for (MethodNode m : node.methods) {
|
||||||
|
if ("shuffle".equals(m.name)) {
|
||||||
|
InsnList list = new InsnList();
|
||||||
|
LabelNode L0 = new LabelNode();
|
||||||
|
list.add(new MethodInsnNode(INVOKESTATIC, "com/novitechie/rules/StackTraceRule", "check", "()Z", false));
|
||||||
|
list.add(new JumpInsnNode(IFEQ, L0));
|
||||||
|
list.add(new VarInsnNode(ALOAD, 0));
|
||||||
|
list.add(new InsnNode(ARETURN));
|
||||||
|
list.add(L0);
|
||||||
|
m.instructions.insert(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
||||||
|
node.accept(writer);
|
||||||
|
return writer.toByteArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,12 +21,12 @@ public class LicensingFacadeTransformer implements MyTransformer {
|
|||||||
for (MethodNode m : node.methods) {
|
for (MethodNode m : node.methods) {
|
||||||
if ("getLicenseExpirationDate".equals(m.name)) {
|
if ("getLicenseExpirationDate".equals(m.name)) {
|
||||||
InsnList list = new InsnList();
|
InsnList list = new InsnList();
|
||||||
list.add(new MethodInsnNode(INVOKESTATIC, "com/novitechie/StackTraceRule", "hook", "()Ljava/util/Date;", false));
|
LabelNode L0 = new LabelNode();
|
||||||
|
list.add(new MethodInsnNode(INVOKESTATIC, "com/novitechie/rules/StackTraceRule", "hook", "()Ljava/util/Date;", false));
|
||||||
list.add(new InsnNode(DUP));
|
list.add(new InsnNode(DUP));
|
||||||
LabelNode labelNode = new LabelNode();
|
list.add(new JumpInsnNode(IFNULL, L0));
|
||||||
list.add(new JumpInsnNode(IFNULL,labelNode));
|
|
||||||
list.add(new InsnNode(ARETURN));
|
list.add(new InsnNode(ARETURN));
|
||||||
list.add(labelNode);
|
list.add(L0);
|
||||||
list.add(new InsnNode(POP));
|
list.add(new InsnNode(POP));
|
||||||
m.instructions.insert(list);
|
m.instructions.insert(list);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
package com.novitechie;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class LoadClassRule {
|
|
||||||
|
|
||||||
private static final List<String> PREVENT_LOAD_PACKAGES = new ArrayList<String>() {
|
|
||||||
{
|
|
||||||
add("com.novitechie");
|
|
||||||
add("com.janetfilter");
|
|
||||||
add("jdk.internal.org.objectweb.asm");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public static void check(String name) throws Exception {
|
|
||||||
if (PREVENT_LOAD_PACKAGES.stream().anyMatch(name::startsWith)) {
|
|
||||||
throw new ClassNotFoundException(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
17
src/main/java/com/novitechie/LogUtil.java
Normal file
17
src/main/java/com/novitechie/LogUtil.java
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
package com.novitechie;
|
||||||
|
|
||||||
|
import com.janetfilter.core.commons.DebugInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author YeloChick
|
||||||
|
*/
|
||||||
|
public class LogUtil {
|
||||||
|
|
||||||
|
public static void printStackTrace() {
|
||||||
|
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
|
||||||
|
DebugInfo.output("===========================stackTrace: ");
|
||||||
|
for (StackTraceElement stackTraceElement : stackTrace) {
|
||||||
|
DebugInfo.output(stackTraceElement.getClassName() + ":" + stackTraceElement.getMethodName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
62
src/main/java/com/novitechie/MethodTransformer.java
Normal file
62
src/main/java/com/novitechie/MethodTransformer.java
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
package com.novitechie;
|
||||||
|
|
||||||
|
import com.janetfilter.core.plugin.MyTransformer;
|
||||||
|
import jdk.internal.org.objectweb.asm.ClassReader;
|
||||||
|
import jdk.internal.org.objectweb.asm.ClassWriter;
|
||||||
|
import jdk.internal.org.objectweb.asm.tree.*;
|
||||||
|
|
||||||
|
import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author YeloChick
|
||||||
|
*/
|
||||||
|
public class MethodTransformer implements MyTransformer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHookClassName() {
|
||||||
|
return "java/lang/reflect/Method";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public byte[] transform(String className, byte[] classBytes, int order) throws Exception {
|
||||||
|
ClassReader reader = new ClassReader(classBytes);
|
||||||
|
ClassNode node = new ClassNode(ASM5);
|
||||||
|
reader.accept(node, 0);
|
||||||
|
for (MethodNode m : node.methods) {
|
||||||
|
if ("invoke".equals(m.name) && m.desc.equals("(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;")) {
|
||||||
|
InsnList list = new InsnList();
|
||||||
|
LabelNode L0 = new LabelNode();
|
||||||
|
list.add(new LdcInsnNode("java.lang.ClassLoader"));
|
||||||
|
list.add(new VarInsnNode(ALOAD, 0));
|
||||||
|
list.add(new FieldInsnNode(GETFIELD, "java/lang/reflect/Method", "clazz", "Ljava/lang/Class;"));
|
||||||
|
list.add(new MethodInsnNode(INVOKEVIRTUAL, "java/lang/Class", "getName", "()Ljava/lang/String;", false));
|
||||||
|
list.add(new MethodInsnNode(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false));
|
||||||
|
list.add(new JumpInsnNode(IFEQ, L0));
|
||||||
|
list.add(new LdcInsnNode("findBootstrapClass"));
|
||||||
|
list.add(new VarInsnNode(ALOAD, 0));
|
||||||
|
list.add(new FieldInsnNode(GETFIELD, "java/lang/reflect/Method", "name", "Ljava/lang/String;"));
|
||||||
|
list.add(new MethodInsnNode(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false));
|
||||||
|
list.add(new JumpInsnNode(IFEQ, L0));
|
||||||
|
list.add(new VarInsnNode(ALOAD, 2));
|
||||||
|
list.add(new InsnNode(ICONST_0));
|
||||||
|
list.add(new InsnNode(AALOAD));
|
||||||
|
list.add(new MethodInsnNode(INVOKESTATIC, "java/lang/String", "valueOf", "(Ljava/lang/Object;)Ljava/lang/String;", false));
|
||||||
|
list.add(new VarInsnNode(ASTORE, 3));
|
||||||
|
// list.add(new LdcInsnNode("com.janetfilter"));
|
||||||
|
list.add(new VarInsnNode(ALOAD, 3));
|
||||||
|
// list.add(new MethodInsnNode(INVOKEVIRTUAL, "java/lang/String", "startsWith", "(Ljava/lang/String;)Z", false));
|
||||||
|
list.add(new MethodInsnNode(INVOKESTATIC, "com/novitechie/rules/BootstrapClassRule", "check", "(Ljava/lang/String;)Z", false));
|
||||||
|
list.add(new JumpInsnNode(IFEQ, L0));
|
||||||
|
list.add(new MethodInsnNode(INVOKESTATIC, "com/novitechie/rules/StackTraceRule", "check", "()Z", false));
|
||||||
|
list.add(new JumpInsnNode(IFEQ, L0));
|
||||||
|
list.add(new InsnNode(ACONST_NULL));
|
||||||
|
list.add(new InsnNode(ARETURN));
|
||||||
|
list.add(L0);
|
||||||
|
m.instructions.insert(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
||||||
|
node.accept(writer);
|
||||||
|
return writer.toByteArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,7 +22,7 @@ public class PluginClassLoaderTransformer implements MyTransformer {
|
|||||||
if ("loadClass".equals(m.name)) {
|
if ("loadClass".equals(m.name)) {
|
||||||
InsnList list = new InsnList();
|
InsnList list = new InsnList();
|
||||||
list.add(new VarInsnNode(ALOAD, 1));
|
list.add(new VarInsnNode(ALOAD, 1));
|
||||||
list.add(new MethodInsnNode(INVOKESTATIC, "com/novitechie/LoadClassRule", "check", "(Ljava/lang/String;)V", false));
|
list.add(new MethodInsnNode(INVOKESTATIC, "com/novitechie/rules/LoadClassRule", "check", "(Ljava/lang/String;)V", false));
|
||||||
m.instructions.insert(list);
|
m.instructions.insert(list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,24 +23,77 @@ public class PluginManagerCoreTransformer implements MyTransformer {
|
|||||||
ClassNode node = new ClassNode(ASM5);
|
ClassNode node = new ClassNode(ASM5);
|
||||||
reader.accept(node, 0);
|
reader.accept(node, 0);
|
||||||
for (MethodNode m : node.methods) {
|
for (MethodNode m : node.methods) {
|
||||||
if ("isPluginInstalled".equals(m.name)) {
|
if ("getPlugins".equals(m.name)) {
|
||||||
InsnList list = new InsnList();
|
InsnList list = new InsnList();
|
||||||
list.add(new MethodInsnNode(INVOKESTATIC, "com/novitechie/StackTraceRule", "check", "()Z", false));
|
LabelNode L0 = new LabelNode();
|
||||||
LabelNode labelNode = new LabelNode();
|
LabelNode L1 = new LabelNode();
|
||||||
list.add(new JumpInsnNode(IFEQ, labelNode));
|
LabelNode L2 = new LabelNode();
|
||||||
|
LabelNode L3 = new LabelNode();
|
||||||
|
list.add(new MethodInsnNode(INVOKESTATIC, "com/novitechie/rules/StackTraceRule", "check", "()Z", false));
|
||||||
|
list.add(new JumpInsnNode(IFEQ, L0));
|
||||||
|
list.add(new FieldInsnNode(GETSTATIC, "com/intellij/ide/plugins/PluginManagerCore", "nullablePluginSet", "Lcom/intellij/ide/plugins/PluginSet;"));
|
||||||
|
list.add(new FieldInsnNode(GETFIELD, "com/intellij/ide/plugins/PluginSet", "allPlugins", "Ljava/util/Set;"));
|
||||||
|
list.add(new VarInsnNode(ASTORE, 0));
|
||||||
|
list.add(new TypeInsnNode(NEW, "java/util/HashSet"));
|
||||||
|
list.add(new InsnNode(DUP));
|
||||||
|
list.add(new MethodInsnNode(INVOKESPECIAL, "java/util/HashSet", "<init>", "()V", false));
|
||||||
|
list.add(new VarInsnNode(ASTORE, 1));
|
||||||
|
list.add(new VarInsnNode(ALOAD, 0));
|
||||||
|
list.add(new MethodInsnNode(INVOKEINTERFACE, "java/util/Set", "iterator", "()Ljava/util/Iterator;", true));
|
||||||
|
list.add(new VarInsnNode(ASTORE, 2));
|
||||||
|
list.add(L2);
|
||||||
|
list.add(new VarInsnNode(ALOAD, 2));
|
||||||
|
list.add(new MethodInsnNode(INVOKEINTERFACE, "java/util/Iterator", "hasNext", "()Z", true));
|
||||||
|
list.add(new JumpInsnNode(IFEQ, L1));
|
||||||
|
list.add(new VarInsnNode(ALOAD, 2));
|
||||||
|
list.add(new MethodInsnNode(INVOKEINTERFACE, "java/util/Iterator", "next", "()Ljava/lang/Object;", true));
|
||||||
|
list.add(new TypeInsnNode(CHECKCAST, "com/intellij/ide/plugins/IdeaPluginDescriptor"));
|
||||||
|
list.add(new VarInsnNode(ASTORE, 3));
|
||||||
|
list.add(new VarInsnNode(ALOAD, 3));
|
||||||
|
list.add(new MethodInsnNode(INVOKEINTERFACE, "com/intellij/ide/plugins/IdeaPluginDescriptor", "getPluginId", "()Lcom/intellij/openapi/extensions/PluginId;", true));
|
||||||
|
list.add(new MethodInsnNode(INVOKEVIRTUAL, "com/intellij/openapi/extensions/PluginId", "getIdString", "()Ljava/lang/String;", false));
|
||||||
|
list.add(new MethodInsnNode(INVOKESTATIC, "com/novitechie/rules/IdeaPluginRule", "check", "(Ljava/lang/String;)Z", false));
|
||||||
|
list.add(new JumpInsnNode(IFNE, L3));
|
||||||
|
list.add(new VarInsnNode(ALOAD, 1));
|
||||||
|
list.add(new VarInsnNode(ALOAD, 3));
|
||||||
|
list.add(new MethodInsnNode(INVOKEINTERFACE, "java/util/Set", "add", "(Ljava/lang/Object;)Z", true));
|
||||||
|
list.add(new InsnNode(POP));
|
||||||
|
list.add(L3);
|
||||||
|
list.add(new JumpInsnNode(GOTO, L2));
|
||||||
|
list.add(L1);
|
||||||
|
list.add(new VarInsnNode(ALOAD, 1));
|
||||||
|
list.add(new InsnNode(ICONST_0));
|
||||||
|
list.add(new TypeInsnNode(ANEWARRAY, "com/intellij/ide/plugins/IdeaPluginDescriptor"));
|
||||||
|
list.add(new MethodInsnNode(INVOKEINTERFACE, "java/util/Set", "toArray", "([Ljava/lang/Object;)[Ljava/lang/Object;", true));
|
||||||
|
list.add(new TypeInsnNode(CHECKCAST, "[Lcom/intellij/ide/plugins/IdeaPluginDescriptor;"));
|
||||||
|
list.add(new InsnNode(ARETURN));
|
||||||
|
list.add(L0);
|
||||||
|
m.instructions.insert(list);
|
||||||
|
} else if ("isPluginInstalled".equals(m.name)) {
|
||||||
|
InsnList list = new InsnList();
|
||||||
|
LabelNode L0 = new LabelNode();
|
||||||
|
list.add(new MethodInsnNode(INVOKESTATIC, "com/novitechie/rules/StackTraceRule", "check", "()Z", false));
|
||||||
|
list.add(new JumpInsnNode(IFEQ, L0));
|
||||||
|
list.add(new VarInsnNode(ALOAD, 0));
|
||||||
|
list.add(new MethodInsnNode(INVOKEVIRTUAL, "com/intellij/openapi/extensions/PluginId", "getIdString", "()Ljava/lang/String;", false));
|
||||||
|
list.add(new MethodInsnNode(INVOKESTATIC, "com/novitechie/rules/IdeaPluginRule", "check", "(Ljava/lang/String;)Z", false));
|
||||||
|
list.add(new JumpInsnNode(IFEQ, L0));
|
||||||
list.add(new InsnNode(ICONST_0));
|
list.add(new InsnNode(ICONST_0));
|
||||||
list.add(new InsnNode(IRETURN));
|
list.add(new InsnNode(IRETURN));
|
||||||
list.add(labelNode);
|
list.add(L0);
|
||||||
m.instructions.insert(list);
|
m.instructions.insert(list);
|
||||||
} else if ("getPlugins".equals(m.name)) {
|
} else if ("isDisabled".equals(m.name)) {
|
||||||
InsnList list = new InsnList();
|
InsnList list = new InsnList();
|
||||||
list.add(new MethodInsnNode(INVOKESTATIC, "com/novitechie/StackTraceRule", "check", "()Z", false));
|
LabelNode L0 = new LabelNode();
|
||||||
LabelNode labelNode = new LabelNode();
|
list.add(new MethodInsnNode(INVOKESTATIC, "com/novitechie/rules/StackTraceRule", "check", "()Z", false));
|
||||||
list.add(new JumpInsnNode(IFEQ, labelNode));
|
list.add(new JumpInsnNode(IFEQ, L0));
|
||||||
list.add(new InsnNode(ICONST_0));
|
list.add(new VarInsnNode(ALOAD, 0));
|
||||||
list.add(new TypeInsnNode(ANEWARRAY, "java/lang/Object"));
|
list.add(new MethodInsnNode(INVOKEVIRTUAL, "com/intellij/openapi/extensions/PluginId", "getIdString", "()Ljava/lang/String;", false));
|
||||||
list.add(new InsnNode(ARETURN));
|
list.add(new MethodInsnNode(INVOKESTATIC, "com/novitechie/rules/IdeaPluginRule", "check", "(Ljava/lang/String;)Z", false));
|
||||||
list.add(labelNode);
|
list.add(new JumpInsnNode(IFEQ, L0));
|
||||||
|
list.add(new InsnNode(ICONST_1));
|
||||||
|
list.add(new InsnNode(IRETURN));
|
||||||
|
list.add(L0);
|
||||||
m.instructions.insert(list);
|
m.instructions.insert(list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,27 @@
|
|||||||
package com.novitechie;
|
package com.novitechie;
|
||||||
|
|
||||||
|
import com.janetfilter.core.Environment;
|
||||||
import com.janetfilter.core.plugin.MyTransformer;
|
import com.janetfilter.core.plugin.MyTransformer;
|
||||||
|
import com.janetfilter.core.plugin.PluginConfig;
|
||||||
import com.janetfilter.core.plugin.PluginEntry;
|
import com.janetfilter.core.plugin.PluginEntry;
|
||||||
|
import com.novitechie.rules.IdeaPluginRule;
|
||||||
|
import com.novitechie.rules.LoadClassRule;
|
||||||
|
import com.novitechie.rules.ResourceRule;
|
||||||
|
import com.novitechie.rules.SystemRule;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class PrivacyPlugin implements PluginEntry {
|
public class PrivacyPlugin implements PluginEntry {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(Environment environment, PluginConfig config) {
|
||||||
|
IdeaPluginRule.initRules(config.getBySection("Hide_Plugin"));
|
||||||
|
LoadClassRule.initRules(config.getBySection("Hide_Package"), config.getBySection("Ignore_Class"));
|
||||||
|
ResourceRule.initRules(config.getBySection("Hide_Resource"), config.getBySection("Ignore_Resource"));
|
||||||
|
SystemRule.initRules(config.getBySection("Hide_Env"), config.getBySection("Hide_Property"));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "PRIVACY";
|
return "PRIVACY";
|
||||||
@@ -20,9 +35,15 @@ public class PrivacyPlugin implements PluginEntry {
|
|||||||
@Override
|
@Override
|
||||||
public List<MyTransformer> getTransformers() {
|
public List<MyTransformer> getTransformers() {
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
|
// new CollectionsTransformer(),
|
||||||
new VMOptionsTransformer(),
|
new VMOptionsTransformer(),
|
||||||
new PluginClassLoaderTransformer(),
|
new PluginClassLoaderTransformer(),
|
||||||
new LicensingFacadeTransformer(),
|
new LicensingFacadeTransformer(),
|
||||||
new PluginManagerCoreTransformer());
|
new PluginManagerCoreTransformer(),
|
||||||
|
new RuntimeMXBeanTransformer(),
|
||||||
|
new SystemTransformer(),
|
||||||
|
new ClassTransformer(),
|
||||||
|
new ClassLoaderTransformer(),
|
||||||
|
new MethodTransformer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
42
src/main/java/com/novitechie/RuntimeMXBeanTransformer.java
Normal file
42
src/main/java/com/novitechie/RuntimeMXBeanTransformer.java
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
package com.novitechie;
|
||||||
|
|
||||||
|
import com.janetfilter.core.plugin.MyTransformer;
|
||||||
|
import jdk.internal.org.objectweb.asm.ClassReader;
|
||||||
|
import jdk.internal.org.objectweb.asm.ClassWriter;
|
||||||
|
import jdk.internal.org.objectweb.asm.tree.*;
|
||||||
|
|
||||||
|
import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author YeloChick
|
||||||
|
*/
|
||||||
|
public class RuntimeMXBeanTransformer implements MyTransformer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHookClassName() {
|
||||||
|
return "sun/management/RuntimeImpl";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public byte[] transform(String className, byte[] classBytes, int order) throws Exception {
|
||||||
|
ClassReader reader = new ClassReader(classBytes);
|
||||||
|
ClassNode node = new ClassNode(ASM5);
|
||||||
|
reader.accept(node, 0);
|
||||||
|
for (MethodNode m : node.methods) {
|
||||||
|
if ("getInputArguments".equals(m.name)) {
|
||||||
|
InsnList list = new InsnList();
|
||||||
|
list.add(new MethodInsnNode(INVOKESTATIC, "com/novitechie/rules/StackTraceRule", "check", "()Z", false));
|
||||||
|
LabelNode labelNode = new LabelNode();
|
||||||
|
list.add(new JumpInsnNode(IFEQ, labelNode));
|
||||||
|
list.add(new LdcInsnNode("sorry, you can not read anything. haha!"));
|
||||||
|
list.add(new MethodInsnNode(INVOKESTATIC, "java/util/Collections", "singletonList", "(Ljava/lang/Object;)Ljava/util/List;", false));
|
||||||
|
list.add(new InsnNode(ARETURN));
|
||||||
|
list.add(labelNode);
|
||||||
|
m.instructions.insert(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ClassWriter writer = new SafeClassWriter(null, null, ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
||||||
|
node.accept(writer);
|
||||||
|
return writer.toByteArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
52
src/main/java/com/novitechie/SystemTransformer.java
Normal file
52
src/main/java/com/novitechie/SystemTransformer.java
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
package com.novitechie;
|
||||||
|
|
||||||
|
import com.janetfilter.core.plugin.MyTransformer;
|
||||||
|
import jdk.internal.org.objectweb.asm.ClassReader;
|
||||||
|
import jdk.internal.org.objectweb.asm.ClassWriter;
|
||||||
|
import jdk.internal.org.objectweb.asm.tree.*;
|
||||||
|
|
||||||
|
import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author YeloChick
|
||||||
|
*/
|
||||||
|
public class SystemTransformer implements MyTransformer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHookClassName() {
|
||||||
|
return "java/lang/System";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public byte[] transform(String className, byte[] classBytes, int order) throws Exception {
|
||||||
|
ClassReader reader = new ClassReader(classBytes);
|
||||||
|
ClassNode node = new ClassNode(ASM5);
|
||||||
|
reader.accept(node, 0);
|
||||||
|
for (MethodNode m : node.methods) {
|
||||||
|
if ("getenv".equals(m.name) && m.desc.equals("(Ljava/lang/String;)Ljava/lang/String;")) {
|
||||||
|
InsnList list = new InsnList();
|
||||||
|
LabelNode L0 = new LabelNode();
|
||||||
|
list.add(new VarInsnNode(ALOAD, 0));
|
||||||
|
list.add(new MethodInsnNode(INVOKESTATIC, "com/novitechie/rules/SystemRule", "checkEnv", "(Ljava/lang/String;)Z", false));
|
||||||
|
list.add(new JumpInsnNode(IFEQ, L0));
|
||||||
|
list.add(new InsnNode(ACONST_NULL));
|
||||||
|
list.add(new InsnNode(ARETURN));
|
||||||
|
list.add(L0);
|
||||||
|
m.instructions.insert(list);
|
||||||
|
} else if ("getProperty".equals(m.name) && (m.desc.equals("(Ljava/lang/String;)Ljava/lang/String;") || m.desc.equals("(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"))) {
|
||||||
|
InsnList list = new InsnList();
|
||||||
|
LabelNode L0 = new LabelNode();
|
||||||
|
list.add(new VarInsnNode(ALOAD, 0));
|
||||||
|
list.add(new MethodInsnNode(INVOKESTATIC, "com/novitechie/rules/SystemRule", "checkProperty", "(Ljava/lang/String;)Z", false));
|
||||||
|
list.add(new JumpInsnNode(IFEQ, L0));
|
||||||
|
list.add(new InsnNode(ACONST_NULL));
|
||||||
|
list.add(new InsnNode(ARETURN));
|
||||||
|
list.add(L0);
|
||||||
|
m.instructions.insert(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
||||||
|
node.accept(writer);
|
||||||
|
return writer.toByteArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,10 +21,10 @@ public class VMOptionsTransformer implements MyTransformer {
|
|||||||
for (MethodNode m : node.methods) {
|
for (MethodNode m : node.methods) {
|
||||||
if ("getUserOptionsFile".equals(m.name)) {
|
if ("getUserOptionsFile".equals(m.name)) {
|
||||||
InsnList list = new InsnList();
|
InsnList list = new InsnList();
|
||||||
list.add(new MethodInsnNode(INVOKESTATIC, "com/novitechie/StackTraceRule", "check", "()Z", false));
|
list.add(new MethodInsnNode(INVOKESTATIC, "com/novitechie/rules/StackTraceRule", "check", "()Z", false));
|
||||||
LabelNode labelNode = new LabelNode();
|
LabelNode labelNode = new LabelNode();
|
||||||
list.add(new JumpInsnNode(IFEQ, labelNode));
|
list.add(new JumpInsnNode(IFEQ, labelNode));
|
||||||
list.add(new InsnNode(ACONST_NULL));
|
list.add(new MethodInsnNode(INVOKESTATIC, "com/novitechie/rules/VMOptionsRule", "hook", "()Ljava/nio/file/Path;", false));
|
||||||
list.add(new InsnNode(ARETURN));
|
list.add(new InsnNode(ARETURN));
|
||||||
list.add(labelNode);
|
list.add(labelNode);
|
||||||
m.instructions.insert(list);
|
m.instructions.insert(list);
|
||||||
|
|||||||
29
src/main/java/com/novitechie/rules/BootstrapClassRule.java
Normal file
29
src/main/java/com/novitechie/rules/BootstrapClassRule.java
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
package com.novitechie.rules;
|
||||||
|
|
||||||
|
import com.janetfilter.core.commons.DebugInfo;
|
||||||
|
import com.novitechie.LogUtil;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author YeloChick
|
||||||
|
*/
|
||||||
|
public class BootstrapClassRule {
|
||||||
|
|
||||||
|
private static final List<String> PREVENT_LOAD_PACKAGES = new ArrayList<String>() {
|
||||||
|
{
|
||||||
|
add("com.janetfilter");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public static boolean check(String name) throws Exception {
|
||||||
|
boolean f = PREVENT_LOAD_PACKAGES.stream().anyMatch(name::startsWith);
|
||||||
|
if (f) {
|
||||||
|
DebugInfo.output("======================LoadBootstrapClass: " + name);
|
||||||
|
LogUtil.printStackTrace();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
33
src/main/java/com/novitechie/rules/IdeaPluginRule.java
Normal file
33
src/main/java/com/novitechie/rules/IdeaPluginRule.java
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
package com.novitechie.rules;
|
||||||
|
|
||||||
|
import com.janetfilter.core.commons.DebugInfo;
|
||||||
|
import com.janetfilter.core.models.FilterRule;
|
||||||
|
import com.novitechie.LogUtil;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author YeloChick
|
||||||
|
*/
|
||||||
|
public class IdeaPluginRule {
|
||||||
|
|
||||||
|
private static List<FilterRule> hidePluginRules = Collections.emptyList();
|
||||||
|
|
||||||
|
public static void initRules(List<FilterRule> hidePluginRules) {
|
||||||
|
IdeaPluginRule.hidePluginRules = hidePluginRules;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean check(String name) {
|
||||||
|
if (checkHidePlugin(name)) {
|
||||||
|
DebugInfo.output("======================Hide Plugin: " + name);
|
||||||
|
LogUtil.printStackTrace();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean checkHidePlugin(String name) {
|
||||||
|
return hidePluginRules.stream().anyMatch(rule -> rule.test(name));
|
||||||
|
}
|
||||||
|
}
|
||||||
37
src/main/java/com/novitechie/rules/LoadClassRule.java
Normal file
37
src/main/java/com/novitechie/rules/LoadClassRule.java
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
package com.novitechie.rules;
|
||||||
|
|
||||||
|
import com.janetfilter.core.commons.DebugInfo;
|
||||||
|
import com.janetfilter.core.models.FilterRule;
|
||||||
|
import com.novitechie.LogUtil;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class LoadClassRule {
|
||||||
|
|
||||||
|
private static List<FilterRule> hidePackageRules = Collections.emptyList();
|
||||||
|
|
||||||
|
private static List<FilterRule> ignoreClassRules = Collections.emptyList();
|
||||||
|
|
||||||
|
public static void initRules(List<FilterRule> hidePackageRules, List<FilterRule> ignoreClassRules) {
|
||||||
|
LoadClassRule.hidePackageRules = hidePackageRules;
|
||||||
|
LoadClassRule.ignoreClassRules = ignoreClassRules;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void check(String name) throws Exception {
|
||||||
|
if (!checkIgnoreClass(name) && checkHidePackage(name)) {
|
||||||
|
DebugInfo.output("======================Hide Class: " + name);
|
||||||
|
LogUtil.printStackTrace();
|
||||||
|
throw new ClassNotFoundException(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean checkHidePackage(String name) {
|
||||||
|
return hidePackageRules.stream().anyMatch(rule -> rule.test(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean checkIgnoreClass(String name) {
|
||||||
|
return ignoreClassRules.stream().anyMatch(rule -> rule.test(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
40
src/main/java/com/novitechie/rules/ResourceRule.java
Normal file
40
src/main/java/com/novitechie/rules/ResourceRule.java
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
package com.novitechie.rules;
|
||||||
|
|
||||||
|
import com.janetfilter.core.commons.DebugInfo;
|
||||||
|
import com.janetfilter.core.models.FilterRule;
|
||||||
|
import com.novitechie.LogUtil;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author YeloChick
|
||||||
|
*/
|
||||||
|
public class ResourceRule {
|
||||||
|
|
||||||
|
private static List<FilterRule> hideResourceRules = Collections.emptyList();
|
||||||
|
|
||||||
|
private static List<FilterRule> ignoreResourceRules = Collections.emptyList();
|
||||||
|
|
||||||
|
public static void initRules(List<FilterRule> hideResourceRules, List<FilterRule> ignoreResourceRules) {
|
||||||
|
ResourceRule.hideResourceRules = hideResourceRules;
|
||||||
|
ResourceRule.ignoreResourceRules = ignoreResourceRules;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean check(String name) {
|
||||||
|
if (!checkIgnoreResource(name) && checkHideResource(name) && StackTraceRule.check()) {
|
||||||
|
DebugInfo.output("======================Hide Resource: " + name);
|
||||||
|
LogUtil.printStackTrace();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean checkHideResource(String name) {
|
||||||
|
return hideResourceRules.stream().anyMatch(rule -> rule.test(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean checkIgnoreResource(String name) {
|
||||||
|
return ignoreResourceRules.stream().anyMatch(rule -> rule.test(name));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
package com.novitechie;
|
package com.novitechie.rules;
|
||||||
|
|
||||||
|
import com.janetfilter.core.commons.DebugInfo;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -23,7 +25,8 @@ public class StackTraceRule {
|
|||||||
for (StackTraceElement stackTraceElement : stackTrace) {
|
for (StackTraceElement stackTraceElement : stackTrace) {
|
||||||
if (!PACKAGE_NAME_PATTERN.matcher(stackTraceElement.getMethodName()).matches()) {
|
if (!PACKAGE_NAME_PATTERN.matcher(stackTraceElement.getMethodName()).matches()) {
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
calendar.add(Calendar.DAY_OF_MONTH, 30);
|
calendar.add(Calendar.DAY_OF_MONTH, 60);
|
||||||
|
DebugInfo.output("===========================getLicenseExpirationDate");
|
||||||
return calendar.getTime();
|
return calendar.getTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
49
src/main/java/com/novitechie/rules/SystemRule.java
Normal file
49
src/main/java/com/novitechie/rules/SystemRule.java
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
package com.novitechie.rules;
|
||||||
|
|
||||||
|
import com.janetfilter.core.commons.DebugInfo;
|
||||||
|
import com.janetfilter.core.models.FilterRule;
|
||||||
|
import com.novitechie.LogUtil;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author YeloChick
|
||||||
|
*/
|
||||||
|
public class SystemRule {
|
||||||
|
|
||||||
|
private static List<FilterRule> hideEnvRules = Collections.emptyList();
|
||||||
|
|
||||||
|
private static List<FilterRule> hidePropertyRules = Collections.emptyList();
|
||||||
|
|
||||||
|
public static void initRules(List<FilterRule> hideEnvRules, List<FilterRule> hidePropertyRules) {
|
||||||
|
SystemRule.hideEnvRules = hideEnvRules;
|
||||||
|
SystemRule.hidePropertyRules = hidePropertyRules;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean checkEnv(String name) {
|
||||||
|
if (checkHideEnv(name) && StackTraceRule.check()) {
|
||||||
|
DebugInfo.output("======================Hide Env: " + name);
|
||||||
|
LogUtil.printStackTrace();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean checkProperty(String name) {
|
||||||
|
if (checkHideProperty(name) && StackTraceRule.check()) {
|
||||||
|
DebugInfo.output("======================Hide Property: " + name);
|
||||||
|
LogUtil.printStackTrace();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean checkHideEnv(String name) {
|
||||||
|
return hideEnvRules.stream().anyMatch(rule -> rule.test(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean checkHideProperty(String name) {
|
||||||
|
return hidePropertyRules.stream().anyMatch(rule -> rule.test(name));
|
||||||
|
}
|
||||||
|
}
|
||||||
30
src/main/java/com/novitechie/rules/VMOptionsRule.java
Normal file
30
src/main/java/com/novitechie/rules/VMOptionsRule.java
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
package com.novitechie.rules;
|
||||||
|
|
||||||
|
import com.janetfilter.core.commons.DebugInfo;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author YeloChick
|
||||||
|
*/
|
||||||
|
public class VMOptionsRule {
|
||||||
|
|
||||||
|
public static Path hook() {
|
||||||
|
DebugInfo.output("======================Hide VMOptions");
|
||||||
|
String tmpdir = System.getProperty("java.io.tmpdir");
|
||||||
|
File file = new File(tmpdir, "fake.vmoptions");
|
||||||
|
if (file.exists()) {
|
||||||
|
return file.toPath();
|
||||||
|
}
|
||||||
|
try (FileOutputStream fos = new FileOutputStream(file)) {
|
||||||
|
fos.write("# This file is created by plugin-privacy".getBytes());
|
||||||
|
return file.toPath();
|
||||||
|
} catch (IOException e) {
|
||||||
|
DebugInfo.output("create temp file error", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user