mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2026-11-26 23:27:00 +00:00
parser: recognize 蓝奏 ajaxfiles.php in file pages
File page iframes now post to /ajaxfiles.php?file=… instead of ajaxfile.php. The ajax regexes only accepted ajaxm/ajaxfile, so every file share failed with 获取失败0. The form fields are unchanged. Co-authored-by: qaiu <[email protected]>
This commit is contained in:
3 files changed
+134
-3
No files matched your search
@@ -99,11 +99,14 @@ public class LzTool extends PanBase {
|
||||
private static final Pattern P_AJAXDATA = Pattern.compile("ajaxdata\\s*=\\s*'([^']+)'");
|
||||
private static final Pattern P_WEBSIGN = Pattern.compile("'websign'\\s*:\\s*'([^']*)'");
|
||||
private static final Pattern P_WEBPAGE = Pattern.compile("[?&]webpage=([^&\"'\\s#]+)");
|
||||
/** 页面脚本里的绝对 ajax,例如 https://apifile.lanzouw.com/ajaxfile.php?file=123 */
|
||||
/**
|
||||
* 页面脚本里的绝对 ajax,例如 https://apifile.lanzouw.com/ajaxfile.php?file=123。
|
||||
* 文件名有 ajaxm / ajaxfile / ajaxfiles 三种,2026-11 起文件页 iframe 改用 ajaxfiles.php。
|
||||
*/
|
||||
private static final Pattern P_AJAX_ABSOLUTE = Pattern.compile(
|
||||
"['\"]((?:https?:)?//[^'\"\\s<>]+/ajax(?:m|file)\\.php\\?file=\\d+)['\"]",
|
||||
"['\"]((?:https?:)?//[^'\"\\s<>]+/ajax(?:m|files?)\\.php\\?file=\\d+)['\"]",
|
||||
Pattern.CASE_INSENSITIVE);
|
||||
private static final Pattern P_AJAX_PATH = Pattern.compile("(?:['\"/]|^)(ajax(?:m|file)\\.php\\?file=\\d+)");
|
||||
private static final Pattern P_AJAX_PATH = Pattern.compile("(?:['\"/]|^)(ajax(?:m|files?)\\.php\\?file=\\d+)");
|
||||
private static final Pattern P_SIGN = Pattern.compile("'sign'\\s*:\\s*'([^']+)'");
|
||||
private static final Pattern P_ISNGIS = Pattern.compile("var\\s+isngis\\s*=\\s*'([^']+)'");
|
||||
private static final Pattern P_VERIFY_FILE = Pattern.compile("'file'\\s*:\\s*'([^']+)'");
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
package cn.qaiu.parser.impl;
|
||||
|
||||
import cn.qaiu.WebClientVertxInit;
|
||||
import cn.qaiu.entity.ShareLinkInfo;
|
||||
import io.vertx.core.MultiMap;
|
||||
import io.vertx.core.Vertx;
|
||||
import io.vertx.core.http.HttpServer;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* 蓝奏文件页离线回归:2026-11 起文件页 iframe 的下载 ajax 改名为 ajaxfiles.php,
|
||||
* 其余字段(wp_sign / ajaxdata / kd / ves)不变。本地模拟 分享页 → /fn iframe → ajaxfiles.php → 下载域 302。
|
||||
*/
|
||||
public class LzToolAjaxfilesTest {
|
||||
|
||||
private static final String SHARE_KEY = "winx123";
|
||||
private static final String FILE_ID = "333017612";
|
||||
|
||||
private Vertx vertx;
|
||||
private HttpServer server;
|
||||
private final List<String> ajaxPaths = new CopyOnWriteArrayList<>();
|
||||
private final List<MultiMap> ajaxForms = new CopyOnWriteArrayList<>();
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
vertx = Vertx.vertx();
|
||||
WebClientVertxInit.init(vertx);
|
||||
server = vertx.createHttpServer().requestHandler(req -> {
|
||||
String path = req.path();
|
||||
if ("GET".equals(req.method().name()) && path.equals("/" + SHARE_KEY)) {
|
||||
html(req.response(), sharePage());
|
||||
} else if ("GET".equals(req.method().name()) && path.equals("/fn")) {
|
||||
html(req.response(), iframePage());
|
||||
} else if ("POST".equals(req.method().name()) && path.startsWith("/ajax")) {
|
||||
req.setExpectMultipart(true);
|
||||
req.endHandler(v -> {
|
||||
ajaxPaths.add(req.uri());
|
||||
ajaxForms.add(MultiMap.caseInsensitiveMultiMap().addAll(req.formAttributes()));
|
||||
String dom = "http://127.0.0.1:" + server.actualPort();
|
||||
req.response().putHeader("Content-Type", "application/json")
|
||||
.end("{\"zt\":1,\"dom\":\"" + dom + "\",\"url\":\"?mock-token\",\"inf\":0}");
|
||||
});
|
||||
} else if (path.equals("/file/")) {
|
||||
req.response().setStatusCode(302)
|
||||
.putHeader("Location", "http://cdn.test/2026/11/25/steam.zip")
|
||||
.end();
|
||||
} else {
|
||||
req.response().setStatusCode(404).end();
|
||||
}
|
||||
}).listen(0, "127.0.0.1").toCompletionStage().toCompletableFuture().get(10, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@After
|
||||
public void cleanup() throws Exception {
|
||||
server.close().toCompletionStage().toCompletableFuture().get(10, TimeUnit.SECONDS);
|
||||
vertx.close().toCompletionStage().toCompletableFuture().get(10, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filePageWithAjaxfilesIframeResolvesDirectLink() throws Exception {
|
||||
String url = "http://127.0.0.1:" + server.actualPort() + "/" + SHARE_KEY;
|
||||
ShareLinkInfo info = ShareLinkInfo.newBuilder().type("lz").panName("蓝奏云").shareKey(SHARE_KEY)
|
||||
.shareUrl(url).standardUrl(url).build();
|
||||
|
||||
String link = new LzTool(info).parse().toCompletionStage().toCompletableFuture()
|
||||
.get(30, TimeUnit.SECONDS);
|
||||
|
||||
assertEquals("http://cdn.test/2026/11/25/steam.zip", link);
|
||||
assertEquals(List.of("/ajaxfiles.php?file=" + FILE_ID), ajaxPaths);
|
||||
MultiMap form = ajaxForms.get(0);
|
||||
assertEquals("downprocess", form.get("action"));
|
||||
assertEquals("test-wp-sign", form.get("sign"));
|
||||
assertEquals("test-ajaxdata", form.get("websignkey"));
|
||||
assertEquals("test-ajaxdata", form.get("signs"));
|
||||
assertEquals("1", form.get("ves"));
|
||||
}
|
||||
|
||||
private static void html(io.vertx.core.http.HttpServerResponse res, String body) {
|
||||
res.putHeader("Content-Type", "text/html; charset=utf-8").end(body);
|
||||
}
|
||||
|
||||
private static String sharePage() {
|
||||
return """
|
||||
<!DOCTYPE html><html><head><title>steam.zip - 蓝奏云</title>
|
||||
<meta name="description" content="文件大小:1.1 M" /></head><body>
|
||||
<div class="n_box_3fn" id="filenajax">steam.zip</div>
|
||||
<div class="n_file"><div class="n_filesize">大小:1.1 M</div>
|
||||
<iframe class="n_downlink" name="1795620352" src="/fn?mock-fn-query" frameborder="0" scrolling="no"></iframe></div>
|
||||
</body></html>
|
||||
""";
|
||||
}
|
||||
|
||||
private static String iframePage() {
|
||||
return """
|
||||
<html><body><div id="tourl"></div>
|
||||
<script type="text/javascript">
|
||||
var wsk_sign = 'c20230908';
|
||||
var wp_sign = 'test-wp-sign';
|
||||
var ajaxdata = 'test-ajaxdata';
|
||||
var kdns =1;
|
||||
$.ajax({
|
||||
type : 'post',
|
||||
url : '/ajaxfiles.php?file=%s',
|
||||
data : { 'action':'downprocess','websignkey':ajaxdata,'signs':ajaxdata,'sign':wp_sign,'websign':'','kd':kdns,'ves':1 },
|
||||
dataType : 'json'
|
||||
});
|
||||
</script></body></html>
|
||||
""".formatted(FILE_ID);
|
||||
}
|
||||
}
|
||||
@@ -156,6 +156,16 @@ public class LzToolShareUrlTest {
|
||||
assertEquals("https://apifile.lanzouw.com/ajaxm.php?file=42", LzTool.fileAjaxTarget(html));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ajaxfilesEndpointIsRecognized() {
|
||||
assertEquals("/ajaxfiles.php?file=333017612",
|
||||
LzTool.fileAjaxTarget("url : '/ajaxfiles.php?file=333017612',"));
|
||||
assertEquals("https://apifile.lanzouw.com/ajaxfiles.php?file=7",
|
||||
LzTool.fileAjaxTarget("url : 'https://apifile.lanzouw.com/ajaxfiles.php?file=7',"));
|
||||
assertEquals("/ajaxm.php?file=5", LzTool.fileAjaxTarget("url : '/ajaxm.php?file=5',"));
|
||||
assertNull(LzTool.fileAjaxTarget("url : '/ajaxfilex.php?file=5',"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void relativeFileAjaxFallsThroughToApifileBeforeWwww() {
|
||||
String html = "url : '/ajaxfile.php?file=150233466',";
|
||||
|
||||
Reference in new issue
Block a user