Skip to content

Instantly share code, notes, and snippets.

View csrutil's full-sized avatar

TSAO csrutil

View GitHub Profile
@csrutil
csrutil / Makefile
Created November 9, 2026 09:52
HTTP Hello World server in x86-64 assembly: 4-thread worker pool, AVX2/SIMD request parsing, no libc
AS ?= as
LD ?= ld
server: server.o
$(LD) -o $@ $<
server.o: server.s
$(AS) -o $@ $<
run: server
@csrutil
csrutil / iocommandgate-uaf-analysis.md
Last active October 9, 2026 12:58
macOS 15.7 kernel panic analysis: IOCommandGate use-after-free in Apple USB host stack (xnu zone UAF checker)

Kernel panic analysis: [iokit.IOCommandGate] use-after-free

Machine: MacBook Pro M1 Pro/Max (T6000) · macOS 15.7 (24G222) · xnu-11417.140.69.701.11 Trigger: flashing a Wio board over USB (rapid detach / re-enumeration)

The panic

panic(cpu 0): [iokit.IOCommandGate]: element modified after free
(off:72, val:0xffffffffffffff00, sz:80, ptr:0xfffffe2fa0076020)
@csrutil
csrutil / gist:a8ee45e9f44464523de7b5ac2db2da5b
Created July 2, 2026 03:53
dangerously-bypass-approvals-and-sandbox.patch
diff --git a/codex-rs/tui/src/lib.rs b/codex-rs/tui/src/lib.rs
index 2904306..0c16686 100644
--- a/codex-rs/tui/src/lib.rs
+++ b/codex-rs/tui/src/lib.rs
@@ -1379,8 +1379,11 @@ async fn run_ratatui_app(
}
let mut app_server = Some(app_server_session);
- let should_show_trust_screen_flag =
- !uses_remote_workspace && should_show_trust_screen(&initial_config);

It is table-driven, not a simple full-range linear fit.

We read the battery voltage in millivolts, then convert it to state-of-charge using an open-circuit-voltage table. Between adjacent table entries, the code does linear interpolation.

For the Wio Tracker L1, the OCV table is:

Charge Voltage
100% 4200 mV
90% 3876 mV
import sys
import hashlib
# Usage: xiaomi-purifier-pwd.py 04A03CAA1E7080
def getpwd(uid):
uid = bytearray.fromhex(uid)
h = bytearray.fromhex(hashlib.sha1(uid).hexdigest())
pwd = ""
pwd += "%02X" % h[h[0] % 20]
pwd += "%02X" % h[(h[0]+5) % 20]
# 文件路径和目标参数
input_file = "recovery.bin" # 输入文件名
output_file = "output.bin" # 输出文件名
search_marker = b"UBI#" # 要查找的标记
cut_size = 0x04000000 # 切割的大小
try:
with open(input_file, "rb") as f:
data = f.read() # 读取整个文件内容
#!/bin/sh
# /etc/network/if-up.d
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# /sys/devices/platform/gpio-leds/leds
echo cpu > /sys/devices/platform/gpio-leds/leds/green\:sys/trigger
[ "$IFACE" != "lo" ] || exit 0
#!/bin/sh
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# JAIL
ipset -N JAIL hash:net maxelem 65536 -exist
if ! iptables -S | grep -q -- "JAIL"; then
iptables -t filter -I INPUT \
-p tcp \
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrivacyAccessedAPITypes</key>
<array>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
@csrutil
csrutil / tmux-cheatsheet.markdown
Created March 5, 2024 03:06 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname