Skip to content

Instantly share code, notes, and snippets.

View ZeroSkill1's full-sized avatar

ZeroSkill ZeroSkill1

  • Iraq
  • 13:07 (UTC +03:00)
View GitHub Profile
@ZeroSkill1
ZeroSkill1 / main.c
Created April 16, 2025 07:55
Handling friends sysmodule logout via NDM
#include "3ds/result.h"
#include "3ds/services/ndm.h"
#include "3ds/svc.h"
#include <3ds/services/frd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <3ds.h>
int main(int argc, char* argv[])
from pyctr.crypto.engine import CryptoEngine, Keyslot
from io import BytesIO
from typing import IO
import os
def readle(i: IO, s) -> int:
return int.from_bytes(i.read(s), 'little')
def readbe(i: IO, s) -> int:
return int.from_bytes(i.read(s), 'big')
#!/usr/bin/env python3
import sys
def ipc_getcmdid(hdr: int) -> int:
return ((hdr & ~0xFFFF) >> 16)
def ipc_get_normal_args_count(hdr: int) -> int:
return ((hdr >> 6) & 0x3F)
@ZeroSkill1
ZeroSkill1 / main.c
Last active January 11, 2025 14:42
DSP patch to signal custom handle on interrupt
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <3ds.h>
typedef struct arg {
Handle exit;
Handle interrupt;
int fire_count;
} arg;
@ZeroSkill1
ZeroSkill1 / apt_wraps.py
Created December 16, 2024 19:47
APT:Wrap/APT:Unwrap reimplementation in python
from Cryptodome.Cipher import AES
wrap_key = ... # keyslot 0x31 normalkey, obtain KeyX from boot9 and KeyY from NATIVE_FIRM, use something like pyctr to keygen
def apt_unwrap(inp: bytes, nnc_offset: int, nnc_size: int, skip_verify_nonstandard_ccm: bool = False):
unwrapped_len = len(inp) - 0x10
nnc_size &= 12
nonce = inp[0:nnc_size] + b'\x00' * (12 - nnc_size)
@ZeroSkill1
ZeroSkill1 / verify_ncch_extheader_signature.py
Created June 29, 2022 19:44
useful for assisting with achieving the recreation of a signed NCCH header, requires dumped ARM9 ITCM (obtainable via gm9 in M:/itcm.mem), extheader.bin and ncch.bin in the current working directory
from cryptography.hazmat.primitives.asymmetric.padding import PKCS1v15 as pd
from cryptography.hazmat.primitives.hashes import SHA256 as sha256
from cryptography.hazmat.primitives.asymmetric import rsa
import cryptography.hazmat.backends
with open("ncch.bin", "rb") as f:
ncch_sig = f.read(0x100)
ncch_header_data = f.read(0x100)
with open("extheader.bin", "rb") as f: