Skip to content

Instantly share code, notes, and snippets.

@NicolaiSoeborg
NicolaiSoeborg / hook-method-in-binary.c
Created March 12, 2023 10:55
hook method in binary
#include <string.h>
/*
gcc -c -o hook.o hook.c
gcc -shared -o hook.so hook.o
LD_PRELOAD=./hook.so ./binary
*/
int getentropy(char *s, int size) {
memset(s, 0x41, size);
@NicolaiSoeborg
NicolaiSoeborg / Caddyfile
Last active September 24, 2022 19:10
Trying to make a Signal bridge using Caddy webserver
# Edit: this doesn't work, I can't get the upstream part to be "raw"
# Also this error: "http.request.tls.server_name" will be "signal.xn--sb-lka.org" and not the inner SNI
signal.xn--sb-lka.org {
#respond / "HELLO"
map {http.request.tls.server_name} {my_placeholder} {
chat.signal.org "chat.signal.org:443"
ud-chat.signal.org "chat.signal.org:443"
textsecure-service.whispersystems.org "chat.signal.org:443"
@NicolaiSoeborg
NicolaiSoeborg / motion.py
Created May 1, 2022 11:12
Motion detection PiCamera
from io import BytesIO
from time import sleep, time
from picamera import PiCamera
from PIL import Image, ImageChops
import numpy as np
def take_image(cam, stream):
stream.seek(0)
# stream.truncate() # resize to current position
print("Taking image")
from io import BytesIO
from time import sleep, time
from picamera import PiCamera
from PIL import Image, ImageChops
import numpy as np
def take_image(cam, stream):
cam.capture(stream, resize=(320, 240), format='jpeg')
# "Rewind" the stream to the beginning so we can read its content
stream.seek(0)
# Start matrix with tor proxy:
# torsocks python3 -m synapse.app.homeserver --config-path /etc/matrix/homeserver.yaml
# /etc/matrix/homeserver.yaml
listeners:
- port: 8448
type: http
tls: false # <-- needs to be false
bind_addresses: ['127.0.0.1']
resources:
Problem:
Error TS2688: Cannot find type definition file for 'frida-gum'
Solution:
yarn add --dev @types/frida-gum
Problem:
[TypeScript error: /node_modules/@types/frida-gum/index.d.ts(2317,15): Error TS2300: Duplicate identifier 'File'.]
Solution:
@NicolaiSoeborg
NicolaiSoeborg / BME680-logger.py
Last active January 30, 2022 16:03
Save and plot data from BME680 (Raspberry Pi)
#!/usr/bin/env python3
import json, os, sqlite3
from datetime import datetime
from random import randint
from time import time, sleep
try:
from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient # pip3 install azure-storage-blob
except: pass
def get_db():
from time import time
from functools import partial
import random
import trio # python3 -m pip install --upgrade trio
FTP_RESPONSE = "\r\n".join([
"220 ProFTPD 1.3.1 Server (ProFTPD)",
"220 " + "".join(random.choice('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') for _ in range(1001)),
"331 Password required"
])
@NicolaiSoeborg
NicolaiSoeborg / forwarder.py
Last active March 18, 2021 10:35
MITM proxy program to forward (tee) traffic between two TCP ports
import trio # python3 -m pip install --upgrade trio
from functools import partial
async def forward_from_a_to_b(a, b):
async for chunk in a:
print(f"=> {chunk}", flush=True)
await b.send_all(chunk)
@NicolaiSoeborg
NicolaiSoeborg / smittestop-scrape.py
Created November 17, 2020 23:11
Scrape smittestop status
import re
import time
import httpx
URL = "https://smittestop.dk/status/"
r = httpx.get(URL)
assert r.status_code == 200, f'{r.status_code}: {r.content}'