https://zhuanlan.zhihu.com/p/107786616python
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
【文章恢復,首次發表時間 2017-11-09】
0. GeeTest.6.0.0
GeeTest極驗驗證碼悄悄在這一兩個月更新了js代碼,從5.X到了6.0,破解的難度比以前稍微複雜了一些,破解已成功,就來複盤一下吧。算法
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
1. 總體思路
拿這個《國家企業信用信息公示系統》爲例,查詢時會先須要經過滑動驗證碼。打開f12刷新網頁,完成一次失敗的滑動,查看加載項。數組
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
請求時提交一些參數完成驗證。函數
passtime應該就是滑動的時間。imgload多是圖片加載時間優化
先記下這個參數,繼續看加載項。編碼
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
gt和challenge的值在這裏。記爲1號包,接着看下一個加密
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
這裏返回的是一些參數,記爲2號包,這裏的返回值是後面3號包的請求的參數。url
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
3號包:這個返回值也有challenge和gt,但gt的值沒有變化是一個固定的值,challenge每次請求都發生了變化。但這個結果的返回值和提交時的challenge一致,這就找到了兩個參數。spa
同時還有fullbg和bg兩個參數,獲得亂排序後的圖片,經過排序以後能夠計算滑動偏移量。.net
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
(圖片還原能夠參照以GeeTest爲例的滑動驗證碼破解 - 圖片還原2)!!!
另外的userresponse 和aa值是經過後面的geetest.6.0.0.js加密算法算出
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
那下一步則是解析這個js文件
2. userresponse和aa
鏡頭來到Source中找到這個js。一頓查找,終於發現:
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
只想說在這一堆混淆的js寫得真不容易,編碼也下了功夫。可真很差找!!!!
r1Y中就是咱們須要的各個參數,其中的aa和userresponse加密算法也在。
- userresponse
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
這裏userresponse須要的參數是滑動軌跡數組的長度和上文3號包的challenge,這裏和5.x版本很像,可是發現加密算法改了.
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
看着真蛋疼,不過還好解決了,改寫成了python
- aa
aa就是對軌跡的加密也是和上一版本很大區別,看完6.0,以爲上一版本簡直不能再簡單了。
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
aa從這裏開始,找到這個函數,須要的參數就是提交的軌跡,這裏放到後面
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
接着返回一串加密的字符串,可是還不夠,還要加密一次,也找到了
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
找到函數:
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
這裏返回也是一串加密字符串,最後通過encodeURIComponent處理便可
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
到這裏全部參數出處和算法搞定了。最後就是看看軌跡
3. 軌跡
這裏先完成一次滑動,查看結果
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
結果是軌跡用一組數組表示,數組裏每一個小數組表明每個微小滑動的數據:
[滑動距離, 上下偏移量, 累計時間]
(上文中的passtime就是這裏的累計時間)
- 累計時間能夠每次變化加上一個限定範圍內的隨機值。
- 上下偏移量設定有小小範圍的(例如[-5, 5]內)的偏移。
- 滑動距離採用了一個sigmoid函數(相似下面),還能夠優化,成功率會更高。
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
# b偏移量
def sigmoid(x, b):
return (1 / (1 + exp(-x + 4))) * b
獲得結果,恩能夠了。
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
4. 最後
不提供代碼, 畢竟人家工程師不容易,本文僅提供一個思路。