diff --git a/Makefile b/Makefile index dfcf6d4..7d5cfd3 100644 --- a/Makefile +++ b/Makefile @@ -14,12 +14,15 @@ all: $(TARGET).vpk %.vpk: eboot.bin vita-mksfoex -s TITLE_ID=$(TITLE_ID) "iTLS-Enso" param.sfo vita-pack-vpk -s param.sfo -b eboot.bin \ + -a sce_sys/icon0.png=sce_sys/icon0.png \ -a sce_sys/livearea/contents/bg.png=sce_sys/livearea/contents/bg.png \ -a sce_sys/livearea/contents/template.xml=sce_sys/livearea/contents/template.xml \ -a kernel/itls.skprx=kernel.skprx \ + -a old_dns_fix/old_dns_fix.suprx=dnsfix.suprx \ -a misc/compat.suprx=compat.suprx \ -a misc/lhttp.suprx=lhttp.suprx \ -a misc/lssl.suprx=lssl.suprx \ + -a misc/comm2.suprx=comm2.suprx \ -a misc/certs.cer=certs.cer \$@ eboot.bin: $(TARGET).velf diff --git a/README.md b/README.md index cb7e926..f3f3ee9 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ Adds TLS v1.2 to devices with enso installed. # How-To - 1) Install the provided VPK file. 2) Start the app, select "Install the full iTLS package" and wait til it finishes. @@ -10,24 +9,25 @@ Adds TLS v1.2 to devices with enso installed. 3) Reboot. -# Credits - -Thanks to: -- Team Molecule -- Testers from the HenKaku discord server - # FAQ - - Can I use it without enso? - - Yes for browser-only patch, but it is strongly recommended to use enso. + - Yes for the browser patch only. - Where can I find the CA certs? - vs0:/data/external/cert/CA_LIST.cer -- How can I update the tool? - - Uninstall via the previous installer, install via the new one. # Notes -- Since version 3.0 iTLS also patches apps-side TLS stuff. +- Since version 3.0 iTLS also patches app-side TLS stuff. +- Since version 3.2 iTLS also patches the NP server link on firmware 3.60. - Updating CA certs may fix some problems with web sites, apps (like netflix), etc. - For any help/serious issue DM me on twitter (twitter.com/skgleba) +### Donation +- Via [ko-fi](https://ko-fi.com/skgleba), thanks! + +# Credits +Thanks to: +- Team Molecule +- Testers from the HenKaku discord server +- Cuevavirus for the 3.60 np server fix + ## CURRENT MODULES ORIGIN FW: 3.73 diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt index fa64fba..5943cb8 100644 --- a/kernel/CMakeLists.txt +++ b/kernel/CMakeLists.txt @@ -28,6 +28,9 @@ target_link_libraries(itls.elf taihenForKernel_stub SceSysmemForDriver_stub SceIofilemgrForDriver_stub + SceDebugForDriver_stub + SceModulemgrForDriver_stub + SceSysrootForDriver_stub ) set_target_properties(itls.elf diff --git a/kernel/main.c b/kernel/main.c index 880fb4c..3351926 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -1,5 +1,5 @@ /* - iTLS-Enso v3.1 by SKGleba + iTLS-Enso v3.2 by SKGleba All Rights Reserved */ @@ -9,72 +9,62 @@ #include #include -#define INJECT(name, off, data, sz) \ -do { \ - uintptr_t addr; \ - tai_module_info_t info; \ - info.size = sizeof(info); \ - if (module_get_by_name_nid(KERNEL_PID, name, TAI_IGNORE_MODULE_NID, &info) >= 0) { \ - module_get_offset(KERNEL_PID, info.modid, 0, off, &addr); \ - ksceKernelCpuUnrestrictedMemcpy((void *)addr, (void *)data, sz); \ - } \ -} while (0) +const char* new_modules[5] = { "vs0:/data/external/itls/ScePsp2Compat.suprx" , "vs0:/data/external/itls/libhttp.suprx" , "vs0:/data/external/itls/libssl.suprx", "vs0:/data/external/itls/old_dns_fix.suprx", "vs0:/data/external/itls/np_commerce2.suprx" }; +static char replace[5] = {0, 0, 0, 0, 0}; +static char replace_iap = 0, replace_comm2 = 0; -int ex(char *path) { +int add_replace_flags(void) { SceIoStat stat; - int stat_ret = ksceIoGetstat(path, &stat); - if (stat_ret < 0) - return 0; - return 1; + for(int i = 0; i < 5; i-=-1) { + if (ksceIoGetstat(new_modules[i], &stat) >= 0) + replace[i] = 1; + } + replace_iap = replace[1] & replace[2]; + replace_comm2 = replace[3] & replace[4]; + replace_comm2 -=- replace_comm2; + return replace[0] + replace_iap + replace_comm2; } - -uint8_t pmode = 0; -static char path_k[0x80]; -static int hk; -static tai_hook_ref_t lum_hook; -static SceUID lum_patch(char *path, SceSize args, void *argp, int flags, SceKernelLMOption *option, int *status) { - int state; - ENTER_SYSCALL(state); - int pathlen = ksceKernelStrnlenUser((uintptr_t)path, 0x80); - if (pathlen < 0x80) { - ksceKernelMemcpyUserToKernel(path_k, (uintptr_t)path, pathlen); - if (path_k[pathlen - 14] == 0x70 && path_k[pathlen - 13] == 0x32 && path_k[pathlen - 12] == 0x43) { - path_k[pathlen - 1] = 0x30; - ksceKernelMemcpyKernelToUser((uintptr_t)path, path_k, pathlen); - } + +static int hk = 0; +static tai_hook_ref_t lfp_hook; +// load module for pid (0 to get), running in kernel context, path is in kernel +static SceUID load_for_pid_patched(int pid, const char *path, uint32_t flags, int *ptr_to_four) { + int len = strnlen(path, 0x400); + if (len > 0 && len < 0x400) { + if (replace_iap && strncmp(path, "vs0:sys/external/libhttp.suprx", 30) == 0) + path = new_modules[1]; + else if (replace_iap && strncmp(path, "vs0:sys/external/libssl.suprx", 29) == 0) + path = new_modules[2]; + else if (replace[0] && strncmp(path + len - 27, "webcore/ScePsp2Compat.suprx", 27) == 0) + strncpy((char *)(path + len - 27), new_modules[0] + 19, 25); + else if (replace_comm2 && strncmp(path, "vs0:sys/external/np_commerce2.suprx", 35) == 0) + path = new_modules[4]; + }; + int res = TAI_CONTINUE(SceUID, lfp_hook, pid, path, flags, ptr_to_four); + if (replace_comm2 == 2 && path == new_modules[2] && pid == ksceKernelSysrootGetShellPid()) { // 3.60 dns fix + ksceKernelLoadStartModuleForPid(pid, new_modules[3], 0, NULL, 0, NULL, NULL); + replace_comm2 = 1; } - EXIT_SYSCALL(state); - SceUID ret = TAI_CONTINUE(SceUID, lum_hook, path, args, argp, flags, option, status); - return ret; + return res; } void _start() __attribute__ ((weak, alias ("module_start"))); int module_start(SceSize argc, const void *args) { - char zero[1] = {0x30}; - if (ex("vs0:/sys/external/libhttp.supr0") == 1) { - INJECT("SceSysmodule", 0x162c, zero, sizeof(zero)); - INJECT("SceSysmodule", 0x163b, zero, sizeof(zero)); - pmode = 1; - } - if (ex("vs0:/data/external/webcore/ScePsp2Compat.supr0") == 1) { - hk = taiHookFunctionExportForKernel(KERNEL_PID, &lum_hook, "SceKernelModulemgr", TAI_ANY_LIBRARY, 0x60647592, lum_patch); - pmode = pmode + 0x10; + ksceDebugPrintf("itls module loaded\n"); + if (add_replace_flags() > 0) { + int modid = ksceKernelSearchModuleByName("SceKernelModulemgr"); + if (modid > 0) + hk = taiHookFunctionOffsetForKernel(KERNEL_PID, &lfp_hook, modid, 0, 0x21ec, 1, load_for_pid_patched); + if (modid < 0 || hk < 0) + return SCE_KERNEL_START_FAILED; } return SCE_KERNEL_START_SUCCESS; } int module_stop(SceSize argc, const void *args) { - if (pmode >= 0x10) { - if (hk >= 0) - taiHookReleaseForKernel(hk, lum_hook); - pmode = pmode - 0x10; - } - char x[1] = {0x7A}; - if (pmode == 1) { - INJECT("SceSysmodule", 0x162c, x, sizeof(x)); - INJECT("SceSysmodule", 0x163b, x, sizeof(x)); - } + if (hk >= 0) + taiHookReleaseForKernel(hk, lfp_hook); return SCE_KERNEL_STOP_SUCCESS; } diff --git a/main.c b/main.c index 229d991..f3ca2fd 100644 --- a/main.c +++ b/main.c @@ -1,5 +1,5 @@ /* - iTLS-Enso v3.1 by SKGleba + iTLS-Enso v3.2 by SKGleba All Rights Reserved */ @@ -11,10 +11,12 @@ #include #include #include +#include #include "graphics.h" #define printf psvDebugScreenPrintf +const char* new_modules[5] = { "vs0:/data/external/itls/ScePsp2Compat.suprx" , "vs0:/data/external/itls/libhttp.suprx" , "vs0:/data/external/itls/libssl.suprx", "vs0:/data/external/itls/old_dns_fix.suprx", "vs0:/data/external/itls/np_commerce2.suprx" }; char mmit[][512] = {" -> Install the full iTLS package"," -> Install the iTLS plugin"," -> Install the iTLS compat module (web-browser)"," -> Install the iTLS http & ssl modules (in-app)"," -> Install the iTLS CA certs"," -> Exit"}; char mmut[][512] = {" -> Uninstall the full iTLS package"," -> Uninstall the iTLS plugin"," -> Uninstall the iTLS compat module (web-browser)"," -> Uninstall the iTLS http & ssl modules (in-app)"," -> Uninstall the iTLS CA certs"," -> Exit"}; @@ -69,7 +71,7 @@ int fcp(const char *from, const char *to) { void smenu(){ psvDebugScreenClear(COLOR_BLACK); psvDebugScreenSetFgColor(COLOR_CYAN); - printf(" iTLS-Enso 3.1 \n"); + printf(" iTLS-Enso 3.2 \n"); printf(" By SKGleba \n"); psvDebugScreenSetFgColor(COLOR_RED); for(i = 0; i < optct; i++){ @@ -82,63 +84,100 @@ void smenu(){ psvDebugScreenSetFgColor(COLOR_GREEN); } +void installPluginC() { + long psz; + FILE* fp = fopen("ur0:tai/config.txt", "rb"); + fseek(fp, 0, SEEK_END); + psz = ftell(fp); + rewind(fp); + char* pbf = (char*)malloc(sizeof(char) * psz); + fread(pbf, sizeof(char), (size_t)psz, fp); + fclose(fp); + sceIoRename("ur0:tai/config.txt", "ur0:tai/config_preitls.txt"); + + FILE* pFile = fopen("ur0:tai/config.txt", "wb"); + char* pkx = strstr(pbf, "# ITLS\n"); + char* pzx = strstr(pbf, "ur0:tai/itls.skprx\n"); + if (!pkx || !pzx) { + const char* patch1 = + "# ITLS\n*KERNEL\nur0:tai/itls.skprx\n\n"; + fwrite(patch1, 1, strlen(patch1), pFile); + } + + fwrite(pbf, 1, psz, pFile); + fclose(pFile); + free(pbf); +} + void installPlugin(int ior) { if (cfg[1] == ior || ior == 69) { - if (cfg[1] == 1) { + if (cfg[1]) { printf("Removing the iTLS plugin... \n"); riex("ur0:tai/itls.skprx"); - if (ex("ur0:tai/config_preitls.txt") == 1) { - sceIoRemove("ur0:tai/config.txt"); - sceIoRename("ur0:tai/config_preitls.txt", "ur0:tai/config.txt"); - } } else { printf("Installing the iTLS plugin... \n"); fcp("app0:kernel.skprx", "ur0:tai/itls.skprx"); - if (ex("ux0:tai/config.txt") == 1 && ex("ux0:tai/config_preitls.txt") == 0) - sceIoRename("ux0:tai/config.txt", "ux0:tai/config_preitls.txt"); - SceUID fd = sceIoOpen("ur0:tai/config_temp.txt", SCE_O_WRONLY | SCE_O_TRUNC | SCE_O_CREAT, 6); - sceIoWrite(fd, (void *)"\n# ITLS\n*KERNEL\nur0:tai/itls.skprx\n", strlen("\n# ITLS\n*KERNEL\nur0:tai/itls.skprx\n")); - sceIoClose(fd); - fcp("ur0:tai/config.txt", "ur0:tai/config_preitls.txt"); - fap("ur0:tai/config_temp.txt", "ur0:tai/config.txt"); - sceIoRemove("ur0:tai/config_temp.txt"); + riex("ux0:tai/config_preitls.txt"); + installPluginC(); } } } void installCompat(int ior) { + riex("vs0:/data/external/webcore/ScePsp2Compat.supr0"); if (cfg[2] == ior || ior == 69) { - if (cfg[2] == 1) { + if (cfg[2]) { printf("Removing the iTLS compat module... \n"); - riex("vs0:/data/external/webcore/ScePsp2Compat.supr0"); + riex("vs0:/data/external/itls/ScePsp2Compat.suprx"); } else { printf("Installing the iTLS compat module... \n"); - fcp("app0:compat.suprx", "vs0:/data/external/webcore/ScePsp2Compat.supr0"); + fcp("app0:compat.suprx", "vs0:/data/external/itls/ScePsp2Compat.suprx"); + } + } +} + +void installDnsFix(int ior) { + if (cfg[3] == ior || ior == 69) { + if (cfg[3]) { + printf("Installing the 3.60 DNS fix... \n"); + riex("vs0:/data/external/itls/old_dns_fix.suprx"); + riex("vs0:/data/external/itls/np_commerce2.suprx"); + } else { + printf("Removing the 3.60 DNS fix... \n"); + fcp("app0:dnsfix.suprx", "vs0:/data/external/itls/old_dns_fix.suprx"); + fcp("app0:comm2.suprx", "vs0:/data/external/itls/np_commerce2.suprx"); } } } void installIapp(int ior) { + riex("vs0:sys/external/libhttp.supr0"); + SceKernelFwInfo fwinfo; + fwinfo.size = sizeof(SceKernelFwInfo); + _vshSblGetSystemSwVersion(&fwinfo); if (cfg[3] == ior || ior == 69) { - if (cfg[3] == 1) { + if (cfg[3]) { printf("Removing the iTLS http & ssl modules... \n"); - riex("vs0:/sys/external/libhttp.supr0"); - riex("vs0:/sys/external/libssl.supr0"); + riex("vs0:/data/external/itls/libhttp.suprx"); + riex("vs0:/data/external/itls/libssl.suprx"); + if (fwinfo.version == 0x03600000) + installDnsFix(ior); } else { printf("Installing the iTLS http & ssl modules... \n"); - fcp("app0:lhttp.suprx", "vs0:/sys/external/libhttp.supr0"); - fcp("app0:lssl.suprx", "vs0:/sys/external/libssl.supr0"); + fcp("app0:lhttp.suprx", "vs0:/data/external/itls/libhttp.suprx"); + fcp("app0:lssl.suprx", "vs0:/data/external/itls/libssl.suprx"); + if (fwinfo.version == 0x03600000) + installDnsFix(ior); } } } void installCerts(int ior) { if (cfg[4] == ior || ior == 69) { - if (cfg[4] == 1) { + if (cfg[4]) { printf("Removing iTLS CA certs... \n"); riex("vs0:/data/external/cert/CA_LIST.cer"); sceIoRename("vs0:/data/external/cert/CA_LIST.cer_old", "vs0:/data/external/cert/CA_LIST.cer"); - riex("vs0:/data/external/cert/CA_LIST.cer_old"); } else { printf("Adding iTLS CA certs... \n"); sceIoRename("vs0:/data/external/cert/CA_LIST.cer", "vs0:/data/external/cert/CA_LIST.cer_old"); @@ -155,31 +194,38 @@ int work(){ vshIoUmount(0x300, 1, 0, 0); _vshIoMount(0x300, 0, 2, buf); printf("Working...\n"); - if (sel == 0) { - if (cfg[0] == 0) { - printf("Installing iTLS... \n"); - installPlugin(0); - installCompat(0); - installIapp(0); - installCerts(0); - } else { - printf("Uninstalling iTLS... \n"); - installPlugin(1); - installCompat(1); - installIapp(1); - installCerts(1); - } - } else if (sel == 1) { - installPlugin(69); - } else if (sel == 2) { - installCompat(69); - } else if (sel == 3) { - installIapp(69); - } else if (sel == 4) { - installCerts(69); + switch(sel) { + case 0: + if (cfg[0] == 0) { + printf("Installing iTLS... \n"); + installPlugin(0); + installCompat(0); + installIapp(0); + installCerts(0); + } else { + printf("Uninstalling iTLS... \n"); + installPlugin(1); + installCompat(1); + installIapp(1); + installCerts(1); + } + break; + case 1: + installPlugin(69); + break; + case 2: + installCompat(69); + break; + case 3: + installIapp(69); + break; + case 4: + installCerts(69); + break; } - printf("Done, please reboot the device\n"); - sceKernelDelayThread(5 * 1000 * 1000); + printf("Done, rebooting in 3 seconds\n"); + sceKernelDelayThread(3 * 1000 * 1000); + vshPowerRequestColdReset(); sceKernelExitProcess(0); return 0; } @@ -195,17 +241,13 @@ int main() if (ex("ur0:tai/itls.suprx") == 1) sceIoRemove("ur0:tai/itls.suprx"); - if (ex("ur0:tai/itls.skprx") == 1) - cfg[1] = 1; - if (ex("vs0:/data/external/webcore/ScePsp2Compat.supr0") == 1) - cfg[2] = 1; - if (ex("vs0:/sys/external/libhttp.supr0") == 1) - cfg[3] = 1; - if (ex("vs0:/data/external/cert/CA_LIST.cer_old") == 1) - cfg[4] = 1; - - if (cfg[1] == 1 && cfg[2] == 1 && cfg[3] == 1 && cfg[4] == 1) - cfg[0] = 1; + if (!ex("vs0:sys/external/libhttp.supr0") && !ex("vs0:/data/external/webcore/ScePsp2Compat.supr0")) { + cfg[1] = ex("ur0:tai/itls.skprx"); + cfg[2] = ex(new_modules[0]); + cfg[3] = ex(new_modules[1]); + cfg[4] = ex("vs0:/data/external/cert/CA_LIST.cer_old"); + cfg[0] = cfg[1] & cfg[2] & cfg[3] & cfg[4]; + } smenu(); diff --git a/misc/comm2.suprx b/misc/comm2.suprx new file mode 100644 index 0000000..b61cd30 Binary files /dev/null and b/misc/comm2.suprx differ diff --git a/old_dns_fix/CMakeLists.txt b/old_dns_fix/CMakeLists.txt new file mode 100644 index 0000000..0568d08 --- /dev/null +++ b/old_dns_fix/CMakeLists.txt @@ -0,0 +1,28 @@ +cmake_minimum_required(VERSION 2.8) + +if(NOT DEFINED CMAKE_TOOLCHAIN_FILE) + if(DEFINED ENV{VITASDK}) + set(CMAKE_TOOLCHAIN_FILE "$ENV{VITASDK}/share/vita.toolchain.cmake" CACHE PATH "toolchain file") + else() + message(FATAL_ERROR "Please define VITASDK to point to your SDK path!") + endif() +endif() + +project(itlsfix) +include("${VITASDK}/share/vita.cmake" REQUIRED) + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-q -Wall -O3 -nostdlib") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions") + +add_executable(itlsfix + main.c +) + +target_link_libraries(itlsfix + SceIofilemgr_stub + SceLibKernel_stub + taihen_stub + SceKernelThreadMgr_stub +) + +vita_create_self(old_dns_fix.suprx itlsfix CONFIG exports.yml UNSAFE) diff --git a/old_dns_fix/exports.yml b/old_dns_fix/exports.yml new file mode 100644 index 0000000..103df42 --- /dev/null +++ b/old_dns_fix/exports.yml @@ -0,0 +1,8 @@ +itlsfix: + attributes: 0 + version: + major: 1 + minor: 0 + main: + start: module_start + stop: module_stop diff --git a/old_dns_fix/main.c b/old_dns_fix/main.c new file mode 100644 index 0000000..ed8cb14 --- /dev/null +++ b/old_dns_fix/main.c @@ -0,0 +1,35 @@ +/* + iTLS-Enso v3.2 by SKGleba + All Rights Reserved +*/ + +#include +#include +#include +#include + +#include + +static SceUID httpConnHookID; +static tai_hook_ref_t httpConnHookRef; + +static int httpConnPatched(int tmplId, const char* serverName, const char* scheme, unsigned short port, int enableKeepalive) { + if (sceClibStrncmp("native.np.ac.playstation.net", serverName, 29) == 0) + serverName = "native-vita.np.ac.playstation.net"; + return TAI_CONTINUE(int, httpConnHookRef, tmplId, serverName, scheme, port, enableKeepalive); +} + +void _start() __attribute__((weak, alias("module_start"))); +int module_start(SceSize args, void* argp) { + tai_module_info_t info; + info.size = sizeof(info); + if (taiGetModuleInfo("SceShell", &info) >= 0) + httpConnHookID = taiHookFunctionImport(&httpConnHookRef, "SceShell", 0xE8F15CDE, 0xAEB3307E, httpConnPatched); + return SCE_KERNEL_START_SUCCESS; +} + +int module_stop(SceSize args, void* argp) { + if (httpConnHookID >= 0) + taiHookRelease(httpConnHookID, httpConnHookRef); + return SCE_KERNEL_STOP_SUCCESS; +} diff --git a/sce_sys/icon0.png b/sce_sys/icon0.png new file mode 100644 index 0000000..76cd956 Binary files /dev/null and b/sce_sys/icon0.png differ