花瓣 v4.6.12版本的 MD5 值为:6a3515d4d16d98931f1b3d25a91b257e
以下内容为反编译后的 ac.java 源代码,内容仅作参考
package com.kuaishou.weapon.p0;
import android.content.Context;
import android.os.Build;
import android.os.Process;
import android.text.TextUtils;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.lang.reflect.Field;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import org.json.JSONArray;
public class ac {
private String a(int i2, int i3) {
StringBuilder sb;
String str;
if (i3 < 26) {
return "u:r:untrusted_app";
}
if (i2 < i3) {
if (i2 >= 26) {
if (i3 != 27) {
if (i3 == 28 || i3 == 29) {
if (i2 >= 26) {
sb = new StringBuilder();
sb.append("u:r:untrusted_app");
sb.append("_27:s0");
}
} else if (i3 == 30) {
if (i2 >= 29) {
sb = new StringBuilder();
sb.append("u:r:untrusted_app");
str = "_29:s0";
} else {
sb = new StringBuilder();
sb.append("u:r:untrusted_app");
sb.append("_27:s0");
}
}
return sb.toString();
} else if (i2 >= 26) {
sb = new StringBuilder();
}
return "u:r:untrusted_app";
}
sb = new StringBuilder();
sb.append("u:r:untrusted_app");
str = "_25:s0";
sb.append(str);
return sb.toString();
}
sb = new StringBuilder();
sb.append("u:r:untrusted_app");
sb.append(":s0");
return sb.toString();
}
public boolean a() {
return Process.myUid() / com.google.android.exoplayer2.audio.m.f5562f != 0;
}
public boolean a(Context context) {
try {
String absolutePath = context.getFilesDir().getParentFile().getAbsolutePath();
return new File(absolutePath + File.separator + "..").canRead();
} catch (Throwable unused) {
return false;
}
}
public String b(Context context) {
try {
return context.getFilesDir().getParentFile().getAbsolutePath();
} catch (Throwable unused) {
return "";
}
}
public String c(Context context) {
try {
Object invoke = Class.forName("android.app.ActivityThread").getMethod("currentActivityThread", new Class[0]).invoke(null, new Object[0]);
Field declaredField = invoke.getClass().getDeclaredField("mPackages");
declaredField.setAccessible(true);
Map map = (Map) declaredField.get(invoke);
if (map != null && map.size() > 0) {
for (Object obj : map.keySet()) {
if (obj.toString().length() > 1 && !obj.toString().equals(context.getPackageName())) {
File file = new File("/data/data" + File.separator + obj.toString());
if (file.exists() && file.canWrite()) {
return obj.toString();
}
}
}
}
} catch (Throwable unused) {
}
return null;
}
public JSONArray d(Context context) {
BufferedReader bufferedReader;
String substring;
try {
bufferedReader = new BufferedReader(new FileReader("/proc/self/maps"));
try {
HashSet hashSet = new HashSet();
String packageName = context.getPackageName();
while (true) {
String readLine = bufferedReader.readLine();
if (readLine != null) {
if (!readLine.contains("@Hw") && !readLine.contains(".apk@classes.dex") && !readLine.contains("WebViewGoogle") && !readLine.contains("FeatureFramework") && !readLine.contains("framework@oppo") && !readLine.contains("framework@mediatek")) {
if (hashSet.size() > 15) {
break;
}
if (!readLine.contains(packageName) && readLine.contains("/data/") && readLine.contains(".so")) {
substring = readLine.substring(readLine.indexOf("/data/"), readLine.indexOf(".so") + 3);
} else if (!readLine.contains(packageName) && readLine.contains("/data/") && readLine.contains(".dex")) {
substring = readLine.substring(readLine.indexOf("/data/"), readLine.indexOf(".dex") + 4);
}
hashSet.add(substring);
}
} else {
break;
}
}
if (hashSet.size() > 0) {
JSONArray jSONArray = new JSONArray((Collection) hashSet);
try {
bufferedReader.close();
} catch (IOException unused) {
}
return jSONArray;
}
} catch (Throwable unused2) {
}
} catch (Throwable unused3) {
bufferedReader = null;
}
try {
bufferedReader.close();
} catch (IOException unused4) {
return null;
}
}
public int e(Context context) {
FileOutputStream fileOutputStream;
try {
if (Build.VERSION.SDK_INT >= 26) {
String str = "fk_w_" + System.currentTimeMillis();
fileOutputStream = new FileOutputStream(context.getFilesDir().getParentFile().getAbsolutePath() + File.separator + str);
try {
FileDescriptor fd = fileOutputStream.getFD();
Field declaredField = fd.getClass().getDeclaredField("descriptor");
declaredField.setAccessible(true);
declaredField.get(fd);
String absolutePath = Files.readSymbolicLink(Paths.get(String.format("/proc/self/fd/%d", Integer.valueOf(((Integer) declaredField.get(fd)).intValue())), new String[0])).toFile().getAbsolutePath();
if (!absolutePath.substring(absolutePath.lastIndexOf(File.separator)).equals(File.separator + str)) {
try {
fileOutputStream.close();
} catch (Exception unused) {
}
return 1;
}
boolean canRead = new File(absolutePath.replace(str, "")).getParentFile().canRead();
File file = new File(absolutePath);
if (file.exists()) {
file.delete();
}
if (canRead) {
try {
fileOutputStream.close();
} catch (Exception unused2) {
}
return 1;
}
try {
fileOutputStream.close();
} catch (Exception unused3) {
}
return 0;
} catch (Throwable unused4) {
if (fileOutputStream != null) {
try {
fileOutputStream.close();
} catch (Exception unused5) {
}
}
return 0;
}
}
return a(context) ? 1 : 0;
} catch (Throwable unused6) {
fileOutputStream = null;
}
}
public boolean f(Context context) {
try {
int i2 = context.getApplicationInfo().targetSdkVersion;
Class<?> cls = Class.forName("android.os.SELinux");
String str = (String) cls.getDeclaredMethod("getContext", new Class[0]).invoke(cls, new Object[0]);
String a = a(i2, Build.VERSION.SDK_INT);
if (TextUtils.isEmpty(str)) {
return false;
}
return !str.startsWith(a);
} catch (Exception unused) {
return false;
}
}
}