import
android.content.
*
;
import
android.content.pm.
*
;
import
android.widget.
*
;
import
java.io.
*
;
public
class
ZDump
{
public static void Dump(Context var,String pclass){
Class<?> clz
=
null;
try
{
clz
=
var.getClass().getClassLoader().loadClass(pclass);
if
(clz !
=
null){
if
(dumphackDex(clz,var)){
Toast(var,
"dump成功"
);
}
else
{
Toast(var,
"dump失败"
);
}
}
}
catch (ClassNotFoundException e)
{
Toast(var,
"dump失败:"
+
e.toString());
}
}
private static Boolean dumphackDex(Class<?>
cls
, Context cont){
/
/
脱壳 活动(类:不一定非要活动) 上下文
try
{
byte[] bArr
=
(byte[]) Class.forName(
"com.android.dex.Dex"
).getDeclaredMethod(
"getBytes"
, new Class[
0
]).invoke(Class.forName(
"java.lang.Class"
).getMethod(
"getDex"
, new Class[
0
]).invoke(
cls
, new
Object
[
0
]), new
Object
[
0
]);
File
file
=
new
File
(dataDir(cont),
"Dexdump"
+
Integer.toHexString(bArr.length)
+
".dex"
);
if
(!
file
.exists())
{
file
.createNewFile();
}
FileOutputStream fileOutputStream
=
new FileOutputStream(
file
);
fileOutputStream.write(bArr);
fileOutputStream.flush();
fileOutputStream.close();
return
true;
}
catch (Exception e)
{
return
false;
}
}
private static String dataDir(Context cont){
/
/
获取应用 data数据路径
try
{
return
cont.getPackageManager().getApplicationInfo(cont.getPackageName(),
0
).dataDir;
}
catch (PackageManager.NameNotFoundException e)
{
return
null;
}
}
private static void Toast(Context cont,String
str
) {
/
/
弹窗提示方法
Toast.makeText(cont,
str
,
1000
).show();
}
}