正在查看: MT Manager v2.13.3 应用的 C9952.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: MT Manager v2.13.3 应用的 C9952.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package l;
import android.os.Build;
import android.os.SystemClock;
import android.provider.CalendarContract;
import android.text.TextUtils;
import bin.mt.plus.R;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
public final class C9952 {
public static int f31083 = 7;
public static String f31084;
static {
m22352();
}
public static File m22350() {
File dataDir;
if (Build.VERSION.SDK_INT >= 24) {
dataDir = C5870.m14013().getDataDir();
return new File(dataDir, CalendarContract.CalendarCache.TIMEZONE_TYPE_HOME);
}
return new File(C5870.m14028().getParentFile(), CalendarContract.CalendarCache.TIMEZONE_TYPE_HOME);
}
public static C6513 m22351(String str, boolean z) {
if (str == null) {
str = "";
}
String str2 = str;
String m22344 = z ? m22344() : "/system/bin/sh";
String[] split = ((z && m22344 == null) ? "/system/bin/sh" : m22344).split("\\s+");
C6513 c6513 = new C6513(split[0], str2, split, C9425.m21341(System.getenv()), new C1822());
c6513.f21733 = true;
return c6513;
}
public static C6513 m22345(String str, boolean z) {
String str2;
String[] strArr;
boolean z2;
if (str == null) {
str = "";
}
String str3 = str;
File file = new File(C5870.m14028(), "term");
File m22350 = m22350();
if (m22350.isFile()) {
m22350.delete();
}
m22350.mkdirs();
String path = m22350.getPath();
HashMap hashMap = new HashMap(System.getenv());
hashMap.put("HOME", path);
if (m22348()) {
String path2 = new File(file, "usr").getPath();
File file2 = new File(path2, "tmp");
if (file2.isFile()) {
file2.delete();
}
file2.mkdirs();
str2 = path2 + "/bin/bash";
String[] strArr2 = z ? new String[]{str2, "-c", C3509.m8825(path2, "/bin/su")} : new String[]{str2};
hashMap.put("TERM", "xterm-256color");
hashMap.put("PREFIX", path2);
hashMap.put("TMPDIR", file2.getPath());
hashMap.put("SHELL", str2);
hashMap.put("PWD", str3);
String m21339 = C9425.m21339(C3509.m8825(path2, "/bin"), C3509.m8825(path, "/bin"), C3509.m8825(path2, "/bin/applets"));
String m213392 = C9425.m21339(C3509.m8825(path2, "/lib"), C3509.m8825(path, "/lib"));
C9425.m21340(hashMap, "PATH", m21339);
C9425.m21340(hashMap, "LD_LIBRARY_PATH", m213392);
z2 = false;
strArr = strArr2;
} else {
String m22344 = z ? m22344() : "/system/bin/sh";
String str4 = (z && m22344 == null) ? "/system/bin/sh" : m22344;
str2 = str4;
strArr = new String[]{str4};
z2 = true;
}
C6513 c6513 = new C6513(str2, str3, strArr, C9425.m21341(hashMap), new C1822());
c6513.f21733 = z2;
return c6513;
}
public static void m22346(final C6513 c6513) {
if (c6513 == null || !c6513.m15616()) {
return;
}
if (c6513.m15611().endsWith("/bash")) {
c6513.m25410("history -d -1 && history -w; exit\r");
final long currentTimeMillis = System.currentTimeMillis();
new Thread(new Runnable() {
@Override
public final void run() {
while (true) {
C6513 c65132 = C6513.this;
if (!c65132.m15616()) {
return;
}
if (System.currentTimeMillis() - currentTimeMillis > 500) {
c65132.m15609();
return;
}
SystemClock.sleep(5L);
}
}
}).start();
return;
}
c6513.m15609();
}
public static boolean m22348() {
return (Build.VERSION.SDK_INT < 21 ? false : new File(C5870.m14028(), "term/DISABLED").exists() ^ true) && m22349();
}
public static boolean m22349() {
File m14028 = C5870.m14028();
if (!new File(m14028, "EXPANSION_VERSION").exists() || !new File(m14028, "term/usr/bin/bash").exists()) {
return false;
}
try {
return Integer.parseInt(C4983.m12183(new File(m14028, "EXPANSION_VERSION"), C7316.f23823)) >= f31083;
} catch (Exception unused) {
return false;
}
}
public static void m22347(InterfaceC10680 interfaceC10680) {
try {
try {
m22353(interfaceC10680);
} catch (Exception e) {
C4983.m12190(new File(C5870.m14028(), "term"));
throw e;
}
} finally {
C4983.m12190(new File(C5870.m14028(), "term.xz"));
}
}
public static void m22353(InterfaceC10680 interfaceC10680) {
String str;
char c;
String[] strArr;
C4983.m12190(new File(C5870.m14028(), "EXPANSION_VERSION"));
File file = new File(C5870.m14028(), "term.xz");
File file2 = new File(C5870.m14028(), "term");
C4983.m12190(file2);
StringBuilder sb = new StringBuilder();
sb.append(AbstractC5452.m13104().mo6699("/term/download"));
sb.append("?p=");
sb.append(C5870.m14021());
sb.append("&v=23031969&a=");
if (Build.VERSION.SDK_INT >= 21) {
strArr = Build.SUPPORTED_ABIS;
str = strArr[0];
} else {
str = Build.CPU_ABI;
}
str.getClass();
String str2 = "x86";
switch (str.hashCode()) {
case -806050265:
if (str.equals("x86_64")) {
c = 0;
break;
}
c = 65535;
break;
case 117110:
if (str.equals("x86")) {
c = 1;
break;
}
c = 65535;
break;
case 145444210:
if (str.equals("armeabi-v7a")) {
c = 2;
break;
}
c = 65535;
break;
case 1431565292:
if (str.equals("arm64-v8a")) {
c = 3;
break;
}
c = 65535;
break;
default:
c = 65535;
break;
}
if (c == 0) {
str2 = "x64";
} else if (c != 1) {
if (c == 2) {
str2 = "arm";
} else {
if (c != 3) {
throw new RuntimeException("Unsupported architecture: " + Build.CPU_ABI);
}
str2 = "arm64";
}
}
sb.append(str2);
String sb2 = sb.toString();
C4979 m14027 = C5870.m14027();
C2026 c2026 = new C2026();
c2026.m5475(sb2);
C6395 mo1964 = m14027.m12163(c2026.m5469()).mo1964();
try {
if (!mo1964.m15333()) {
throw new IOException("Code-" + mo1964.m15328() + ": " + mo1964.m15332());
}
AbstractC10763 m15324 = mo1964.m15324();
if (m15324 == null) {
throw new IOException("Response body is null");
}
C1538 c1538 = new C1538(m15324.mo21043());
c1538.m4450(new C9224(interfaceC10680));
interfaceC10680.mo23589(R.string.MT_Protector_res_0x7f100639);
InputStream m23794 = m15324.m23794();
try {
FileOutputStream fileOutputStream = new FileOutputStream(file);
try {
byte[] bArr = new byte[512];
do {
int read = m23794.read(bArr);
if (read == -1) {
fileOutputStream.close();
m23794.close();
mo1964.close();
interfaceC10680.mo23589(R.string.MT_Protector_res_0x7f10063a);
C4983.m12182(file2);
ZipInputStream zipInputStream = new ZipInputStream(new C0634(new FileInputStream(file)));
do {
try {
ZipEntry nextEntry = zipInputStream.getNextEntry();
if (nextEntry == null) {
zipInputStream.close();
File file3 = new File(file2, "init.sh");
C4983.m12189(file3, C4983.m12183(file3, Charset.defaultCharset()).replace("usr/bin/busybox", new File(file2, "usr/bin/busybox").getAbsolutePath()), Charset.defaultCharset());
FileOutputStream fileOutputStream2 = null;
int waitFor = Runtime.getRuntime().exec("sh init.sh", (String[]) null, file2).waitFor();
if (waitFor != 0) {
throw new IOException(C5475.m13135("Init failed: ", waitFor));
}
C4983.m12187(new File(file2, "init.sh"));
File file4 = new File(C5870.m14028(), "EXPANSION_VERSION");
byte[] bytes = String.valueOf(f31083).getBytes(C7316.f23823);
int length = bytes.length;
try {
fileOutputStream2 = C4983.m12188(file4);
fileOutputStream2.write(bytes, 0, length);
fileOutputStream2.close();
C11496.m25299(fileOutputStream2);
m22352();
return;
} catch (Throwable th) {
C11496.m25299(fileOutputStream2);
throw th;
}
}
File file5 = new File(file2, nextEntry.getName());
if (nextEntry.isDirectory()) {
C4983.m12182(file5);
} else {
File parentFile = file5.getParentFile();
if (parentFile != null) {
C4983.m12182(parentFile);
}
FileOutputStream m12188 = C4983.m12188(file5);
try {
C11496.m25301(zipInputStream, m12188);
m12188.close();
} finally {
}
}
} catch (Throwable th2) {
try {
zipInputStream.close();
} catch (Throwable th3) {
try {
Throwable.class.getDeclaredMethod("addSuppressed", Throwable.class).invoke(th2, th3);
} catch (Exception unused) {
}
}
throw th2;
}
} while (!interfaceC10680.mo955());
zipInputStream.close();
return;
}
c1538.m4452(read);
fileOutputStream.write(bArr, 0, read);
} while (!interfaceC10680.mo955());
fileOutputStream.close();
m23794.close();
mo1964.close();
} catch (Throwable th4) {
try {
fileOutputStream.close();
} catch (Throwable th5) {
try {
Throwable.class.getDeclaredMethod("addSuppressed", Throwable.class).invoke(th4, th5);
} catch (Exception unused2) {
}
}
throw th4;
}
} catch (Throwable th6) {
if (m23794 != null) {
try {
m23794.close();
} catch (Throwable th7) {
try {
Throwable.class.getDeclaredMethod("addSuppressed", Throwable.class).invoke(th6, th7);
} catch (Exception unused3) {
}
}
}
throw th6;
}
} catch (Throwable th8) {
try {
mo1964.close();
} catch (Throwable th9) {
try {
Throwable.class.getDeclaredMethod("addSuppressed", Throwable.class).invoke(th8, th9);
} catch (Exception unused4) {
}
}
throw th8;
}
}
public static void m22352() {
if (!m22348()) {
f31084 = null;
return;
}
File file = new File(C5870.m14028(), "term/usr/bin/su");
File file2 = new File(C5870.m14028(), "term/usr/bin/su2");
String m22344 = m22344();
if (m22344 == null) {
m22344 = "";
}
if (m22344.equals(f31084)) {
return;
}
if (m22344.isEmpty()) {
try {
C4983.m12189(file, "echo \"su: command not found\" 1>&2\nexit 1\n", C7316.f23823);
if (!file.canExecute()) {
file.setExecutable(true);
}
} catch (IOException unused) {
}
try {
C4983.m12189(file2, "echo \"su: command not found\" 1>&2\nexit 1\n", C7316.f23823);
if (!file2.canExecute()) {
file2.setExecutable(true);
}
} catch (IOException unused2) {
}
f31084 = m22344;
return;
}
try {
C4983.m12189(file, C7746.m17998("SU_LOCATION=\"", m22344, "\"\nSU_BASH=\"$TMPDIR/su.bash\"\n\nfunction main() {\n local cmd\n\n while [[ \"$#\" > 0 ]]; do\n local arg=\"$1\"; shift\n case \"$arg\" in\n \"-h\" | \"--help\" ) echo \"Usage: su [-c commands]\"; exit 0 ;;\n \"-c\" | \"--command\" ) cmd=\"$@\"; break ;;\n esac\n done\n\n local su_info=$($SU_LOCATION --help 2>&1)\n local supportCmd=$(echo $su_info | grep \"\\-c\\\\b\")\n\n local CURRENT_PWD=\"$(pwd)\";\n local wd=${CURRENT_PWD//\\\"/\\\\\\\"}\n echo \"# su.bash\" >$SU_BASH\n echo \"export HOME=$HOME\" >>$SU_BASH\n echo \"export TERM=$TERM\" >>$SU_BASH\n echo \"export PREFIX=$PREFIX\" >>$SU_BASH\n echo \"export TMPDIR=$TMPDIR\" >>$SU_BASH\n echo \"export SHELL=$SHELL\" >>$SU_BASH\n echo \"export PATH=$PATH\" >>$SU_BASH\n echo \"export LD_LIBRARY_PATH=$LD_LIBRARY_PATH\" >>$SU_BASH\n echo \"cd \\\"$wd\\\"\" >>$SU_BASH\n echo \"export PWD=\\\"$wd\\\"\" >>$SU_BASH\n if [[ $cmd == \"\" ]]; then\n echo \"exec $SHELL\" >>$SU_BASH\n else\n echo \"exec $SHELL -c '$cmd'\" >>$SU_BASH\n fi\n chmod 700 $SU_BASH\n\n if [[ $supportCmd ]]; then\n cmd=\"-c $SU_BASH\"\n else\n cmd=\"0 $SU_BASH\"\n fi\n\n $SU_LOCATION $cmd\n}\n\nmain \"$@\""), C7316.f23823);
if (!file.canExecute()) {
file.setExecutable(true);
}
} catch (Throwable unused3) {
}
try {
C4983.m12189(file2, m22344.concat(" \"$@\"\n"), C7316.f23823);
if (!file2.canExecute()) {
file2.setExecutable(true);
}
} catch (IOException unused4) {
}
f31084 = m22344;
}
public static String m22344() {
String trim = C5870.f20176.getString("custom_su_command", "").trim();
if (!TextUtils.isEmpty(trim)) {
return trim;
}
for (String str : System.getenv("PATH").split(":")) {
File file = new File(str, "su");
if (file.exists() && file.canExecute()) {
return file.getPath();
}
}
return null;
}
}