ncat修复

This commit is contained in:
“lushunming” 2024-09-16 09:10:52 +08:00
parent 2cdf7cbd19
commit 5f7e292f98
11 changed files with 106 additions and 105 deletions

View File

@ -67,6 +67,7 @@ dependencies {
implementation 'androidx.core:core-ktx:1.10.1' implementation 'androidx.core:core-ktx:1.10.1'
testImplementation "io.github.dokar3:quickjs-kt-jvm:1.0.0-alpha13" testImplementation "io.github.dokar3:quickjs-kt-jvm:1.0.0-alpha13"
testImplementation 'org.nanohttpd:nanohttpd:2.3.1' testImplementation 'org.nanohttpd:nanohttpd:2.3.1'
implementation 'commons-codec:commons-codec:1.17.1'
// Required -- JUnit 4 framework // Required -- JUnit 4 framework
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
@ -77,7 +78,6 @@ dependencies {
//implementation 'wang.harlon.quickjs:wrapper-java:1.0.0' //implementation 'wang.harlon.quickjs:wrapper-java:1.0.0'
// implementation(ext: 'aar', name: 'quickjs', group: 'fongmi', version: 'release') // implementation(ext: 'aar', name: 'quickjs', group: 'fongmi', version: 'release')
// api 'wang.harlon.quickjs:wrapper-android:2.0.0' // api 'wang.harlon.quickjs:wrapper-android:2.0.0'
implementation 'cn.hutool:hutool-all:5.8.26'
} }

View File

@ -243,7 +243,7 @@ public class ChangZhang extends Spider {
String kc8a64 = "336460fdcb76a597"; String kc8a64 = "336460fdcb76a597";
String iv = "1234567890983456"; String iv = "1234567890983456";
return AESEncryption.decrypt(data, kc8a64, iv); return AESEncryption.decrypt(data, kc8a64, iv,AESEncryption.CBC_PKCS_7_PADDING);
} }
; ;

View File

@ -1,32 +1,19 @@
package com.github.catvod.spider; package com.github.catvod.spider;
import cn.hutool.core.codec.Base64;
import cn.hutool.crypto.Mode;
import cn.hutool.crypto.Padding;
import cn.hutool.crypto.symmetric.AES;
import com.github.catvod.bean.Class; import com.github.catvod.bean.Class;
import com.github.catvod.bean.Result; import com.github.catvod.bean.Result;
import com.github.catvod.bean.Vod; import com.github.catvod.bean.Vod;
import com.github.catvod.crawler.Spider; import com.github.catvod.crawler.Spider;
import com.github.catvod.net.OkHttp; import com.github.catvod.net.OkHttp;
import com.github.catvod.utils.AESEncryption;
import com.github.catvod.utils.Util; import com.github.catvod.utils.Util;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import org.apache.commons.lang3.StringUtils;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
import org.jsoup.nodes.Document; import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element; import org.jsoup.nodes.Element;
import org.jsoup.select.Elements; import org.jsoup.select.Elements;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -191,12 +178,7 @@ public class NCat extends Spider {
try { try {
String encryptedKey = "VNF9aVQF!G*0ux@2hAigUeH3"; String encryptedKey = "VNF9aVQF!G*0ux@2hAigUeH3";
byte[] keyBytes = encryptedKey.getBytes(Charset.defaultCharset()); return AESEncryption.decrypt(encryptedData, encryptedKey, iv,AESEncryption.ECB_PKCS_7_PADDING);
byte[] encryptedBytes = Base64.decode(encryptedData);
AES aes = StringUtils.isAllBlank(iv) ? new AES(Mode.ECB, Padding.PKCS5Padding, keyBytes) : new AES(Mode.ECB, Padding.PKCS5Padding, keyBytes, iv.getBytes(Charset.defaultCharset()));
byte[] decryptedBytes = aes.decrypt(encryptedBytes);
return new String(decryptedBytes, Charset.defaultCharset());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return "123456"; return "123456";

View File

@ -1,11 +1,16 @@
package com.github.catvod.spider; package com.github.catvod.spider;
import static com.github.catvod.utils.AESEncryption.CBC_PKCS_7_PADDING;
import android.content.Context;
import com.github.catvod.bean.Class; import com.github.catvod.bean.Class;
import com.github.catvod.bean.Result; import com.github.catvod.bean.Result;
import com.github.catvod.bean.Vod; import com.github.catvod.bean.Vod;
import com.github.catvod.crawler.Spider; import com.github.catvod.crawler.Spider;
import com.github.catvod.net.OkHttp; import com.github.catvod.net.OkHttp;
import com.github.catvod.utils.AESEncryption; import com.github.catvod.utils.AESEncryption;
import com.github.catvod.utils.Json;
import com.github.catvod.utils.Util; import com.github.catvod.utils.Util;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
@ -23,16 +28,18 @@ import java.security.NoSuchAlgorithmException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
public class W55Movie extends Spider { public class W55Movie extends Spider {
private static final String siteUrl = "https://55flix.com"; private static String siteUrl = "https://55flix.com";
private static final String cateUrl = siteUrl + "/index.php/api/vod"; private static final String cateUrl = siteUrl + "/index.php/api/vod";
private static final String detailUrl = siteUrl + "/voddetail/"; private static String detailUrl = siteUrl + "/voddetail/";
private static final String playUrl = siteUrl + "/vodplay/"; private static String playUrl = siteUrl + "/vodplay/";
private static final String searchUrl = siteUrl + "/vodsearch/page/1/wd/"; private static String searchUrl = siteUrl + "/vodsearch/page/1/wd/";
private HashMap<String, String> getHeaders() { private HashMap<String, String> getHeaders() {
HashMap<String, String> headers = new HashMap<>(); HashMap<String, String> headers = new HashMap<>();
@ -40,11 +47,25 @@ public class W55Movie extends Spider {
return headers; return headers;
} }
@Override
public void init(Context context, String extend) throws Exception {
super.init(context, extend);
Document doc = Jsoup.parse(OkHttp.string(extend));
String data = doc.select("#domainData").attr("data-info");
String info = Util.base64Decode(data);
Map<String, Object> json = Json.parseSafe(info, Map.class);
siteUrl = "https://" + json.get("site_main").toString();
detailUrl = siteUrl + "/voddetail/";
playUrl = siteUrl + "/vodplay/";
searchUrl = siteUrl + "/vodsearch/page/1/wd/";
}
@Override @Override
public String homeContent(boolean filter) throws Exception { public String homeContent(boolean filter) throws Exception {
List<Vod> list = new ArrayList<>(); List<Vod> list = new ArrayList<>();
List<Class> classes = new ArrayList<>(); List<Class> classes = new ArrayList<>();
String[] typeIdList = {"/label/netflix/page/","/vodshow/1","/vodshow/2","/vodshow/124","/vodshow/4","/vodshow/3"}; String[] typeIdList = {"/label/netflix", "/vodshow/1", "/vodshow/2", "/vodshow/124", "/vodshow/4", "/vodshow/3"};
String[] typeNameList = {"Netflix", "电影", "连续剧", "福利", "动漫", "综艺"}; String[] typeNameList = {"Netflix", "电影", "连续剧", "福利", "动漫", "综艺"};
for (int i = 0; i < typeNameList.length; i++) { for (int i = 0; i < typeNameList.length; i++) {
classes.add(new Class(typeIdList[i], typeNameList[i])); classes.add(new Class(typeIdList[i], typeNameList[i]));
@ -192,6 +213,9 @@ public class W55Movie extends Spider {
return Result.string(list); return Result.string(list);
} }
private static final String keyString = "a67e9a3a85049339";
private static final String ivString = "86ad9b37cc9f5b9501b3cecc7dc6377c";
@Override @Override
public String playerContent(String flag, String id, List<String> vipFlags) throws Exception { public String playerContent(String flag, String id, List<String> vipFlags) throws Exception {
String target = playUrl.concat(id); String target = playUrl.concat(id);
@ -208,12 +232,12 @@ public class W55Movie extends Spider {
} }
String encrytStr = url;// "{\"url\":\"" + url + "\",\"next_url\":\"" + url_next + "\"}"; String encrytStr = url;// "{\"url\":\"" + url + "\",\"next_url\":\"" + url_next + "\"}";
// 加密 // 加密
String encrypt = AESEncryption.encrypt(encrytStr); String encrypt = AESEncryption.encrypt(encrytStr, keyString, ivString,CBC_PKCS_7_PADDING);
String encodeURI = AESEncryption.encodeURIComponent(encrypt); String encodeURI = AESEncryption.encodeURIComponent(encrypt);
// 请求获取url // 请求获取url
String data = OkHttp.string("https://player.ddzyku.com:3653/get_url_v2?data=" + encodeURI); String data = OkHttp.string("https://player.ddzyku.com:3653/get_url_v2?data=" + encodeURI);
// 解密 // 解密
String decrypted = AESEncryption.decrypt(data); String decrypted = AESEncryption.decrypt(data, keyString, ivString,CBC_PKCS_7_PADDING);
Gson gson = new Gson(); Gson gson = new Gson();
JsonObject jsonObject = gson.fromJson(decrypted, JsonObject.class); JsonObject jsonObject = gson.fromJson(decrypted, JsonObject.class);
JsonObject dataObject = jsonObject.getAsJsonObject("data"); JsonObject dataObject = jsonObject.getAsJsonObject("data");

View File

@ -2,6 +2,8 @@ package com.github.catvod.utils;
import android.util.Base64; import android.util.Base64;
import org.apache.commons.lang3.StringUtils;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.nio.charset.Charset; import java.nio.charset.Charset;
@ -13,10 +15,11 @@ import javax.crypto.spec.SecretKeySpec;
public class AESEncryption { public class AESEncryption {
private static final String keyString = "a67e9a3a85049339";
private static final String ivString = "86ad9b37cc9f5b9501b3cecc7dc6377c";
public static String encrypt(String word) { public static final String CBC_PKCS_7_PADDING = "AES/CBC/PKCS7Padding";
public static final String ECB_PKCS_7_PADDING = "AES/ECB/PKCS5Padding";
public static String encrypt(String word, String keyString, String ivString,String trans) {
try { try {
byte[] keyBytes = keyString.getBytes("UTF-8"); byte[] keyBytes = keyString.getBytes("UTF-8");
SecretKeySpec keySpec = new SecretKeySpec(keyBytes, "AES"); SecretKeySpec keySpec = new SecretKeySpec(keyBytes, "AES");
@ -24,19 +27,25 @@ public class AESEncryption {
byte[] ivBytes = hexStringToByteArray(ivString); byte[] ivBytes = hexStringToByteArray(ivString);
IvParameterSpec ivSpec = new IvParameterSpec(ivBytes); IvParameterSpec ivSpec = new IvParameterSpec(ivBytes);
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding"); Cipher cipher = Cipher.getInstance(trans);
if(StringUtils.isAllBlank(ivString)){
cipher.init(Cipher.ENCRYPT_MODE, keySpec);
}else{
cipher.init(Cipher.ENCRYPT_MODE, keySpec, ivSpec); cipher.init(Cipher.ENCRYPT_MODE, keySpec, ivSpec);
}
byte[] encrypted = cipher.doFinal(word.getBytes("UTF-8")); byte[] encrypted = cipher.doFinal(word.getBytes("UTF-8"));
return Base64.encodeToString(encrypted, Base64.DEFAULT); return org.apache.commons.codec.binary.Base64.encodeBase64String(encrypted);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return null; return null;
} }
} }
public static String decrypt(String word) { public static String decrypt(String word,String keyString,String ivString,String trans) {
try { try {
byte[] keyBytes = keyString.getBytes("UTF-8"); byte[] keyBytes = keyString.getBytes("UTF-8");
SecretKeySpec keySpec = new SecretKeySpec(keyBytes, "AES"); SecretKeySpec keySpec = new SecretKeySpec(keyBytes, "AES");
@ -44,10 +53,15 @@ public class AESEncryption {
byte[] ivBytes = hexStringToByteArray(ivString); byte[] ivBytes = hexStringToByteArray(ivString);
IvParameterSpec ivSpec = new IvParameterSpec(ivBytes); IvParameterSpec ivSpec = new IvParameterSpec(ivBytes);
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding"); Cipher cipher = Cipher.getInstance(trans);
if(StringUtils.isAllBlank(ivString)){
cipher.init(Cipher.DECRYPT_MODE, keySpec);
}else{
cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec); cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec);
byte[] decoded = Base64.decode(word, Base64.DEFAULT); }
byte[] decoded = org.apache.commons.codec.binary.Base64.decodeBase64(word);
byte[] decrypted = cipher.doFinal(decoded); byte[] decrypted = cipher.doFinal(decoded);
return new String(decrypted, "UTF-8"); return new String(decrypted, "UTF-8");
@ -57,26 +71,7 @@ public class AESEncryption {
} }
} }
public static String decrypt(String word,String key,String iv) {
try {
byte[] keyBytes = key.getBytes("UTF-8");
SecretKeySpec keySpec = new SecretKeySpec(keyBytes, "AES");
byte[] ivBytes = iv.getBytes("UTF-8");
IvParameterSpec ivSpec = new IvParameterSpec(ivBytes);
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding");
cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec);
byte[] decoded = Base64.decode(word, Base64.DEFAULT);
byte[] decrypted = cipher.doFinal(decoded);
return new String(decrypted, Charset.defaultCharset());
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
private static byte[] hexStringToByteArray(String hexString) { private static byte[] hexStringToByteArray(String hexString) {
int len = hexString.length(); int len = hexString.length();

View File

@ -28,7 +28,7 @@ public class W55MovieTest {
mockContext = RuntimeEnvironment.application; mockContext = RuntimeEnvironment.application;
Init.init(mockContext); Init.init(mockContext);
spider = new W55Movie(); spider = new W55Movie();
spider.init(mockContext, ""); spider.init(mockContext, "https://jlghjy.com/");
} }
@org.junit.Test @org.junit.Test
@ -65,7 +65,7 @@ public class W55MovieTest {
@org.junit.Test @org.junit.Test
public void detailContent() throws Exception { public void detailContent() throws Exception {
String content = spider.detailContent(Arrays.asList("472585.html")); String content = spider.detailContent(Arrays.asList("489833.html"));
JsonObject map = Json.safeObject(content); JsonObject map = Json.safeObject(content);
Gson gson = new GsonBuilder().setPrettyPrinting().create(); Gson gson = new GsonBuilder().setPrettyPrinting().create();
System.out.println("detailContent--" + gson.toJson(map)); System.out.println("detailContent--" + gson.toJson(map));

Binary file not shown.

View File

@ -1 +1 @@
01a5f6374ea24987cd0598188079d504 97267a31afae36f108e1065bddc72c23

View File

@ -1,5 +1,5 @@
{ {
"spider": "https://androidcatvodspider.pages.dev/jar/custom_spider.jar;md5;01a5f6374ea24987cd0598188079d504", "spider": "https://androidcatvodspider.pages.dev/jar/custom_spider.jar;md5;97267a31afae36f108e1065bddc72c23",
"lives": [ "lives": [
{ {
"name": "直播ipv6", "name": "直播ipv6",
@ -51,7 +51,8 @@
"searchable": 1, "searchable": 1,
"changeable": 1, "changeable": 1,
"ext": {} "ext": {}
},{ },
{
"key": "XuanFeng", "key": "XuanFeng",
"name": "旋风影视", "name": "旋风影视",
"type": 3, "type": 3,
@ -102,7 +103,8 @@
"type": 3, "type": 3,
"api": "csp_W55Movie", "api": "csp_W55Movie",
"searchable": 0, "searchable": 0,
"filterable": 1 "filterable": 1,
"ext": "https://jlghjy.com/"
}, },
{ {
"key": "DaGongRen", "key": "DaGongRen",
@ -120,7 +122,6 @@
"searchable": 0, "searchable": 0,
"filterable": 1 "filterable": 1
}, },
{ {
"key": "NGkt", "key": "NGkt",
"name": "瓜瓜", "name": "瓜瓜",
@ -130,7 +131,6 @@
"filterable": 0, "filterable": 0,
"ext": {} "ext": {}
}, },
{ {
"key": "JustLive", "key": "JustLive",
"name": "JustLive直播", "name": "JustLive直播",

View File

@ -1,5 +1,5 @@
{ {
"spider": "https://androidcatvodspider.pages.dev/jar/custom_spider.jar;md5;01a5f6374ea24987cd0598188079d504", "spider": "https://androidcatvodspider.pages.dev/jar/custom_spider.jar;md5;97267a31afae36f108e1065bddc72c23",
"lives": [ "lives": [
{ {
"name": "直播ipv6", "name": "直播ipv6",

View File

@ -1,5 +1,5 @@
{ {
"spider": "https://androidcatvodspider.pages.dev/jar/custom_spider.jar;md5;01a5f6374ea24987cd0598188079d504", "spider": "https://androidcatvodspider.pages.dev/jar/custom_spider.jar;md5;97267a31afae36f108e1065bddc72c23",
"lives": [ "lives": [
{ {
"name": "直播ipv6", "name": "直播ipv6",