Skip to content

Commit 11b5561

Browse files
author
tiann
committed
[VXP]: feature, allow to install apk without signatures.
1 parent 814143b commit 11b5561

File tree

7 files changed

+51
-1
lines changed

7 files changed

+51
-1
lines changed

VirtualApp/app/src/main/java/io/virtualapp/settings/SettingsActivity.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public class SettingsActivity extends Activity {
5555
private static final String YIELD_MODE = "advance_settings_yield_mode2";
5656
private static final String RECOMMEND_PLUGIN = "settings_plugin_recommend";
5757
private static final String DISABLE_RESIDENT_NOTIFICATION = "advance_settings_disable_resident_notification";
58+
private static final String ALLOW_FAKE_SIGNATURE = "advance_settings_allow_fake_signature";
5859

5960
@Override
6061
protected void onCreate(Bundle savedInstanceState) {
@@ -97,6 +98,7 @@ public void onCreate(Bundle savedInstanceState) {
9798
SwitchPreference disableInstaller = (SwitchPreference) findPreference(DISABLE_INSTALLER_KEY);
9899
SwitchPreference yieldMode = (SwitchPreference) findPreference(YIELD_MODE);
99100
SwitchPreference disableResidentNotification = (SwitchPreference) findPreference(DISABLE_RESIDENT_NOTIFICATION);
101+
SwitchPreference allowFakeSignature = (SwitchPreference) findPreference(ALLOW_FAKE_SIGNATURE);
100102

101103
addApp.setOnPreferenceClickListener(preference -> {
102104
ListAppActivity.gotoListApp(getActivity());
@@ -343,6 +345,26 @@ public void onCreate(Bundle savedInstanceState) {
343345
advance.removePreference(disableResidentNotification);
344346
}
345347

348+
allowFakeSignature.setOnPreferenceChangeListener((preference, newValue) -> {
349+
if (!(newValue instanceof Boolean)) {
350+
return false;
351+
}
352+
353+
boolean on = (boolean) newValue;
354+
File flag = getActivity().getFileStreamPath(Constants.FAKE_SIGNATURE_FLAG);
355+
if (on) {
356+
boolean success;
357+
try {
358+
success = flag.createNewFile();
359+
} catch (IOException e) {
360+
success = false;
361+
}
362+
return success;
363+
} else {
364+
return !flag.exists() || flag.delete();
365+
}
366+
});
367+
346368
}
347369

348370
private static void dismiss(ProgressDialog dialog) {

VirtualApp/app/src/main/res/values-es/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,6 @@
139139
<string name="settings_module_manage">Gestión de módulos</string>
140140
<string name="settings_module_manage_summary">Encienda o apague el módulo Xposed (el módulo Xposed debe encenderse manualmente después de la instalación para que tenga efecto)</string>
141141
<string name="xposed_installer_not_found">Instalador Xposed no encontrado, por favor agrégalo a VirtualXposed!</string>
142+
<string name="advance_settings_allow_fake_signature_summary">Cuando está habilitado, puede instalar apk que no tiene firmas (Generalmente se usa en apk craqueado, Por favor, preste atención a la seguridad)</string>
143+
<string name="advance_settings_allow_fake_signature">Permitir la instalación de apk sin firmas.</string>
142144
</resources>

VirtualApp/app/src/main/res/values-zh-rCN/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,6 @@
135135
<string name="settings_module_manage">模块管理</string>
136136
<string name="settings_module_manage_summary">开启或者关闭Xposed模块(Xposed模块安装之后必须手动开启才能生效)</string>
137137
<string name="xposed_installer_not_found">没有找到 Xposed Installer, 请先把它添加到 VirtualXposed 中!</string>
138+
<string name="advance_settings_allow_fake_signature_summary">启用之后,您可以安装没有签名的APK到 VirtualXposed (通常用于破解版的APP,请注意安全。如果APP有签名校检,依然会无法使用)</string>
139+
<string name="advance_settings_allow_fake_signature">允许安装没有签名的应用</string>
138140
</resources>

VirtualApp/app/src/main/res/values/strings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,7 @@
139139
<string name="settings_module_manage">Manage Xposed Module</string>
140140
<string name="settings_module_manage_summary">Enable/Disable Xposed module (You must enable it manually for it to take effect)</string>
141141
<string name="xposed_installer_not_found">Xposed Installer not found, please add it to VirtualXposed first!</string>
142+
<string name="advance_settings_allow_fake_signature_summary">When enabled, you can install apk which has no signatures(Usually used in cracked apk, please be careful
143+
)</string>
144+
<string name="advance_settings_allow_fake_signature">Allow to install apk without signatures.</string>
142145
</resources>

VirtualApp/app/src/main/res/xml/settings_preferences.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@
4848
android:summary="@string/advance_settings_hide_settings_summary"
4949
android:title="@string/advance_settings_hide_settings" />
5050

51+
<SwitchPreference
52+
android:defaultValue="false"
53+
android:key="advance_settings_allow_fake_signature"
54+
android:persistent="true"
55+
android:summary="@string/advance_settings_allow_fake_signature_summary"
56+
android:title="@string/advance_settings_allow_fake_signature" />
57+
5158
<SwitchPreference
5259
android:defaultValue="false"
5360
android:key="advance_settings_disable_installer"

VirtualApp/lib/src/main/java/com/lody/virtual/client/env/Constants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class Constants {
3535
public static String META_VALUE_STUB = "Stub-User";
3636

3737
public static String NO_NOTIFICATION_FLAG = ".no_notification";
38+
public static String FAKE_SIGNATURE_FLAG = ".fake_signature";
3839

3940
public static final String WECHAT_PACKAGE = EncodeUtils.decode("Y29tLnRlbmNlbnQubW0="); // wechat
4041
public static final List<String> PRIVILEGE_APP = Arrays.asList(

VirtualApp/lib/src/main/java/com/lody/virtual/server/pm/parser/PackageParserEx.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import android.text.TextUtils;
1919

2020
import com.lody.virtual.client.core.VirtualCore;
21+
import com.lody.virtual.client.env.Constants;
2122
import com.lody.virtual.client.fixer.ComponentFixer;
2223
import com.lody.virtual.helper.collection.ArrayMap;
2324
import com.lody.virtual.helper.compat.PackageParserCompat;
@@ -47,6 +48,8 @@ public class PackageParserEx {
4748

4849
private static final ArrayMap<String, String[]> sSharedLibCache = new ArrayMap<>();
4950

51+
private static final String FAKE_SIG = "308203553082023da0030201020204378edaaa300d06092a864886f70d01010b0500305a310d300b0603550406130466616b65310d300b0603550408130466616b65310d300b0603550407130466616b65310d300b060355040a130466616b65310d300b060355040b130466616b65310d300b0603550403130466616b653020170d3138303533303034343434385a180f32313237313230353034343434385a305a310d300b0603550406130466616b65310d300b0603550408130466616b65310d300b0603550407130466616b65310d300b060355040a130466616b65310d300b060355040b130466616b65310d300b0603550403130466616b6530820122300d06092a864886f70d01010105000382010f003082010a0282010100b766ff6afd8a53edd4cee4985bc90e0c515157b5e9f731818961f7250d0d1ac7c7fb80eb5aeb8c28478732e8ff38cff574bfa0eba8039f73af1532f939c4ef9684719efbaba2dd3c583a20907c1c55248a63098c6da23dcfc877763d5fe6061dddd399cf2f49e3250e23f9e687a4d182bcd0662179ba4c9983448e34b4c83e5abbf4f87e87add9157c75fd40de3416744507a3517915f35b6fcad78766e8e1879df8ab823a6ffa335e4790f6e29c87393732025b63ce3a38e42cb0d48cdceb902f191d7d45823db9a0678895e8bfc59b2af7526ca4c2dc3dbe7e70c7c840e666b9629d36e5ddf1d9a80c37f1ab1bc1fb30432914008fbde95d5d3db7853565510203010001a321301f301d0603551d0e04160414d8513e1ae21c64e9ebeee3507e24ea375eef958e300d06092a864886f70d01010b0500038201010088bf20b36428558359536dddcfff16fe233656a92364cb544d8acc43b0859f880a8da339dd430616085edf035e4e6e6dd2281ceb14adde2f05e9ac58d547a09083eece0c6d405289cb7918f85754ee545eefe35e30c103cad617905e94eb4fb68e6920a60d30577855f9feb6e3a664856f74aa9f824aa7d4a3adf85e162c67b9a4261e3185f038ead96112ae3e574d280425e90567352fb82bc9173302122025eaecfabd94d0f9be69a85c415f7cf7759c9651734300952027b316c37aaa1b2418865a3fc7b6bd1072c92ccaacdaa1cf9586d9b8310ceee066ce68859107dfc45ccce729ad9e75b53b584fa37dcd64da8673b1279c6c5861ed3792deac156c8a";
52+
5053
public static VPackage parsePackage(File packageFile) throws Throwable {
5154
PackageParser parser = PackageParserCompat.createParser(packageFile);
5255
PackageParser.Package p = PackageParserCompat.parsePackage(parser, packageFile, 0);
@@ -57,7 +60,17 @@ public static VPackage parsePackage(File packageFile) throws Throwable {
5760
p.mSignatures = new Signature[]{new Signature(sig)};
5861
VLog.d(TAG, "Using fake-signature feature on : " + p.packageName);
5962
} else {
60-
PackageParserCompat.collectCertificates(parser, p, PackageParser.PARSE_IS_SYSTEM);
63+
try {
64+
PackageParserCompat.collectCertificates(parser, p, PackageParser.PARSE_IS_SYSTEM);
65+
} catch (Throwable e) {
66+
VLog.e(TAG, "collectCertificates failed", e);
67+
if (VirtualCore.get().getContext().getFileStreamPath(Constants.FAKE_SIGNATURE_FLAG).exists()) {
68+
VLog.w(TAG, "Using fake signature: " + p.packageName);
69+
p.mSignatures = new Signature[]{new Signature(FAKE_SIG)};
70+
} else {
71+
throw e;
72+
}
73+
}
6174
}
6275
return buildPackageCache(p);
6376
}

0 commit comments

Comments
 (0)