Skip to content

Instantly share code, notes, and snippets.

View SKGleba's full-sized avatar
🔔
Counting bits

Sebastian Kubala SKGleba

🔔
Counting bits
  • Warsaw
  • 06:24 (UTC +02:00)
View GitHub Profile
@SKGleba
SKGleba / sdwire.py
Last active October 14, 2024 16:06
A simple python script to control sdwire mux on Windows / Linux / MacOS
#!/usr/bin/env python3
#
# sdwire.py - SDWire control script
#
# Copyright (c) 2024 skgleba
#
# This software may be modified and distributed under the terms
# of the MIT license. See the LICENSE file for details.
#
@SKGleba
SKGleba / curling.sh
Last active May 28, 2024 07:27
Google Drive API wrapper for basic ops
# !/bin/bash
# Google Drive API wrapper
# Create a project in Google Cloud Console, enable Drive API for chosen scopes, create OAuth 2.0 credentials, save them as secret.json in the same directory as this script
# and run this script with the 'init' argument to get the refresh token
SCRIPT_DIR=$(dirname $0)
RTOKEN_FILE="$SCRIPT_DIR/rtoken.json" # Refresh token file
TTOKEN_FILE="$SCRIPT_DIR/ttoken.json" # Temporary token file
SECRET_FILE="$SCRIPT_DIR/secret.json" # Secrets
RFILES_LIST="$SCRIPT_DIR/rfiles.csv" # remote files list
@SKGleba
SKGleba / mkfakesd.c
Created November 4, 2023 20:26
create a fake bootable emmc/gcsd image for psp2 glitching
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <inttypes.h>
#include <stdint.h>
#define BLOCK_SIZE 0x200
#define ALIGN_SECTOR(s) ((s + (BLOCK_SIZE - 1)) & -BLOCK_SIZE) // align (arg) to BLOCK_SIZE
uint32_t getSz(const char* src) {
@SKGleba
SKGleba / qaf_xtractor.c
Created October 13, 2022 15:49
find, extract, etoify qaf tokens from a blob
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <inttypes.h>
#include <stdint.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <stdbool.h>
@SKGleba
SKGleba / toggle_qaf.c
Created September 3, 2022 15:39
toggle use_qaf in syscon scratchpad, persists until power loss
#include <stdio.h>
#include <string.h>
#include <psp2kern/kernel/modulemgr.h>
#include <vitasdkkern.h>
void hexdump(uint8_t* data, int size) {
for (int i = 0; i < size; i -= -1) {
if (!(i % 0x10))
ksceDebugPrintf("\n %04X: ", i);
ksceDebugPrintf("%02X ", data[i]);
@SKGleba
SKGleba / nvs_read.c
Last active August 28, 2022 18:16
gets MGMT flags, reads and decrypts S/NVS of PSP2's syscon
#include <stdio.h>
#include <string.h>
#include <psp2kern/kernel/modulemgr.h>
#include <vitasdkkern.h>
typedef struct SceSblSmCommContext130 {
uint32_t unk_0;
uint32_t self_type; // 2 - user = 1 / kernel = 0
char data0[0x90]; //hardcoded data
char data1[0x90];
@SKGleba
SKGleba / Makefile
Created March 15, 2022 15:46
bypass 24bit _start in mep gcc
%.S: %.c
$(CC) -S -o $@ $< $(CFLAGS)
%.o: %.S
mv $< $<.w
awk '{if ($$1 == "movu" && !($$3 ~ /^[0-9]/)) {$$1 = "or3"; $$4 = $$3; $$3 = $$2; printf("\tmovh %s 0x0004\n\t", $$2)}} 1' $<.w > $<
rm $<.w
$(CC) -c -o $@ $< $(CFLAGS)
@SKGleba
SKGleba / readas.c
Created January 23, 2022 00:39
Snuffleupagus interface for f00d
/*
* Copyright (C) 2021-2022 skgleba
*
* This software may be modified and distributed under the terms
* of the MIT license.
*/
#define READAS_REG 0xE0020040 // readas32 device
#define RAS_DEV_S 0 // default secure
@SKGleba
SKGleba / f00dbg.c
Last active February 21, 2022 06:32
switch to f00d debug mode without bothering the debugger
// warning: the dbg exception (0x00040018) must be set to "reti"
// simply call set_dbg_mode(true) or (false) to enter or exit debug mode
// this code needs to be a separate function, do not inline it
__attribute__((noinline))
void set_dbg_mode(bool debug_mode) {
if (!debug_mode) {
asm(
"ldc $0, $lp\n"
"stc $0, $depc\n"
/* THIS FILE IS A PART OF PSP2FWTOOL
*
* Copyright (C) 2019-2021 skgleba
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
#include <stdio.h>
#include <string.h>