Skip to content

Instantly share code, notes, and snippets.

View Lessica's full-sized avatar

i_82 Lessica

View GitHub Profile
@Lessica
Lessica / patch-to-securityd-tweak.mm
Last active February 28, 2024 11:28
A patch to securityd
#import <Foundation/Foundation.h>
#import <os/log.h>
#define FAKE_BASE 0x100000000
#define FAKE_PAGE 4096
template <unsigned B> inline int64_t SignExtend64(uint64_t x) {
static_assert(B > 0, "Bit width can't be 0.");
static_assert(B <= 64, "Bit width out of range.");
return int64_t(x << (64 - B)) >> (64 - B);
@Lessica
Lessica / fetch-libimobiledevice.sh
Created May 13, 2023 15:11
Fetch libraries and executables for macOS from libimobiledevice artifacts. This script will make executables runnable without install them to specific paths.
#!/bin/sh
set -e
if ! test -x "`which ldid`"; then
echo "Cannot find ldid, you may install it via Homebrew."
exit 1
fi
if [ ! -d "$(xcode-select -p)" ]; then
@Lessica
Lessica / MGCopyAnswer-Tweak.mm
Last active March 17, 2024 19:04
Hook Internal Implementation of MGCopyAnswer (iOS 15)
#import <dlfcn.h>
#import <os/log.h>
#import <substrate.h>
#import <Foundation/Foundation.h>
#import "pac_helper.h"
#define _FUNC_ADDR_(A, O) (const void *)((long)(A) + (O))
/* ... */
@Lessica
Lessica / daemon-main.m
Created September 7, 2022 07:54
iOS Daemon without Jetsam
#import <Foundation/Foundation.h>
#import <dlfcn.h>
#import <sys/proc.h>
// these headers can be found at https://github.com/apple/darwin-xnu
#import "libproc.h"
#import "kern_memorystatus.h"
static __attribute__ ((constructor(101), visibility("hidden")))
void BypassJetsam(void) {
@Lessica
Lessica / idevicerestore-static-patch.diff
Created April 13, 2022 15:26
Static patch of idevicerestore
diff --git a/src/fdr.c b/src/fdr.c
index ee76de6..c092b0b 100644
--- a/src/fdr.c
+++ b/src/fdr.c
@@ -549,7 +549,7 @@ static int fdr_handle_proxy_cmd(fdr_client_t fdr)
}
/* else wait for messages and forward them */
- int sockfd = socket_connect(host, port);
+ int sockfd = idevicerestore_socket_connect(host, port);
@Lessica
Lessica / argon-fan.sh
Created March 25, 2022 17:07
Configure Raspberry Pi + Argon One Case for Lineage OS
#!/system/bin/sh
sleeptime=120
while true
do
cputemp=$(cat /sys/class/thermal/thermal_zone0/temp)
if [[ $cputemp -lt 55000 ]]; then
fanspeed="0x00"
elif [ $cputemp -ge 55000 -a $cputemp -lt 60000 ]; then
fanspeed="0x10"
@Lessica
Lessica / configure-xcode-for-embedded-development.py
Created March 8, 2022 17:40
iOS Jailbreak Development: Add Command-Line Tool
#!/usr/bin/env python3
#
# Copyright (C) 2014-2020 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
@Lessica
Lessica / make_panes.sh
Created July 17, 2021 11:52
Make muliple panes in iTerm
#!/bin/zsh
repeatBy() { for i in {1..$(expr $1)}; do echo -n "$2"; done }
if [ "$#" -lt 2 ]; then
echo "usage: $0 v h [command]"
exit 1
fi
CMD="$3"
@Lessica
Lessica / expects_json.py
Created July 12, 2021 18:20
Validate JSON request data
def expects_json(obj: dict, schema: tuple):
# or use library `flask-expects-json`
_type = type(obj)
if _type != dict:
raise werkzeug.exceptions.BadRequest(f"wrong type of root object, except dict, got {str(_type.__name__)}")
_keys = schema
for _key in _keys:
assert len(_key) >= 2
if _key[0] not in obj:
if len(_key) >= 3 and _key[2] is False:
@Lessica
Lessica / ssn_mappings.json
Created July 10, 2021 05:39
Prefix List for Social Security Numbers USA
{
"AK": {
"ssn_parts": [
"574"
],
"ssn_prefixes": [
"574"
],
"ssn_sql_parts": [
"LIKE '574%'"