add dump all feature i guess
This commit is contained in:
parent
c15b9d8a1e
commit
c74ad08297
|
@ -1,34 +1,18 @@
|
|||
#include <stdlib.h>
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "nopsmdrm.h"
|
||||
#include "hooks/inlineHook.h"
|
||||
|
||||
#define FAKE_AID 0x0123456789ABCDEFLL
|
||||
#define FAKE_LICENSE_OUTPUT "/mnt/sdcard/psm"
|
||||
#define FAKE_LICENSE_OUTPUT "/sdcard/psm"
|
||||
static void* LIB_DEFAULT_HANDLE = NULL;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char magic[0x8]; // 0x00
|
||||
uint32_t unk1; // 0x08
|
||||
uint32_t unk2; // 0x0C
|
||||
uint64_t aid; // 0x10
|
||||
uint32_t unk3; // 0x18
|
||||
uint32_t unk4; // 0x1C
|
||||
uint64_t start_time; // 0x20
|
||||
uint64_t expiration_time; // 0x28
|
||||
uint8_t act_digest[0x20]; // 0x30
|
||||
char content_id[0x30]; // 0x50
|
||||
uint8_t unk5[0x80]; // 0x80
|
||||
uint8_t key[0x200]; // 0x100
|
||||
uint8_t sha256digest[0x100]; // 0x300
|
||||
} ScePsmDrmLicense;
|
||||
|
||||
int (*scePsmDrmGetKeySet_orig)(ScePsmDrmLicense*, char*, int*, uint64_t*, uint64_t*) = NULL;
|
||||
void* (*scePsmDrmGetRif_orig)(char*, char*, ScePsmDrmLicense *) = NULL;
|
||||
|
||||
|
||||
|
||||
void* get_func_addr(char* function_name) {
|
||||
if(LIB_DEFAULT_HANDLE != NULL){
|
||||
uintptr_t function_addr = (uintptr_t)dlsym(LIB_DEFAULT_HANDLE, function_name);
|
||||
|
@ -66,6 +50,34 @@ void MakeFakeLicense(ScePsmDrmLicense* license_buf, uint8_t* klicensee) {
|
|||
|
||||
}
|
||||
|
||||
void GetAllLicenses(char* psm_folder) {
|
||||
|
||||
char contentId[0x100];
|
||||
char klicensee[0x200];
|
||||
ScePsmDrmLicense license;
|
||||
|
||||
DIR* dfd = opendir(psm_folder);
|
||||
if(dfd == NULL)
|
||||
return;
|
||||
|
||||
struct dirent* ent = NULL;
|
||||
while((ent = readdir(dfd)) != NULL) {
|
||||
snprintf(contentId, sizeof(contentId) - 1, "UM0105-%s-0000000000000000", ent->d_name);
|
||||
LOG("obtaining rif for: %s", contentId);
|
||||
|
||||
int res = scePsmDrmGetRif_orig(contentId, psm_folder, &license);
|
||||
LOG("scePsmDrmGetRif was %x", res);
|
||||
|
||||
if(res >= 0) {
|
||||
res = scePsmDrmGetKeySet_orig(&license, klicensee, NULL, NULL, NULL);
|
||||
LOG("scePsmDrmGetKeySet was %x", res);
|
||||
if(res >= 0) {
|
||||
MakeFakeLicense(&license, klicensee);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int scePsmDrmGetKeySet_patch(ScePsmDrmLicense *license_buf, char *klicensee, int* flags, uint64_t* start_time, uint64_t* expiration_time) {
|
||||
|
||||
LOG("license_buf %p, klicensee %p, flags %p, start_time %p, expiration_time %p", license_buf, klicensee, flags, start_time, expiration_time);
|
||||
|
@ -93,6 +105,7 @@ int scePsmDrmGetKeySet_patch(ScePsmDrmLicense *license_buf, char *klicensee, int
|
|||
|
||||
return res;
|
||||
}
|
||||
|
||||
int scePsmDrmGetRif_patch(char *contentid, char *psm_folder, ScePsmDrmLicense *rif_file) {
|
||||
LOG("contentid: %s psm_folder: %s", contentid, psm_folder);
|
||||
int res = scePsmDrmGetRif_orig(contentid, psm_folder, rif_file);
|
||||
|
@ -100,7 +113,7 @@ int scePsmDrmGetRif_patch(char *contentid, char *psm_folder, ScePsmDrmLicense *r
|
|||
|
||||
if(res < 0) {
|
||||
// get title id :
|
||||
char titleid[9];
|
||||
char titleid[10];
|
||||
memcpy(titleid, contentid + 7, sizeof(titleid));
|
||||
titleid[9] = '\0';
|
||||
|
||||
|
@ -125,10 +138,13 @@ int scePsmDrmGetRif_patch(char *contentid, char *psm_folder, ScePsmDrmLicense *r
|
|||
return 0;
|
||||
}
|
||||
|
||||
if(access("/sdcard/psm/dump_all", F_OK) == 0){
|
||||
GetAllLicenses(psm_folder);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
int patch_libdefault(void* handle) {
|
||||
|
||||
LIB_DEFAULT_HANDLE = handle;
|
||||
|
@ -144,8 +160,7 @@ int patch_libdefault(void* handle) {
|
|||
res = registerInlineHook((uintptr_t)scePsmDrmGetKeySet, (uintptr_t)scePsmDrmGetKeySet_patch, (uintptr_t**)&scePsmDrmGetKeySet_orig);
|
||||
if(res == 0)
|
||||
inlineHook((uintptr_t)scePsmDrmGetKeySet);
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,32 @@
|
|||
#include <android/log.h>
|
||||
#define LOG(...) __android_log_print(ANDROID_LOG_DEBUG, "LIBDEFAULTPROXY", __VA_ARGS__)
|
||||
#define LOGFUNCTION() __android_log_print(ANDROID_LOG_DEBUG, "LIBDEFAULTPROXY", "%s", __FUNCTION__)
|
||||
#define LOGBUF(buffer, buffer_sz) char buf[buffer_sz * 3 + 2]; \
|
||||
char *out_p = buf;\
|
||||
const unsigned char *const in_p = (void*)buffer;\
|
||||
for (int i = 0; i < buffer_sz; i++) { \
|
||||
sprintf(out_p, " %02x", in_p[i]); \
|
||||
out_p += 3; \
|
||||
} \
|
||||
LOG("%s", buf);
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char magic[0x8]; // 0x00
|
||||
uint32_t unk1; // 0x08
|
||||
uint32_t unk2; // 0x0C
|
||||
uint64_t aid; // 0x10
|
||||
uint32_t unk3; // 0x18
|
||||
uint32_t unk4; // 0x1C
|
||||
uint64_t start_time; // 0x20
|
||||
uint64_t expiration_time; // 0x28
|
||||
uint8_t act_digest[0x20]; // 0x30
|
||||
char content_id[0x30]; // 0x50
|
||||
uint8_t unk5[0x80]; // 0x80
|
||||
uint8_t key[0x200]; // 0x100
|
||||
uint8_t sha256digest[0x100]; // 0x300
|
||||
} ScePsmDrmLicense;
|
||||
|
||||
|
||||
int patch_libdefault(void* handle);
|
||||
|
|
Loading…
Reference in New Issue