|
@@ -1,5 +1,6 @@
|
|
|
package io.nexilis.transformer;
|
|
|
|
|
|
+import org.gradle.api.Project;
|
|
|
import org.objectweb.asm.ClassVisitor;
|
|
|
import org.objectweb.asm.MethodVisitor;
|
|
|
import org.objectweb.asm.Opcodes;
|
|
@@ -7,8 +8,11 @@ import org.objectweb.asm.commons.AdviceAdapter;
|
|
|
|
|
|
public class ProtectionInjector extends ClassVisitor {
|
|
|
|
|
|
- public ProtectionInjector(ClassVisitor cv) {
|
|
|
+ private final Project project;
|
|
|
+
|
|
|
+ public ProtectionInjector(ClassVisitor cv, Project project) {
|
|
|
super(Opcodes.ASM9, cv);
|
|
|
+ this.project = project;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -28,15 +32,18 @@ public class ProtectionInjector extends ClassVisitor {
|
|
|
public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) {
|
|
|
MethodVisitor mv = super.visitMethod(access, name, descriptor, signature, exceptions);
|
|
|
if ("onCreate".equals(name) && "(Landroid/os/Bundle;)V".equals(descriptor)) {
|
|
|
- return new InjectDetectionLibraryMethodVisitor(api, mv, access, name, descriptor);
|
|
|
+ return new InjectDetectionLibraryMethodVisitor(api, mv, access, name, descriptor, project);
|
|
|
}
|
|
|
return mv;
|
|
|
}
|
|
|
|
|
|
private static class InjectDetectionLibraryMethodVisitor extends AdviceAdapter {
|
|
|
|
|
|
- protected InjectDetectionLibraryMethodVisitor(int api, MethodVisitor methodVisitor, int access, String name, String descriptor) {
|
|
|
+ private final Project project;
|
|
|
+
|
|
|
+ protected InjectDetectionLibraryMethodVisitor(int api, MethodVisitor methodVisitor, int access, String name, String descriptor, Project project) {
|
|
|
super(api, methodVisitor, access, name, descriptor);
|
|
|
+ this.project = project;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -47,8 +54,8 @@ public class ProtectionInjector extends ClassVisitor {
|
|
|
@Override
|
|
|
protected void onMethodExit(int opcode) {
|
|
|
super.onMethodExit(opcode);
|
|
|
- mv.visitLdcInsn("gow3");
|
|
|
- mv.visitLdcInsn("8B0449EA6ECD9C67EAD8A4C5AA716A0ECE803F28A4082E61D3F6DB488D1C185C");
|
|
|
+ mv.visitLdcInsn(project != null ? project.getProperties().get("nexilis.appId") : "");
|
|
|
+ mv.visitLdcInsn(project != null ? project.getProperties().get("nexilis.account") : "");
|
|
|
mv.visitVarInsn(ALOAD, 0);
|
|
|
mv.visitVarInsn(ALOAD, 0);
|
|
|
mv.visitMethodInsn(INVOKESTATIC, "io/nexilis/service/API", "connect", "(Ljava/lang/String;Ljava/lang/String;Landroid/app/Activity;Lio/nexilis/service/Callback;)V", false);
|
|
@@ -62,8 +69,8 @@ public class ProtectionInjector extends ClassVisitor {
|
|
|
mv.visitCode();
|
|
|
mv.visitMethodInsn(Opcodes.INVOKESTATIC, "io/security/streamshield/SecurityShield", "getInstance", "()Lio/security/streamshield/SecurityShield;", false);
|
|
|
mv.visitInsn(Opcodes.DUP);
|
|
|
- mv.visitLdcInsn("gow3");
|
|
|
- mv.visitLdcInsn("8B0449EA6ECD9C67EAD8A4C5AA716A0ECE803F28A4082E61D3F6DB488D1C185C");
|
|
|
+ mv.visitLdcInsn(project != null ? project.getProperties().get("nexilis.appId") : "");
|
|
|
+ mv.visitLdcInsn(project != null ? project.getProperties().get("nexilis.account") : "");
|
|
|
mv.visitVarInsn(Opcodes.ALOAD, 0);
|
|
|
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "io/security/streamshield/SecurityShield", "check", "(Ljava/lang/String;Ljava/lang/String;Landroid/app/Activity;)V", false);
|
|
|
mv.visitInsn(Opcodes.RETURN);
|