最近出于学习目的尝试抓取据说难度爆炸的文书网,由于最近恶补了一段时间javascript相关的知识,一开始很顺利,很快找到了列表页的全部抓取加密参数及加密流程。然后抱着昂扬的斗志扑向了详情页。加密参数也很快找齐了,跟开发者工具上的加密效果作对比,完美!一猫一样,然而。。。
然而就是没有任何docId返回,找啊找,原来特妹的_Key这个写在页面里的定值居然会被其他地方的请求篡改。傻了!!找了很久无果后忍不住网上看了看攻略,原来列表页返回的runEval这个参数会用来对_Key进行篡改,然后发现这段代码在被unzip解压后变成了下面这个鬼样子。。。Are you kidding me???这是一堆什么东西?
经过不懈的查资料,原来它本质上来讲就是很正常的javascript代码,只不过灵活应用了javascript的语言特性:自动根据优先级进行类型转换的功能。好吧,我又开始痛苦的学习,终于小有成长,对js这门语言的了解又上了一个台阶。不容易啊不容易,想要了解的可以了解下js的具体基础语法,然后按照我下面逐字逐句的翻译进行理解吧
参考资料:
源文件:
js_fuck = '_="constructor";_[_][_]((+{}+[]+[]+[]+[]+{})[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+$hidescript[(+[])]+([![]]+[][[]])[+!+[]+[+[]]]+$hidescript[(+!+[])]+(!![]+[])[!+[]+!+[]+!+[]]+([]+[]+{})[+!+[]]+(!![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+$hidescript[+!+[]+!+[]]+$hidescript[+!+[]+!+[]+!+[]]+([![]]+{})[+!+[]+[+[]]]+([]+[]+{})[+!+[]]+$hidescript[(+!+[])]+$hidescript[+!+[]+!+[]+!+[]+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+$hidescript[+!+[]+!+[]+!+[]+!+[]]+$hidescript[+!+[]+!+[]+!+[]+!+[]+!+[]]+$hidescript[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]+$hidescript[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]+$hidescript[+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[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]+$hidescript[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]])();'
"""
1. (+{}+[]+[]+[]+[]+{})
2. (NaN+0+0+0+[object Object]) ===> 'NaN[object Object]'
"""
"""
1. [+!+[]+[+[]]]
2. [+!0+[0]]
3. [1+[0]] ===> ['10']
"""
# 'NaN[object Object]'["10"] ===> ' '
"""
1. (![]+[])
2. false+[] ===> ('false') ===> 'false'
"""
"""
1. [!+[]+!+[]+!+[]]
2. [1+1+1] ===> [3]
"""
# (![]+[])[!+[]+!+[]+!+[]] ===> 'false'[3] ===> s
"""
1. (!![]+[])
2. (true+[]) ===> ('true') ===> 'true'
"""
# (!![]+[])[!+[]+!+[]+!+[]] ===> 'true'[3] ===> e
# (!![]+[])[+[]] ===> 'true'[0] ===> t
"""
1. [(+[])]
2. [0]
"""
"""
1. ([![]]+[][[]])
2. ([false]+[][0])
3. ([false]+undefined)
4. ("false"+"undefined") ===> "falseundefined"
"""
"""
1. [(+!+[])]
2. [(1)] ===> [1]
"""
"""
1. ([]+[]+{})
2. ([]+[object Object])
3. ('[object Object]') ===> "[object Object]"
"""
"""
1. [+!+[]]
2. [1]
"""
"""
1. [!+[]+!+[]]
2. [2]
"""
"""
1. ([![]]+{})
2. ([false]+{})
3. "false[object Object]"
"""
"""
1. ([]+[]+[][[]])
2. (""+undefined) ===> "undefined"
"""
js_fuck = js_fuck.replace('(+{}+[]+[]+[]+[]+{})', '"NaN[object Object]"')
js_fuck = js_fuck.replace('([]+[]+{})', '"[object Object]"')
js_fuck = js_fuck.replace('([![]]+{})', '"false[object Object]"')
js_fuck = js_fuck.replace('([![]]+[][[]])', '"falseundefined"')
js_fuck = js_fuck.replace('(!![]+[])', "'true'")
js_fuck = js_fuck.replace('(![]+[])', '"false"')
js_fuck = js_fuck.replace('([]+[]+[][[]])', '"undefined"')
js_fuck = js_fuck.replace('[+!+[]+[+[]]]', "['10']")
js_fuck = js_fuck.replace('[!+[]+!+[]+!+[]]', '[3]')
js_fuck = js_fuck.replace('[(+[])]', '[0]')
js_fuck = js_fuck.replace('[(+!+[])]', '[1]')
js_fuck = js_fuck.replace('[!+[]+!+[]]', '[2]')
js_fuck = js_fuck.replace('[+[]]', '[0]')
js_fuck = js_fuck.replace('[+!+[]]', '[1]')
js_fuck = js_fuck.replace('[+!+[]+!+[]]', '[2]')
js_fuck = js_fuck.replace('[+!+[]+!+[]+!+[]]', '[3]')
js_fuck = js_fuck.replace('[+!+[]+!+[]+!+[]+!+[]]', '[4]')
js_fuck = js_fuck.replace('[+!+[]+!+[]+!+[]+!+[]+!+[]]', '[5]')
js_fuck = js_fuck.replace('[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]', '[6]')
js_fuck = js_fuck.replace('[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]', '[7]')
js_fuck = js_fuck.replace('[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]', '[8]')
js_fuck = js_fuck.replace('[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]', '[9]')
js_fuck = js_fuck.replace('[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]', '[10]')
js_fuck = js_fuck.replace('[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]', '[11]')
js_fuck = js_fuck.replace('[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]', '[12]')
js_fuck = js_fuck.replace('[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]', '[13]')
js_fuck = js_fuck.replace('[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]', '[14]')
js_fuck = js_fuck.replace('[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]', '[15]')
js_fuck = js_fuck.replace('[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]', '[16]')
js_fuck = js_fuck.replace('[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]', '[17]')
js_fuck = js_fuck.replace('[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]', '[18]')
js_fuck = js_fuck.replace('[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]', '[19]')
js_fuck = js_fuck.replace('[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]', '[20]')
js_fuck = js_fuck.replace('[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]', '[21]')
js_fuck = js_fuck.replace('[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]', '[22]')
js_fuck = js_fuck.replace('[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]', '[23]')
js_fuck = js_fuck.replace('[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]', '[24]')
js_fuck = js_fuck.replace('[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]', '[25]')
js_fuck = js_fuck.replace('[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]', '[26]')
js_fuck = js_fuck.replace('[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]', '[27]')
js_fuck = js_fuck.replace('[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]', '[28]')
js_fuck = js_fuck.replace('[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]', '[29]')
js_fuck = js_fuck.replace('[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]', '[30]')
js_fuck = js_fuck.replace('[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]', '[31]')
更换后的代码:
_="constructor";_[_][_]("NaN[object Object]"['10']+"false"[3]+'true'[3]+'true'[0]+$hidescript[0]+"falseundefined"['10']+$hidescript[1]+'true'[3]+"[object Object]"[1]+'true'[2]+'true'[0]+$hidescript[2]+$hidescript[3]+"false[object Object]"['10']+"[object Object]"[1]+$hidescript[1]+$hidescript[4]+"false"[3]+'true'[0]+'true'[1]+$hidescript[4]+$hidescript[5]+$hidescript[6]+$hidescript[7]+$hidescript[8]+$hidescript[9]+$hidescript[10]+"false"[1]+$hidescript[11]+$hidescript[12]+$hidescript[13]+'true'[3]+$hidescript[11]+"[object Object]"[2]+$hidescript[11]+"[object Object]"[2]+$hidescript[13]+"undefined"[2]+$hidescript[11]+$hidescript[14]+"false"[1]+$hidescript[14]+"false"[0]+"[object Object]"[2]+$hidescript[14]+$hidescript[15]+$hidescript[16]+'true'[3]+"false[object Object]"['10']+$hidescript[17]+"false[object Object]"['10']+"[object Object]"[2]+'true'[3]+$hidescript[14]+$hidescript[16]+$hidescript[16]+"undefined"[2]+$hidescript[13]+"[object Object]"[2]+$hidescript[10]+$hidescript[18]+$hidescript[3]+$hidescript[19]+$hidescript[20]+$hidescript[16]+$hidescript[16]+$hidescript[16]+$hidescript[21]+$hidescript[22]+"false"[1]+'true'[0]+$hidescript[23]+$hidescript[4]+'true'[1]+"false"[1]+"undefined"[1]+"undefined"[2]+"[object Object]"[1]+$hidescript[1]+$hidescript[2]+$hidescript[24]+$hidescript[24]+$hidescript[18])();