11 Commits
6 changed files with 109 additions and 22 deletions
+58
View File
@@ -0,0 +1,58 @@
name: Extract
on:
workflow_dispatch:
schedule:
- cron: '0 4 * * 1' # Runs every Monday at 04:00 UTC
jobs:
extract:
runs-on: ubuntu-latest
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
# JADX requires Java 11 or higher to run
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
# Download and install the latest version of JADX
- name: Install JADX
run: |
# Fetch the latest version tag from the JADX GitHub repository
JADX_VERSION=$(curl -s "https://api.github.com/repos/skylot/jadx/releases/latest" | grep -Po '"tag_name": "v\K[0-9.]+')
echo "Installing JADX version ${JADX_VERSION}..."
# Download the release zip file
curl -Lo jadx.zip "https://github.com/skylot/jadx/releases/download/v${JADX_VERSION}/jadx-${JADX_VERSION}.zip"
# Unzip the archive
unzip -q jadx.zip -d jadx-dist
# Add the JADX bin directory to the GitHub Actions path
# This makes the 'jadx' command available in subsequent steps
echo "$(pwd)/jadx-dist/jadx-${JADX_VERSION}/bin" >> $GITHUB_PATH
# Clean up the downloaded zip file
rm jadx.zip
shell: bash
# Verify that JADX was installed correctly
- name: Verify JADX installation
run: jadx --version
# Verify that JADX was installed correctly
- name: Extract app credentials
run: node . --target mobile --output ./credentials.mobile.json && node . --target tv --output ./credentials.tv.json
# Commit all changed files back to the repository
- uses: stefanzweifel/git-auto-commit-action@v5
+22 -13
View File
@@ -1,31 +1,34 @@
# Crextractor
Utility for extracting credentials from the Crunchyroll Android app
Utility for extracting credentials from the Crunchyroll Android app (both TV and mobile versions).
The [credentials](https://github.com/vitalygashkov/crextractor/blob/main/credentials.tv.json) are [automatically](https://github.com/vitalygashkov/crextractor/actions/workflows/extract.yml) updated once a week (if there are any changes).
## Prerequisites
- [Node.js](https://nodejs.org/en)
- [jadx](https://github.com/skylot/jadx)
## Installation
## Usage
### Library
```bash
npm i crextractor
```
## Usage
### Fetching already extracted secrets
#### Fetch ready credentials from this GitHub repository
```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());
import { pull } from 'crextractor';
// You can use the extracted secrets to obtain access tokens for Crunchyroll APIs
async function main() {
const credentials = await pull('tv');
// You can use the extracted credentials to obtain access tokens for Crunchyroll APIs
const response = await fetch('https://beta-api.crunchyroll.com/auth/v1/token', {
headers: {
Authorization: data.authorization,
Authorization: credentials.authorization, // Ready HTTP header in the format `Basic <encoded>`, can be used to access some Crunchyroll APIs
'User-Agent': 'Crunchyroll/ANDROIDTV/3.42.1_22267 (Android 16; en-US; sdk_gphone64_x86_64)',
// ...
},
@@ -37,17 +40,23 @@ async function main() {
}
```
#### Library
#### Extract credentials from the latest APK using jadx
```js
import { extract } from 'crextractor';
async function main() {
const { id, secret, encoded, authorization } = await extract();
// id - Crunchyroll app ID
// secret - Crunchyroll app secret
// encoded - Base64 encoded `id:secret` string
// authorization - ready HTTP header in the format `Basic <encoded>`, can be used to access some Crunchyroll APIs
// Do something with the extracted secrets
// Do something with the extracted credentials
}
```
#### Command-line interface
### Command-line interface
```bash
npx crextractor --target mobile --output ./credentials.mobile.json
+17 -3
View File
@@ -1,10 +1,24 @@
export function extractSecrets(): Promise<{
export type CrunchyrollAppCredentials = {
// Crunchyroll app ID
id: string;
// Crunchyroll app secret
secret: string;
// Base64 encoded `id:secret` string
encoded: string;
// HTTP header with Basic Authorization to access Crunchyroll mobile APIs
// Ready HTTP header in the format `Basic <encoded>`, can be used to access some Crunchyroll APIs
authorization: string;
}>;
};
/**
* Extract credentials from the Crunchyroll Android APK using jadx.
*/
export function extract(options?: {
target?: 'mobile' | 'tv';
output?: string;
cleanup?: boolean;
}): Promise<CrunchyrollAppCredentials>;
/**
* Fetch ready credentials from the GitHub repository.
*/
export function pull(options?: { target: 'mobile' | 'tv' }): Promise<CrunchyrollAppCredentials>;
+8 -2
View File
@@ -96,7 +96,7 @@ const parseVersion = async (decompiledDir) => {
}
};
const extract = async ({ target, output, cleanup = false } = {}) => {
const extract = async ({ target = 'mobile', output, cleanup = false } = {}) => {
console.log('Downloading APK...');
const apkPath = target === 'tv' ? await downloadTvApk() : await downloadMobileApk();
@@ -128,4 +128,10 @@ const extract = async ({ target, output, cleanup = false } = {}) => {
return { version, id, secret, encoded, authorization };
};
module.exports = { extract };
const pull = async ({ target = 'mobile' } = {}) => {
const url = `https://raw.githubusercontent.com/vitalygashkov/crextractor/refs/heads/main/credentials.${target}.json`;
const credentials = await fetch(url).then((response) => response.json());
return credentials;
};
module.exports = { extract, pull };
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "crextractor",
"version": "1.2.1",
"version": "1.3.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "crextractor",
"version": "1.2.1",
"version": "1.3.0",
"funding": [
{
"type": "individual",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "crextractor",
"version": "1.2.1",
"version": "1.3.0",
"description": "Utility for extracting credentials from the Crunchyroll Android app",
"main": "crextractor.js",
"bin": {