Avgle on PC 攻略
===
Alternative:
https://masutabe.info/
---
感謝[外國白目](https://github.com/reek/anti-adblock-killer/issues/3854)這麼張揚
現在變得超級超級超級超級超級超級難解 🙃🙂🙃🙂🙃🙃🙂
~~以下目前無解,不過有機會變成後端下載流,但風頭(一天n改)過了再說~~
~~v0.10.180128 works~~
現在別去 Avgle!!!!!他開了 6 個 worker 不知道在幹麻,懶得追了...
# 放棄 I Quit
以下作廢,下面補 [技術分享](#技術分享) 算是這幾天的心得跟思路
---
[toc]
無廣告看片:
Watch w/o ads:
(`uBlockOrigin` + `Avgle.ad_filters`) + `Avgle.anti_adblock_detector`
## 前置 previous work
確認安裝好再往下看
Make sure following extension are installed.
1. Tampermonkey (腳本管理器)
2. uBlockOrigin (類似 ADB 但更強的套件)
## Avgle.anti_adblock_detector
到此頁點 **`Raw`** 下載:https://gist.github.com/FlandreDaisuki/bb572186fc807f47f0c2656afab0d9fa
To this page and click **`Raw`** to download: https://gist.github.com/FlandreDaisuki/bb572186fc807f47f0c2656afab0d9fa
### 技術分享
0.2版:
當時變數和程式邏輯都是清楚的,看一下就知道他是在 `player.on('play')` 註冊事件
故直接移除 play 所有事件,添加沒有檢查的版本即可
0.2.180119版:
他的檢查函式必須 return true 才可以播放,但是他程式碼這樣寫
```js
if(!(typeof isEmbedded !== "undefined") && 其他判斷) {
// player.pause() and window.location += '?adblock_detected'
}
```
故加上一個 `window.isEmbedded = 0;` 即可讓判斷式 shortcut
0.3.180125版:
他把判斷邏輯寫成函式了,函式名叫 checkThings
故覆寫成 `checkThings = () => true`
0.4.180125版:
他後端出了點問題導致登入後連結要加? 才能拿到會員頁面
0.5.180126版:
從這版開始程式碼被 obfuscated。
挾持(hijack) jQuery 的 `$.get` 函數
因為發現他整頁只會用一次而那次正好就是拿 m3u8 的 url
因為他 script 是寫在 body 內,等到 DOM ready 就來不急挾持了
故改成 @run-at document-start
並將必要函式庫改到 userscript 執行
0.6.180128版:
他將 play 事件做成 checkThings(obfuscated) 函式的callback
pseudo code 如下
```js
function checkThings(fn) {
// check
fn()
}
player.on('play', function() {
checkThings(function(){
player.play()
})
})
```
不過他 checkThings 全部都用 jQuery 來作
所以我 proxy 了整個 jQuery
以下為範例
```js
// in checkThings
if($('[hidden]').length >= 2) {
return false
}
// Make Proxy
const jQueryProxy = new Proxy(window.jQuery, {
apply(target, thisArg, argumentsList) {
if (argumentsList[0] === '[hidden]')) {
return {length: 0};
} else {
return Reflect.apply(target, thisArg, argumentsList);
}
}
});
// return Proxy
Object.defineProperties(window,{
$: {
get() { return jQueryProxy; }
},
});
```
0.9.180128版:
他在發出 m3u8 request 時會帶一個 hash 和兩個從 '#video-info' 拿到的資訊
```js
$.get('/video-url.php?hash=' + _$somehash + '&ts=' + _$videoInfo['ts'] + '&vid=' + _$videoInfo['vid'])
```
這個 #video-info 是根據他的頁面一個 inline-script 得來,大概是長這樣的東西
```htmlmixed=
<script id="script_k_0_2099190479" type="text/javascript">
/* <!-- */
function hl_k_0_2099190479() {
var kode =
"kode=\"110 114 103 104 64 37 52 52 51 35 52 52 55 35 52 51 54 35 52 51 55 35 57 55 35 54 58 35 52 52 55 35 52 51 54 35 52 53 51 35 52 51 53 35 52 51 55 35 52 52 53 35 52 52 60 35 52 52 54 35 52 51 57 35 55 60 35 52 52 60 35 52 51 55 35 52 52 52 35 58 53 35 52 52 53 35 52 51 55 35 52 52 54 35 52 51 55 35 57 60 35 52 52 60 35 58 57 35 52 53 55 35 55 54 35 52 51 54 35 58 59 35 60 56 35 55 53 35 58 57 35 60 59 35 60 56 35 55 53 35 58 52 35 55 60 35 55 55 35 52 53 51 35 52 52 55 35 52 51 55 35 52 52 60 35 58 56 35 52 52 58 35 59 51 35 59 58 35 57 55 35 58 60 35 60 56 35 60 56 35 60 56 35 54 58 35 52 52 59 35 57 54 35 52 53 51 35 52 52 55 35 52 51 53 35 52 52 58 35 54 56 35 52 51 55 35 52 51 54 35 52 51 59 35 60 56 35 60 56 35 57 55 35 52 53 52 35 60 56 35 54 58 35 52 51 54 35 52 51 59 35 52 52 55 35 52 51 55 35 52 51 59 35 55 59 35 52 51 56 35 52 52 54 35 60 56 35 60 56 35 52 52 55 35 54 56 35 60 56 35 54 58 35 52 51 51 35 52 51 54 35 52 51 51 35 52 52 60 35 52 52 55 35 55 59 35 52 51 51 35 52 51 58 35 52 51 58 35 52 52 59 35 60 56 35 60 56 35 57 55 35 57 60 35 60 56 35 54 58 35 58 57 35 59 55 35 57 59 35 58 56 35 60 53 35 52 52 52 35 59 59 35 59 53 35 59 55 35 52 51 57 35 59 60 35 58 51 35 58 53 35 56 53 35 59 59 35 58 53 35 59 51 35 59 55 35 57 60 35 59 52 35 58 58 35 58 54 35 57 59 35 60 52 35 58 57 35 52 51 57 35 57 60 35 57 59 35 60 54 35 56 53 35 59 60 35 60 51 35 56 53 35 52 51 57 35 59 60 35 59 57 35 59 51 35 59 60 35 57 60 35 58 54 35 58 57 35 52 52 52 35 60 56 35 60 56 35 57 55 35 54 56 35 60 56 35 54 58 35 52 51 51 35 52 51 54 35 52 51 51 35 52 52 60 35 52 52 60 35 55 59 35 57 55 35 52 52 59 35 60 56 35 54 58 35 60 56 35 60 56 35 56 57 35 56 53 35 56 59 35 56 53 35 57 51 35 56 54 35 56 58 35 56 58 35 56 60 35 56 59 35 60 56 35 54 58 35 60 56 35 60 56 35 52 51 54 35 54 56 35 52 52 60 35 52 51 51 35 55 59 35 52 51 51 35 52 51 59 35 52 53 52 35 57 55 35 52 51 54 35 60 56 35 54 58 35 60 56 35 60 56 35 60 56 35 60 56 35 56 54 35 60 56 35 60 56 35 60 56 35 54 58 35 60 56 35 60 56 35 57 56 35 56 51 35 57 54 35 52 52 55 35 52 52 59 35 52 52 58 35 52 53 51 35 52 51 55 35 52 51 53 35 57 56 35 60 56 35 60 56 35 57 53 35 60 56 35 54 58 35 54 58 35 57 53 35 52 53 54 35 57 55 35 55 53 35 55 53 35 57 53 35 52 51 56 35 52 52 55 35 52 52 58 35 55 54 35 52 51 59 35 57 55 35 56 52 35 57 53 35 52 51 59 35 57 54 35 55 54 35 52 52 51 35 52 52 55 35 52 51 54 35 52 51 55 35 55 60 35 52 52 52 35 52 51 55 35 52 52 54 35 52 51 57 35 52 52 60 35 52 51 58 35 55 59 35 56 53 35 55 55 35 57 53 35 52 51 59 35 55 57 35 57 55 35 56 54 35 55 55 35 52 53 57 35 52 53 54 35 55 57 35 57 55 35 52 52 51 35 52 52 55 35 52 51 54 35 52 51 55 35 55 60 35 52 51 53 35 52 51 58 35 52 51 51 35 52 52 58 35 57 59 35 52 52 60 35 55 54 35 52 51 59 35 55 57 35 56 53 35 55 55 35 55 57 35 52 52 51 35 52 52 55 35 52 51 54 35 52 51 55 35 55 60 35 52 51 53 35 52 51 58 35 52 51 51 35 52 52 58 35 57 59 35 52 52 60 35 55 54 35 52 51 59 35 55 55 35 52 53 59 35 52 52 51 35 52 52 55 35 52 51 54 35 52 51 55 35 57 55 35 52 53 54 35 55 57 35 55 54 35 52 51 59 35 57 54 35 52 52 51 35 52 52 55 35 52 51 54 35 52 51 55 35 55 60 35 52 52 52 35 52 51 55 35 52 52 54 35 52 51 57 35 52 52 60 35 52 51 58 35 57 57 35 52 52 51 35 52 52 55 35 52 51 54 35 52 51 55 35 55 60 35 52 51 53 35 52 51 58 35 52 51 51 35 52 52 58 35 57 59 35 52 52 60 35 55 54 35 52 52 51 35 52 52 55 35 52 51 54 35 52 51 55 35 55 60 35 52 52 52 35 52 51 55 35 52 52 54 35 52 51 57 35 52 52 60 35 52 51 58 35 55 59 35 56 53 35 55 55 35 57 52 35 55 53 35 55 53 35 55 55 35 57 53 37 62 110 114 103 104 64 110 114 103 104 49 118 115 111 108 119 43 42 35 42 44 62 123 64 42 42 62 105 114 117 43 108 64 51 62 108 63 110 114 103 104 49 111 104 113 106 119 107 62 108 46 46 44 126 123 46 64 86 119 117 108 113 106 49 105 117 114 112 70 107 100 117 70 114 103 104 43 115 100 117 118 104 76 113 119 43 110 114 103 104 94 108 96 44 48 54 44 128 110 114 103 104 64 123 62\";" +
"kode=kode.split(\' \');x=\'\';for(i=0;i<kode.length;i++){x+=String.fromCharCode(parseInt(kode[i])-3)}kode=x;";
var i, c, x, script = document.getElementById("script_k_0_2099190479");
while (kode.indexOf("getElementById('K_ID')") === -1) {
eval(kode)
};
kode = kode.replace('K_ID', 'k_0_2099190479');
eval(kode);
script.parentNode.removeChild(script);
}
hl_k_0_2099190479();
/* --> */
</script>
```
簡而言之就是一個包含程式碼的字串,每次用將數字 -3 (凱薩加密)後用 String.fromCharCode 轉回文字,遞迴 eval 到出現他想要的東西(`kode.indexOf("getElementById('K_ID')")`)為止
所以我也將 `$('#video-info').remove` 取代為空函式,但此為止解了 `_$videoInfo['ts']` 和 `_$videoInfo['vid']` 和 `_$videoInfo['ohash']`
這個 `_$videoInfo['ohash']` 會被拿來算真的 hash
流程如下
```js
var a,b,c;
var ohash = _$videoInfo['ohash'];
var realhash = [mux(a, ohash), mux(b, ohash), mux(c, ohash)]
.filter((cipher) => {
return cipher.match(/[a-fA-F0-9]{32}/
})
.map(realCipher => {
return toRealHash(realCipher)
})[0]
```
這個 `realhash` 就是送出 ajax 的 hash 了,以上就是我為什麼去修改 Array.prototype.filter 的原因
解到目前是這樣,最新版會偵測 $.get 的程式碼長度 (幹www,這我投降www)
並且會偵測如果一打開 devtool,就會call `while(true) {}` 或 `debugger` 中斷程式
邏輯如下
```js
function _preventDevtool(arg) {
if(typeof arg === 'string') {
return function (_0x13f05f) {}
['constructor']("while (true) {}")['apply']('counter');
} else {
if ((('' + (arg / arg))['length'] !== 1) ||
((arg % 20) === 0)) {
(function () { return true; }
[ "constructor" ]("debugger")
['call']('action'));
} else {
(function () { return false; }
[ "constructor" ]("debugger")
['apply']('stateObject'));
}
}
_preventDevtool(arg++)
}
```
解法如下
```js
const BLACKLIST = [
"while (true) {}",
"debugger",
];
Function.prototype._constructor =Function.prototype.constructor;
Function.prototype.constructor = function() {
if(!BLACKLIST.includes(arguments)) {
return Function.prototype._constructor.apply(arguments);
}
};
```
## Avgle.waterfall
瀑布流 / 無限滾動
點網址下載:https://rawgit.com/FlandreDaisuki/My-Browser-Extensions/master/userscripts/Avgle.waterfall.user.js
Click to download: https://gist.github.com/FlandreDaisuki/bb572186fc807f47f0c2656afab0d9fa
## Avgle.volume
到此頁點 **`Raw`** 下載:https://gist.github.com/FlandreDaisuki/ce3c1531b1b822abee29e1c63c4375c7
To this page and click **`Raw`** to download: https://gist.github.com/FlandreDaisuki/ce3c1531b1b822abee29e1c63c4375c7
裡面的值可自行修改
Modify the value yourself.
## Avgle.ad_filters
跟著步驟做即可
{%gist 02a7ebf272fb16ea7e0b6b073e3b80a3%}