{"id":655,"date":"2018-04-28T16:34:21","date_gmt":"2018-04-28T08:34:21","guid":{"rendered":"https:\/\/sora.sound.moe\/?p=655"},"modified":"2018-04-28T16:34:21","modified_gmt":"2018-04-28T08:34:21","slug":"something-about-freshtv","status":"publish","type":"post","link":"https:\/\/sora.sound.moe\/?p=655","title":{"rendered":"Something about FreshTV"},"content":{"rendered":"<p><!--more--><\/p>\n<p>FreshTV \u8fd9\u4e2a M3U8 \u6700\u5927\u7684\u5751\u7239\u4e4b\u5904\u5728\u4e8e\u5b83\u7684 key \u662f\u4e00\u4e2a\u79c1\u6709\u534f\u8bae\u3002<\/p>\n<p>\u4f8b\u5b50\uff1a<\/p>\n<p><code>#EXT-X-KEY:METHOD=AES-128,URI=\"abemafresh:\/\/abemafresh\/206437t2806498f02ad88f4aecd7aa2083a6374edef\/2928e09b0fa322020bbe5d854eb92984\",IV=0xd3d54ce117415b571eb96ac49ed11e9d<\/code><\/p>\n<p>\u597d\uff0c\u8fd9\u4e2a<code>abemafresh:\/\/<\/code>\u662f\u4ec0\u4e48\u5751\u7239\u73a9\u610f\u5462\u3002<\/p>\n<p>\u7ffb\u4e86\u4e0b\u4ee3\u7801\u53d1\u73b0\u539f\u6765\u662f\u52ab\u6301\u4e86 XMLHTTPRequest \u6765\u652f\u6301\u8fd9\u4e48\u4e2a\u73a9\u610f\u7684\u52a0\u8f7d\u3002<\/p>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large\" src=\"http:\/\/ww1.sinaimg.cn\/large\/e985a6f7gy1fqsfe5bwzrj20jr0ffdhc.jpg\" width=\"711\" height=\"555\" \/><\/p>\n<p>\u597d\u6211\u4eec\u6765\u4ed4\u7ec6\u7814\u7a76\u4e00\u4e0b\u3002<\/p>\n<p>\u9996\u5148\u8fd9\u4e2as\u5c31\u662f\u6765\u5224\u5b9a\u8981\u52a0\u8f7d\u7684url\u662f\u4e0d\u662f\u4ee5<code>abemafresh:\/\/<\/code>\u5f00\u5934\uff0c\u8fd9\u795e\u5947\u7684\u5199\u6cd5\u6211\u4e5f\u662f\u9189\u4e86\u3002<code>String.prototype.startsWith()<\/code>\u4e86\u89e3\u4e00\u4e0b\uff1f<\/p>\n<p>\u5982\u679c\u662f\u7684\u8bdd\u5c31\u6309<code>\/<\/code>\u6765\u5206\u5272\u3002<\/p>\n<p>\u5f97\u5230 <code>i = [\"abemafresh:\", \"\", \"abemafresh\", \"206437t2806498f02ad88f4aecd7aa2083a6374edef\", \"2928e09b0fa322020bbe5d854eb92984\"]<\/code><\/p>\n<p>\u7136\u540e c \u548c l \u5c31\u5206\u522b\u662f\u00a0<code>\"206437t2806498f02ad88f4aecd7aa2083a6374edef\"<\/code> \u548c\u00a0<code>\"2928e09b0fa322020bbe5d854eb92984\"<\/code><\/p>\n<p>u \u662f c \u548c l \u8fde\u63a5\u8d77\u6765\u3002<\/p>\n<p>\u7136\u540e\u8c03\u7528\u4e86\u4e00\u4e2a<code>a(c, l, s)<\/code><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large\" src=\"http:\/\/ww1.sinaimg.cn\/large\/e985a6f7gy1fqsfk369kbj20uc0ea400.jpg\" width=\"1092\" height=\"514\" \/><\/p>\n<p><code>a()<\/code>\u00a0\u51fd\u6570\u7684\u5185\u90e8\uff0c\u9996\u5148\u662f\u8c03\u7528\u4e86\u4e2a <code>d.create()<\/code>\u00a0\uff0c\u5176\u5b9e\u8fd9\u4e2a\u51fd\u6570\u662f <code>cryptojs.lib.WordArray()<\/code>\u00a0\u628a\u4e00\u7ec4\u56fa\u5b9a\u7684\u6570\u521b\u5efa\u6210\u4e00\u4e2a WordArray<\/p>\n<p>\u968f\u540e\u4f7f\u7528 HmacSHA256 \u505a\u4e2a\u8fd0\u7b97\u3002\u968f\u540e\u4f7f\u7528 AES \u8fdb\u884c\u89e3\u5bc6\uff0c\u524d\u9762 SHA256 \u5f97\u5230\u7684\u7ed3\u679c\u5c31\u662f\u5bc6\u94a5\u3002\u4e5f\u5c31\u662f\u8bf4\u90a3\u4e2aabemafresh\u7684url \u524d\u534a\u90e8\u5206\u662f\u5bc6\u94a5\u540e\u534a\u90e8\u5206\u662f\u5bc6\u6587\u3002<\/p>\n<p>\u603b\u4e4b\u7ecf\u8fc7\u8fd8\u539f\u540e\u7684\u4ee3\u7801\u662f\u8fd9\u6837\u7684<\/p>\n<pre class=\"lang:js decode:true \">const cryptojs = require('crypto-js');\nconst abemafresh = [1413502068, 2104980084, 1144534056, 1967279194, 2051549272, 860632952, 1464353903, 1212380503];\nconst url = \"abemafresh:\/\/abemafresh\/206437t2806498f02ad88f4aecd7aa2083a6374edef\/2928e09b0fa322020bbe5d854eb92984\";\n\nconst part1 = url.split('\/')[3];\nconst part2 = url.split('\/')[4];\n\nconst hash = cryptojs.HmacSHA256(part1, cryptojs.lib.WordArray.create(abemafresh));\nconst decryptResult = cryptojs.AES.decrypt(cryptojs.lib.CipherParams.create({\n    ciphertext: cryptojs.enc.Hex.parse(part2)\n}), hash, {\n        mode: cryptojs.mode.ECB,\n        padding: cryptojs.pad.NoPadding\n    }).toString();\n\nfor (var t = new Uint8Array(16), r = 0; 16 &gt; r; r++)\n    t[r] = parseInt(decryptResult.substr(2 * r, 2), 16);\n\nconst result = [];\n\nfor (const i of t) {\n    result.push(i.toString(16).length === 1 ? ('0' + i.toString(16)) : i.toString(16));\n}\n\nconsole.log('key = ', result.join(''));<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"twentyseventeen-featured-image":false,"twentyseventeen-thumbnail-avatar":false},"uagb_author_info":{"display_name":"Sora","author_link":"https:\/\/sora.sound.moe\/?author=1"},"uagb_comment_info":2,"uagb_excerpt":null,"_links":{"self":[{"href":"https:\/\/sora.sound.moe\/index.php?rest_route=\/wp\/v2\/posts\/655"}],"collection":[{"href":"https:\/\/sora.sound.moe\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sora.sound.moe\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sora.sound.moe\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sora.sound.moe\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=655"}],"version-history":[{"count":0,"href":"https:\/\/sora.sound.moe\/index.php?rest_route=\/wp\/v2\/posts\/655\/revisions"}],"wp:attachment":[{"href":"https:\/\/sora.sound.moe\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=655"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sora.sound.moe\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=655"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sora.sound.moe\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=655"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}