## 今日头条
【转行三重奏】-爬虫Js逆向复习-今日头条as、cp、_signature参数分析。
## [回到总目录](https://github.com/LeoLin9527/ZSpider)
## 逆向简述
1、feed关键字XHR断点,Call Stack找到如下位置的代码,找到signature参数生成位置。
2、推测this._setParams这个方法生成as,cp参数,断点调试。
![]()
```javascript
function a() {
var t = Math.floor((new Date).getTime() / 1e3)
, e = t.toString(16).toUpperCase()
, i = (0,
o.default)(t).toString().toUpperCase();
if (8 != e.length)
return {
as: "479BB4B7254C150",
cp: "7E0AC8874BB0985"
};
for (var n = i.slice(0, 5), a = i.slice(-5), s = "", r = 0; r < 5; r++)
s += n[r] + e[r];
for (var l = "", u = 0; u < 5; u++)
l += e[u + 3] + a[u];
return {
as: "A1" + s + e.slice(-3),
cp: e.slice(0, 3) + l + "E1"
}
}
var s = i(128)
, o = n(s);
t.exports = a
}
```
3、max_behot_time时间戳,初始为0,后续请求前一请求的返回值。
4、_signature 跟UA指纹有关,页面加载完毕全局搜索或从步骤一XHR追踪位置,发现由g.sign生成。
5、解决方案一、使用selenium执行JS代码 return window.TAC.sign(max_behot_time_tmp)。
6、调试g.sign,js的anonymous算法应用了控制流平坦方式,无法从g.sign得出结果,往上查找g对象寻找思路。
7、o对象涵盖一些已经生成好函数,那么下列代码个人理解为若该函数已经生成则直接调用,不存在则进行生成。
```javascript
function t(a) {
if (o[a])
return o[a].exports;
var r = o[a] = {
exports: {},
id: a,
loaded: !1
};
return e[a].call(r.exports, r, r.exports, t),
r.loaded = !0,
r.exports
}
```
8、那么a=87时候,e[a]表示的函数为下列
```
function(e, t) {
Function(function(e) {
return 'e(e,a,r){(b[e]||(b[e]=t("x,y","x "+e+" y")(r,a)}a(e,a,r){(k[r]||(k[r]=t("x,y","new x[y]("+Array(r+1).join(",x[y]")(1)+")")(e,a)}r(e,a,r){n,t,s={},b=s.d=r?r.d+1:0;for(s["$"+b]=s,t=0;t<b;t)s[n="$"+t]=r[n];for(t=0,b=s=a;t<b;t)s[t]=a[t];c(e,0,s)}c(t,b,k){u(e){v[x]=e}f{g=,ting(bg)}l{try{y=c(t,b,k)}catch(e){h=e,y=l}}for(h,y,d,g,v=[],x=0;;)switch(g=){case 1:u(!)4:f5:u((e){a=0,r=e;{c=a<r;c&&u(e[a]),c}}(6:y=,u((y8:if(g=,lg,g=,y===c)b+=g;else if(y!==l)y9:c10:u(s(11:y=,u(+y)12:for(y=f,d=[],g=0;g<y;g)d[g]=y.charCodeAt(g)^g+y;u(String.fromCharCode.apply(null,d13:y=,h=delete [y]14:59:u((g=)?(y=x,v.slice(x-=g,y:[])61:u([])62:g=,k[0]=65599*k[0]+k[1].charCodeAt(g)>>>065:h=,y=,[y]=h66:u(e(t[b],,67:y=,d=,u((g=).x===c?r(g.y,y,g.z):g.apply(d,y68:u(e((g=t[b])<"<"?(b--,f):g+g,,70:u(!1)71:n72:+f73:u(parseInt(f,3675:if(){bcase 74:g=<<16>>16g76:u(k[])77:y=,u([y])78:g=,u(a(v,x-=g+1,g79:g=,u(k["$"+g])81:h=,[f]=h82:u([f])83:h=,k[]=h84:!085:void 086:u(v[x-1])88:h=,y=,h,y89:u({e{r(e.y,arguments,k)}e.y=f,e.x=c,e.z=k,e})90:null91:h93:h=0:;default:u((g<<16>>16)-16)}}n=this,t=n.Function,s=Object.keys||(e){a={},r=0;for(c in e)a[r]=c;a=r,a},b={},k={};r'.replace(/[-]/g, function(t) {
return e[15 & t.charCodeAt(0)]
})
}("v[x++]=v[--x]t.charCodeAt(b++)-32function return ))++.substrvar .length(),b+=;break;case ;break}".split("")))()('g,$@drbms!l!n Иb/s"g,&Usz`dlms#g,.}jcb{|zFbxjx}~ms$g,(lfi~ah`{ms%g,)gk}ejo{cms&g,&qnfme|ms\',!^s(,)|doikgauus),,jabSysaWzrrs*,(|fY~d`hs+,&jbfn~cs,,\'nfmosCks-,*icmM`ttSgs.,&eoi{Ks/,)ziy|f~vs0l#l*ms10s2yWl ._b&s o ]1l l Jb<k$.aj;l .Tb<k$.gj/l .^b<k&i"-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c}0l v,1vwg@|{rbvt~S{xlEUmx[ cb-s"gr$Mathvr#minxl!l"["c s=yď(ąo ]%v,-n|jqewVxp{rvmmx,&effkx[!cs l v,*mnxNaadtjgmx,%rceoe[!cs!l!v,,khzJhew}g|yymx,9N_Y[QA{ECWD{WCILLXN^rGAV^[!cs"l!v,,khz_qcs~qasemxl",5@XZYJQ^XBHZnemq{rceoem[!cs#l!v,,khz_qcs~qasemxl",7BVT[HWXZ@rdlgawcuw~oikam[!cs$l#$!/+l$+ ) &{s $ s>yĩ[ s o ]&,\'wd|mbb~ms!l!v!k#}[ s"0s#l#l"o ],mb<ké(Þl"l#ms$[ s%0s&l&l$o ],mb<k\\l$vr$itemxl&[!ckCl%vr$pushxl$vr$itemxl&[!cr$type[!c}l&1+s&jᅲl$r$name$ +s&l$r\'versionk3l&l$r\'version$ ++s&l&l$r(filename$ ++s&l&l%vr$joinx$ [!c+s&l vr$pushxl&[!c}) l#1+s#jjl vr$joinx$!_[!c s?yᱫ,)deec~~nst,*yjb~#|uc{u,%vcuao[#s gr&Objectn s!gr&Objectn s"l %s#l#u&kās$o ]%v,-n|jqewVxp{rvmmx,$wugi[!cs%l%,)`deiF[]],-`cb}|~yx{{tpal%,%vr~dlm,(nfd_dtj,$37val%,%vr~dlm,*ldbyHn}x~jl$ao ]%,$fjb~mv,+j|}katRzzxqmxl%[!c}l!l$l%r+offsetWidthal"l$l%r,offsetHeightao ]%,$fjb~mv,+yi`ayuRzzxqmxl%[!c}jY,+Jbiocu1_|zz,%Dtnie,+J~doc0S~rw~,,Mgn|1Zvvgs`,(I{cj`-C[,,Mgn|1\\rfgy`,5Td~yu:Ishp{EEnpdHDM,0Qc{rx5Cyqzuy=SL,8Zpnhho{~MtFVDtIGY\vaB@@,,Nbad0P|g}dcv,1S}|xwy8Vv<NjfLD,\'Dieci~d,\'Didhyel,,Olcmbxs3Ytb,\'Dmg~~~t,.Mj~egam5Qxlqsx,2Qvzacea9IxtrqsBNMH,*Idadm/Cp|`,-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