Skip to content

Instantly share code, notes, and snippets.

@NyaMisty
NyaMisty / ida_linux_kernel_ptr.py
Last active October 1, 2024 16:09
Gist for Linux Kernel Pointer Recoginzation
import idaapi
import idc
import struct
KERNEL_START = 0xFFFFFFC008000000
KERNEL_END = 0xFFFFFFC008EF1008
def is_kernel_addr(a):
return KERNEL_START <= a <= KERNEL_END
@NyaMisty
NyaMisty / linux_arm64_relocate.py
Last active September 9, 2024 12:42
IDA Pro script for Linux ARM64/AArch64 kernel relocation (__relocate_kernel)
import idaapi
import re
def get_reloc_region():
relocFunc = idaapi.get_name_ea(idaapi.BADADDR, '__relocate_kernel')
#nexthead = lambda ea: idaapi.next_head(ea, idaapi.BADADDR)
d = idc.GetDisasm(relocFunc)
try:
relocOff = re.findall(r'LDR *.*?, =(0x[0-9A-F]+)', d)[0]
@NyaMisty
NyaMisty / README.md
Created May 13, 2024 14:56
MetacubeXD 作为dashboard-ui时避免手动指定url
sed -i 's|"http://127.0.0.1:9090"|location.origin|' assets/Setup-*.js 
@NyaMisty
NyaMisty / chinese_checker.xml
Created April 15, 2024 11:11
Overleaf Copilot 中文语法检查器
<agent name="中文 Checker">
<icon mdi="text-search-variant" />
<desc>中文语法检查</desc>
<model temperature="0.7">gpt-3.5-turbo-16k</model>
<def>
<render-diff>
<join-diff format="html">
<diff unit="char"> <!-- 必须是char,因为word模式没法匹配 -->
<source>
<input />
@NyaMisty
NyaMisty / phpbb_concat.go
Created March 25, 2024 18:43
phpbb concat
package main
import (
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"net/url"
"regexp"
@NyaMisty
NyaMisty / mount_zfs_snapshot.sh
Created February 23, 2024 14:36
Recursively mount ZFS snapshot for a dataset
#!/bin/bash
# Change these parameters
mntdir=/mnt/cache/_tmp_restic-snapshot
dataset_name="cache"
datasets=($(zfs list -t filesystem -H | cut -d$'\t' -f1 | grep -E '^'$dataset_name'(/|$)'))
echo "Datasets selected: ${datasets[@]}"
for d in "${datasets[@]}"; do
mntsubdir=${d#"$dataset_name"}
@NyaMisty
NyaMisty / damage.c
Last active January 26, 2024 08:37
Evol deepspace damage calculation
// local variable allocation has failed, the output may be wrong!
__int64 __fastcall DamageFormula__CalcDamage(
DamageInfo **damageInfo,
void *damageExporter,
Actor *damageTaker,
Actor *assistor,
HitParamConfig *hitParamConfig,
float hurtAddAngle,
float damageProportion,
char isCritical,
@NyaMisty
NyaMisty / _CoCoPilot.md
Last active January 26, 2024 03:44
A small snippet to use CoCoPilot without patching Copilot plugin

cocopilot-gh-enterprise

Turn cocopilot into github enterprise server, so that we can use CoCoPilot without patching Copilot plugin.

Usage

  1. Add the following JS to a cloudflare worker.
  2. Add Cloudflare Worker Routes: *cocopilot-gh-enterprise.XXXXXXXX.XXX. You should also add DNS records cocopilot-gh-enterprise.XXXXXXXX.XXX & *.cocopilot-gh-enterprise.XXXXXXXX.XXX to make the route available image
  3. Setting GitHub Enterprise URL to cocopilot-gh-enterprise.XXXXXXXX.XXX
// https://op-prod-tr.ozan.com/api/(oauth/token\?grant_type=pre_verification|users/update-mobile-number)
const url = $request.url
var new_hdrs = {}
for (var k in $request.headers) {
new_hdrs[k.toLowerCase()] = $request.headers[k]
}
function main() {
if (url == 'https://op-prod-tr.ozan.com/api/oauth/token?grant_type=pre_verification') {
if (!($request.body.includes('mfa_code') && $request.body.includes('mfa_token'))) {
@NyaMisty
NyaMisty / http_fileobj.py
Created August 5, 2023 12:47
Python fileobj from HTTP, with ranged request!
import io
import requests
class HTTPFileObj:
def __init__(self, url, chunk_size=1024):
self.url = url
self.chunk_size = chunk_size
self.start_byte = 0 # Initialize start_byte here
self.buffer = b"" # Initialize buffer to store remaining data
self.max_size = -1