init
This commit is contained in:
commit
439a127799
|
@ -0,0 +1,38 @@
|
|||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
.idea/
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
|
@ -0,0 +1,71 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
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>com.novitechie</groupId>
|
||||
<artifactId>plugin-privacy</artifactId>
|
||||
<version>1.0.0</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>8</source>
|
||||
<target>8</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
<compilerArgument>-XDignore.symbol.file</compilerArgument>
|
||||
<fork>true</fork>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<configuration>
|
||||
<appendAssemblyId>false</appendAssemblyId>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
<archive>
|
||||
<manifest>
|
||||
<addClasspath>true</addClasspath>
|
||||
</manifest>
|
||||
<manifestEntries>
|
||||
<Built-By>novice.li</Built-By>
|
||||
<JANF-Plugin-Entry>com.novitechie.PrivacyPlugin</JANF-Plugin-Entry>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
<finalName>privacy</finalName>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-assembly</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.ja-netfilter</groupId>
|
||||
<artifactId>ja-netfilter</artifactId>
|
||||
<version>2.0.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,9 @@
|
|||
package com.novitechie;
|
||||
|
||||
public class LoadClassRule {
|
||||
public static void check(String name) throws Exception {
|
||||
if (name.startsWith("com.janetfilter")) {
|
||||
throw new ClassNotFoundException(name);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.novitechie;
|
||||
|
||||
import com.janetfilter.core.plugin.MyTransformer;
|
||||
import jdk.internal.org.objectweb.asm.*;
|
||||
import jdk.internal.org.objectweb.asm.commons.AdviceAdapter;
|
||||
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.ASM5;
|
||||
|
||||
public class PluginClassLoaderTransformer implements MyTransformer {
|
||||
@Override
|
||||
public String getHookClassName() {
|
||||
return "com/intellij/ide/plugins/cl/PluginClassLoader";
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] transform(String className, byte[] classBytes, int order) throws Exception {
|
||||
ClassReader cr = new ClassReader(classBytes);
|
||||
ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_FRAMES);
|
||||
cr.accept(new ClassVisitor(ASM5, cw) {
|
||||
@Override
|
||||
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
|
||||
if (name.equals("loadClass")) {
|
||||
MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);
|
||||
return new AdviceAdapter(api, mv, access, name, desc) {
|
||||
@Override
|
||||
protected void onMethodEnter() {
|
||||
mv.visitVarInsn(ALOAD, 1);
|
||||
mv.visitMethodInsn(INVOKESTATIC, "com/novitechie/LoadClassRule", "check", "(Ljava/lang/String;)V", false);
|
||||
}
|
||||
};
|
||||
}
|
||||
return super.visitMethod(access, name, desc, signature, exceptions);
|
||||
}
|
||||
}, 6);
|
||||
return cw.toByteArray();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.novitechie;
|
||||
|
||||
import com.janetfilter.core.plugin.MyTransformer;
|
||||
import com.janetfilter.core.plugin.PluginEntry;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class PrivacyPlugin implements PluginEntry {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "PRIVACY";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthor() {
|
||||
return "novice.li";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MyTransformer> getTransformers() {
|
||||
return Arrays.asList(new VMOptionsTransformer(),new PluginClassLoaderTransformer());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.novitechie;
|
||||
|
||||
public class StackTraceRule {
|
||||
public static boolean check() {
|
||||
RuntimeException e = new RuntimeException();
|
||||
for (StackTraceElement stackTraceElement : e.getStackTrace()) {
|
||||
if (stackTraceElement.getFileName() == null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package com.novitechie;
|
||||
|
||||
import com.janetfilter.core.plugin.MyTransformer;
|
||||
import jdk.internal.org.objectweb.asm.*;
|
||||
import jdk.internal.org.objectweb.asm.commons.AdviceAdapter;
|
||||
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.ASM5;
|
||||
|
||||
public class VMOptionsTransformer implements MyTransformer {
|
||||
@Override
|
||||
public String getHookClassName() {
|
||||
return "com/intellij/diagnostic/VMOptions";
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] transform(String className, byte[] classBytes, int order) throws Exception {
|
||||
ClassReader cr = new ClassReader(classBytes);
|
||||
ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_FRAMES);
|
||||
cr.accept(new ClassVisitor(ASM5, cw) {
|
||||
@Override
|
||||
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
|
||||
if (name.equals("getUserOptionsFile")) {
|
||||
MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);
|
||||
return new AdviceAdapter(api, mv, access, name, desc) {
|
||||
@Override
|
||||
protected void onMethodEnter() {
|
||||
mv.visitMethodInsn(INVOKESTATIC, "com/novitechie/StackTraceRule", "check", "()Z", false);
|
||||
Label l0 = new Label();
|
||||
mv.visitJumpInsn(IFEQ, l0);
|
||||
mv.visitInsn(ACONST_NULL);
|
||||
mv.visitInsn(ARETURN);
|
||||
mv.visitLabel(l0);
|
||||
}
|
||||
};
|
||||
}
|
||||
return super.visitMethod(access, name, desc, signature, exceptions);
|
||||
}
|
||||
}, 6);
|
||||
return cw.toByteArray();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue