flyingyu-z / apkencryptor Goto Github PK
View Code? Open in Web Editor NEWA android app for encrypting apk
License: Other
A android app for encrypting apk
License: Other
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.fly.apkencryptor, PID: 20650
java.lang.UnsatisfiedLinkError: dlopen failed: library "/data/data/com.fly.apkencryptor/lib/libmylib.so" not found
at java.lang.Runtime.load0(Runtime.java:909)
at java.lang.System.load(System.java:1537)
at com.fly.apkencryptor.application.MyApp.attachBaseContext(MyApp.java:81)
Title says
在上个Issues后,重新编译了项目,但是因为assets中找不到sub.apk故会报错。我个人理解是不是这个sub.apk就是我要加密的apk,之后我把要加密的apk放到了assets中,之后顺利运行加壳程序,但是结果如下无法运行了。
在ShellSubTask.java-》start函数执行整体的加壳流程,个人理解如下:
public void start() {
try {
stepLoading.setStepStatus(1, StepLoading.Running);
File apk=new File(MyApp.getContext().getFilesDir()+File.separator+"sub.apk");
FileUtils.mkdir(apk.getParent());
BYProtectUtils.copyAssetsFile("sub.apk",apk.getAbsolutePath());
stepLoading.setStepStatus(1, StepLoading.Success);
} catch (Exception e) {
activity.showDialog(e.toString());
stepLoading.setStepStatus(1, StepLoading.Failure);
return;
}
try {
stepLoading.setStepStatus(2, StepLoading.Running);
byte[] manifest = parseManifest(getZipInputStream("AndroidManifest.xml"), new EncryptorConfig.Conf().getSubApplicationName());
zipOut.addFile("AndroidManifest.xml", manifest);
stepLoading.setStepStatus(2, StepLoading.Success);
} catch (Exception e) {
activity.showDialog(e.toString());
stepLoading.setStepStatus(2, StepLoading.Failure);
return;
}
try {
stepLoading.setStepStatus(3, StepLoading.Running);
byte[] dex = EncryptorConfig.getDex();
zipOut.addFile("classes.dex", dex);
if(singleDEX){
String dexName="classes.dex";
zipOut.addFile("src/" + BYProtectUtils.getAssetsName(dexName), xorEncode(FileUtils.toByteArray(getZipInputStream(dexName)),packageName));
zipOut.removeFile(dexName);
enDexList.add(BYProtectUtils.getAssetsName(dexName));
}else {
for (String dexName : dexEntries) {
zipOut.addFile("src/" + BYProtectUtils.getAssetsName(dexName), xorEncode(FileUtils.toByteArray(getZipInputStream(dexName)),packageName));
zipOut.removeFile(dexName);
enDexList.add(BYProtectUtils.getAssetsName(dexName));
}
}
stepLoading.setStepStatus(3, StepLoading.Success);
} catch (Exception e) {
activity.showDialog(e.toString());
stepLoading.setStepStatus(3, StepLoading.Failure);
return;
}
try {
stepLoading.setStepStatus(4, StepLoading.Running);
JSONObject jsonObject=new JSONObject();
jsonObject.put("application",customApplicationName);
jsonObject.put("sub",new EncryptorConfig.Conf().getSubApplicationName());
jsonObject.put("dex", ListUtil.ListToString(enDexList));
jsonObject.put("checkVirtual",fragment.cb_checkVirtual.isChecked());
jsonObject.put("checkXposed",fragment.cb_checkXposed.isChecked());
jsonObject.put("checkRoot",fragment.cb_checkRoot.isChecked());
jsonObject.put("checkVPN",fragment.cb_checkVPN.isChecked());
byte[] conf=ByteEncoder.Encrypt(jsonObject.toString().getBytes(),packageName);
zipOut.addFile(confEntry, conf);
zipOut.save();
stepLoading.setStepStatus(4, StepLoading.Success);
} catch (Exception e) {
activity.showDialog(e.toString());
stepLoading.setStepStatus(4, StepLoading.Failure);
return;
}
try {
stepLoading.setStepStatus(5, StepLoading.Running);
File tmpFile = new File(outputPath + ".tmp");
new File(outputPath).renameTo(tmpFile);
if (useKey) {
KeyStore keyStore = KeyStore.getInstance("JKS");
keyStore.load(new FileInputStream(conf.getKeyStorePath()), conf.getKeyStorePw().toCharArray());
String alias =conf.getCertAlias();
PrivateKey privateKey = (PrivateKey) keyStore.getKey(alias, conf.getCertPw().toCharArray());
X509Certificate x509Certificate = (X509Certificate) keyStore.getCertificate(alias);
ApkSigner.Builder builder = new ApkSigner.Builder(ImmutableList.of(new ApkSigner.SignerConfig.Builder("Fly", privateKey, ImmutableList.of(x509Certificate)).build()));
builder.setInputApk(tmpFile);
builder.setOutputApk(new File(outputPath));
builder.setCreatedBy("Fly");
builder.setMinSdkVersion(9);
builder.setV1SigningEnabled(true);
builder.setV2SigningEnabled(false);
builder.build().sign();
} else {
KeyStore keyStore = KeyStore.getInstance("JKS");
keyStore.load(BYProtectUtils.getStreamFromAssets("fly.jks"), "123456".toCharArray());
String alias ="test";
PrivateKey privateKey = (PrivateKey) keyStore.getKey(alias, "123456".toCharArray());
X509Certificate x509Certificate = (X509Certificate) keyStore.getCertificate(alias);
ApkSigner.Builder builder = new ApkSigner.Builder(ImmutableList.of(new ApkSigner.SignerConfig.Builder("Fly", privateKey, ImmutableList.of(x509Certificate)).build()));
builder.setInputApk(tmpFile);
builder.setOutputApk(new File(outputPath));
builder.setCreatedBy("Fly");
builder.setMinSdkVersion(9);
builder.setV1SigningEnabled(true);
builder.setV2SigningEnabled(false);
builder.build().sign();
}
tmpFile.delete();
stepLoading.setStepStatus(6, StepLoading.Success);
showFinish(context, new File(outputPath));
stepLoading.setStepStatus(5, StepLoading.Success);
} catch (Exception e) {
activity.showDialog(e.toString());
stepLoading.setStepStatus(5, StepLoading.Failure);
return;
}
File apk=new File(MyApp.getContext().getFilesDir()+File.separator+"sub.apk");
ZipFile zipFile=new ZipFile(apk); //把apk当作zip打开出现上述异常
但是这个sub.apk在是在位置ShellSubTask.java(80)创建的
File apk=new File(MyApp.getContext().getFilesDir()+File.separator+"sub.apk");
FileUtils.mkdir(apk.getParent());
BYProtectUtils.copyAssetsFile("sub.apk",apk.getAbsolutePath());
应该是拷贝了资源文件(MD5:89122AB303A8DA6FC5694C6BAD48229E )到sub.apk当中?才导致后面当作zip解析不正确?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.