pull/69/head
FongMi 2 years ago
parent 6e474781d7
commit 2e139688bb
  1. 3
      app/build.gradle
  2. 4
      app/proguard-rules.pro
  3. 2
      app/src/main/java/com/github/catvod/js/Method.java
  4. 64
      app/src/main/java/com/github/catvod/net/Cronet.java
  5. 10
      app/src/main/java/com/github/catvod/net/OkhttpInterceptor.java
  6. 9
      app/src/main/java/com/github/catvod/spider/UpYun.java
  7. 93
      tools/src/main/java/com/fongmi/tools/Config.java
  8. 1
      tools/src/main/java/com/fongmi/tools/bean/Data.java

@ -34,12 +34,9 @@ android {
}
dependencies {
//Debug For HTTP/3
debugImplementation 'org.chromium.net:cronet-embedded:101.4951.41'
implementation('com.github.thegrizzlylabs:sardine-android:0.8') { exclude group: 'com.squareup.okhttp3', module: 'okhttp' }
implementation 'com.googlecode.juniversalchardet:juniversalchardet:1.0.3'
implementation 'wang.harlon.quickjs:wrapper-android:0.21.1'
implementation 'com.google.net.cronet:cronet-okhttp:0.1.0'
implementation 'com.squareup.okhttp3:okhttp:3.12.13'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'cn.wanghaomiao:JsoupXpath:2.5.1'

@ -29,10 +29,6 @@
-keep class okio.** { *; }
-keep class okhttp3.** { *; }
# Cronet
-keep class org.chromium.net.** { *; }
-keep class com.google.net.cronet.** { *; }
# Sardine
-keep class com.thegrizzlylabs.sardineandroid.** { *; }

@ -1,7 +1,6 @@
package com.github.catvod.js;
import com.github.catvod.utils.Utils;
import com.google.errorprone.annotations.Keep;
import com.whl.quickjs.wrapper.JSMethod;
import com.whl.quickjs.wrapper.QuickJSContext;
@ -13,7 +12,6 @@ public class Method {
this.ctx = ctx;
}
@Keep
@JSMethod
public void showToast(String msg) {
Utils.notify(msg);

@ -1,64 +0,0 @@
package com.github.catvod.net;
import com.github.catvod.spider.Init;
import com.google.net.cronet.okhttptransport.CronetInterceptor;
import org.chromium.net.CronetEngine;
import java.util.Map;
import okhttp3.OkHttpClient;
public class Cronet {
private OkHttpClient client;
private static class Loader {
static volatile Cronet INSTANCE = new Cronet();
}
public static Cronet get() {
return Loader.INSTANCE;
}
public static OkHttpClient client() {
if (get().client != null) return get().client;
return get().client = getBuilder().build();
}
public static OkHttpClient noRedirect() {
return client().newBuilder().followRedirects(false).followSslRedirects(false).build();
}
public static String string(String url) {
return string(url, null);
}
public static String string(String url, Map<String, String> header) {
return string(url, null, header);
}
public static String string(String url, Map<String, String> params, Map<String, String> header) {
return new OkRequest(OkHttp.GET, url, params, header).execute(client()).getBody();
}
public static String post(String url, Map<String, String> params) {
return post(url, params, null).getBody();
}
public static OkResult post(String url, Map<String, String> params, Map<String, String> header) {
return new OkRequest(OkHttp.POST, url, params, header).execute(client());
}
public static String post(String url, String json) {
return post(url, json, null).getBody();
}
public static OkResult post(String url, String json, Map<String, String> header) {
return new OkRequest(OkHttp.POST, url, json, header).execute(client());
}
private static OkHttpClient.Builder getBuilder() {
return OkHttp.getBuilder().addInterceptor(CronetInterceptor.newBuilder(new CronetEngine.Builder(Init.context()).build()).build());
}
}

@ -1,9 +1,6 @@
package com.github.catvod.net;
import com.github.catvod.utils.Utils;
import com.google.common.net.HttpHeaders;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.io.IOException;
import java.util.zip.Inflater;
@ -22,7 +19,7 @@ public class OkhttpInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Response response = chain.proceed(getRequest(chain));
String encoding = response.header(HttpHeaders.CONTENT_ENCODING);
String encoding = response.header("Content-Encoding");
if (response.body() == null || encoding == null || !encoding.equals("deflate")) return response;
InflaterInputStream is = new InflaterInputStream(response.body().byteStream(), new Inflater(true));
return response.newBuilder().headers(response.headers()).body(new ResponseBody() {
@ -36,7 +33,6 @@ public class OkhttpInterceptor implements Interceptor {
return response.body().contentLength();
}
@NonNull
@Override
public BufferedSource source() {
return Okio.buffer(Okio.source(is));
@ -44,9 +40,9 @@ public class OkhttpInterceptor implements Interceptor {
}).build();
}
private Request getRequest(@NonNull Chain chain) {
private Request getRequest(Chain chain) {
Request request = chain.request();
if (request.url().host().equals("gitcode.net")) return request.newBuilder().addHeader(HttpHeaders.USER_AGENT, Utils.CHROME).build();
if (request.url().host().equals("gitcode.net")) return request.newBuilder().addHeader("User-Agent", Utils.CHROME).build();
return request;
}
}

@ -5,7 +5,6 @@ import com.github.catvod.bean.Vod;
import com.github.catvod.bean.upyun.Data;
import com.github.catvod.bean.upyun.Item;
import com.github.catvod.net.OkHttp;
import com.google.common.io.BaseEncoding;
import java.net.URLEncoder;
import java.util.ArrayList;
@ -43,8 +42,14 @@ public class UpYun extends Ali {
IvParameterSpec ivSpec = new IvParameterSpec("qq1920520460qqzz".getBytes());
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec);
byte[] encryptDataBytes = BaseEncoding.base16().decode(data.toUpperCase());
byte[] encryptDataBytes = decodeHex(data.toUpperCase());
byte[] decryptData = cipher.doFinal(encryptDataBytes);
return new String(decryptData, "UTF-8");
}
private static byte[] decodeHex(String s) {
byte[] bytes = new byte[s.length() / 2];
for (int i = 0; i < bytes.length; i++) bytes[i] = Integer.valueOf(s.substring(i * 2, i * 2 + 2), 16).byteValue();
return bytes;
}
}

@ -1,93 +0,0 @@
package com.fongmi.tools;
import com.google.common.io.BaseEncoding;
import com.google.gson.Gson;
import com.google.gson.JsonParser;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
public class Config {
private final Gson gson;
public static void main(String[] args) {
try {
Config config = new Config();
String json = config.getJson("http://饭太硬.top/tv");
System.out.println(config.gson.toJson(JsonParser.parseString(json)));
} catch (Exception e) {
e.printStackTrace();
}
}
public Config() {
gson = new Gson().newBuilder().disableHtmlEscaping().setPrettyPrinting().create();
}
private String getJson(String url) throws Exception {
String key = url.contains(";") ? url.split(";")[2] : "";
url = url.contains(";") ? url.split(";")[0] : url;
String data = getData(url);
if (Utils.isJson(data)) return data;
if (data.isEmpty()) throw new Exception();
if (data.contains("**")) data = base64(data);
if (data.startsWith("2423")) data = cbc(data);
if (key.length() > 0) data = ecb(data, key);
return data;
}
private String getData(String url) throws Exception {
if (url.startsWith("http")) return Utils.call(url);
throw new Exception();
}
private String ecb(String data, String key) throws Exception {
SecretKeySpec spec = new SecretKeySpec(padEnd(key), "AES");
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, spec);
return new String(cipher.doFinal(decodeHex(data)), StandardCharsets.UTF_8);
}
private String cbc(String data) throws Exception {
int indexKey = data.indexOf("2324") + 4;
String key = new String(decodeHex(data.substring(0, indexKey)), StandardCharsets.UTF_8);
key = key.replace("$#", "").replace("#$", "");
int indexIv = data.length() - 26;
String iv = data.substring(indexIv).trim();
iv = new String(decodeHex(iv), StandardCharsets.UTF_8);
SecretKeySpec keySpec = new SecretKeySpec(padEnd(key), "AES");
IvParameterSpec ivSpec = new IvParameterSpec(padEnd(iv));
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec);
data = data.substring(indexKey, indexIv).trim();
byte[] encryptDataBytes = decodeHex(data);
byte[] decryptData = cipher.doFinal(encryptDataBytes);
return new String(decryptData, StandardCharsets.UTF_8);
}
private String base64(String data) {
String extract = extract(data);
if (extract.isEmpty()) return data;
return new String(Base64.getDecoder().decode(extract));
}
private String extract(String data) {
Matcher matcher = Pattern.compile("[A-Za-z0-9]{8}\\*\\*").matcher(data);
return matcher.find() ? data.substring(data.indexOf(matcher.group()) + 10) : "";
}
private byte[] padEnd(String key) {
return (key + "0000000000000000".substring(key.length())).getBytes(StandardCharsets.UTF_8);
}
private byte[] decodeHex(String s) {
return BaseEncoding.base16().decode(s.toUpperCase());
}
}

@ -14,7 +14,6 @@ public class Data {
private String name;
@SerializedName("epg")
private String epg;
@SerializedName("logo")
private String logo;

Loading…
Cancel
Save