Fork me on GitHub

爬虫笔记之Google镜像导航链接JS加密破解(http://ac.scmor.com/)

这是个非常非常简单的js加密链接。

 

这是一个导航网站,实际链接到的网站的url被加密了,并没有直接显示在页面上,首先开发者模式选中链接元素:

发现这个链接有一个onclick事件,是调用了visit方法传入了一个很长的看上去像是base64的字符串,猜测实际的url应该就是根据这个字符串生成的,但是怎么跟进去visit方法呢,这个方法能够在html中直接访问到,说明其作用域是全局的,那么切换到console面板,输入刚才那个函数的名称visit回车将其打印:

单击输出,跳转到函数所在的代码:

 可以看到这部分关键的代码在strdecode函数中,如法炮制,跳转到strdecode所在的代码:

 

单击跳转:

 

 

这部分用到了两个全局变量,Gword和hn,通过搜索请求找到这两个变量都在页面doc里声明的:

 

 hn就是域名的主机名部分转为小写,即“ac.scmor.com”,然后就是Gword貌似是作者的邮箱,这样写在页面代码中还不得被各种爬虫发的小广告给烦死啊。。。

 

搞清楚了这两个变量,再回到之前的js:

 默认情况下每个链接都会有一串看上去像是base64的字符串,这里strdecode传入的参数就是那个字符串,传进来的字符串首先进行base64解码,然后基于Gword和hn转换为一个新的base64编码的字符串,然后继续对其base64解码,就得到了最终的url。

根据上面的逻辑编写出代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package cc11001100.misc.crawler.js.acscmorcom;
 
import cc11001100.misc.crawler.utils.HttpUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jsoup.Connection;
 
import java.util.ArrayList;
import java.util.Base64;
import java.util.Collections;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
 
/**
 * http://ac.scmor.com/
 *
 * @author CC11001100
 */
@Slf4j
public class AcscmorcomCrawler {
 
    public static List<String> getMirrorSiteLink() {
        String responseBody = HttpUtil.request("http://ac.scmor.com/", null, Connection.Response::body);
        if (StringUtils.isBlank(responseBody)) {
            log.error("response empty");
            return Collections.emptyList();
        }
        Matcher matcher = Pattern.compile("autourl\\[\\d+] = \"(.+?)\"").matcher(responseBody);
        List<String> result = new ArrayList<>();
        while (matcher.find()) {
            result.add(decodeToLink(matcher.group(1)));
        }
        return result;
    }
 
    /**
     * <pre>
     * function strdecode(string) {
     *     string = base64decode(string);
     *     key = Gword + hn;
     *     len = key.length;
     *     code = '';
     *     for (i = 0; i < string.length; i++) {
     *         var k = i % len;
     *         code += String.fromCharCode(string.charCodeAt(i) ^ key.charCodeAt(k));
     *     }
     *     return base64decode(code);
     * }
     * </pre>
     *
     * @param likeBase64
     * @return
     */
    private static String decodeToLink(String likeBase64) {
        String hn = "ac.scmor.com";
        String gword = "author: link@scmor.com.";
        String s1 = base64DecodeToString(likeBase64);
        String key = gword + hn;
        StringBuilder result = new StringBuilder();
        for (int i = 0; i < s1.length(); i++) {
            char c = (char) (s1.charAt(i) ^ key.charAt(i % key.length()));
            result.append(c);
        }
        return base64DecodeToString(result.toString());
    }
 
    private static String base64DecodeToString(String raw) {
        return new String(Base64.getDecoder().decode(raw));
    }
 
    public static void main(String[] args) {
 
//      System.out.println(decodeToLink("AD0mWAw2VVYgWiAdDB4LHQwqaxY2XxcVL0M9FiEYTxM="));
 
        List<String> list = getMirrorSiteLink();
        System.out.println("count: " + list.size());
        list.forEach(System.out::println);
//      count: 16
//      http://so.hiqq.com.cn/
//      https://sci-hub.org.cn/
//      https://xueshu.soogle.top
//      http://www.ndtsg.com/
//      https://www.80xueshu.com/
//      https://xs.glgoo.top/scholar
//      https://scholar.123admin.com/
//      https://g3.luciaz.me/scholar
//      http://nav.hiqq.com.cn/twy/
//      https://a.g456.top
//      https://g.sudo.gq/
//      https://q.g456.top
//      https://ice.g456.top
//      http://206.189.135.241/
//      https://www.kuaimen.bid/
//      https://gg.chn.moe/
 
    }
 
}

 输出:

 

.

 

posted @   CC11001100  阅读(3602)  评论(0编辑  收藏  举报
编辑推荐:
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架
点击右上角即可分享
微信分享提示