Skip to content
This repository has been archived by the owner on May 1, 2022. It is now read-only.

Commit

Permalink
Add support for KissManga encrypted urls.
Browse files Browse the repository at this point in the history
  • Loading branch information
Roel van Uden committed May 18, 2017
1 parent bf68557 commit b01cd2e
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 8 deletions.
1 change: 1 addition & 0 deletions mangarack-component-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"typings": "dist/default",
"version": "4.0.11",
"dependencies": {
"crypto-js": "3.1.9-1",
"tslib": "1.7.1"
},
"devDependencies": {
Expand Down
5 changes: 3 additions & 2 deletions mangarack-component-core/src/providers/kissmanga/chapter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as mio from '../../default';
import {createPage} from './page';
import {site} from './site';
const httpService = mio.dependency.get<mio.IHttpService>('IHttpService');
const htmlService = mio.dependency.get<mio.IHtmlService>('IHtmlService');

Expand Down Expand Up @@ -47,13 +48,13 @@ async function downloadPagesAsync(address: string): Promise<mio.IPage[]> {
function getPages($: mio.IHtmlServiceDocument): mio.IPage[] {
let i = 0;
let match: mio.IOption<RegExpExecArray>;
let regexp = /lstImages\.push\("(.+?)"\)/gi;
let regexp = /lstImages\.push\(wrapKA\("(.+?)"\)\)/gi;
let results: mio.IPage[] = [];
let text = $('script:contains(lstImages)').text();
while (true) {
match = regexp.exec(text) || undefined;
if (match) {
results.push(createPage(match[1], {number: i + 1}));
results.push(createPage(site.decodeImageUrl(match[1]), {number: i + 1}));
i += 1;
} else {
break;
Expand Down
12 changes: 6 additions & 6 deletions mangarack-component-core/src/providers/kissmanga/series.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ async function downloadDocumentAsync(address: string): Promise<mio.IHtmlServiceD
} catch (error) {
if (mio.HttpServiceError.isInstance(error) && error.statusCode === 503) {
let document = htmlService().load(error.body);
let form = document('form[id=challenge-form]');
let jschl_vc = form.find('input[name=jschl_vc]').attr('value');
let pass = form.find('input[name=pass]').attr('value');
if (pass) {
await mio.promise(callback => setTimeout(callback, 8000));
await httpService().text(`${providerDomain}/cdn-cgi/l/chk_jschl?jschl_vc=${jschl_vc}&pass=${pass}`, mio.ControlType.Timeout).getAsync();
let documentForm = document('form[id=challenge-form]');
let formJs = documentForm.find('input[name=jschl_vc]').attr('value');
let formPass = documentForm.find('input[name=pass]').attr('value');
if (formPass) {
await mio.promise(callback => setTimeout(callback, 8500));
await httpService().text(`${providerDomain}/cdn-cgi/l/chk_jschl?jschl_vc=${formJs}&pass=${formPass}`, mio.ControlType.Timeout).getAsync();
return downloadDocumentAsync(address);
}
}
Expand Down
33 changes: 33 additions & 0 deletions mangarack-component-core/src/providers/kissmanga/site.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
declare let require: any;
let decode: any;
let d18052017 = 'var _0x331e=["\x6C\x69\x62","\x57\x6F\x72\x64\x41\x72\x72\x61\x79","\x48\x61\x73\x68\x65\x72","\x61\x6C\x67\x6F","\x73\x71\x72\x74","\x70\x6F\x77","\x53\x48\x41\x32\x35\x36","\x5F\x68\x61\x73\x68","\x73\x6C\x69\x63\x65","\x69\x6E\x69\x74","\x77\x6F\x72\x64\x73","\x5F\x64\x61\x74\x61","\x5F\x6E\x44\x61\x74\x61\x42\x79\x74\x65\x73","\x73\x69\x67\x42\x79\x74\x65\x73","\x66\x6C\x6F\x6F\x72","\x6C\x65\x6E\x67\x74\x68","\x63\x61\x6C\x6C","\x63\x6C\x6F\x6E\x65","\x65\x78\x74\x65\x6E\x64","\x48\x6D\x61\x63\x53\x48\x41\x32\x35\x36","\x61\x35\x65\x38\x65\x32\x65\x39\x63\x32\x37\x32\x31\x62\x65\x30\x61\x38\x34\x61\x64\x36\x36\x30\x63\x34\x37\x32\x63\x31\x66\x33","\x6D\x73\x68\x73\x64\x66\x38\x33\x32\x6E\x73\x64\x62\x61\x73\x68\x32\x30\x61\x73\x64\x6D","\x70\x61\x72\x73\x65","\x48\x65\x78","\x65\x6E\x63","\x42\x61\x73\x65\x36\x34","\x63\x72\x65\x61\x74\x65","\x43\x69\x70\x68\x65\x72\x50\x61\x72\x61\x6D\x73","\x43\x42\x43","\x6D\x6F\x64\x65","\x50\x6B\x63\x73\x37","\x70\x61\x64","\x64\x65\x63\x72\x79\x70\x74","\x41\x45\x53"];(function(_0xfac5x1){for(var _0xfac5x2=CryptoJS,_0xfac5x3=_0xfac5x2[_0x331e[0]],_0xfac5x4=_0xfac5x3[_0x331e[1]],_0xfac5x5=_0xfac5x3[_0x331e[2]],_0xfac5x3=_0xfac5x2[_0x331e[3]],_0xfac5x6=[],_0xfac5x7=[],_0xfac5x8=function(_0xfac5xb){return 4294967296*(_0xfac5xb-(_0xfac5xb|0))|0},_0xfac5x9=2,_0xfac5xa=0;64>_0xfac5xa;){var _0xfac5xc;a:{_0xfac5xc=_0xfac5x9;for(var _0xfac5xd=_0xfac5x1[_0x331e[4]](_0xfac5xc),_0xfac5xe=2;_0xfac5xe<=_0xfac5xd;_0xfac5xe++){if(!(_0xfac5xc%_0xfac5xe)){_0xfac5xc=!1;break a}};_0xfac5xc=!0}_0xfac5xc&&(8>_0xfac5xa&&(_0xfac5x6[_0xfac5xa]=_0xfac5x8(_0xfac5x1[_0x331e[5]](_0xfac5x9,0.5))),_0xfac5x7[_0xfac5xa]=_0xfac5x8(_0xfac5x1[_0x331e[5]](_0xfac5x9,1/3)),_0xfac5xa++);_0xfac5x9++};var _0xfac5xf=[],_0xfac5x3=_0xfac5x3[_0x331e[6]]=_0xfac5x5[_0x331e[18]]({_doReset:function(){this[_0x331e[7]]=new _0xfac5x4[_0x331e[9]](_0xfac5x6[_0x331e[8]](0))},_doProcessBlock:function(_0xfac5xb,_0xfac5x3){for(var _0xfac5x10=this[_0x331e[7]][_0x331e[10]],_0xfac5x11=_0xfac5x10[0],_0xfac5xc=_0xfac5x10[1],_0xfac5xa=_0xfac5x10[2],_0xfac5x1=_0xfac5x10[3],_0xfac5x12=_0xfac5x10[4],_0xfac5x2=_0xfac5x10[5],_0xfac5x5=_0xfac5x10[6],_0xfac5x9=_0xfac5x10[7],_0xfac5x13=0;64>_0xfac5x13;_0xfac5x13++){if(16>_0xfac5x13){_0xfac5xf[_0xfac5x13]=_0xfac5xb[_0xfac5x3+ _0xfac5x13]|0}else{var _0xfac5x14=_0xfac5xf[_0xfac5x13- 15],_0xfac5x15=_0xfac5xf[_0xfac5x13- 2];_0xfac5xf[_0xfac5x13]=((_0xfac5x14<<25|_0xfac5x14>>>7)^(_0xfac5x14<<14|_0xfac5x14>>>18)^_0xfac5x14>>>3)+ _0xfac5xf[_0xfac5x13- 7]+((_0xfac5x15<<15|_0xfac5x15>>>17)^(_0xfac5x15<<13|_0xfac5x15>>>19)^_0xfac5x15>>>10)+ _0xfac5xf[_0xfac5x13- 16]};_0xfac5x14=_0xfac5x9+((_0xfac5x12<<26|_0xfac5x12>>>6)^(_0xfac5x12<<21|_0xfac5x12>>>11)^(_0xfac5x12<<7|_0xfac5x12>>>25))+(_0xfac5x12&_0xfac5x2^~_0xfac5x12&_0xfac5x5)+ _0xfac5x7[_0xfac5x13]+ _0xfac5xf[_0xfac5x13];_0xfac5x15=((_0xfac5x11<<30|_0xfac5x11>>>2)^(_0xfac5x11<<19|_0xfac5x11>>>13)^(_0xfac5x11<<10|_0xfac5x11>>>22))+(_0xfac5x11&_0xfac5xc^_0xfac5x11&_0xfac5xa^_0xfac5xc&_0xfac5xa);_0xfac5x9=_0xfac5x5;_0xfac5x5=_0xfac5x2;_0xfac5x2=_0xfac5x12;_0xfac5x12=_0xfac5x1+ _0xfac5x14|0;_0xfac5x1=_0xfac5xa;_0xfac5xa=_0xfac5xc;_0xfac5xc=_0xfac5x11;_0xfac5x11=_0xfac5x14+ _0xfac5x15|0};_0xfac5x10[0]=_0xfac5x10[0]+ _0xfac5x11|0;_0xfac5x10[1]=_0xfac5x10[1]+ _0xfac5xc|0;_0xfac5x10[2]=_0xfac5x10[2]+ _0xfac5xa|0;_0xfac5x10[3]=_0xfac5x10[3]+ _0xfac5x1|0;_0xfac5x10[4]=_0xfac5x10[4]+ _0xfac5x12|0;_0xfac5x10[5]=_0xfac5x10[5]+ _0xfac5x2|0;_0xfac5x10[6]=_0xfac5x10[6]+ _0xfac5x5|0;_0xfac5x10[7]=_0xfac5x10[7]+ _0xfac5x9|0},_doFinalize:function(){var _0xfac5xc=this[_0x331e[11]],_0xfac5xa=_0xfac5xc[_0x331e[10]],_0xfac5x10=8*this[_0x331e[12]],_0xfac5x11=8*_0xfac5xc[_0x331e[13]];_0xfac5xa[_0xfac5x11>>>5]|=128<<24- _0xfac5x11%32;_0xfac5xa[(_0xfac5x11+ 64>>>9<<4)+ 14]=_0xfac5x1[_0x331e[14]](_0xfac5x10/4294967296);_0xfac5xa[(_0xfac5x11+ 64>>>9<<4)+ 15]=_0xfac5x10;_0xfac5xc[_0x331e[13]]=4*_0xfac5xa[_0x331e[15]];this._process();return this[_0x331e[7]]},clone:function(){var _0xfac5xa=_0xfac5x5[_0x331e[17]][_0x331e[16]](this);_0xfac5xa[_0x331e[7]]=this[_0x331e[7]][_0x331e[17]]();return _0xfac5xa}});_0xfac5x2[_0x331e[6]]=_0xfac5x5._createHelper(_0xfac5x3);_0xfac5x2[_0x331e[19]]=_0xfac5x5._createHmacHelper(_0xfac5x3)})(Math);var boxzq=_0x331e[20];var chko=_0x331e[21];var iv,key;iv=CryptoJS[_0x331e[24]][_0x331e[23]][_0x331e[22]](boxzq);key=CryptoJS.SHA256(chko);function wrapKA(_0xfac5x1b){var _0xfac5x1c=null;try{var _0xfac5x1d=CryptoJS[_0x331e[0]][_0x331e[27]][_0x331e[26]]({ciphertext:CryptoJS[_0x331e[24]][_0x331e[25]][_0x331e[22]](_0xfac5x1b)});var _0xfac5x1e=CryptoJS[_0x331e[33]][_0x331e[32]](_0xfac5x1d,key,{mode:CryptoJS[_0x331e[29]][_0x331e[28]],iv:iv,padding:CryptoJS[_0x331e[31]][_0x331e[30]]});_0xfac5x1c=_0xfac5x1e.toString(CryptoJS[_0x331e[24]].Utf8);return _0xfac5x1c}catch(err){alert(err)}}';

/**
* Represents the collection of site utilities.
*/
export let site = {
/**
* Decodes an image url.
* @param url The url.
* @return The decoded image url.
*/
decodeImageUrl(url: string): string {
decode = decode || createDecoder();
return decode(url);
}
};

/**
* Creates a decoder.
* @return The decoder.
*/
function createDecoder(): any {
var CryptoJS = require('crypto-js');
if (CryptoJS) {
var out = {wrapKA: undefined};
eval(`${d18052017};out.wrapKA = wrapKA`);
return out.wrapKA;
} else {
throw new Error('Invalid CryptoJS module.');
}
}

0 comments on commit b01cd2e

Please sign in to comment.