51黑料 v2.0版本的 MD5 值为:cc00ad70c70d95f274d15d4654c16262

以下内容为反编译后的 c.java 源代码,内容仅作参考


package g.a.b.f;

import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
import android.text.TextUtils;
import g.a.b.c.d;
import g.a.b.e.a;
import g.a.b.j.h;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.security.KeyFactory;
import java.security.PublicKey;
import java.security.spec.X509EncodedKeySpec;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.crypto.Cipher;
import net.sourceforge.pinyin4j.ChineseToPinyinResource;
import org.json.JSONException;
import org.json.JSONObject;
public abstract class c {
    public static JSONObject g(String str, String str2) {
        JSONObject jSONObject = new JSONObject();
        JSONObject jSONObject2 = new JSONObject();
        jSONObject2.put("type", str);
        jSONObject2.put("method", str2);
        jSONObject.put("action", jSONObject2);
        return jSONObject;
    }

    public static boolean h(a.b bVar) {
        List<String> list;
        Map<String, List<String>> map = bVar.a;
        return Boolean.valueOf((map == null || (list = map.get("msp-gzip")) == null) ? null : TextUtils.join(ChineseToPinyinResource.Field.COMMA, list)).booleanValue();
    }

    public a a(g.a.b.h.a aVar, Context context, String str) {
        if (context != null) {
            TextUtils.isEmpty("https://mobilegw.alipay.com/mgw.htm");
        }
        return b(aVar, context, str, "https://mobilegw.alipay.com/mgw.htm", true);
    }

