抖音APP接口签名xgorgon和 xlog 算法和 注册设备号算法

x-gorgon和 xlog算法几乎是大家玩抖音的必经之路,为了方便大家更好的跑起来自己的业务,留下邮箱,会给大家免费测试的机会,来迅速验证自己的业务能够跑起来。

1.x-gorgon的关键地点
抖音APP接口签名xgorgon和 xlog 算法和 注册设备号算法_第1张图片
2、xlog的做法

GET https://xlog.snssdk.com/v2/s?os=0&ver=0.6.10.25.17-IH-Do&m=2&app_ver=9.9.0&region=zh_CN&aid=1128&did=19671560880 HTTP/1.1
Host: xlog.snssdk.com
Connection: keep-alive
Cookie: sessionid=
X-SS-REQ-TICKET: 1582898273153
sdk-version: 1
x-tt-trace-id: 00-8c16dd31094948432b05140591f60468-8c16dd3109494843-01
User-Agent: com.ss.android.ugc.aweme/990 (Linux; U; Android 5.1.1; zh_CN; YQ601; Build/LMY47V; Cronet/77.0.3844.0)
Accept-Encoding: gzip, deflate
X-Gorgon: 0401d012000449c94d909ca41fa968eb6a8ab9ea7528d54eadae
X-Khronos: 1582898273


首先调用解密方法,将02开头的 byte[]数组进行解密,解密后是一个json字符串,然后再调用xlog加密接口进行加密,然后提交,返回的依然是一个02开头的,然后再进行解密,就可以看到结果了,
再次之前还有一个 sdfp包,也是需要用到这个加密解密的 可以参考文档

package hook;

import android.text.TextUtils;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public final class ByteUtil {

  private static final String NULL_MD5_STRING = "00000000000000000000000000000000";

  public static byte[] b(String paramString) {
    int i = paramString.length();
    byte[] arrayOfByte = new byte[i / 2];
    for (byte b = 0; b < i; b += 2)
      arrayOfByte[b / 2] = (byte)((Character.digit(paramString.charAt(b), 16) << 4) + Character
          .digit(paramString.charAt(b + 1), 16));
    return arrayOfByte;
  }

  public static String ByteToStr(byte[] bArr) {

    int i = 0;

    char[] toCharArray = "0123456789abcdef".toCharArray();
    char[] cArr = new char[(bArr.length * 2)];
    while (i < bArr.length) {
      int i2 = bArr[i] & 255;
      int i3 = i * 2;
      cArr[i3] = toCharArray[i2 >>> 4];
      cArr[i3 + 1] = toCharArray[i2 & 15];
      i++;
    }
    return new String(cArr);
  }

  public static String getXGon(String url, String stub, String ck, String sessionid){
    StringBuilder sb=new StringBuilder();
    if (TextUtils.isEmpty(url)){
      sb.append(NULL_MD5_STRING);
    }else {
      sb.append(encryption(url).toLowerCase());
    }

    if (TextUtils.isEmpty(stub)){
      sb.append(NULL_MD5_STRING);
    }else {
      sb.append(stub);
    }

    if (TextUtils.isEmpty(ck)){
      sb.append(NULL_MD5_STRING);
    }else {
      sb.append(encryption(ck).toLowerCase());
    }

    if (TextUtils.isEmpty(sessionid)){
      sb.append(NULL_MD5_STRING);
    }else {
      sb.append(encryption(sessionid).toLowerCase());
    }
    return sb.toString();
  }

  public static String encryption(String str) {
    String re_md5=null;
    try {
      MessageDigest md = MessageDigest.getInstance("MD5");
      md.update(str.getBytes());
      byte b[] = md.digest();

      int i;

      StringBuffer buf = new StringBuffer("");
      for (int offset = 0; offset < b.length; offset++) {
        i = b[offset];
        if (i < 0)
          i += 256;
        if (i < 16)
          buf.append("0");
        buf.append(Integer.toHexString(i));
      }

      re_md5 = buf.toString();

    } catch (NoSuchAlgorithmException e) {
      e.printStackTrace();
    }
    return re_md5.toUpperCase();
  }

  public static byte[] StrToByte(String str) {
    String str2 = str;
    Object[] objArr = new Object[1];
    int i = 0;
    objArr[0] = str2;

    int length = str.length();
    byte[] bArr = new byte[(length / 2)];
    while (i < length) {
      bArr[i / 2] = (byte) ((Character.digit(str2.charAt(i), 16) << 4) + Character
          .digit(str2.charAt(i + 1), 16));
      i += 2;
    }
    return bArr;
  }
}

你可能感兴趣的:(抖音和快手)