├── .github └── workflows │ └── master.yml ├── Dockerfile ├── Makefile ├── README.md └── source ├── crt.c ├── crt0.s └── main.cpp /.github/workflows/master.yml: -------------------------------------------------------------------------------- 1 | name: build 2 | 3 | on: 4 | push: 5 | branch: 6 | - master 7 | 8 | jobs: 9 | build-binary: 10 | name: Build binary 11 | runs-on: ubuntu-20.04 12 | steps: 13 | - name: Checkout 14 | uses: actions/checkout@v3 15 | with: 16 | fetch-depth: 0 17 | - name: Build artifacts 18 | run: | 19 | docker build . -t builder 20 | docker run --rm -v ${PWD}:/project builder make 21 | id: version 22 | - name: Upload Artifact 23 | uses: actions/upload-artifact@v3 24 | with: 25 | name: 01_sigpatches 26 | path: 01_sigpatches.rpx 27 | if-no-files-found: warn 28 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM wiiuenv/devkitppc:20221228 AS final 2 | ENV PATH=$DEVKITPPC/bin:$PATH \ 3 | WUT_ROOT=$DEVKITPRO/wut 4 | COPY --from=wiiuenv/libmocha:20220919112600f3c45c /artifacts $DEVKITPRO 5 | WORKDIR /project 6 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------- 2 | .SUFFIXES: 3 | #------------------------------------------------------------------------------- 4 | 5 | ifeq ($(strip $(DEVKITPRO)),) 6 | $(error "Please set DEVKITPRO in your environment. export DEVKITPRO=/devkitpro") 7 | endif 8 | 9 | TOPDIR ?= $(CURDIR) 10 | 11 | include $(DEVKITPRO)/wut/share/wut_rules 12 | 13 | #------------------------------------------------------------------------------- 14 | # TARGET is the name of the output 15 | # BUILD is the directory where object files & intermediate files will be placed 16 | # SOURCES is a list of directories containing source code 17 | # DATA is a list of directories containing data files 18 | # INCLUDES is a list of directories containing header files 19 | #------------------------------------------------------------------------------- 20 | TARGET := 01_sigpatches 21 | BUILD := build 22 | SOURCES := source 23 | DATA := data 24 | INCLUDES := source include 25 | 26 | #------------------------------------------------------------------------------- 27 | # options for code generation 28 | #------------------------------------------------------------------------------- 29 | CFLAGS := $(MACHDEP) -ffunction-sections -fno-exceptions \ 30 | $(INCLUDE) -D__WIIU__ -D__WUT__ 31 | 32 | ifeq ($(DEBUG),1) 33 | CFLAGS += -Og -DDEBUG -g 34 | else 35 | CFLAGS += -Ofast 36 | endif 37 | 38 | CXXFLAGS := $(CFLAGS) -std=c++20 -fno-rtti 39 | 40 | ASFLAGS := -g $(ARCH) 41 | LDFLAGS = -g $(ARCH) $(RPXSPECS) --entry=_start -Wl,-Map,$(notdir $*.map) 42 | 43 | LIBS := -lmocha -lwut 44 | 45 | #------------------------------------------------------------------------------- 46 | # list of directories containing libraries, this must be the top level 47 | # containing include and lib 48 | #------------------------------------------------------------------------------- 49 | LIBDIRS := $(PORTLIBS) $(WUT_ROOT) $(WUT_ROOT)/usr 50 | 51 | #------------------------------------------------------------------------------- 52 | # no real need to edit anything past this point unless you need to add additional 53 | # rules for different file extensions 54 | #------------------------------------------------------------------------------- 55 | ifneq ($(BUILD),$(notdir $(CURDIR))) 56 | #------------------------------------------------------------------------------- 57 | 58 | export OUTPUT := $(CURDIR)/$(TARGET) 59 | export TOPDIR := $(CURDIR) 60 | 61 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 62 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) 63 | 64 | export DEPSDIR := $(CURDIR)/$(BUILD) 65 | 66 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 67 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 68 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 69 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 70 | 71 | #------------------------------------------------------------------------------- 72 | # use CXX for linking C++ projects, CC for standard C 73 | #------------------------------------------------------------------------------- 74 | ifeq ($(strip $(CPPFILES)),) 75 | #------------------------------------------------------------------------------- 76 | export LD := $(CC) 77 | #------------------------------------------------------------------------------- 78 | else 79 | #------------------------------------------------------------------------------- 80 | export LD := $(CXX) 81 | #------------------------------------------------------------------------------- 82 | endif 83 | #------------------------------------------------------------------------------- 84 | 85 | export OFILES_BIN := $(addsuffix .o,$(BINFILES)) 86 | export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 87 | export OFILES := $(OFILES_BIN) $(OFILES_SRC) 88 | export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES))) 89 | 90 | export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ 91 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 92 | -I$(CURDIR)/$(BUILD) 93 | 94 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 95 | 96 | .PHONY: $(BUILD) clean all 97 | 98 | #------------------------------------------------------------------------------- 99 | all: $(BUILD) 100 | 101 | $(BUILD): 102 | @[ -d $@ ] || mkdir -p $@ 103 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 104 | 105 | #------------------------------------------------------------------------------- 106 | clean: 107 | @echo clean ... 108 | @rm -fr $(BUILD) $(TARGET).rpx $(TARGET).elf 109 | 110 | #------------------------------------------------------------------------------- 111 | else 112 | .PHONY: all 113 | 114 | DEPENDS := $(OFILES:.o=.d) 115 | 116 | #------------------------------------------------------------------------------- 117 | # main targets 118 | #------------------------------------------------------------------------------- 119 | 120 | all : $(OUTPUT).rpx 121 | 122 | $(OUTPUT).rpx : $(OUTPUT).elf 123 | $(OUTPUT).elf : $(OFILES) 124 | $(OFILES) : 125 | 126 | $(OFILES_SRC) : $(HFILES_BIN) 127 | 128 | #------------------------------------------------------------------------------- 129 | # you need a rule like this for each extension you use as binary data 130 | #------------------------------------------------------------------------------- 131 | %.png.o %_png.h : %.png 132 | #------------------------------------------------------------------------------- 133 | @echo $(notdir $<) 134 | @$(bin2o) 135 | 136 | #------------------------------------------------------------------------------- 137 | endif 138 | #------------------------------------------------------------------------------- 139 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SigpatchesModuleWiiU 2 | 3 | This is a module meant to be executed via the [EnvironmentLoader](https://github.com/wiiu-env/EnvironmentLoader), for example, using the [Tiramisu Environment](https://github.com/wiiu-env/Tiramisu), on the Wii U. 4 | 5 | This module implements signature check patches originally found in the [Mocha CFW](https://github.com/dimok789/mocha). 6 | -------------------------------------------------------------------------------- /source/crt.c: -------------------------------------------------------------------------------- 1 | void __init_wut_malloc(); 2 | 3 | void __init_wut_newlib(); 4 | 5 | void __init_wut_stdcpp(); 6 | 7 | void __init_wut_devoptab(); 8 | 9 | void __attribute__((weak)) __init_wut_socket(); 10 | 11 | void __fini_wut_malloc(); 12 | 13 | void __fini_wut_newlib(); 14 | 15 | void __fini_wut_stdcpp(); 16 | 17 | void __fini_wut_devoptab(); 18 | 19 | void __fini(); 20 | 21 | void __attribute__((weak)) __fini_wut_socket(); 22 | 23 | void __attribute__((weak)) 24 | __init_wut_() { 25 | __init_wut_malloc(); 26 | __init_wut_newlib(); 27 | __init_wut_stdcpp(); 28 | __init_wut_devoptab(); 29 | if (&__init_wut_socket) __init_wut_socket(); 30 | } 31 | 32 | void __attribute__((weak)) 33 | __fini_wut_() { 34 | __fini(); 35 | __fini_wut_devoptab(); 36 | __fini_wut_stdcpp(); 37 | __fini_wut_newlib(); 38 | __fini_wut_malloc(); 39 | } 40 | -------------------------------------------------------------------------------- /source/crt0.s: -------------------------------------------------------------------------------- 1 | .extern main 2 | .extern exit 3 | .extern __init_wut_ 4 | .extern __fini_wut_ 5 | 6 | .global _start 7 | _start: 8 | stwu 1, -0x28(1) 9 | mflr 0 10 | stw 0, 0x2C(1) 11 | stw 31, 0x24(1) 12 | or 31, 1, 1 13 | stw 3, 0x18(31) 14 | stw 4, 0x1C(31) 15 | bl __init_wut_ 16 | lwz 4, 0x1C(31) 17 | lwz 3, 0x18(31) 18 | bl main 19 | or 9, 3, 3 20 | stw 9, 0x8(31) 21 | bl __fini_wut_ 22 | lwz 9, 0x8(31) 23 | or 3, 9, 9 24 | addi 11, 31, 0x28 25 | lwz 0, 0x4(11) 26 | mtlr 0 27 | lwz 31, -0x4(11) 28 | or 1, 11, 11 29 | blr -------------------------------------------------------------------------------- /source/main.cpp: -------------------------------------------------------------------------------- 1 | /* This module assumes the IOSUHAX exploit to have been performed (e.g., 00_mocha.rpx has been executed before this module). 2 | 3 | This module implements the following patches from the original Mocha CFW: 4 | 5 | .arm 6 | 7 | patch_MCP_authentication_check: 8 | .thumb 9 | mov r0, #0 10 | bx lr 11 | 12 | patch_IOSC_VerifyPubkeySign: 13 | patch_cert_verification: 14 | patch_cached_cert_check: 15 | .arm 16 | mov r0, #0 17 | bx lr 18 | 19 | 20 | .globl mcp_patches_table, mcp_patches_table_end 21 | mcp_patches_table: 22 | # origin data size 23 | .word 0x05014CAC, patch_MCP_authentication_check, 4 24 | .word 0x05052C44, patch_IOSC_VerifyPubkeySign, 8 25 | .word 0x05052A90, patch_cert_verification, 8 26 | .word 0x05054D6C, patch_cached_cert_check, 8 27 | mcp_patches_table_end: 28 | */ 29 | 30 | 31 | #include 32 | 33 | #define VALUE_A 0xe3a00000 // mov r0, #0 34 | #define VALUE_B 0xe12fff1e // bx lr 35 | #define VALUE_C 0x20004770 // mov r0, #0; bx lr 36 | 37 | int main(int argc, char **argv) 38 | { 39 | if (Mocha_InitLibrary() == MOCHA_RESULT_SUCCESS) { 40 | Mocha_IOSUKernelWrite32(0x5014cac, VALUE_C); // patch_MCP_authentication_check 41 | Mocha_IOSUKernelWrite32(0x5052c44, VALUE_A); // patch_IOSC_VerifyPubkeySign - first u32 42 | Mocha_IOSUKernelWrite32(0x5052c48, VALUE_B); // patch_IOSC_VerifyPubkeySign - second u32 43 | Mocha_IOSUKernelWrite32(0x5052a90, VALUE_A); // patch_cert_verification - first u32 44 | Mocha_IOSUKernelWrite32(0x5052a94, VALUE_B); // patch_cert_verification - second u32 45 | Mocha_IOSUKernelWrite32(0x5054d6c, VALUE_A); // patch_cached_cert_check - first u32 46 | Mocha_IOSUKernelWrite32(0x5054d70, VALUE_B); // patch_cached_cert_check - second u32 47 | Mocha_DeInitLibrary(); 48 | } 49 | 50 | return 0; 51 | } 52 | 53 | --------------------------------------------------------------------------------