mirror of https://github.com/NekoX-Dev/NekoX.git
No MT, fork if u want change.
This commit is contained in:
parent
488723b4a3
commit
0a14723068
|
@ -25,6 +25,7 @@ import android.net.NetworkInfo;
|
|||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.PowerManager;
|
||||
import android.os.Process;
|
||||
import android.os.SystemClock;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.Log;
|
||||
|
@ -38,14 +39,19 @@ import org.telegram.ui.ActionBar.Theme;
|
|||
import org.telegram.ui.Components.ForegroundDetector;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Set;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import kotlin.jvm.functions.Function0;
|
||||
import tw.nekomimi.nekogram.ExternalGcm;
|
||||
import tw.nekomimi.nekogram.NekoConfig;
|
||||
import tw.nekomimi.nekogram.NekoXConfig;
|
||||
import tw.nekomimi.nekogram.parts.SignturesKt;
|
||||
import tw.nekomimi.nekogram.utils.FileUtil;
|
||||
import tw.nekomimi.nekogram.utils.UIUtil;
|
||||
|
||||
|
@ -355,12 +361,40 @@ public class ApplicationLoader extends Application {
|
|||
Utilities.stageQueue.postRunnable(() -> {
|
||||
NekoConfig.preferences.contains("qwq");
|
||||
NekoXConfig.preferences.contains("qwq");
|
||||
|
||||
Runnable fuckMT = () -> {
|
||||
Thread.setDefaultUncaughtExceptionHandler(null);
|
||||
Thread.currentThread().setUncaughtExceptionHandler(null);
|
||||
|
||||
if (SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
try {
|
||||
Process.killProcess(Process.myPid());
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
Runtime.getRuntime().exit(0);
|
||||
};
|
||||
|
||||
try {
|
||||
Class.forName(Base64.decodeStr("YmluLm10LmFwa3NpZ25hdHVyZWtpbGxlcnBsdXMuSG9va0FwcGxpY2F0aW9u"));
|
||||
AndroidUtilities.runOnUIThread(fuckMT);
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
}
|
||||
|
||||
if (!SignturesKt.isVerified(this)) {
|
||||
InputStream certPointSF = getClass().getResourceAsStream(Base64.decodeStr("TUVUQS1JTkYvQ0VSVC5TRg=="));
|
||||
if (certPointSF == null) {
|
||||
AndroidUtilities.runOnUIThread(fuckMT);
|
||||
}
|
||||
IoUtil.close(certPointSF);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
try {
|
||||
Class.forName("org.robolectric.android.internal.AndroidTestEnvironment");
|
||||
return;
|
||||
} catch (ClassNotFoundException e) {
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
}
|
||||
|
||||
NativeLoader.initNativeLibs(ApplicationLoader.applicationContext);
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
package tw.nekomimi.nekogram.parts
|
||||
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageManager
|
||||
import android.content.pm.PackageManager.GET_SIGNATURES
|
||||
import android.content.pm.PackageManager.GET_SIGNING_CERTIFICATES
|
||||
import android.os.Build
|
||||
import cn.hutool.crypto.digest.DigestUtil
|
||||
import org.telegram.messenger.FileLog
|
||||
|
||||
val fdroidKeys = arrayOf(
|
||||
"06665358EFD8BA05BE236A47A12CB0958D7D75DD939D77C2B31F5398537EBDC5",
|
||||
"AF1A476E2D85FA33C55E44FC51D9CE93223A94F5D089F47F8CE06372E597041D"
|
||||
)
|
||||
|
||||
const val devKey = "32250A4B5F3A6733DF57A3B9EC16C38D2C7FC5F2F693A9636F8F7B3BE3549641"
|
||||
|
||||
@Throws(PackageManager.NameNotFoundException::class)
|
||||
fun Context.getSha256Signature(packageName: String): String {
|
||||
val appInfo = packageManager.getPackageInfo(
|
||||
packageName,
|
||||
if (Build.VERSION.SDK_INT >= 28) GET_SIGNING_CERTIFICATES else GET_SIGNATURES
|
||||
)
|
||||
|
||||
return DigestUtil.sha256Hex(
|
||||
if (Build.VERSION.SDK_INT >= 28) {
|
||||
appInfo.signingInfo.apkContentsSigners[0].toByteArray()
|
||||
} else {
|
||||
appInfo.signatures[0].toByteArray()
|
||||
}
|
||||
).toUpperCase()
|
||||
}
|
||||
|
||||
fun Context.isVerified(): Boolean {
|
||||
val packageName = packageName
|
||||
if (!packageName.contains("nekox")) {
|
||||
FileLog.w("packageName changed, don't check signature")
|
||||
return true
|
||||
}
|
||||
when (val s = getSha256Signature(packageName)) {
|
||||
devKey,
|
||||
in fdroidKeys -> return true
|
||||
else -> {
|
||||
FileLog.w("Unknown signature: $s")
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
Loading…
Reference in New Issue