mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2025-12-16 04:13:03 +00:00
@@ -3,15 +3,14 @@ package cn.qaiu.parser.impl;
|
||||
import cn.qaiu.entity.FileInfo;
|
||||
import cn.qaiu.entity.ShareLinkInfo;
|
||||
import cn.qaiu.parser.PanBase;
|
||||
import cn.qaiu.util.CastUtil;
|
||||
import cn.qaiu.util.FileSizeConverter;
|
||||
import cn.qaiu.util.HeaderUtils;
|
||||
import cn.qaiu.util.JsExecUtils;
|
||||
import cn.qaiu.util.*;
|
||||
import io.netty.handler.codec.http.cookie.DefaultCookie;
|
||||
import io.vertx.core.Future;
|
||||
import io.vertx.core.MultiMap;
|
||||
import io.vertx.core.Promise;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.ext.web.client.WebClient;
|
||||
import io.vertx.ext.web.client.WebClientSession;
|
||||
import org.openjdk.nashorn.api.scripting.ScriptObjectMirror;
|
||||
|
||||
import javax.script.ScriptException;
|
||||
@@ -28,7 +27,7 @@ import java.util.regex.Pattern;
|
||||
*/
|
||||
public class LzTool extends PanBase {
|
||||
|
||||
public static final String SHARE_URL_PREFIX = "https://wwww.lanzoup.com";
|
||||
public static final String SHARE_URL_PREFIX = "https://wwww.lanzoum.com";
|
||||
|
||||
|
||||
public LzTool(ShareLinkInfo shareLinkInfo) {
|
||||
@@ -117,7 +116,7 @@ public class LzTool extends PanBase {
|
||||
map.add((String) k, v.toString());
|
||||
});
|
||||
MultiMap headers = HeaderUtils.parseHeaders("""
|
||||
Accept: application/json, text/javascript, */*
|
||||
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
|
||||
Accept-Encoding: gzip, deflate, br, zstd
|
||||
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6
|
||||
Cache-Control: no-cache
|
||||
@@ -146,8 +145,38 @@ public class LzTool extends PanBase {
|
||||
}
|
||||
String downUrl = urlJson.getString("dom") + "/file/" + urlJson.getString("url");
|
||||
headers.remove("Referer");
|
||||
client.getAbs(downUrl).putHeaders(headers).send()
|
||||
.onSuccess(res3 -> promise.complete(res3.headers().get("Location")))
|
||||
WebClientSession webClientSession = WebClientSession.create(client);
|
||||
webClientSession.getAbs(downUrl).putHeaders(headers).send()
|
||||
.onSuccess(res3 -> {
|
||||
String location = res3.headers().get("Location");
|
||||
if (location == null) {
|
||||
String text = asText(res3);
|
||||
// 使用cookie 再请求一次
|
||||
headers.add("Referer", downUrl);
|
||||
int beginIndex = text.indexOf("arg1='") + 6;
|
||||
String arg1 = text.substring(beginIndex, text.indexOf("';", beginIndex));
|
||||
String acw_sc__v2 = AcwScV2Generator.acwScV2Simple(arg1);
|
||||
// 创建一个 Cookie 并放入 CookieStore
|
||||
DefaultCookie nettyCookie = new DefaultCookie("acw_sc__v2", acw_sc__v2);
|
||||
nettyCookie.setDomain(".lanrar.com"); // 设置域名
|
||||
nettyCookie.setPath("/"); // 设置路径
|
||||
nettyCookie.setSecure(false);
|
||||
nettyCookie.setHttpOnly(false);
|
||||
webClientSession.cookieStore().put(nettyCookie);
|
||||
webClientSession.getAbs(downUrl).putHeaders(headers).send()
|
||||
.onSuccess(res4 -> {
|
||||
String location0 = res4.headers().get("Location");
|
||||
if (location0 == null) {
|
||||
fail(downUrl + " -> 直链获取失败, 可能分享已失效");
|
||||
} else {
|
||||
promise.complete(location0);
|
||||
}
|
||||
}).onFailure(handleFail(downUrl));
|
||||
return;
|
||||
}
|
||||
|
||||
promise.complete(location);
|
||||
})
|
||||
.onFailure(handleFail(downUrl));
|
||||
} catch (Exception e) {
|
||||
fail("解析异常");
|
||||
|
||||
52
parser/src/main/java/cn/qaiu/util/AcwScV2Generator.java
Normal file
52
parser/src/main/java/cn/qaiu/util/AcwScV2Generator.java
Normal file
@@ -0,0 +1,52 @@
|
||||
package cn.qaiu.util;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class AcwScV2Generator {
|
||||
|
||||
public static String acwScV2Simple(String arg1) {
|
||||
// 映射表
|
||||
int[] posList = {15,35,29,24,33,16,1,38,10,9,19,31,40,27,22,23,25,
|
||||
13,6,11,39,18,20,8,14,21,32,26,2,30,7,4,17,5,3,
|
||||
28,34,37,12,36};
|
||||
|
||||
String mask = "3000176000856006061501533003690027800375";
|
||||
String[] outPutList = new String[40];
|
||||
Arrays.fill(outPutList, "");
|
||||
|
||||
// 重排 arg1
|
||||
for (int i = 0; i < arg1.length(); i++) {
|
||||
char ch = arg1.charAt(i);
|
||||
for (int j = 0; j < posList.length; j++) {
|
||||
if (posList[j] == i + 1) {
|
||||
outPutList[j] = String.valueOf(ch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder arg2 = new StringBuilder();
|
||||
for (String s : outPutList) {
|
||||
arg2.append(s);
|
||||
}
|
||||
|
||||
// 按 mask 异或
|
||||
StringBuilder result = new StringBuilder();
|
||||
int length = Math.min(arg2.length(), mask.length());
|
||||
|
||||
for (int i = 0; i < length; i += 2) {
|
||||
String strHex = arg2.substring(i, i + 2);
|
||||
String maskHex = mask.substring(i, i + 2);
|
||||
|
||||
int strVal = Integer.parseInt(strHex, 16);
|
||||
int maskVal = Integer.parseInt(maskHex, 16);
|
||||
|
||||
int xor = strVal ^ maskVal;
|
||||
|
||||
// 补齐 2 位小写 16 进制
|
||||
result.append(String.format("%02x", xor));
|
||||
}
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
}
|
||||
18
parser/src/test/java/cn/qaiu/util/AcwScV2GeneratorTest.java
Normal file
18
parser/src/test/java/cn/qaiu/util/AcwScV2GeneratorTest.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package cn.qaiu.util;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import static cn.qaiu.util.AcwScV2Generator.acwScV2Simple;
|
||||
|
||||
public class AcwScV2GeneratorTest {
|
||||
|
||||
// 简单测试
|
||||
@Test
|
||||
public void testCookie() {
|
||||
String arg1 = "3E40CCD6747C0E55B0531DB86380DDA1D08CE247";
|
||||
String cookie = acwScV2Simple(arg1);
|
||||
Assert.assertEquals("68d8c25247df18dd66d24165d11084d09bc00db9", cookie);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user