网页抓取解密(visitjs点击函数的作用对这一串字符串进行了解密)

优采云 发布时间: 2022-03-30 05:17

  网页抓取解密(visitjs点击函数的作用对这一串字符串进行了解密)

  首先,从问题开始:

  在 Google Scholar 镜像网络上采集了多个指向 Google 镜像的链接。我们的目标是掌握这些链接。

  F12查看源码,可以发现对应的a标签不是我们要的链接,而是一个js点击函数。

  事实上

  οonclick="访问('AD0mWAw2VVYgWiAdDB4LHQwqaxY2XxcVL0M9FiEYTxM=')"

  在上面的代码中,AD0mWAw2VVYgWiAdDB4LHQwqaxY2XxcVL0M9FiEYTxM=是加密后的url链接。

  角色

  访问函数就是解密和访问这串字符串。

  通过搜索,我们可以清楚访问函数的源码:

  这是段落:

  functionvisit(url) {var newTab = window.open('about:blank'); //打开一个新窗口 if(Gword!='') url =strdecode(url);//解密字符串,转换成url

  newTab.location.href=url;//访问这个url

  }

  ok,又拉出了一个叫strdecode的函数,我们继续找:

  functionstrdecode(string) {

  string=base64decode(string);//base64decode函数处理参数

  key= gword +hn;//gword和hn两个变量可以在网页源码中找到

  len=key.length;//密钥长度

  code= '';for (i = 0; i

  code+= String.fromCharCode(string.charCodeAt(i) ^key.charCodeAt(k));

  }returnbase64decode(code);//使用base64decode处理中间过程产生的code变量,其实这才是真正的url

  }

  其实sredecode的参数串类似“AD0mWAw2VVYgWiAdDB4LHQwqaxY2XxcVL0M9FiEYTxM="

  还有一个函数叫base64decode,我们来找一下:

  好的,一段很长的js代码。我什至不想理解它。

  我该怎么办?

  我们可以使用python的execjs库来执行js代码,只需保存js代码即可。然后我们就这样保存所有可以使用的js:

  execjs 安装:pip install PyExecJS

  var base64DecodeChars = 新数组(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 , -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 1、-1、-1、-1、-1、-1、-1、-1、-1、-1、-1、-1、-1、62、-1、-1、-1、63 , 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 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, -1, -1, -1, -1, -1, -1, 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, -1, -1, -1, -1, -1);functionbase64decode(str) {varc1, c2, c3, *敏*感*词*;vari, len,出;

  len=str.length;

  i=0;

  out="";while (i

  c1= base64DecodeChars[str.charCodeAt(i++) & 0xff]

  }而(我

  c2= base64DecodeChars[str.charCodeAt(i++) & 0xff]

  }而(我

  out+= String.fromCharCode((c1 > 4));do{

  c3= str.charCodeAt(i++) & 0xff;if (c3 == 61) returnout;

  c3=base64DecodeChars[c3]

  }而(我

  out+= String.fromCharCode(((c2 & 0XF) > 2));do{

  *敏*感*词*= str.charCodeAt(i++) & 0xff;if (*敏*感*词* == 61) returnout;

  *敏*感*词*=base64DecodeChars[*敏*感*词*]

  }而(我

  out+= String.fromCharCode(((c3 & 0x03)

0 个评论

要回复文章请先登录注册


官方客服QQ群

微信人工客服

QQ人工客服


线