正在查看: Credmex v3.12.2 应用的 NetworkUtils.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Credmex v3.12.2 应用的 NetworkUtils.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.veda.supertoolkit.phonetools;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.DhcpInfo;
import android.net.NetworkInfo;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.telephony.TelephonyManager;
import android.telephony.cdma.CdmaCellLocation;
import android.telephony.gsm.GsmCellLocation;
import android.text.TextUtils;
import androidx.annotation.RequiresPermission;
import androidx.core.content.ContextCompat;
import com.umeng.analytics.pro.d;
import com.veda.supertoolkit.customtools.Logger;
import cz.msebera.android.httpclient.conn.util.InetAddressUtils;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Enumeration;
import org.json.JSONObject;
public class NetworkUtils {
public static int a(Context context) {
String e = e(context);
if (TextUtils.isEmpty(e)) {
return 0;
}
if (e.startsWith("46000") || e.startsWith("46002") || e.startsWith("46007")) {
return 1;
}
if (e.startsWith("46001") || e.startsWith("46006")) {
return 2;
}
return (e.startsWith("46003") || e.startsWith("46005") || e.startsWith("46011")) ? 3 : 0;
}
public static String b(Context context) {
return "UNAUTHORIZED";
}
public static JSONObject c(Context context) {
String str;
String str2;
String str3;
if (ContextCompat.checkSelfPermission(context.getApplicationContext(), "android.permission.ACCESS_COARSE_LOCATION") != 0) {
return null;
}
try {
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService("phone");
int a = a(context);
if (a == 0) {
return null;
}
String str4 = "";
if (a == 1 || a == 2) {
GsmCellLocation gsmCellLocation = (GsmCellLocation) telephonyManager.getCellLocation();
str = gsmCellLocation.getLac() + "";
str2 = gsmCellLocation.getCid() + "";
} else {
if (a != 3) {
str3 = "";
int parseInt = Integer.parseInt(telephonyManager.getNetworkOperator().substring(3));
JSONObject jSONObject = new JSONObject();
jSONObject.put("mnc", parseInt);
jSONObject.put("lac", str4);
jSONObject.put("cid", str3);
jSONObject.put(d.f41y, n(context));
return jSONObject;
}
CdmaCellLocation cdmaCellLocation = (CdmaCellLocation) telephonyManager.getCellLocation();
str = cdmaCellLocation.getNetworkId() + "";
str2 = cdmaCellLocation.getBaseStationId() + "";
}
str3 = str2;
str4 = str;
int parseInt2 = Integer.parseInt(telephonyManager.getNetworkOperator().substring(3));
JSONObject jSONObject2 = new JSONObject();
jSONObject2.put("mnc", parseInt2);
jSONObject2.put("lac", str4);
jSONObject2.put("cid", str3);
jSONObject2.put(d.f41y, n(context));
return jSONObject2;
} catch (Throwable th) {
th.printStackTrace();
return null;
}
}
public static String d(Context context) {
try {
WifiManager wifiManager = (WifiManager) context.getSystemService("wifi");
if (wifiManager == null) {
return null;
}
DhcpInfo dhcpInfo = wifiManager.getDhcpInfo();
return r(dhcpInfo.dns1) + "," + r(dhcpInfo.dns2);
} catch (Throwable th) {
th.printStackTrace();
return null;
}
}
public static String e(Context context) {
return "";
}
public static String f(Context context) {
try {
int ipAddress = ((WifiManager) context.getSystemService("wifi")).getConnectionInfo().getIpAddress();
if (ipAddress != 0) {
Logger c = Logger.c();
StringBuilder sb = new StringBuilder();
sb.append("WIFI network, IP=");
long j = ipAddress;
sb.append(r(j));
c.a(sb.toString());
return r(j);
}
} catch (Exception unused) {
Logger.c().e("当前不在 WIFI 环境");
}
try {
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
while (networkInterfaces.hasMoreElements()) {
Enumeration<InetAddress> inetAddresses = networkInterfaces.nextElement().getInetAddresses();
while (inetAddresses.hasMoreElements()) {
InetAddress nextElement = inetAddresses.nextElement();
if (!nextElement.isLoopbackAddress() && InetAddressUtils.isIPv4Address(nextElement.getHostAddress().toUpperCase())) {
Logger.c().a("Cellphone network IPv4=" + nextElement.getHostAddress());
return nextElement.getHostAddress();
}
}
}
} catch (SocketException unused2) {
Logger.c().b("未获取到当前设备移动网络IP");
}
Logger.c().h("未获取到当前设备ip");
return "127.0.0.1";
}
public static String g(Context context) {
return "";
}
public static String h(Context context) {
return "";
}
private static String i(int i) {
switch (i) {
case 1:
return "GPRS";
case 2:
return "EDGE";
case 3:
return "UMTS";
case 4:
return "CDMA";
case 5:
return "CDMA - EvDo rev. 0";
case 6:
return "CDMA - EvDo rev. A";
case 7:
return "CDMA - 1xRTT";
case 8:
return "HSDPA";
case 9:
return "HSUPA";
case 10:
return "HSPA";
case 11:
return "iDEN";
case 12:
return "CDMA - EvDo rev. B";
case 13:
return "LTE";
case 14:
return "CDMA - eHRPD";
case 15:
return "HSPA+";
case 16:
return "GSM";
case 17:
return "TD_SCDMA";
case 18:
return "IWLAN";
default:
return "UNKNOWN";
}
}
public static String j(Context context) {
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
if (connectivityManager != null) {
try {
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
if (activeNetworkInfo != null) {
int type = activeNetworkInfo.getType();
if (type == 0) {
return i(activeNetworkInfo.getSubtype());
}
if (type == 1) {
return "WIFI";
}
}
} catch (Exception unused) {
return "UNAUTHORIZED";
}
}
return i(0);
}
public static String k(Context context) {
String networkOperatorName = ((TelephonyManager) context.getSystemService("phone")).getNetworkOperatorName();
return networkOperatorName == null ? "" : networkOperatorName;
}
public static String l(Context context) {
try {
int phoneType = ((TelephonyManager) context.getSystemService("phone")).getPhoneType();
return phoneType != 1 ? phoneType != 2 ? phoneType != 3 ? "NONE" : "SIP" : "CDMA" : "GSM";
} catch (Throwable unused) {
return "NONE";
}
}
public static String m(Context context) {
try {
return System.getProperty("http.proxyHost") + ":" + System.getProperty("http.proxyPort");
} catch (Throwable th) {
th.printStackTrace();
return null;
}
}
public static String n(Context context) {
return null;
}
@RequiresPermission("android.permission.ACCESS_WIFI_STATE")
public static WifiInfo o(Context context) {
try {
WifiManager wifiManager = (WifiManager) context.getApplicationContext().getSystemService("wifi");
if (wifiManager != null) {
return wifiManager.getConnectionInfo();
}
return null;
} catch (Throwable th) {
th.printStackTrace();
return null;
}
}
@RequiresPermission("android.permission.ACCESS_WIFI_STATE")
public static String p(Context context) {
try {
return r(((WifiManager) context.getSystemService("wifi")).getDhcpInfo().netmask);
} catch (Throwable th) {
th.printStackTrace();
return null;
}
}
@RequiresPermission("android.permission.ACCESS_WIFI_STATE")
public static String q(Context context) {
try {
return r(((WifiManager) context.getSystemService("wifi")).getDhcpInfo().gateway);
} catch (Throwable th) {
th.printStackTrace();
return null;
}
}
public static String r(long j) {
return (j & 255) + "." + ((j >> 8) & 255) + "." + ((j >> 16) & 255) + "." + ((j >> 24) & 255);
}
public static boolean s(Context context) {
NetworkInfo activeNetworkInfo = ((ConnectivityManager) context.getSystemService("connectivity")).getActiveNetworkInfo();
return activeNetworkInfo != null && activeNetworkInfo.isAvailable();
}
public static boolean t(Context context) {
try {
return ((ConnectivityManager) context.getSystemService("connectivity")).getNetworkInfo(1).getState() == NetworkInfo.State.CONNECTED;
} catch (Throwable th) {
th.printStackTrace();
return false;
}
}
}