如何计算摘要/将使用哪种算法?
How to calculate the digest / Which algorithm will be used?
我发现了一个从Java JNI调用的C++ API。该libcma.so
包含将创建摘要的方法Java_com_smule_android_network_core_NetworkUtils_makeDigest
- 我认为它MD5
.
这是相反的来源:
https://raw.githubusercontent.com/Bizarrus/Sing/master/cma.cpp
这是JNI
定义:
https://github.com/Bizarrus/Sing/blob/7ef0e748bae710bde2d07111bd66f1e7fc0810b4/com/smule/android/network/core/NetworkUtils.java#L53
谁能告诉我,将使用哪种Algorithm
?
编辑
将进行以下HTTP-Request
:
POST http://api-sing.smule.com/v2/login/guest?msgId=1776&appVersion=5.7.5&app=sing_google&appVariant=1&digest=179645edb702ce4a57197141522d848145f8861f HTTP/1.1
User-Agent: com.smule.singandroid/5.7.5 (6.0,F3311,de_DE)
Content-Type: application/json; charset=UTF-8
Content-Length: 501
Host: api-sing.smule.com
Connection: Keep-Alive
Accept-Encoding: gzip
{
"common": {
"advId": "e133b6d9-25b1-4651-b4b8-94d80fa25ed9",
"automaticLogin": true,
"device": {
"carrierCountry": "de",
"country": "DE",
"deviceId": "a:e133b6d9-25b1-4651-b4b8-94d80fa25ed9",
"deviceType": "AND",
"googlePlayServices": "12.6.85 (040306-197041431)",
"hasMail": true,
"lang": "de",
"limitAdTrack": false,
"locale": "de_DE",
"machine": "F3311",
"manufacturer": "Sony",
"os": "6.0",
"product": "F3311",
"screenSize": "normal",
"script": ""
},
"pulp": 17,
"tzOffset": 3600,
"vorgom": true
},
"forceNewPlayer": true,
"lookupAccount": true
}
具有以下Response
:
HTTP/1.1 200 OK
Server: nginx/1.11.5
Date: Sun, 24 Jun 2018 16:27:31 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
X-Smule-Host: a155.sf.smle.co
X-Smule-Digest: 64dc15893bbf43240798c73ae652bfb80e848f57
Set-Cookie: L=N; Max-Age=172800; Expires=Tue, 26 Jun 2018 16:27:31 GMT; Path=/; Domain=.smule.com; Secure
Cache-Control: no-cache
Content-Encoding: gzip
{
"data": {
"loginResult": {
"elControl": {
"npt": false
},
"handleNew": false,
"handlePrefill": true,
"language": "de",
"loginCount": 1,
"playerId": 1762444898,
"playerNew": true,
"playerNewlyRegistered": false,
"playerStat": {
"installDate": 1529857651000
},
"policyUrl": "https://www.smule.com/privacy/embed/20180523",
"policyVersion": "PRIVACY_POLICY_20180523",
"serverTime": 1529857651,
"sessionToken": "g4_10_wma5HOX13kDeho2gvEuIQyf5EnUaAp0Uw3C24O5w9s9xUB1U0JOC0w==",
"sessionTtl": 86400,
"showEmailOpt": true,
"termUrl": "https://www.smule.com/termsofservice/embed/20180523"
},
"settings": {}
},
"status": {
"code": 0,
"message": "ok",
"version": 1
}
}
在POST
请求中,Query-Argument
**摘要is the
哈希of the request. These
摘要will be created by
Java_com_smule_android_network_core_NetworkUtils_makeDigest(i think). I don't know, which data will be used for the
哈希算法- I've tried to reproduce the
摘要",参数如下:
- 只有所有
Query-Parameters
,按字母顺序排序,不包括digest
-Argument(这些方法将在JavaScript下在网站上使用' - 只有内容正文,在 JSON 字符串中(尝试作为漂亮的印刷和组合(
- 预期的内容正文和查询参数 如上所述
我已经尝试了一些数据组合来重现digest
,但我没有找到解决方案,这些数据重新发送了原始摘要。
从X-Smule-Digest
头上的Response
将按我上周重新制作的MD5
进行哈希处理。这里(PHP
(一个工作样本来计算X-Smule-Digest
:
$string = sprintf('%s=%s', 'secret', 'M=|ZUyMu^-qWb}VL^jJd}Mv)8y%bQWXf>IFBDcJ>%4zg2Ci|telj`dVZ@');
$string .= sprintf('&%s=%s', 'path', '/user/json/login'); // sample url-path
$string .= sprintf('&%s=%s', 'csrf', $this->csrf); // from Website, <meta content="([^"]+)" name="csrf-token" or from Header "x-csrf-token"
$string .= sprintf('&%s', http_build_query($this->data)); // POST-Body
$array = explode('&', $string);
sort($array); // Alphabetical sort
$x_smule_digest = md5(implode('&', $array));
1 .您指示的摘要长度为 40 个字符,包含从0
到9
的数字和从a
到f
的字母。所以它是 40 个十六进制值。因此,它很可能是使用摘要函数创建的SHA-1
。
阿拉伯数字。您指示的C++函数具有以下签名:
int32_t Java_com_smule_android_network_core_NetworkUtils_makeDigest(int32_t * a1, int32_t a2, int32_t a3)
而Java源代码中对应的签名是:
private static native String makeDigest(String str, byte[] bArr);
第一个参数a1
可能是 JNI 环境保留的指针。因此,输入a1
输入放在一边,该函数接受两个参数:一个字符串和一个字节数组,并返回一个字符串:摘要。C++代码本身太复杂了,我无法深入研究。
3 .此 JNI 函数在您指定的 Java 文件中使用两次。在函数m18107a
和m18106a
.让我们在源代码中添加一些注释:
// Function that takes three arguments :
// - a list of pairs of string we will call the "json pairs"
// - a string we will call the "secret"
// - an other string we will call the "optional token"
// and return the returned string of makeDigest which may be the digest.
public static String m18107a(List<Pair<String, String>> list, String str, String str2)
{
// Sort the json pairs alphabetically according to the first string of each pairs.
// (Check the source code of C35442 to verify my statement, I may be wrong )
Collections.sort(list, new C35442());
// Create a single string, that concatenate all the json pairs.
// ( I guess { age : 21, name : "bob" } becomes "age21namebob" )
// We will call that the "digest input"
StringBuilder stringBuilder = new StringBuilder();
for (Pair pair : list) {
stringBuilder.append((String) pair.first).append((String) pair.second);
}
// Append the "digest input" just created with the "optional token" if it exists.
if (str2 != null) {
stringBuilder.append(str2);
}
// Send the "secret" string, and the "digest input" as BYTES (may be important)
// Return the digest computed as returned string of the function.
return makeDigest(str, stringBuilder.toString().getBytes());
}
// Function that takes four arguments :
// - a string str
// - a number j
// - a string str2
// - a string str3 (can be null, as seen later)
// and return the returned string of makeDigest which may be the digest.
public static String m18106a(String str, long j, String str2, String str3)
{
// Create a single string, that concatenate j and str2.
// We will call that the "digest input"
StringBuilder append = new StringBuilder().append("").append(j).append(str2);
// If str3 is null, make it empty.
if (str3 == null) {
str3 = "";
}
// Send the "secret" string, and the "digest input" concatenated with str3, as BYTES (may be important).
// Return the digest computed as returned string of the function.
return makeDigest(str, append.append(str3).toString().getBytes());
}
很难走得更远。尝试挖掘一些东西:
- 这些函数
m18107a
和m18106a
在哪里调用?您至少可以找到这些输入的内容吗?因此,您可以使用良好的输入。 - 你能在这些函数周围放置断点吗?跟踪输入和输出并尝试重现?
- 从所有可疑的输入中,您能找到一种方法来仅修改每个输入一个并检查摘要是否更改吗?消除可疑输入。
- 如何实现高效的算法来计算大型数据集的多个不同值?
- OpenCV - Python 断言错误:SAD 算法 - 立体相机视差图计算
- 通过指针算法计算数组长度
- 计算数组重复次数的组合的有效算法,加起来达到给定的总和
- 我们如何并行运行算法的 n 个实例并以有效的方式计算结果函数的平均值?
- 当比特数不是8的倍数时,使用切片8算法计算CRC
- 使用 Prim 算法计算最小生成树:如何使其简单?
- 计算数组中存在其总和的对数的算法
- 如何计算摘要/将使用哪种算法?
- 如何在不导致堆栈溢出的情况下计算非常大的数字和很小的 HCF.我正在使用欧几里得算法
- 如何通过 stl 容器和算法库计算两个向量的内积?
- 使用加法链接计算 (a^x)mod n.C++算法
- 通过分而治算法计算数组的最大数量
- 浮点计算可以用于任何可靠的函数,特别是容器和算法吗?
- OPENCV:如何使用5点算法从来自不同相机的两个图像之间的特征匹配来计算必需矩阵
- MFC 用于计算控件的高光、阴影等的算法或函数是什么?
- 如何在BFS算法中计算移动?(迷宫中的最短路径)
- 使用什么算法来计算浮点半径的圆
- 递归矩阵乘法算法无法计算
- 使用rtree(或任何其他算法)计算向量中组的频率