    public a b(g.a.b.h.a aVar, Context context, String str, String str2, boolean z) {
        byte[] bArr;
        boolean z2;
        ByteArrayOutputStream byteArrayOutputStream;
        byte[] bArr2;
        byte[] bArr3;
        a.b a;
        ByteArrayInputStream byteArrayInputStream;
        ByteArrayInputStream byteArrayInputStream2;
        String str3;
        String str4;
        a aVar2;
        e.a.a.b.a.G("mspl", "Packet: " + str2);
        String b = h.b(24);
        String j2 = j();
        String c = c(aVar, str, f());
        Map<String, String> e2 = e(false, str);
        String str5 = e2.get("iSr");
        byte[] bytes = j2.getBytes();
        byte[] bytes2 = c.getBytes();
        try {
            bArr = e.a.a.b.a.r(bytes2);
            z2 = true;
        } catch (Exception unused) {
            bArr = bytes2;
            z2 = false;
        }
        try {
            PublicKey generatePublic = KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(g.a.b.d.a.b(g.a.b.b.a.a)));
            Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
            cipher.init(1, generatePublic);
            byte[] bytes3 = b.getBytes("UTF-8");
            int blockSize = cipher.getBlockSize();
            byteArrayOutputStream = new ByteArrayOutputStream();
            for (int i2 = 0; i2 < bytes3.length; i2 += blockSize) {
                try {
                    try {
                        byteArrayOutputStream.write(cipher.doFinal(bytes3, i2, bytes3.length - i2 < blockSize ? bytes3.length - i2 : blockSize));
                    } catch (Exception e3) {
                        e = e3;
                        e.a.a.b.a.l(e);
                        if (byteArrayOutputStream != null) {
                            bArr3 = null;
                            bArr2 = bArr3;
                            byteArrayOutputStream.close();
                            boolean z3 = false;
                            a = g.a.b.e.a.a(context, new a.C0037a(str2, e(z2, str), b.a(bytes, bArr2, g.a.b.d.b.a(b, bArr, str5))));
                            if (a != null) {
                            }
                        } else {
                            bArr2 = null;
                            boolean z32 = false;
                            a = g.a.b.e.a.a(context, new a.C0037a(str2, e(z2, str), b.a(bytes, bArr2, g.a.b.d.b.a(b, bArr, str5))));
                            if (a != null) {
                            }
                        }
                    }
                } catch (Throwable th) {
                    th = th;
                    Throwable th2 = th;
                    if (byteArrayOutputStream != null) {
                        try {
                            byteArrayOutputStream.close();
                        } catch (IOException e4) {
                            e.a.a.b.a.l(e4);
                        }
                    }
                    throw th2;
                }
            }
            bArr3 = byteArrayOutputStream.toByteArray();
        } catch (Exception e5) {
            e = e5;
            byteArrayOutputStream = null;
        } catch (Throwable th3) {
            th = th3;
            byteArrayOutputStream = null;
            Throwable th22 = th;
            if (byteArrayOutputStream != null) {
            }
            throw th22;
        }
        bArr2 = bArr3;
        try {
            byteArrayOutputStream.close();
        } catch (IOException e6) {
            e.a.a.b.a.l(e6);
        }
        boolean z322 = false;
        a = g.a.b.e.a.a(context, new a.C0037a(str2, e(z2, str), b.a(bytes, bArr2, g.a.b.d.b.a(b, bArr, str5))));
        if (a != null) {
            boolean h2 = h(a);
            byte[] bArr4 = a.b;
            String str6 = e2.get("iSr");
            try {
                byteArrayInputStream2 = new ByteArrayInputStream(bArr4);
                try {
                    try {
                        byte[] bArr5 = new byte[5];
                        byteArrayInputStream2.read(bArr5);
                        byte[] bArr6 = new byte[Integer.parseInt(new String(bArr5))];
                        byteArrayInputStream2.read(bArr6);
                        str3 = new String(bArr6);
                        try {
                            byte[] bArr7 = new byte[5];
                            byteArrayInputStream2.read(bArr7);
                            int parseInt = Integer.parseInt(new String(bArr7));
                            if (parseInt > 0) {
                                byte[] bArr8 = new byte[parseInt];
                                byteArrayInputStream2.read(bArr8);
                                byte[] b2 = g.a.b.d.b.b(b, bArr8, str6);
                                if (h2) {
                                    b2 = e.a.a.b.a.x(b2);
                                }
                                str4 = new String(b2);
                            } else {
                                str4 = null;
                            }
                            try {
                                byteArrayInputStream2.close();
                            } catch (Exception unused2) {
                            }
                        } catch (Exception e7) {
                            e = e7;
                            e.a.a.b.a.l(e);
                            if (byteArrayInputStream2 != null) {
                                try {
                                    byteArrayInputStream2.close();
                                } catch (Exception unused3) {
                                }
                            }
                            str4 = null;
                            aVar2 = (str3 == null || str4 != null) ? new a(str3, str4) : null;
                            if (aVar2 != null) {
                            }
                        }
                    } catch (Exception e8) {
                        e = e8;
                        str3 = null;
                        e.a.a.b.a.l(e);
                        if (byteArrayInputStream2 != null) {
                        }
                        str4 = null;
                        aVar2 = (str3 == null || str4 != null) ? new a(str3, str4) : null;
                        if (aVar2 != null) {
                        }
                    }
                } catch (Throwable th4) {
                    th = th4;
                    byteArrayInputStream = byteArrayInputStream2;
                    if (byteArrayInputStream != null) {
                        try {
                            byteArrayInputStream.close();
                        } catch (Exception unused4) {
                        }
                    }
                    throw th;
                }
            } catch (Exception e9) {
                e = e9;
                byteArrayInputStream2 = null;
            } catch (Throwable th5) {
                th = th5;
                byteArrayInputStream = null;
                if (byteArrayInputStream != null) {
                }
                throw th;
            }
            aVar2 = (str3 == null || str4 != null) ? new a(str3, str4) : null;
            if (aVar2 != null) {
                String str7 = aVar2.a;
                if (!TextUtils.isEmpty(str7)) {
                    try {
                        JSONObject jSONObject = new JSONObject(str7).getJSONObject("data");
                        if (jSONObject.has("params")) {
                            String optString = jSONObject.getJSONObject("params").optString("public_key", null);
                            if (!TextUtils.isEmpty(optString)) {
                                d.c(optString);
                                z322 = true;
                            }
                        }
                    } catch (JSONException e10) {
                        e.a.a.b.a.l(e10);
                    }
                }
                return (z322 && z) ? b(aVar, context, str, str2, false) : aVar2;
            }
            return aVar2;
        }
        throw new RuntimeException("Response is null.");
    }

    public String c(g.a.b.h.a aVar, String str, JSONObject jSONObject) {
        g.a.b.h.b a = g.a.b.h.b.a();
        g.a.b.i.a a2 = g.a.b.i.a.a(a.a);
        JSONObject jSONObject2 = new JSONObject();
        JSONObject jSONObject3 = new JSONObject();
        boolean z = false;
        try {
            JSONObject[] jSONObjectArr = {jSONObject2, jSONObject};
            for (int i2 = 0; i2 < 2; i2++) {
                JSONObject jSONObject4 = jSONObjectArr[i2];
                if (jSONObject4 != null) {
                    Iterator<String> keys = jSONObject4.keys();
                    while (keys.hasNext()) {
                        String next = keys.next();
                        jSONObject3.put(next, jSONObject4.get(next));
                    }
                }
            }
        } catch (JSONException e2) {
            e.a.a.b.a.l(e2);
        }
        try {
            jSONObject3.put("external_info", str);
            jSONObject3.put("tid", a2.a);
            jSONObject3.put("user_agent", d.d().b(aVar, a2));
            jSONObject3.put("has_alipay", h.k(aVar, a.a, g.a.b.a.d.f2017d));
            try {
                if (a.a.getPackageManager().getPackageInfo("com.alipay.android.app", 128) != null) {
                    z = true;
                }
            } catch (PackageManager.NameNotFoundException unused) {
            }
            jSONObject3.put("has_msp_app", z);
            jSONObject3.put("app_key", "2014052600006128");
            jSONObject3.put("utdid", a.c());
            jSONObject3.put("new_client_key", a2.b);
            jSONObject3.put("pa", d.a(a.a));
        } catch (Throwable th) {
            g.a.b.a.g.c.d(aVar, "biz", "BodyErr", th);
            e.a.a.b.a.l(th);
        }
        return jSONObject3.toString();
    }

    public String d(HashMap<String, String> hashMap, HashMap<String, String> hashMap2) {
        JSONObject jSONObject = new JSONObject();
        JSONObject jSONObject2 = new JSONObject();
        for (Map.Entry<String, String> entry : hashMap.entrySet()) {
            jSONObject2.put(entry.getKey(), entry.getValue());
        }
        JSONObject jSONObject3 = new JSONObject();
        for (Map.Entry<String, String> entry2 : hashMap2.entrySet()) {
            jSONObject3.put(entry2.getKey(), entry2.getValue());
        }
        jSONObject2.put("params", jSONObject3);
        jSONObject.put("data", jSONObject2);
        return jSONObject.toString();
    }

    public Map<String, String> e(boolean z, String str) {
        HashMap hashMap = new HashMap();
        hashMap.put("msp-gzip", String.valueOf(z));
        hashMap.put("Operation-Type", "alipay.msp.cashier.dispatch.bytes");
        hashMap.put("content-type", "application/octet-stream");
        hashMap.put("Version", "2.0");
        hashMap.put("AppId", "TAOBAO");
        String str2 = "";
        if (!TextUtils.isEmpty(str)) {
            String[] split = str.split("&");
            if (split.length != 0) {
                String str3 = null;
                String str4 = null;
                String str5 = null;
                String str6 = null;
                for (String str7 : split) {
                    if (TextUtils.isEmpty(str3)) {
                        str3 = !str7.contains("biz_type") ? null : e.a.a.b.a.F(str7);
                    }
                    if (TextUtils.isEmpty(str4)) {
                        str4 = !str7.contains("biz_no") ? null : e.a.a.b.a.F(str7);
                    }
                    if (TextUtils.isEmpty(str5)) {
                        str5 = (!str7.contains("trade_no") || str7.startsWith("out_trade_no")) ? null : e.a.a.b.a.F(str7);
                    }
                    if (TextUtils.isEmpty(str6)) {
                        str6 = !str7.contains("app_userid") ? null : e.a.a.b.a.F(str7);
                    }
                }
                StringBuilder sb = new StringBuilder();
                if (!TextUtils.isEmpty(str3)) {
                    sb.append("biz_type=" + str3 + ";");
                }
                if (!TextUtils.isEmpty(str4)) {
                    sb.append("biz_no=" + str4 + ";");
                }
                if (!TextUtils.isEmpty(str5)) {
                    sb.append("trade_no=" + str5 + ";");
                }
                if (!TextUtils.isEmpty(str6)) {
                    sb.append("app_userid=" + str6 + ";");
                }
                String sb2 = sb.toString();
                if (sb2.endsWith(";")) {
                    sb2 = sb2.substring(0, sb2.length() - 1);
                }
                str2 = sb2;
            }
        }
        hashMap.put("Msp-Param", str2);
        hashMap.put("des-mode", "CBC");
        return hashMap;
    }

    public abstract JSONObject f();

    public String i() {
        return "4.9.0";
    }

    public String j() {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("device", Build.MODEL);
        hashMap.put("namespace", "com.alipay.mobilecashier");
        hashMap.put("api_name", "com.alipay.mcpay");
        hashMap.put("api_version", i());
        return d(hashMap, new HashMap<>());
    }
}