8 Commits
Author SHA1 Message Date
Vitaly Gashkov 451eaa54eb 1.2.0 2025-08-23 23:49:51 +05:00
Vitaly Gashkov 9a9b713682 update static credentials 2025-08-23 23:49:42 +05:00
Vitaly Gashkov 163993824a update README 2025-08-23 23:49:21 +05:00
Vitaly Gashkov 34b033ef57 update gitignore 2025-08-23 23:49:15 +05:00
Vitaly Gashkov 9c96d6f696 feat: support Android TV app 2025-08-23 23:49:07 +05:00
Vitaly Gashkov 9f53d6af9c update README 2025-08-23 21:38:36 +05:00
Vitaly Gashkov 6acf203edb update README 2025-08-23 21:28:46 +05:00
Vitaly Gashkov 2cd3fddd77 update package.json 2025-08-23 21:27:17 +05:00
9 changed files with 145 additions and 46 deletions
+3
View File
@@ -1,2 +1,5 @@
/node_modules
.DS_Store
/crunchyroll
crunchyroll.apk
crunchyroll.xapk
+27 -5
View File
@@ -1,6 +1,6 @@
# Crextractor
Utility for extracting secrets from Crunchyroll mobile app
Utility for extracting credentials from the Crunchyroll Android app
## Prerequisites
@@ -15,12 +15,34 @@ npm i crextractor
## Usage
### Fetching already extracted secrets
```js
async function main() {
const url = 'https://raw.githubusercontent.com/vitalygashkov/crextractor/refs/heads/main/credentials.tv.json';
const data = await fetch(url).then((response) => response.json());
// You can use the extracted secrets to obtain access tokens for Crunchyroll APIs
const response = await fetch('https://beta-api.crunchyroll.com/auth/v1/token', {
headers: {
Authorization: data.authorization,
'User-Agent': 'Crunchyroll/ANDROIDTV/3.42.1_22267 (Android 16; en-US; sdk_gphone64_x86_64)',
// ...
},
method: 'POST',
body: JSON.stringify({
// ...
}),
});
}
```
#### Library
```js
import { extractSecrets } from 'crextractor';
import { extract } from 'crextractor';
const { id, secret, encoded, header } = await extractSecrets();
const { id, secret, encoded, authorization } = await extract();
// Do something with the extracted secrets
```
@@ -28,10 +50,10 @@ const { id, secret, encoded, header } = await extractSecrets();
#### Command-line interface
```bash
npx crextractor
npx crextractor --target mobile --output ./credentials.mobile.json
```
> Results will be printed to the console and saved to `secrets.json` file
> Results will be printed to the console and saved to `credentials.mobile.json` file. By default, the target is TV, but you can change it with `--target mobile` option.
## License
+23 -2
View File
@@ -1,5 +1,26 @@
#!/usr/bin/env node
const { extractSecrets } = require('../crextractor');
const { parseArgs } = require('node:util');
const { extract } = require('../crextractor');
extractSecrets({ output: 'secrets.json' });
const args = parseArgs({
options: {
target: {
type: 'string',
default: 'tv',
},
output: {
type: 'string',
},
cleanup: {
type: 'boolean',
default: false,
},
},
});
extract({
target: args.values.target,
output: args.values.output ?? (args.values.target === 'tv' ? 'credentials.tv.json' : 'credentials.mobile.json'),
cleanup: args.values.cleanup,
});
+7
View File
@@ -0,0 +1,7 @@
{
"version": "3.89.2 (952)",
"id": "n0q2nxl37zig0dqn0aio",
"secret": "P0j3he4N8UG8W2w0-PvDadjGuv62fN2d",
"encoded": "bjBxMm54bDM3emlnMGRxbjBhaW86UDBqM2hlNE44VUc4VzJ3MC1QdkRhZGpHdXY2MmZOMmQ=",
"authorization": "Basic bjBxMm54bDM3emlnMGRxbjBhaW86UDBqM2hlNE44VUc4VzJ3MC1QdkRhZGpHdXY2MmZOMmQ="
}
+7
View File
@@ -0,0 +1,7 @@
{
"version": "3.42.1 (22267)",
"id": "bmbrkxyx3d7u6jsfyla4",
"secret": "AIN4D5VE_cp0wVzfNoP0YqHUrYFp9hSg",
"encoded": "Ym1icmt4eXgzZDd1NmpzZnlsYTQ6QUlONEQ1VkVfY3Awd1Z6Zk5vUDBZcUhVcllGcDloU2c=",
"authorization": "Basic Ym1icmt4eXgzZDd1NmpzZnlsYTQ6QUlONEQ1VkVfY3Awd1Z6Zk5vUDBZcUhVcllGcDloU2c="
}
+69 -28
View File
@@ -2,8 +2,9 @@ const { execSync } = require('node:child_process');
const { join } = require('node:path');
const { readdir, readFile, writeFile, rm } = require('node:fs/promises');
const { download } = require('molnia');
const { existsSync } = require('node:fs');
const downloadLatestApk = async () => {
const downloadMobileApk = async () => {
const source = 'https://apkcombo.com/crunchyroll/com.crunchyroll.crunchyroid/download/apk';
const page = await fetch(source);
const html = await page.text();
@@ -17,11 +18,30 @@ const downloadLatestApk = async () => {
return filepath;
};
const downloadTvApk = async () => {
const source = 'https://webservices.aptoide.com/webservices/3/getApkInfo';
const formData = new FormData();
formData.append('identif', 'id:71305225');
formData.append('mode', 'json');
const response = await fetch(source, {
method: 'POST',
body: formData,
});
const json = await response.json();
const url = json.apk.path;
const filepath = join(process.cwd(), 'crunchyroll.apk');
await download(url, {
output: filepath,
onError: (error) => console.error(error),
});
return filepath;
};
const decompileApk = (apkPath) => {
try {
execSync(`jadx ${apkPath}`, { stdio: 'inherit' });
} catch (error) {}
return apkPath.replace('.xapk', '');
return apkPath.replace('.xapk', '').replace('.apk', '');
};
const findConfigurationImpl = async (sourcesDir) => {
@@ -41,38 +61,59 @@ const findConfigurationImpl = async (sourcesDir) => {
}
};
const parseSecrets = (contents) => {
const lines = contents.split('\n');
const startIndex = lines.findIndex((line) => line.includes('https://sso.crunchyroll.com'));
const endIndex = lines.findIndex((line) => line.includes('CR-AndroidMobile-SSAI-Prod'));
const results = lines
.slice(startIndex, endIndex)
.map((line) => line.replaceAll(';', ''))
.map((line) => line.replaceAll('"', ''))
.map((line) => line.split('= ')[1])
.map((line) => line.trim());
const [, , id, secret] = results;
const encoded = Buffer.from(`${id}:${secret}`).toString('base64');
const authorization = `Basic ${encoded}`;
return { id, secret, encoded, authorization };
const parseCredentials = async (decompiledDir) => {
const sourcesDir = join(decompiledDir, 'sources');
const configurationImpl = await findConfigurationImpl(sourcesDir);
if (configurationImpl) {
const lines = configurationImpl.split('\n');
const startIndex = lines.findIndex((line) => line.includes('https://sso.crunchyroll.com'));
const endIndex = lines.findIndex((line) => line.includes('CR-AndroidMobile-SSAI-Prod'));
const results = lines
.slice(startIndex, endIndex)
.map((line) => line.replaceAll(';', ''))
.map((line) => line.replaceAll('"', ''))
.map((line) => line.split('= ')[1])
.map((line) => line.trim());
const [, , id, secret] = results;
if (id && secret) return { id, secret };
}
const constantsPath = join(decompiledDir, 'sources', 'com', 'crunchyroll', 'api', 'util', 'Constants.java');
const constants = await readFile(constantsPath, 'utf8');
return {
id: constants.split(' PROD_CLIENT_ID = "')[1].split('"')[0],
secret: constants.split(' PROD_CLIENT_SECRET = "')[1].split('"')[0],
};
};
const extractSecrets = async ({ output, cleanup = true } = {}) => {
console.log('Downloading latest APK...');
const apkPath = await downloadLatestApk();
const parseVersion = async (decompiledDir) => {
const manifestJsonPath = join(decompiledDir, 'resources', 'manifest.json');
const manifestXmlPath = join(decompiledDir, 'resources', 'AndroidManifest.xml');
if (existsSync(manifestJsonPath)) {
const manifest = require(manifestJsonPath);
const version = `${manifest.version_name} (${manifest.version_code})`;
return version;
} else if (existsSync(manifestXmlPath)) {
const manifest = await readFile(manifestXmlPath, 'utf8');
const version = `${manifest.match(/versionName="([^"]+)"/)[1]} (${manifest.match(/versionCode="([^"]+)"/)[1]})`;
return version;
}
};
const extract = async ({ target, output, cleanup = false } = {}) => {
console.log('Downloading APK...');
const apkPath = target === 'tv' ? await downloadTvApk() : await downloadMobileApk();
console.log('Decompiling APK...');
const decompiledDir = decompileApk(apkPath);
console.log('Searching for secrets...');
const sourcesDir = join(decompiledDir, 'sources');
const manifest = require(join(decompiledDir, 'resources', 'manifest.json'));
const version = manifest.version_name;
const configurationImpl = await findConfigurationImpl(sourcesDir);
if (!configurationImpl) throw new Error('Could not find ConfigurationImpl.kt');
console.log('Parsing version...');
const version = await parseVersion(decompiledDir);
console.log('Parsing secrets...');
const { id, secret, encoded, authorization } = parseSecrets(configurationImpl);
console.log('Parsing credentials...');
const { id, secret } = await parseCredentials(decompiledDir);
const encoded = Buffer.from(`${id}:${secret}`).toString('base64');
const authorization = `Basic ${encoded}`;
console.log(`Cleaning up files...`);
if (cleanup) await rm(apkPath, { recursive: true, force: true });
@@ -91,4 +132,4 @@ const extractSecrets = async ({ output, cleanup = true } = {}) => {
return { version, id, secret, encoded, authorization };
};
module.exports = { extractSecrets };
module.exports = { extract };
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "crextractor",
"version": "1.1.0",
"version": "1.2.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "crextractor",
"version": "1.1.0",
"version": "1.2.0",
"funding": [
{
"type": "individual",
+7 -2
View File
@@ -1,11 +1,16 @@
{
"name": "crextractor",
"version": "1.1.0",
"description": "Utility for extracting secrets from Crunchyroll mobile app",
"version": "1.2.0",
"description": "Utility for extracting credentials from the Crunchyroll Android app",
"main": "crextractor.js",
"bin": {
"crextractor": "bin/cli.js"
},
"files": [
"bin",
"crextractor.d.ts",
"crextractor.js"
],
"types": "crextractor.d.ts",
"type": "commonjs",
"scripts": {
-7
View File
@@ -1,7 +0,0 @@
{
"version": "3.89.1",
"id": "rybm7nqzc5zfynw7ayef",
"secret": "luDwBZArJNnVnGTJLuoXZufy5czXMWgr",
"encoded": "cnlibTducXpjNXpmeW53N2F5ZWY6bHVEd0JaQXJKTm5WbkdUSkx1b1hadWZ5NWN6WE1XZ3I=",
"authorization": "Basic cnlibTducXpjNXpmeW53N2F5ZWY6bHVEd0JaQXJKTm5WbkdUSkx1b1hadWZ5NWN6WE1XZ3I="
}