add activities
This commit is contained in:
parent
c481eeb10b
commit
abd30de39c
34 changed files with 527 additions and 39 deletions
1
test_apks/dyn_and_ref/.gitignore
vendored
1
test_apks/dyn_and_ref/.gitignore
vendored
|
|
@ -1,3 +1,4 @@
|
||||||
build
|
build
|
||||||
ToyKey.keystore
|
ToyKey.keystore
|
||||||
java/classes/com/example/theseus/dynloading/R.java
|
java/classes/com/example/theseus/dynloading/R.java
|
||||||
|
grodd-venv
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,26 @@
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name=".ClassLoaderContextActivity"/>
|
<activity android:name=".ClassLoaderContextActivity"/>
|
||||||
|
<activity android:name=".DelegateLastClassLoaderActivity"/>
|
||||||
|
<activity android:name=".DexClassLoaderActivity"/>
|
||||||
|
<activity android:name=".InMemoryDexClassLoaderActivity"/>
|
||||||
|
<activity android:name=".PathClassLoaderActivity"/>
|
||||||
|
<activity android:name=".NoCollisionWithParentDelegateLastClassLoaderActivity"/>
|
||||||
|
<activity android:name=".NoCollisionWithParentDexClassLoaderActivity"/>
|
||||||
|
<activity android:name=".NoCollisionWithParentInMemoryDexClassLoaderActivity"/>
|
||||||
|
<activity android:name=".NoCollisionWithParentPathClassLoaderActivity"/>
|
||||||
|
<activity android:name=".NoCollisionWithoutParentDelegateLastClassLoaderActivity"/>
|
||||||
|
<activity android:name=".NoCollisionWithoutParentDexClassLoaderActivity"/>
|
||||||
|
<activity android:name=".NoCollisionWithoutParentInMemoryDexClassLoaderActivity"/>
|
||||||
|
<activity android:name=".NoCollisionWithoutParentPathClassLoaderActivity"/>
|
||||||
|
<activity android:name=".CollisionWithParentDelegateLastClassLoaderActivity"/>
|
||||||
|
<activity android:name=".CollisionWithParentDexClassLoaderActivity"/>
|
||||||
|
<activity android:name=".CollisionWithParentInMemoryDexClassLoaderActivity"/>
|
||||||
|
<activity android:name=".CollisionWithParentPathClassLoaderActivity"/>
|
||||||
|
<activity android:name=".CollisionWithoutParentDelegateLastClassLoaderActivity"/>
|
||||||
|
<activity android:name=".CollisionWithoutParentDexClassLoaderActivity"/>
|
||||||
|
<activity android:name=".CollisionWithoutParentInMemoryDexClassLoaderActivity"/>
|
||||||
|
<activity android:name=".CollisionWithoutParentPathClassLoaderActivity"/>
|
||||||
<activity android:name=".MethodActivity"/>
|
<activity android:name=".MethodActivity"/>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ D8_ARGS =
|
||||||
pass=ahahah
|
pass=ahahah
|
||||||
|
|
||||||
export PATH := $(JAVA_PATH):$(PATH)
|
export PATH := $(JAVA_PATH):$(PATH)
|
||||||
|
export ANDROID_HOME := $(SDK_TOOLS)
|
||||||
|
|
||||||
all: $(shell mkdir -p build)
|
all: $(shell mkdir -p build)
|
||||||
all: clean build/$(APP).apk
|
all: clean build/$(APP).apk
|
||||||
|
|
@ -33,9 +34,10 @@ debug: JAVAC_ARGS += -g
|
||||||
debug: D8_ARGS += --debug
|
debug: D8_ARGS += --debug
|
||||||
debug: all
|
debug: all
|
||||||
|
|
||||||
test: all
|
test: all grodd-venv
|
||||||
$(ADB) install build/$(APP).apk
|
$(ADB) install build/$(APP).apk
|
||||||
$(ADB) shell am start -n $(PACKAGE)/.$(MAIN_ACTIVITY)
|
$(ADB) shell am start -n $(PACKAGE)/.$(MAIN_ACTIVITY)
|
||||||
|
grodd-venv/bin/grodd-runner -d emulator-5554 -r grodd -t 300 -p $(PACKAGE) # -s 1.
|
||||||
|
|
||||||
build/%.v1signed.apk: ./build/%.unsigned.apk ./ToyKey.keystore
|
build/%.v1signed.apk: ./build/%.unsigned.apk ./ToyKey.keystore
|
||||||
$(JARSIGNER) -verbose -keystore ./ToyKey.keystore -storepass $(pass) -keypass $(pass) -signedjar $@ $< SignKey
|
$(JARSIGNER) -verbose -keystore ./ToyKey.keystore -storepass $(pass) -keypass $(pass) -signedjar $@ $< SignKey
|
||||||
|
|
@ -67,6 +69,10 @@ build/%.apk: ./build/%.v2aligned.apk
|
||||||
ToyKey.keystore :
|
ToyKey.keystore :
|
||||||
$(KEYTOOL) -genkeypair -validity 1000 -dname "CN=SomeKey,O=SomeOne,C=FR" -keystore $@ -storepass $(pass) -keypass $(pass) -alias SignKey -keyalg RSA -v
|
$(KEYTOOL) -genkeypair -validity 1000 -dname "CN=SomeKey,O=SomeOne,C=FR" -keystore $@ -storepass $(pass) -keypass $(pass) -alias SignKey -keyalg RSA -v
|
||||||
|
|
||||||
|
grodd-venv:
|
||||||
|
python3 -m venv grodd-venv
|
||||||
|
grodd-venv/bin/pip install 'git+ssh://git@gitlab.inria.fr/CIDRE/malware/grodd-runner.git'
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) -r build/*
|
$(RM) -r build/*
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.example.theseus.dynandref;
|
||||||
|
|
||||||
|
public interface AIReflectee {
|
||||||
|
public String interTransfer(
|
||||||
|
boolean bool,
|
||||||
|
byte by,
|
||||||
|
short sh,
|
||||||
|
char ch,
|
||||||
|
int in,
|
||||||
|
long lo,
|
||||||
|
float fl,
|
||||||
|
double dou,
|
||||||
|
String str,
|
||||||
|
String... args
|
||||||
|
);
|
||||||
|
|
||||||
|
default public String staticInterfaceTransfer(
|
||||||
|
boolean bool,
|
||||||
|
byte by,
|
||||||
|
short sh,
|
||||||
|
char ch,
|
||||||
|
int in,
|
||||||
|
long lo,
|
||||||
|
float fl,
|
||||||
|
double dou,
|
||||||
|
String str,
|
||||||
|
String... args
|
||||||
|
) {
|
||||||
|
String val = "";
|
||||||
|
for (String v : args) {
|
||||||
|
val += " " + v;
|
||||||
|
}
|
||||||
|
return "A:" + val + "(" + bool + " " + by + " " + sh + " " + ch + " " + in + " " + lo + " " + fl + " " + dou + " " + str + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.example.theseus.dynandref;
|
||||||
|
|
||||||
|
public class APReflectee {
|
||||||
|
public String extendedTransfer(
|
||||||
|
boolean bool,
|
||||||
|
byte by,
|
||||||
|
short sh,
|
||||||
|
char ch,
|
||||||
|
int in,
|
||||||
|
long lo,
|
||||||
|
float fl,
|
||||||
|
double dou,
|
||||||
|
String str,
|
||||||
|
String... args
|
||||||
|
) {
|
||||||
|
String val = "";
|
||||||
|
for (String v : args) {
|
||||||
|
val += " " + v;
|
||||||
|
}
|
||||||
|
return "A:" + val + "(" + bool + " " + by + " " + sh + " " + ch + " " + in + " " + lo + " " + fl + " " + dou + " " + str + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
package com.example.theseus.dynandref;
|
||||||
|
|
||||||
|
public class AReflectee extends APReflectee implements AIReflectee {
|
||||||
|
public static String getReflecteeId() {
|
||||||
|
return "A";
|
||||||
|
}
|
||||||
|
public String virtTransfer(
|
||||||
|
boolean bool,
|
||||||
|
byte by,
|
||||||
|
short sh,
|
||||||
|
char ch,
|
||||||
|
int in,
|
||||||
|
long lo,
|
||||||
|
float fl,
|
||||||
|
double dou,
|
||||||
|
String str,
|
||||||
|
String... args
|
||||||
|
) {
|
||||||
|
String val = "";
|
||||||
|
for (String v : args) {
|
||||||
|
val += " " + v;
|
||||||
|
}
|
||||||
|
return getReflecteeId() + ":" + val + "(" + bool + " " + by + " " + sh + " " + ch + " " + in + " " + lo + " " + fl + " " + dou + " " + str + ")";
|
||||||
|
}
|
||||||
|
public static String staticTransfer(
|
||||||
|
boolean bool,
|
||||||
|
byte by,
|
||||||
|
short sh,
|
||||||
|
char ch,
|
||||||
|
int in,
|
||||||
|
long lo,
|
||||||
|
float fl,
|
||||||
|
double dou,
|
||||||
|
String str,
|
||||||
|
String... args
|
||||||
|
) {
|
||||||
|
String val = "";
|
||||||
|
for (String v : args) {
|
||||||
|
val += " " + v;
|
||||||
|
}
|
||||||
|
return getReflecteeId() + ":" + val + "(" + bool + " " + by + " " + sh + " " + ch + " " + in + " " + lo + " " + fl + " " + dou + " " + str + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String interTransfer(
|
||||||
|
boolean bool,
|
||||||
|
byte by,
|
||||||
|
short sh,
|
||||||
|
char ch,
|
||||||
|
int in,
|
||||||
|
long lo,
|
||||||
|
float fl,
|
||||||
|
double dou,
|
||||||
|
String str,
|
||||||
|
String... args
|
||||||
|
) {
|
||||||
|
String val = "";
|
||||||
|
for (String v : args) {
|
||||||
|
val += " " + v;
|
||||||
|
}
|
||||||
|
return getReflecteeId() + ":" + val + "(" + bool + " " + by + " " + sh + " " + ch + " " + in + " " + lo + " " + fl + " " + dou + " " + str + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -30,6 +30,6 @@ public interface ICollider {
|
||||||
for (String v : args) {
|
for (String v : args) {
|
||||||
val += " " + v;
|
val += " " + v;
|
||||||
}
|
}
|
||||||
return "MainAPK:" + val + "(" + bool + " " + by + " " + sh + " " + ch + " " + in + " " + lo + " " + fl + " " + dou + " " + str + ")";
|
return "A:" + val + "(" + bool + " " + by + " " + sh + " " + ch + " " + in + " " + lo + " " + fl + " " + dou + " " + str + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ public class ClassLoaderContextActivity extends Activity {
|
||||||
|
|
||||||
Activity ac = this;
|
Activity ac = this;
|
||||||
|
|
||||||
b1.setText("Direct With Parent");
|
b1.setText("Collision With Parent");
|
||||||
b1.setOnClickListener(new View.OnClickListener() {
|
b1.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
v.setBackgroundTintList(buttonColor);
|
v.setBackgroundTintList(buttonColor);
|
||||||
|
|
@ -102,7 +102,7 @@ public class ClassLoaderContextActivity extends Activity {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
b2.setText("Direct Without Parent");
|
b2.setText("Collision Without Parent");
|
||||||
b2.setOnClickListener(new View.OnClickListener() {
|
b2.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
v.setBackgroundTintList(buttonColor);
|
v.setBackgroundTintList(buttonColor);
|
||||||
|
|
@ -110,14 +110,15 @@ public class ClassLoaderContextActivity extends Activity {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
b3.setText("Indirect With Parent");
|
b3.setText("No Collision With Parent");
|
||||||
b3.setOnClickListener(new View.OnClickListener() {
|
b3.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
v.setBackgroundTintList(buttonColor);
|
v.setBackgroundTintList(buttonColor);
|
||||||
|
nextActivity(classLoaderName, false, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
b4.setText("Indirect Without Parent");
|
b4.setText("No Collision Without Parent");
|
||||||
b4.setOnClickListener(new View.OnClickListener() {
|
b4.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
v.setBackgroundTintList(buttonColor);
|
v.setBackgroundTintList(buttonColor);
|
||||||
|
|
@ -126,10 +127,47 @@ public class ClassLoaderContextActivity extends Activity {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void nextActivity(String classLoaderName, boolean isDirect, boolean hasParent) {
|
public void nextActivity(String classLoaderName, boolean hasCollision, boolean hasParent) {
|
||||||
Intent intent = new Intent(this, MethodActivity.class);
|
Class cl = null;
|
||||||
|
if (classLoaderName.equals("DelegateLastClassLoader") && hasCollision && hasParent) {
|
||||||
|
cl = CollisionWithParentDelegateLastClassLoaderActivity.class;
|
||||||
|
} else if (classLoaderName.equals("DelegateLastClassLoader") && hasCollision && !hasParent) {
|
||||||
|
cl = CollisionWithParentDelegateLastClassLoaderActivity.class;
|
||||||
|
} else if (classLoaderName.equals("DelegateLastClassLoader") && !hasCollision && hasParent) {
|
||||||
|
cl = NoCollisionWithoutParentDelegateLastClassLoaderActivity.class;
|
||||||
|
} else if (classLoaderName.equals("DelegateLastClassLoader") && !hasCollision && !hasParent) {
|
||||||
|
cl = NoCollisionWithoutParentDelegateLastClassLoaderActivity.class;
|
||||||
|
} else if (classLoaderName.equals("DexClassLoader") && hasCollision && hasParent) {
|
||||||
|
cl = CollisionWithParentDexClassLoaderActivity.class;
|
||||||
|
} else if (classLoaderName.equals("DexClassLoader") && hasCollision && !hasParent) {
|
||||||
|
cl = CollisionWithParentDexClassLoaderActivity.class;
|
||||||
|
} else if (classLoaderName.equals("DexClassLoader") && !hasCollision && hasParent) {
|
||||||
|
cl = NoCollisionWithoutParentDexClassLoaderActivity.class;
|
||||||
|
} else if (classLoaderName.equals("DexClassLoader") && !hasCollision && !hasParent) {
|
||||||
|
cl = NoCollisionWithoutParentDexClassLoaderActivity.class;
|
||||||
|
} else if (classLoaderName.equals("InMemoryDexClassLoader") && hasCollision && hasParent) {
|
||||||
|
cl = CollisionWithParentInMemoryDexClassLoaderActivity.class;
|
||||||
|
} else if (classLoaderName.equals("InMemoryDexClassLoader") && hasCollision && !hasParent) {
|
||||||
|
cl = CollisionWithParentInMemoryDexClassLoaderActivity.class;
|
||||||
|
} else if (classLoaderName.equals("InMemoryDexClassLoader") && !hasCollision && hasParent) {
|
||||||
|
cl = NoCollisionWithoutParentInMemoryDexClassLoaderActivity.class;
|
||||||
|
} else if (classLoaderName.equals("InMemoryDexClassLoader") && !hasCollision && !hasParent) {
|
||||||
|
cl = NoCollisionWithoutParentInMemoryDexClassLoaderActivity.class;
|
||||||
|
} else if (classLoaderName.equals("PathClassLoader") && hasCollision && hasParent) {
|
||||||
|
cl = CollisionWithParentPathClassLoaderActivity.class;
|
||||||
|
} else if (classLoaderName.equals("PathClassLoader") && hasCollision && !hasParent) {
|
||||||
|
cl = CollisionWithParentPathClassLoaderActivity.class;
|
||||||
|
} else if (classLoaderName.equals("PathClassLoader") && !hasCollision && hasParent) {
|
||||||
|
cl = NoCollisionWithoutParentPathClassLoaderActivity.class;
|
||||||
|
} else if (classLoaderName.equals("PathClassLoader") && !hasCollision && !hasParent) {
|
||||||
|
cl = NoCollisionWithoutParentPathClassLoaderActivity.class;
|
||||||
|
} else {
|
||||||
|
Log.e("THESEUS", "error: unknown activity for " + classLoaderName + " with hasCollision = " + hasCollision + " and hasParent = " + hasParent);
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
Intent intent = new Intent(this, cl);
|
||||||
intent.putExtra("classLoaderName", classLoaderName);
|
intent.putExtra("classLoaderName", classLoaderName);
|
||||||
intent.putExtra("direct", isDirect);
|
intent.putExtra("collision", hasCollision);
|
||||||
intent.putExtra("parent", hasParent);
|
intent.putExtra("parent", hasParent);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
package com.example.theseus.dynandref;
|
||||||
|
|
||||||
|
public class CollisionWithParentDelegateLastClassLoaderActivity extends MethodActivity {}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
package com.example.theseus.dynandref;
|
||||||
|
|
||||||
|
public class CollisionWithParentDexClassLoaderActivity extends MethodActivity {}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
package com.example.theseus.dynandref;
|
||||||
|
|
||||||
|
public class CollisionWithParentInMemoryDexClassLoaderActivity extends MethodActivity {}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
package com.example.theseus.dynandref;
|
||||||
|
|
||||||
|
public class CollisionWithParentPathClassLoaderActivity extends MethodActivity {}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
package com.example.theseus.dynandref;
|
||||||
|
|
||||||
|
public class CollisionWithoutParentDelegateLastClassLoaderActivity extends MethodActivity {}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
package com.example.theseus.dynandref;
|
||||||
|
|
||||||
|
public class CollisionWithoutParentDexClassLoaderActivity extends MethodActivity {}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
package com.example.theseus.dynandref;
|
||||||
|
|
||||||
|
public class CollisionWithoutParentInMemoryDexClassLoaderActivity extends MethodActivity {}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
package com.example.theseus.dynandref;
|
||||||
|
|
||||||
|
public class CollisionWithoutParentPathClassLoaderActivity extends MethodActivity {}
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
package com.example.theseus.dynandref;
|
||||||
|
|
||||||
|
|
||||||
|
public class DelegateLastClassLoaderActivity extends ClassLoaderContextActivity {}
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
package com.example.theseus.dynandref;
|
||||||
|
|
||||||
|
|
||||||
|
public class DexClassLoaderActivity extends ClassLoaderContextActivity {}
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
package com.example.theseus.dynandref;
|
||||||
|
|
||||||
|
|
||||||
|
public class InMemoryDexClassLoaderActivity extends ClassLoaderContextActivity {}
|
||||||
|
|
@ -29,7 +29,7 @@ public class Main {
|
||||||
return ByteBuffer.wrap(data);
|
return ByteBuffer.wrap(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void run(Activity ac, String clname, boolean isDirect, boolean hasParent, String methodType) {
|
public static void run(Activity ac, String clname, boolean hasCollision, boolean hasParent, String methodType) {
|
||||||
try {
|
try {
|
||||||
ClassLoader cl;
|
ClassLoader cl;
|
||||||
ClassLoader parent;
|
ClassLoader parent;
|
||||||
|
|
@ -50,7 +50,13 @@ public class Main {
|
||||||
cl = Main.class.getClassLoader();
|
cl = Main.class.getClassLoader();
|
||||||
}
|
}
|
||||||
|
|
||||||
Class clz = cl.loadClass("com.example.theseus.dynandref.Collider");
|
Class clz = null;
|
||||||
|
if (hasCollision) {
|
||||||
|
clz = cl.loadClass("com.example.theseus.dynandref.Collider");
|
||||||
|
} else {
|
||||||
|
clz = cl.loadClass("com.example.theseus.dynandref.AReflectee");
|
||||||
|
}
|
||||||
|
|
||||||
Object[] args = {
|
Object[] args = {
|
||||||
true,
|
true,
|
||||||
(byte)42,
|
(byte)42,
|
||||||
|
|
@ -67,23 +73,95 @@ public class Main {
|
||||||
if (methodType.equals("Virtual")) {
|
if (methodType.equals("Virtual")) {
|
||||||
Method mth = clz.getMethod("virtTransfer", boolean.class, byte.class, short.class, char.class, int.class, long.class, float.class, double.class, String.class, String[].class);
|
Method mth = clz.getMethod("virtTransfer", boolean.class, byte.class, short.class, char.class, int.class, long.class, float.class, double.class, String.class, String[].class);
|
||||||
Object instance = clz.getDeclaredConstructor().newInstance();
|
Object instance = clz.getDeclaredConstructor().newInstance();
|
||||||
invoke(ac, instance, mth, args);
|
invoke(ac,
|
||||||
|
instance,
|
||||||
|
mth,
|
||||||
|
args,
|
||||||
|
true,
|
||||||
|
(byte)42,
|
||||||
|
(short)666,
|
||||||
|
'*',
|
||||||
|
0xDEAD_BEEF,
|
||||||
|
0xD1AB011C_5EAF00DL,
|
||||||
|
0.99f,
|
||||||
|
3.1415926535897932384626433d,
|
||||||
|
"",
|
||||||
|
new String[] {"some", "strings"}
|
||||||
|
);
|
||||||
} else if (methodType.equals("Static")) {
|
} else if (methodType.equals("Static")) {
|
||||||
Method mth = clz.getMethod("staticTransfer", boolean.class, byte.class, short.class, char.class, int.class, long.class, float.class, double.class, String.class, String[].class);
|
Method mth = clz.getMethod("staticTransfer", boolean.class, byte.class, short.class, char.class, int.class, long.class, float.class, double.class, String.class, String[].class);
|
||||||
invoke(ac, null, mth, args);
|
invoke(ac,
|
||||||
|
null,
|
||||||
|
mth,
|
||||||
|
args,
|
||||||
|
true,
|
||||||
|
(byte)42,
|
||||||
|
(short)666,
|
||||||
|
'*',
|
||||||
|
0xDEAD_BEEF,
|
||||||
|
0xD1AB011C_5EAF00DL,
|
||||||
|
0.99f,
|
||||||
|
3.1415926535897932384626433d,
|
||||||
|
"",
|
||||||
|
new String[] {"some", "strings"}
|
||||||
|
);
|
||||||
} else if (methodType.equals("Extended")) {
|
} else if (methodType.equals("Extended")) {
|
||||||
Method mth = clz.getMethod("extendedTransfer", boolean.class, byte.class, short.class, char.class, int.class, long.class, float.class, double.class, String.class, String[].class);
|
Method mth = clz.getMethod("extendedTransfer", boolean.class, byte.class, short.class, char.class, int.class, long.class, float.class, double.class, String.class, String[].class);
|
||||||
Object instance = clz.getDeclaredConstructor().newInstance();
|
Object instance = clz.getDeclaredConstructor().newInstance();
|
||||||
invoke(ac, instance, mth, args);
|
invoke(ac,
|
||||||
|
instance,
|
||||||
|
mth,
|
||||||
|
args,
|
||||||
|
true,
|
||||||
|
(byte)42,
|
||||||
|
(short)666,
|
||||||
|
'*',
|
||||||
|
0xDEAD_BEEF,
|
||||||
|
0xD1AB011C_5EAF00DL,
|
||||||
|
0.99f,
|
||||||
|
3.1415926535897932384626433d,
|
||||||
|
"",
|
||||||
|
new String[] {"some", "strings"}
|
||||||
|
);
|
||||||
} else if (methodType.equals("Interface")) {
|
} else if (methodType.equals("Interface")) {
|
||||||
Method mth = clz.getMethod("interTransfer", boolean.class, byte.class, short.class, char.class, int.class, long.class, float.class, double.class, String.class, String[].class);
|
Method mth = clz.getMethod("interTransfer", boolean.class, byte.class, short.class, char.class, int.class, long.class, float.class, double.class, String.class, String[].class);
|
||||||
Object instance = clz.getDeclaredConstructor().newInstance();
|
Object instance = clz.getDeclaredConstructor().newInstance();
|
||||||
invoke(ac, instance, mth, args);
|
invoke(ac,
|
||||||
|
instance,
|
||||||
|
mth,
|
||||||
|
args,
|
||||||
|
true,
|
||||||
|
(byte)42,
|
||||||
|
(short)666,
|
||||||
|
'*',
|
||||||
|
0xDEAD_BEEF,
|
||||||
|
0xD1AB011C_5EAF00DL,
|
||||||
|
0.99f,
|
||||||
|
3.1415926535897932384626433d,
|
||||||
|
"",
|
||||||
|
new String[] {"some", "strings"}
|
||||||
|
);
|
||||||
} else if (methodType.equals("Interface Static")) {
|
} else if (methodType.equals("Interface Static")) {
|
||||||
clz = cl.loadClass("com.example.theseus.dynandref.ICollider$-CC");
|
//clz = cl.loadClass("com.example.theseus.dynandref.ICollider$-CC");
|
||||||
|
//Method mth = clz.getMethod("$default$staticInterfaceTransfer", boolean.class, byte.class, short.class, char.class, int.class, long.class, float.class, double.class, String.class, String[].class);
|
||||||
|
clz = cl.loadClass("com.example.theseus.dynandref.ICollider");
|
||||||
Method mth = clz.getMethod("staticInterfaceTransfer", boolean.class, byte.class, short.class, char.class, int.class, long.class, float.class, double.class, String.class, String[].class);
|
Method mth = clz.getMethod("staticInterfaceTransfer", boolean.class, byte.class, short.class, char.class, int.class, long.class, float.class, double.class, String.class, String[].class);
|
||||||
invoke(ac, null, mth, args);
|
invoke(ac,
|
||||||
} else if (methodType.equals("Factory Pattern")) {
|
null,
|
||||||
|
mth,
|
||||||
|
args,
|
||||||
|
true,
|
||||||
|
(byte)42,
|
||||||
|
(short)666,
|
||||||
|
'*',
|
||||||
|
0xDEAD_BEEF,
|
||||||
|
0xD1AB011C_5EAF00DL,
|
||||||
|
0.99f,
|
||||||
|
3.1415926535897932384626433d,
|
||||||
|
"",
|
||||||
|
new String[] {"some", "strings"}
|
||||||
|
);
|
||||||
|
} else if (methodType.equals("Factory isDirectPattern")) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
|
|
@ -93,9 +171,51 @@ public class Main {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void invoke(Activity ac, Object instance, Method mth, Object[] args) throws Exception {
|
public static void invoke(
|
||||||
|
Activity ac, Object instance, Method mth, Object[] args,
|
||||||
|
// Additionnal args to check the register reservation
|
||||||
|
boolean bool,
|
||||||
|
byte by,
|
||||||
|
short sh,
|
||||||
|
char ch,
|
||||||
|
int in,
|
||||||
|
long lo,
|
||||||
|
float fl,
|
||||||
|
double dou,
|
||||||
|
String str,
|
||||||
|
String... strArgs
|
||||||
|
) throws Exception {
|
||||||
args[8] = Utils.source();
|
args[8] = Utils.source();
|
||||||
|
Log.e("THESEUS", "instance: " + instance + " mth: " + mth);
|
||||||
String res = (String)mth.invoke(instance, args);
|
String res = (String)mth.invoke(instance, args);
|
||||||
Utils.sink(ac, res);
|
Utils.sink(ac, res);
|
||||||
|
if (!(
|
||||||
|
(bool == true) &&
|
||||||
|
(by == (byte)42) &&
|
||||||
|
(sh == (short)666) &&
|
||||||
|
(ch == '*') &&
|
||||||
|
(in == 0xDEAD_BEEF) &&
|
||||||
|
(lo == 0xD1AB011C_5EAF00DL) &&
|
||||||
|
(fl == 0.99f) &&
|
||||||
|
(dou == 3.1415926535897932384626433d) &&
|
||||||
|
str.equals("") &&
|
||||||
|
(strArgs.length == 2) &&
|
||||||
|
strArgs[0].equals("some") &&
|
||||||
|
strArgs[1].equals("strings")
|
||||||
|
)) {
|
||||||
|
Log.e("THESEUS", "Main.invoke additionnal arguments don't match");
|
||||||
|
Log.e("THESEUS", "bool: " + (bool == true));
|
||||||
|
Log.e("THESEUS", "by: " + (by == (byte)42));
|
||||||
|
Log.e("THESEUS", "sh: " + (sh == (short)666));
|
||||||
|
Log.e("THESEUS", "ch: " + (ch == '*'));
|
||||||
|
Log.e("THESEUS", "in: " + (in == 0xDEAD_BEEF));
|
||||||
|
Log.e("THESEUS", "lo: " + (lo == 0xD1AB011C_5EAF00DL));
|
||||||
|
Log.e("THESEUS", "fl: " + (fl == 0.99f));
|
||||||
|
Log.e("THESEUS", "dou: " + (dou == 3.1415926535897932384626433d));
|
||||||
|
Log.e("THESEUS", "str: " + str.equals(""));
|
||||||
|
Log.e("THESEUS", "strArgs.length: " + (strArgs.length == 2));
|
||||||
|
Log.e("THESEUS", "strArgs[0]: " + strArgs[0].equals("some"));
|
||||||
|
Log.e("THESEUS", "strArgs[1]: " + strArgs[1].equals("strings"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,9 @@ public class MainActivity extends Activity {
|
||||||
b1.setOnClickListener(new View.OnClickListener() {
|
b1.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
v.setBackgroundTintList(buttonColor);
|
v.setBackgroundTintList(buttonColor);
|
||||||
nextActivity("DelegateLastClassLoader");
|
Intent intent = new Intent(ac, DelegateLastClassLoaderActivity.class);
|
||||||
|
intent.putExtra("classLoaderName", "DelegateLastClassLoader");
|
||||||
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -118,7 +120,9 @@ public class MainActivity extends Activity {
|
||||||
b2.setOnClickListener(new View.OnClickListener() {
|
b2.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
v.setBackgroundTintList(buttonColor);
|
v.setBackgroundTintList(buttonColor);
|
||||||
nextActivity("DexClassLoader");
|
Intent intent = new Intent(ac, DexClassLoaderActivity.class);
|
||||||
|
intent.putExtra("classLoaderName", "DexClassLoader");
|
||||||
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -126,7 +130,9 @@ public class MainActivity extends Activity {
|
||||||
b3.setOnClickListener(new View.OnClickListener() {
|
b3.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
v.setBackgroundTintList(buttonColor);
|
v.setBackgroundTintList(buttonColor);
|
||||||
nextActivity("InMemoryDexClassLoader");
|
Intent intent = new Intent(ac, InMemoryDexClassLoaderActivity.class);
|
||||||
|
intent.putExtra("classLoaderName", "InMemoryDexClassLoader");
|
||||||
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -134,14 +140,10 @@ public class MainActivity extends Activity {
|
||||||
b4.setOnClickListener(new View.OnClickListener() {
|
b4.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
v.setBackgroundTintList(buttonColor);
|
v.setBackgroundTintList(buttonColor);
|
||||||
nextActivity("PathClassLoader");
|
Intent intent = new Intent(ac, PathClassLoaderActivity.class);
|
||||||
|
intent.putExtra("classLoaderName", "PathClassLoader");
|
||||||
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void nextActivity(String classLoaderName) {
|
|
||||||
Intent intent = new Intent(this, ClassLoaderContextActivity.class);
|
|
||||||
intent.putExtra("classLoaderName", classLoaderName);
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.example.theseus.dynandref;
|
||||||
|
|
||||||
|
public interface MainIReflectee {
|
||||||
|
public String interTransfer(
|
||||||
|
boolean bool,
|
||||||
|
byte by,
|
||||||
|
short sh,
|
||||||
|
char ch,
|
||||||
|
int in,
|
||||||
|
long lo,
|
||||||
|
float fl,
|
||||||
|
double dou,
|
||||||
|
String str,
|
||||||
|
String... args
|
||||||
|
);
|
||||||
|
|
||||||
|
default public String staticInterfaceTransfer(
|
||||||
|
boolean bool,
|
||||||
|
byte by,
|
||||||
|
short sh,
|
||||||
|
char ch,
|
||||||
|
int in,
|
||||||
|
long lo,
|
||||||
|
float fl,
|
||||||
|
double dou,
|
||||||
|
String str,
|
||||||
|
String... args
|
||||||
|
) {
|
||||||
|
String val = "";
|
||||||
|
for (String v : args) {
|
||||||
|
val += " " + v;
|
||||||
|
}
|
||||||
|
return "MainAPK:" + val + "(" + bool + " " + by + " " + sh + " " + ch + " " + in + " " + lo + " " + fl + " " + dou + " " + str + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.example.theseus.dynandref;
|
||||||
|
|
||||||
|
public class MainPReflectee {
|
||||||
|
public String extendedTransfer(
|
||||||
|
boolean bool,
|
||||||
|
byte by,
|
||||||
|
short sh,
|
||||||
|
char ch,
|
||||||
|
int in,
|
||||||
|
long lo,
|
||||||
|
float fl,
|
||||||
|
double dou,
|
||||||
|
String str,
|
||||||
|
String... args
|
||||||
|
) {
|
||||||
|
String val = "";
|
||||||
|
for (String v : args) {
|
||||||
|
val += " " + v;
|
||||||
|
}
|
||||||
|
return "MainAPK:" + val + "(" + bool + " " + by + " " + sh + " " + ch + " " + in + " " + lo + " " + fl + " " + dou + " " + str + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
package com.example.theseus.dynandref;
|
||||||
|
|
||||||
|
public class MainReflectee extends MainPReflectee implements MainIReflectee {
|
||||||
|
public static String getReflecteeId() {
|
||||||
|
return "MainAPK";
|
||||||
|
}
|
||||||
|
public String virtTransfer(
|
||||||
|
boolean bool,
|
||||||
|
byte by,
|
||||||
|
short sh,
|
||||||
|
char ch,
|
||||||
|
int in,
|
||||||
|
long lo,
|
||||||
|
float fl,
|
||||||
|
double dou,
|
||||||
|
String str,
|
||||||
|
String... args
|
||||||
|
) {
|
||||||
|
String val = "";
|
||||||
|
for (String v : args) {
|
||||||
|
val += " " + v;
|
||||||
|
}
|
||||||
|
return getReflecteeId() + ":" + val + "(" + bool + " " + by + " " + sh + " " + ch + " " + in + " " + lo + " " + fl + " " + dou + " " + str + ")";
|
||||||
|
}
|
||||||
|
public static String staticTransfer(
|
||||||
|
boolean bool,
|
||||||
|
byte by,
|
||||||
|
short sh,
|
||||||
|
char ch,
|
||||||
|
int in,
|
||||||
|
long lo,
|
||||||
|
float fl,
|
||||||
|
double dou,
|
||||||
|
String str,
|
||||||
|
String... args
|
||||||
|
) {
|
||||||
|
String val = "";
|
||||||
|
for (String v : args) {
|
||||||
|
val += " " + v;
|
||||||
|
}
|
||||||
|
return getReflecteeId() + ":" + val + "(" + bool + " " + by + " " + sh + " " + ch + " " + in + " " + lo + " " + fl + " " + dou + " " + str + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String interTransfer(
|
||||||
|
boolean bool,
|
||||||
|
byte by,
|
||||||
|
short sh,
|
||||||
|
char ch,
|
||||||
|
int in,
|
||||||
|
long lo,
|
||||||
|
float fl,
|
||||||
|
double dou,
|
||||||
|
String str,
|
||||||
|
String... args
|
||||||
|
) {
|
||||||
|
String val = "";
|
||||||
|
for (String v : args) {
|
||||||
|
val += " " + v;
|
||||||
|
}
|
||||||
|
return getReflecteeId() + ":" + val + "(" + bool + " " + by + " " + sh + " " + ch + " " + in + " " + lo + " " + fl + " " + dou + " " + str + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -38,14 +38,13 @@ import java.util.Arrays;
|
||||||
|
|
||||||
public class MethodActivity extends Activity {
|
public class MethodActivity extends Activity {
|
||||||
public String classLoaderName;
|
public String classLoaderName;
|
||||||
|
public boolean hasCollision;
|
||||||
public boolean hasParent;
|
public boolean hasParent;
|
||||||
public boolean isDirect;
|
|
||||||
|
|
||||||
|
|
||||||
public String getdexfile(String name) {
|
public String getdexfile(String name) {
|
||||||
File dexfile = new File(getCacheDir(), name);
|
File dexfile = new File(getCacheDir(), name);
|
||||||
dexfile.setReadOnly();
|
dexfile.setReadOnly();
|
||||||
Log.e("DEBUG", dexfile.getPath());
|
|
||||||
return dexfile.getPath();
|
return dexfile.getPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -54,7 +53,7 @@ public class MethodActivity extends Activity {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
classLoaderName = intent.getStringExtra("classLoaderName");
|
classLoaderName = intent.getStringExtra("classLoaderName");
|
||||||
isDirect = intent.getBooleanExtra("direct", false);
|
hasCollision = intent.getBooleanExtra("collision", false);
|
||||||
hasParent = intent.getBooleanExtra("parent", false);
|
hasParent = intent.getBooleanExtra("parent", false);
|
||||||
|
|
||||||
ColorStateList buttonColor = ColorStateList.valueOf(0xff808080);
|
ColorStateList buttonColor = ColorStateList.valueOf(0xff808080);
|
||||||
|
|
@ -95,7 +94,7 @@ public class MethodActivity extends Activity {
|
||||||
|
|
||||||
Button b5 = new Button(this);
|
Button b5 = new Button(this);
|
||||||
b5.generateViewId();
|
b5.generateViewId();
|
||||||
linLayout.addView(b5);
|
//linLayout.addView(b5); // Static Interface Methods are a pain
|
||||||
|
|
||||||
Button b6 = new Button(this);
|
Button b6 = new Button(this);
|
||||||
b6.generateViewId();
|
b6.generateViewId();
|
||||||
|
|
@ -111,7 +110,7 @@ public class MethodActivity extends Activity {
|
||||||
b1.setOnClickListener(new View.OnClickListener() {
|
b1.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
v.setBackgroundTintList(buttonColor);
|
v.setBackgroundTintList(buttonColor);
|
||||||
Main.run(ac, classLoaderName, isDirect, hasParent, "Virtual");
|
Main.run(ac, classLoaderName, hasCollision, hasParent, "Virtual");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -119,7 +118,7 @@ public class MethodActivity extends Activity {
|
||||||
b2.setOnClickListener(new View.OnClickListener() {
|
b2.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
v.setBackgroundTintList(buttonColor);
|
v.setBackgroundTintList(buttonColor);
|
||||||
Main.run(ac, classLoaderName, isDirect, hasParent, "Static");
|
Main.run(ac, classLoaderName, hasCollision, hasParent, "Static");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -127,7 +126,7 @@ public class MethodActivity extends Activity {
|
||||||
b3.setOnClickListener(new View.OnClickListener() {
|
b3.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
v.setBackgroundTintList(buttonColor);
|
v.setBackgroundTintList(buttonColor);
|
||||||
Main.run(ac, classLoaderName, isDirect, hasParent, "Extended");
|
Main.run(ac, classLoaderName, hasCollision, hasParent, "Extended");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -135,7 +134,7 @@ public class MethodActivity extends Activity {
|
||||||
b4.setOnClickListener(new View.OnClickListener() {
|
b4.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
v.setBackgroundTintList(buttonColor);
|
v.setBackgroundTintList(buttonColor);
|
||||||
Main.run(ac, classLoaderName, isDirect, hasParent, "Interface");
|
Main.run(ac, classLoaderName, hasCollision, hasParent, "Interface");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -143,7 +142,7 @@ public class MethodActivity extends Activity {
|
||||||
b5.setOnClickListener(new View.OnClickListener() {
|
b5.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
v.setBackgroundTintList(buttonColor);
|
v.setBackgroundTintList(buttonColor);
|
||||||
Main.run(ac, classLoaderName, isDirect, hasParent, "Interface Static");
|
Main.run(ac, classLoaderName, hasCollision, hasParent, "Interface Static");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -151,7 +150,7 @@ public class MethodActivity extends Activity {
|
||||||
b6.setOnClickListener(new View.OnClickListener() {
|
b6.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
v.setBackgroundTintList(buttonColor);
|
v.setBackgroundTintList(buttonColor);
|
||||||
Main.run(ac, classLoaderName, isDirect, hasParent, "Factory Pattern");
|
Main.run(ac, classLoaderName, hasCollision, hasParent, "Factory Pattern");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
package com.example.theseus.dynandref;
|
||||||
|
|
||||||
|
public class NoCollisionWithParentDelegateLastClassLoaderActivity extends MethodActivity {}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
package com.example.theseus.dynandref;
|
||||||
|
|
||||||
|
public class NoCollisionWithParentDexClassLoaderActivity extends MethodActivity {}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
package com.example.theseus.dynandref;
|
||||||
|
|
||||||
|
public class NoCollisionWithParentInMemoryDexClassLoaderActivity extends MethodActivity {}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
package com.example.theseus.dynandref;
|
||||||
|
|
||||||
|
public class NoCollisionWithParentPathClassLoaderActivity extends MethodActivity {}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
package com.example.theseus.dynandref;
|
||||||
|
|
||||||
|
public class NoCollisionWithoutParentDelegateLastClassLoaderActivity extends MethodActivity {}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
package com.example.theseus.dynandref;
|
||||||
|
|
||||||
|
public class NoCollisionWithoutParentDexClassLoaderActivity extends MethodActivity {}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
package com.example.theseus.dynandref;
|
||||||
|
|
||||||
|
public class NoCollisionWithoutParentInMemoryDexClassLoaderActivity extends MethodActivity {}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
package com.example.theseus.dynandref;
|
||||||
|
|
||||||
|
public class NoCollisionWithoutParentPathClassLoaderActivity extends MethodActivity {}
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
package com.example.theseus.dynandref;
|
||||||
|
|
||||||
|
|
||||||
|
public class PathClassLoaderActivity extends ClassLoaderContextActivity {}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue