Add IOSU-side SSL and URL patches

This commit is contained in:
Ash Logan 2022-08-31 22:07:57 +10:00
parent d23f774f7b
commit 24a17536fc
6 changed files with 132 additions and 22 deletions

View File

@ -1,6 +1,7 @@
FROM wiiuenv/devkitppc:20220806
COPY --from=wiiuenv/libkernel:20220724 /artifacts $DEVKITPRO
COPY --from=wiiuenv/libmocha:20220831 /artifacts $DEVKITPRO
COPY --from=wiiuenv/wiiupluginsystem:20220826 /artifacts $DEVKITPRO
WORKDIR /app

Binary file not shown.

View File

@ -40,13 +40,13 @@ LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map)
LDFLAGS += -T$(WUMS_ROOT)/share/libkernel.ld $(WUPSSPECS)
LIBS := -lwups -lkernel -lwut
LIBS := -lwups -lmocha -lkernel -lwut
#-------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level
# containing include and lib
#-------------------------------------------------------------------------------
LIBDIRS := $(PORTLIBS) $(WUMS_ROOT) $(WUPS_ROOT) $(WUT_ROOT)
LIBDIRS := $(PORTLIBS) $(WUMS_ROOT) $(WUPS_ROOT) $(WUT_ROOT) $(WUT_ROOT)/usr
#-------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional

View File

@ -19,10 +19,13 @@
#include <nsysnet/nssl.h>
#include <coreinit/cache.h>
#include <coreinit/dynload.h>
#include <coreinit/mcp.h>
#include <coreinit/memory.h>
#include <coreinit/memorymap.h>
#include <coreinit/memexpheap.h>
#include "wut_extra.h"
#include <utils/logger.h>
#include "url_patches.h"
/**
Mandatory plugin information.
@ -35,6 +38,7 @@ WUPS_PLUGIN_AUTHOR("Pretendo contributors");
WUPS_PLUGIN_LICENSE("ISC");
#include <kernel/kernel.h>
#include <mocha/mocha.h>
//#ifdef OLD_WUPS
extern "C" {
@ -52,14 +56,72 @@ _Static_assert(sizeof(original_url) > sizeof(new_url),
// We'll keep a handle to nn_olv, just to ensure it doesn't get unloaded
static OSDynLoad_Module olv_handle;
#ifndef OLD_WUPS
//thanks @Gary#4139 :p
static void write_string(uint32_t addr, const char* str)
{
int len = strlen(str) + 1;
int remaining = len % 4;
int num = len - remaining;
for (int i = 0; i < (num / 4); i++) {
Mocha_IOSUKernelWrite32(addr + i * 4, *(uint32_t*)(str + i * 4));
}
if (remaining > 0) {
uint8_t buf[4];
Mocha_IOSUKernelRead32(addr + num, (uint32_t*)&buf);
for (int i = 0; i < remaining; i++) {
buf[i] = *(str + num + i);
}
Mocha_IOSUKernelWrite32(addr + num, *(uint32_t*)&buf);
}
}
static bool is555(MCP_SystemVersion version) {
return (version.major == 5) && (version.minor == 5) && (version.patch >= 5);
}
INITIALIZE_PLUGIN() {
WHBLogUdpInit();
auto res = Mocha_InitLibrary();
if (res != MOCHA_RESULT_SUCCESS) {
DEBUG_FUNCTION_LINE("Mocha init failed with code %d!", res);
return;
}
//get os version
MCP_SystemVersion os_version;
int mcp = MCP_Open();
int ret = MCP_GetSystemVersion(mcp, &os_version);
if (ret < 0) {
DEBUG_FUNCTION_LINE("getting system version failed (%d/%d)!", mcp, ret);
os_version = (MCP_SystemVersion) {
.major = 5, .minor = 5, .patch = 5, .region = 'E'
};
}
DEBUG_FUNCTION_LINE("Running on %d.%d.%d%c",
os_version.major, os_version.minor, os_version.patch, os_version.region
);
if (is555(os_version)) {
Mocha_IOSUKernelWrite32(0xE1019F78, 0xE3A00001); // mov r0, #1
} else {
Mocha_IOSUKernelWrite32(0xE1019E84, 0xE3A00001); // mov r0, #1
}
for (const auto& patch : url_patches) {
write_string(patch.address, patch.url);
}
DEBUG_FUNCTION_LINE("Pretendo URL and NoSSL patches applied successfully.")
}
DEINITIALIZE_PLUGIN() {
WHBLogUdpDeinit();
Mocha_DeinitLibrary();
}
#endif
bool checkForOlvLibs() {
OSDynLoad_Module olv_handle = 0;
@ -121,21 +183,3 @@ ON_APPLICATION_ENDS() {
DEBUG_FUNCTION_LINE("Inkay: shutting down...\n");
OSDynLoad_Release(olv_handle);
}
DECL_FUNCTION(NSSLContextHandle, NSSLCreateContext, int32_t unk) {
NSSLContextHandle context = real_NSSLCreateContext(unk);
//Add all commercial certs
for (int cert = NSSL_SERVER_CERT_GROUP_COMMERCIAL_FIRST;
cert <= NSSL_SERVER_CERT_GROUP_COMMERCIAL_LAST; cert++) {
NSSLAddServerPKI(context, (NSSLServerCertId)cert);
}
for (int cert = NSSL_SERVER_CERT_GROUP_COMMERCIAL_4096_FIRST;
cert <= NSSL_SERVER_CERT_GROUP_COMMERCIAL_4096_LAST; cert++) {
NSSLAddServerPKI(context, (NSSLServerCertId)cert);
}
return context;
}
WUPS_MUST_REPLACE(NSSLCreateContext, WUPS_LOADER_LIBRARY_NSYSNET, NSSLCreateContext);

44
src/url_patches.h Normal file
View File

@ -0,0 +1,44 @@
#ifndef _PATCHER_H
#define _PATCHER_H
typedef struct URL_Patch
{
unsigned int address;
char url[80];
} URL_Patch;
static const URL_Patch url_patches[] = {
//nim-boss .rodata
{0xE2282550, "http://pushmore.wup.shop.pretendo.cc/pushmore/r/%s"},
{0xE229A0A0, "http://npns-dev.c.app.pretendo.cc/bst.dat"},
{0xE229A0D0, "http://npns-dev.c.app.pretendo.cc/bst2.dat"},
{0xE2281964, "https://tagaya.wup.shop.pretendo.cc/tagaya/versionlist/%s/%s/%s"},
{0xE22819B4, "https://tagaya.wup.shop.pretendo.cc/tagaya/versionlist/%s/%s/latest_version"},
{0xE2282584, "http://pushmo.wup.shop.pretendo.cc/pushmo/d/%s/%u"},
{0xE22825B8, "http://pushmo.wup.shop.pretendo.cc/pushmo/c/%u/%u"},
{0xE2282DB4, "https://ecs.wup.shop.pretendo.cc/ecs/services/ECommerceSOAP"},
{0xE22830A0, "https://ecs.wup.shop.pretendo.cc/ecs/services/ECommerceSOAP"},
{0xE22830E0, "https://nus.wup.shop.pretendo.cc/nus/services/NetUpdateSOAP"},
{0xE2299990, "nppl.app.pretendo.cc"},
{0xE229A600, "https://pls.wup.shop.pretendo.cc/pls/upload"},
{0xE229A6AC, "https://npvk-dev.app.pretendo.cc/reports"},
{0xE229A6D8, "https://npvk.app.pretendo.cc/reports"},
{0xE229B1F4, "https://npts.app.pretendo.cc/p01/tasksheet/%s/%s/%s/%s?c=%s&l=%s"},
{0xE229B238, "https://npts.app.pretendo.cc/p01/tasksheet/%s/%s/%s?c=%s&l=%s"},
{0xE22AB2D8, "https://idbe-wup.cdn.pretendo.cc/icondata/%02X/%016llX.idbe"},
{0xE22AB318, "https://idbe-ctr.cdn.pretendo.cc/icondata/%02X/%016llX.idbe"},
{0xE22AB358, "https://idbe-wup.cdn.pretendo.cc/icondata/%02X/%016llX-%d.idbe"},
{0xE22AB398, "https://idbe-ctr.cdn.pretendo.cc/icondata/%02X/%016llX-%d.idbe"},
{0xE22B3EF8, "https://ecs.c.shop.pretendo.cc"},
{0xE22B3F30, "https://ecs.c.shop.pretendo.cc/ecs/services/ECommerceSOAP"},
{0xE22B3F70, "https://ias.c.shop.pretendo.cc/ias/services/IdentityAuthenticationSOAP"},
{0xE22B3FBC, "https://cas.c.shop.pretendo.cc/cas/services/CatalogingSOAP"},
{0xE22B3FFC, "https://nus.c.shop.pretendo.cc/nus/services/NetUpdateSOAP"},
{0xE229DE0C, "n.app.pretendo.cc"},
//nim-boss .bss
{0xE24B8A24, "https://nppl.app.pretendo.cc/p01/policylist/1/1/UNK"}, //bit of a hack
{0xE31930D4, "https://%s%saccount.pretendo.cc/v%u/api/"}
};
#endif

21
src/wut_extra.h Normal file
View File

@ -0,0 +1,21 @@
#pragma once
#include <assert.h>
#ifdef __cplusplus
extern "C" {
#endif
//remove all this if wut adds it and it causes errors
typedef struct {
uint32_t major;
uint32_t minor;
uint32_t patch;
char region;
} MCP_SystemVersion;
static_assert(sizeof(MCP_SystemVersion) == 0x10);
int MCP_GetSystemVersion(int handle, MCP_SystemVersion* version);
#ifdef __cplusplus
}
#endif