回答

收藏

某团外卖9.0版本,sign,hook

悬赏求解 悬赏求解 1505 人阅读 | 0 人回复 | 2020-09-14

package com.sankuai.waimai.platform.net;
import android.content.Context;
import android.util.Base64;
import com.meituan.android.pike.bean.proto.ProtoConstant;
import com.meituan.android.time.c;
import com.meituan.robust.ChangeQuickRedirect;
import com.meituan.robust.PatchProxy;
import com.meituan.robust.utils.RobustBitConfig;
import com.sankuai.waimai.foundation.location.v2.WMLocation;
import com.sankuai.waimai.foundation.location.v2.f;
import com.sankuai.waimai.platform.b;
import java.math.BigInteger;
import java.security.InvalidKeyException;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.RSAPublicKeySpec;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
/* compiled from: StatsParams */
public class d {
    public static ChangeQuickRedirect a;
    private static List<a> s = new ArrayList();
    protected final String b;
    protected final String c;
    protected final String d;
    protected final String e;
    protected final String f;
    protected final String g;
    protected final String h;
    protected final String i;
    protected final String j;
    protected final String k;
    protected final String l;
    protected final String m;
    protected final String n;
    protected final String o;
    protected final String p;
    protected final String q;
    protected Map<String, String> r;
    /* compiled from: StatsParams */
    public interface a {
        Map<String, String> a(String str, Map<String, String> map);
    }
    public d() {
        if (PatchProxy.isSupport(new Object[0], this, a, false, "7d0c1c8c03d2c5cea95a2c29a447d6bf", 6917529027641081856L, new Class[0], Void.TYPE)) {
            PatchProxy.accessDispatch(new Object[0], this, a, false, "7d0c1c8c03d2c5cea95a2c29a447d6bf", new Class[0], Void.TYPE);
            return;
        }
        this.b = "wm_dtype";
        this.c = "wm_dversion";
        this.d = "wm_ctype";
        this.e = "wm_uuid";
        this.f = "wm_did";
        this.g = "wm_visitid";
        this.h = "wm_appversion";
        this.i = "wm_channel";
        this.j = "push_token";
        this.k = "wm_logintoken";
        this.l = "wm_actual_latitude";
        this.m = "wm_actual_longitude";
        this.n = "f";
        this.o = ProtoConstant.TOKEN;
        this.p = "userid";
        this.q = "wm_seq";
        this.r = new HashMap();
    }
    static {
        if (PatchProxy.isSupport(new Object[0], (Object) null, a, true, "6fbd4105c6ebaf2a53733d481b52d7a8", RobustBitConfig.DEFAULT_VALUE, new Class[0], Void.TYPE)) {
            PatchProxy.accessDispatch(new Object[0], (Object) null, a, true, "6fbd4105c6ebaf2a53733d481b52d7a8", new Class[0], Void.TYPE);
        }
    }
    public static void a(a aVar) {
        if (PatchProxy.isSupport(new Object[]{aVar}, (Object) null, a, true, "e62e7656aec14f43acbd6bbdaf804afb", RobustBitConfig.DEFAULT_VALUE, new Class[]{a.class}, Void.TYPE)) {
            PatchProxy.accessDispatch(new Object[]{aVar}, (Object) null, a, true, "e62e7656aec14f43acbd6bbdaf804afb", new Class[]{a.class}, Void.TYPE);
            return;
        }
        s.add(aVar);
    }
    public static void b(a aVar) {
        if (PatchProxy.isSupport(new Object[]{aVar}, (Object) null, a, true, "09e3687c8493e002a248e5d13f469b7e", RobustBitConfig.DEFAULT_VALUE, new Class[]{a.class}, Void.TYPE)) {
            PatchProxy.accessDispatch(new Object[]{aVar}, (Object) null, a, true, "09e3687c8493e002a248e5d13f469b7e", new Class[]{a.class}, Void.TYPE);
            return;
        }
        s.remove(aVar);
    }
    public static d a(Context context) {
        if (!PatchProxy.isSupport(new Object[]{context}, (Object) null, a, true, "85564c3b647697e70f45474dff1f2fde", RobustBitConfig.DEFAULT_VALUE, new Class[]{Context.class}, d.class)) {
            return new d();
        }
        return (d) PatchProxy.accessDispatch(new Object[]{context}, (Object) null, a, true, "85564c3b647697e70f45474dff1f2fde", new Class[]{Context.class}, d.class);
    }
    public final Map<String, String> a(Context context, String str) {
        if (!PatchProxy.isSupport(new Object[]{context, str}, this, a, false, "b9cdfed451d1ce66ef53cdf09dddfe93", RobustBitConfig.DEFAULT_VALUE, new Class[]{Context.class, String.class}, Map.class)) {
            return a(context, str, true);
        }
        return (Map) PatchProxy.accessDispatch(new Object[]{context, str}, this, a, false, "b9cdfed451d1ce66ef53cdf09dddfe93", new Class[]{Context.class, String.class}, Map.class);
    }
    public final Map<String, String> a(Context context, String str, boolean z) {
        if (PatchProxy.isSupport(new Object[]{context, str, new Byte(z ? (byte) 1 : 0)}, this, a, false, "6801dda449fced0a7784cd7a1953f585", RobustBitConfig.DEFAULT_VALUE, new Class[]{Context.class, String.class, Boolean.TYPE}, Map.class)) {
            return (Map) PatchProxy.accessDispatch(new Object[]{context, str, new Byte(z)}, this, a, false, "6801dda449fced0a7784cd7a1953f585", new Class[]{Context.class, String.class, Boolean.TYPE}, Map.class);
        }
        this.r.clear();
        if (!b.x().w()) {
            b.x().a(context);
        }
        b.x().b((Map) this.r);
        this.r.put("wm_dtype", b.x().h());
        this.r.put("wm_dversion", b.x().i());
        this.r.put("wm_ctype", "mtandroid");
        this.r.put("wm_uuid", b.x().d());
        WMLocation i2 = f.a().i();
        if (i2 != null) {
            try {
                double latitude = i2.getLatitude();
                double longitude = i2.getLongitude();
                this.r.put("wm_latitude", String.valueOf((long) (latitude * 1000000.0d)));
                this.r.put("wm_longitude", String.valueOf((long) (longitude * 1000000.0d)));
            } catch (NullPointerException e2) {
            }
        }
        this.r.put("wm_appversion", b.x().j());
        this.r.put("wm_did", b.x().b());
        this.r.put("wm_visitid", b.x().g());
        this.r.put("push_token", b.x().y());
        this.r.put("wm_logintoken", com.sankuai.waimai.platform.domain.manager.user.b.i().d());
        WMLocation e3 = f.a().e();
        if (e3 != null) {
            this.r.put("wm_actual_latitude", String.valueOf((long) (e3.getLatitude() * 1000000.0d)));
            this.r.put("wm_actual_longitude", String.valueOf((long) (e3.getLongitude() * 1000000.0d)));
        } else {
            this.r.put("wm_actual_latitude", "0");
            this.r.put("wm_actual_longitude", "0");
        }
        this.r.put("f", "android");
        com.sankuai.waimai.platform.domain.manager.user.b i3 = com.sankuai.waimai.platform.domain.manager.user.b.i();
        if (i3 != null && i3.a()) {
            this.r.put(ProtoConstant.TOKEN, i3.d());
            this.r.put("userid", String.valueOf(i3.c()));
        }
        this.r.put("wm_mac", b.x().c());
        if (z) {
            int o2 = b.x().o();
            this.r.put("wm_seq", String.valueOf(o2));
            long a2 = c.a();
            this.r.put("req_time", new StringBuilder().append(a2).toString());
            this.r.put("waimai_sign", a(str, o2, a2));
        }
        this.r.put("uuid", b.x().d());
        this.r.put("platform", b.x().t());
        this.r.put("partner", b.x().u());
        this.r.put("version", b.x().j());
        this.r.put("app", b.x().v());
        if (!com.sankuai.waimai.foundation.utils.d.a(s)) {
            for (a a3 : s) {
                try {
                    a3.a(str, this.r);
                } catch (Exception e4) {
                    com.sankuai.waimai.foundation.utils.log.a.a((Throwable) e4);
                }
            }
        }
        return this.r;
    }
    private static String a(String str, int i2, long j2) {
        if (PatchProxy.isSupport(new Object[]{str, new Integer(i2), new Long(j2)}, (Object) null, a, true, "c2e2b9b77b32a35f356f10cada352a63", RobustBitConfig.DEFAULT_VALUE, new Class[]{String.class, Integer.TYPE, Long.TYPE}, String.class)) {
            return (String) PatchProxy.accessDispatch(new Object[]{str, new Integer(i2), new Long(j2)}, (Object) null, a, true, "c2e2b9b77b32a35f356f10cada352a63", new Class[]{String.class, Integer.TYPE, Long.TYPE}, String.class);
        }
        BigInteger bigInteger = new BigInteger("AC14E4A51F1B8E11A95971CA4EBD7E2314631F137596A66A43FA2D792B2FD8447CBD6553D591F00A8B9D58E8BA33C229317A0D122C965D84A286114A963C3AE2694C81665D5AF04C80A71CBF350CD4C66280DC8FADBE6B8EDA7B2EC3D0C50E150850445EF84D3A4192662AC135D912C2CA2C68176D79EC64CACFF34089482B69", 16);
        BigInteger bigInteger2 = new BigInteger("010001", 16);
        try {
            Cipher instance = Cipher.getInstance("RSA/ECB/PKCS1Padding");
            instance.init(1, (RSAPublicKey) KeyFactory.getInstance("RSA").generatePublic(new RSAPublicKeySpec(bigInteger, bigInteger2)));
            return Base64.encodeToString(instance.doFinal((str + "/" + b.x().b() + "/" + j2 + "/" + i2).getBytes()), 0);
        } catch (NoSuchAlgorithmException e2) {
            com.sankuai.waimai.foundation.utils.log.a.e("error", "rsa exception: " + e2.getLocalizedMessage(), new Object[0]);
        } catch (IllegalBlockSizeException e3) {
            com.sankuai.waimai.foundation.utils.log.a.e("error", "rsa exception: " + e3.getLocalizedMessage(), new Object[0]);
        } catch (InvalidKeyException e4) {
            com.sankuai.waimai.foundation.utils.log.a.e("error", "rsa exception: " + e4.getLocalizedMessage(), new Object[0]);
        } catch (BadPaddingException e5) {
            com.sankuai.waimai.foundation.utils.log.a.e("error", "rsa exception: " + e5.getLocalizedMessage(), new Object[0]);
        } catch (InvalidKeySpecException e6) {
            com.sankuai.waimai.foundation.utils.log.a.e("error", "rsa exception: " + e6.getLocalizedMessage(), new Object[0]);
        } catch (NoSuchPaddingException e7) {
            com.sankuai.waimai.foundation.utils.log.a.e("error", "rsa exception: " + e7.getLocalizedMessage(), new Object[0]);
        } catch (Exception e8) {
            com.sankuai.waimai.foundation.utils.log.a.e("error", "rsa exception: " + e8.getLocalizedMessage(), new Object[0]);
        }
        return "";
    }
}


分享到:
回复

使用道具 举报