forked from sim1222-mirror/wrapper
Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
976118d948 | |||
86d1c1a507 | |||
aa1886e487 | |||
b96afbbd3a | |||
c37d47c2ec | |||
4fdc3aabce | |||
5e687bed4f | |||
cfd4ad5fd1 |
41
.github/workflows/c-cpp.yml
vendored
Normal file
41
.github/workflows/c-cpp.yml
vendored
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
name: C/C++ CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ "main" ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ "main" ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install aria2
|
||||||
|
run: sudo apt install aria2 -y
|
||||||
|
|
||||||
|
- name: Install LLVM
|
||||||
|
run: sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
|
||||||
|
|
||||||
|
- name: Set up Android NDK r23b
|
||||||
|
run: |
|
||||||
|
aria2c -o android-ndk-r23b-linux.zip https://dl.google.com/android/repository/android-ndk-r23b-linux.zip
|
||||||
|
unzip -q android-ndk-r23b-linux.zip
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
android-ndk-r23b/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android22-clang++ -Wall -Werror -nostdlib -c -O3 -o handle.o main.cpp
|
||||||
|
android-ndk-r23b/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android22-clang -DMyRelease -Wall -Werror -L ./rootfs/system/lib64 -landroidappmusic -lstoreservicescore -lmediaplatform -lc++_shared -O3 -Wall -o rootfs/system/bin/main handle.o test.c
|
||||||
|
clang -O3 -Wall -o wrapper wrapper.c
|
||||||
|
|
||||||
|
- name: Upload artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: Wrapper.x86_64
|
||||||
|
path: |
|
||||||
|
rootfs
|
||||||
|
handle.o
|
||||||
|
wrapper
|
15
README.md
15
README.md
@ -1,2 +1,17 @@
|
|||||||
# wrapper
|
# wrapper
|
||||||
All files from anonymous, No need for an Android emulator to decrypt alac
|
All files from anonymous, No need for an Android emulator to decrypt alac
|
||||||
|
|
||||||
|
|
||||||
|
### 安装
|
||||||
|
推荐Windows Subsystem for Linux (WSL)使用
|
||||||
|
usage: `./wrapper [port] ([username] [password])`
|
||||||
|
get-m3u8为port+10000
|
||||||
|
|
||||||
|
```shell
|
||||||
|
sudo -i
|
||||||
|
wget "https://github.com/zhaarey/wrapper/releases/download/linux/wrapper.linux.x86_64.tar.gz"
|
||||||
|
mkdir wrapper
|
||||||
|
tar -xzf wrapper.linux.x86_64.tar.gz -C wrapper
|
||||||
|
cd wrapper
|
||||||
|
./wrapper
|
||||||
|
```
|
25
import.h
25
import.h
@ -32,6 +32,24 @@ static inline union std_string new_std_string(const char *s) {
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline struct std_vector new_std_vector(void *begin) {
|
||||||
|
struct std_vector vector = {
|
||||||
|
.begin = begin,
|
||||||
|
.end = begin + 1,
|
||||||
|
};
|
||||||
|
vector.end_capacity = vector.end;
|
||||||
|
return vector;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline union std_string new_std_string_short_mode(const char *str) {
|
||||||
|
short str_size = strlen(str);
|
||||||
|
union std_string std_str = {
|
||||||
|
.mark = str_size << 1,
|
||||||
|
};
|
||||||
|
strcpy(std_str.str, str);
|
||||||
|
return std_str;
|
||||||
|
}
|
||||||
|
|
||||||
static inline const char *std_string_data(union std_string *str) {
|
static inline const char *std_string_data(union std_string *str) {
|
||||||
if ((str->mark & 1) == 0) {
|
if ((str->mark & 1) == 0) {
|
||||||
return str->str;
|
return str->str;
|
||||||
@ -215,6 +233,13 @@ extern void _ZN8FootHill24defaultContextIdentifierEv(void *);
|
|||||||
extern void _ZN21RequestContextManager9configureERKNSt6__ndk110shared_ptrIN17storeservicescore14RequestContextEEE(
|
extern void _ZN21RequestContextManager9configureERKNSt6__ndk110shared_ptrIN17storeservicescore14RequestContextEEE(
|
||||||
struct shared_ptr *);
|
struct shared_ptr *);
|
||||||
|
|
||||||
|
extern struct shared_ptr *_ZN22SVPlaybackLeaseManager12requestAssetERKmRKNSt6__ndk16vectorINS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS7_IS9_EEEERKb(
|
||||||
|
void *, void *, unsigned long *, struct std_vector *, uint8_t *
|
||||||
|
);
|
||||||
|
extern int _ZNK23SVPlaybackAssetResponse13hasValidAssetEv(void *);
|
||||||
|
extern struct shared_ptr *_ZNK23SVPlaybackAssetResponse13playbackAssetEv(void *);
|
||||||
|
extern union std_string *_ZNK17storeservicescore13PlaybackAsset9URLStringEv(void *, uint8_t *);
|
||||||
|
|
||||||
const char *const android_id = "dc28071e981c439e";
|
const char *const android_id = "dc28071e981c439e";
|
||||||
const char *const fairplayCert = "MIIEzjCCA7agAwIBAgIIAXAVjHFZDjgwDQYJKoZIhvcNAQEFBQAwfzELMAkGA1UEBhMCVVMxEz"
|
const char *const fairplayCert = "MIIEzjCCA7agAwIBAgIIAXAVjHFZDjgwDQYJKoZIhvcNAQEFBQAwfzELMAkGA1UEBhMCVVMxEz"
|
||||||
"ARBgNVBAoMCkFwcGxlIEluYy4xJjAkBgNVBAsMHUFwcGxlIENlcnRpZmljYXRpb24gQXV0aG9y"
|
"ARBgNVBAoMCkFwcGxlIEluYy4xJjAkBgNVBAsMHUFwcGxlIENlcnRpZmljYXRpb24gQXV0aG9y"
|
||||||
|
101
test.c
101
test.c
@ -5,6 +5,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
@ -112,7 +113,7 @@ static inline void init() {
|
|||||||
// raise(SIGSTOP);
|
// raise(SIGSTOP);
|
||||||
fprintf(stderr, "[+] starting...\n");
|
fprintf(stderr, "[+] starting...\n");
|
||||||
setenv("ANDROID_DNS_MODE", "local", 1);
|
setenv("ANDROID_DNS_MODE", "local", 1);
|
||||||
static const char *resolvers[2] = {"1.1.1.1", "1.0.0.1"};
|
static const char *resolvers[2] = {"1.1.1.1", "223.5.5.5"};
|
||||||
_resolv_set_nameservers_for_net(0, resolvers, 2, ".");
|
_resolv_set_nameservers_for_net(0, resolvers, 2, ".");
|
||||||
#ifndef MyRelease
|
#ifndef MyRelease
|
||||||
subhook_install(subhook_new(
|
subhook_install(subhook_new(
|
||||||
@ -376,7 +377,7 @@ inline static int new_socket() {
|
|||||||
setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &optval, sizeof(optval));
|
setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &optval, sizeof(optval));
|
||||||
|
|
||||||
static struct sockaddr_in serv_addr = {.sin_family = AF_INET};
|
static struct sockaddr_in serv_addr = {.sin_family = AF_INET};
|
||||||
serv_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
|
serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||||
serv_addr.sin_port = htons(port);
|
serv_addr.sin_port = htons(port);
|
||||||
if (bind(fd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) == -1) {
|
if (bind(fd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) == -1) {
|
||||||
perror("bind");
|
perror("bind");
|
||||||
@ -388,7 +389,7 @@ inline static int new_socket() {
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "[!] listening 127.0.0.1:%d\n", port);
|
fprintf(stderr, "[!] listening 0.0.0.0:%d\n", port);
|
||||||
close(STDOUT_FILENO);
|
close(STDOUT_FILENO);
|
||||||
|
|
||||||
static struct sockaddr_in peer_addr;
|
static struct sockaddr_in peer_addr;
|
||||||
@ -423,6 +424,98 @@ inline static int new_socket() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char* get_m3u8_method_play(uint8_t leaseMgr[16], unsigned long adam) {
|
||||||
|
union std_string HLS = new_std_string_short_mode("HLS");
|
||||||
|
struct std_vector HLSParam = new_std_vector(&HLS);
|
||||||
|
static uint8_t z0 = 1;
|
||||||
|
struct shared_ptr *ptr_result = (struct shared_ptr *) malloc(32);
|
||||||
|
_ZN22SVPlaybackLeaseManager12requestAssetERKmRKNSt6__ndk16vectorINS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS7_IS9_EEEERKb(
|
||||||
|
ptr_result, leaseMgr, &adam, &HLSParam, &z0
|
||||||
|
);
|
||||||
|
if (_ZNK23SVPlaybackAssetResponse13hasValidAssetEv(ptr_result->obj)) {
|
||||||
|
struct shared_ptr *playbackAsset = _ZNK23SVPlaybackAssetResponse13playbackAssetEv(ptr_result->obj);
|
||||||
|
union std_string *m3u8 = (union std_string *) malloc(24);
|
||||||
|
_ZNK17storeservicescore13PlaybackAsset9URLStringEv(m3u8, playbackAsset->obj);
|
||||||
|
return std_string_data(m3u8);
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void handle_m3u8(const int connfd) {
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
uint8_t adamSize;
|
||||||
|
if (!readfull(connfd, &adamSize, sizeof(uint8_t))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (adamSize <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
char adam[adamSize];
|
||||||
|
for (int i=0; i<adamSize; i=i+1) {
|
||||||
|
readfull(connfd, &adam[i], sizeof(uint8_t));
|
||||||
|
}
|
||||||
|
char *ptr;
|
||||||
|
unsigned long adamID = strtoul(adam, &ptr, 10);
|
||||||
|
const char *m3u8 = get_m3u8_method_play(leaseMgr, adamID);
|
||||||
|
if (m3u8 == NULL) {
|
||||||
|
fprintf(stderr, "[.] failed to get m3u8 of adamId: %ld\n", adamID);
|
||||||
|
writefull(connfd, NULL, sizeof(NULL));
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "[.] m3u8 adamId: %ld, url: %s\n", adamID, m3u8);
|
||||||
|
strcat((char *)m3u8, "\n");
|
||||||
|
writefull(connfd, (void *)m3u8, strlen(m3u8));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void *new_socket_m3u8(void *args) {
|
||||||
|
const int fd = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, IPPROTO_TCP);
|
||||||
|
if (fd == -1) {
|
||||||
|
perror("socket");
|
||||||
|
}
|
||||||
|
const int optval = 1;
|
||||||
|
const int m3u8_port = port + 10000;
|
||||||
|
setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &optval, sizeof(optval));
|
||||||
|
|
||||||
|
static struct sockaddr_in serv_addr = {.sin_family = AF_INET};
|
||||||
|
serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||||
|
serv_addr.sin_port = htons(m3u8_port);
|
||||||
|
if (bind(fd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) == -1) {
|
||||||
|
perror("bind");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (listen(fd, 5) == -1) {
|
||||||
|
perror("listen");
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "[!] listening m3u8 request on 0.0.0.0:%d\n", m3u8_port);
|
||||||
|
close(STDOUT_FILENO);
|
||||||
|
|
||||||
|
static struct sockaddr_in peer_addr;
|
||||||
|
static socklen_t peer_addr_size = sizeof(peer_addr);
|
||||||
|
while (1) {
|
||||||
|
const int connfd = accept4(fd, (struct sockaddr *)&peer_addr,
|
||||||
|
&peer_addr_size, SOCK_CLOEXEC);
|
||||||
|
if (connfd == -1) {
|
||||||
|
if (errno == ENETDOWN || errno == EPROTO || errno == ENOPROTOOPT ||
|
||||||
|
errno == EHOSTDOWN || errno == ENONET ||
|
||||||
|
errno == EHOSTUNREACH || errno == EOPNOTSUPP ||
|
||||||
|
errno == ENETUNREACH)
|
||||||
|
continue;
|
||||||
|
perror("accept4");
|
||||||
|
}
|
||||||
|
|
||||||
|
handle_m3u8(connfd);
|
||||||
|
|
||||||
|
if (close(connfd) == -1) {
|
||||||
|
perror("close");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
selfPath = argv[0];
|
selfPath = argv[0];
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
@ -452,5 +545,7 @@ int main(int argc, char *argv[]) {
|
|||||||
_ZN22SVPlaybackLeaseManager12requestLeaseERKb(leaseMgr, &autom);
|
_ZN22SVPlaybackLeaseManager12requestLeaseERKb(leaseMgr, &autom);
|
||||||
FHinstance = _ZN21SVFootHillSessionCtrl8instanceEv();
|
FHinstance = _ZN21SVFootHillSessionCtrl8instanceEv();
|
||||||
|
|
||||||
|
pthread_t m3u8_thread;
|
||||||
|
pthread_create(&m3u8_thread, NULL, &new_socket_m3u8, NULL);
|
||||||
return new_socket();
|
return new_socket();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user