Skip to content

Instantly share code, notes, and snippets.

majek /
Last active Jul 19, 2021
msp430 disassembler
#!/usr/bin/env python
import collections
import itertools
import sys
import string
import array
def load_memory(filename):
regs = {}
majek /
Created Feb 8, 2012
Simple python udp server
import logging
import socket
log = logging.getLogger('udp_server')
def udp_server(host='', port=1234):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
majek / Makefile
Created Dec 13, 2018
TCP splice with splice() experimentation
View Makefile
clang -g -O2 -Wall -Wextra net.c send.c -o send
clang -g -O2 -Wall -Wextra net.c receive.c -o receive
clang -g -O2 -Wall -Wextra net.c proxy-naive.c -o proxy-naive
clang -g -O2 -Wall -Wextra net.c proxy-splice.c -o proxy-splice
majek /
Created Feb 1, 2021
repro for kvm gvisor
rm .config
make tinyconfig
make kvm_guest.config
make kvmconfig
./scripts/config \
-e 64BIT \
majek / netstack4netns.go
Last active Apr 16, 2021
netstack from gvisor 4 netns
View netstack4netns.go
package main
import (
majek / echo.go
Created Dec 3, 2020
echo server in go
View echo.go
package main
import (
majek / gvtcpdump.c
Created Dec 17, 2019
gVisor tcpdump
View gvtcpdump.c
* Usage: ./gvtcpdump | tcpdump -n -r -
#include <arpa/inet.h>
#include <errno.h>
#include <error.h>
#include <getopt.h>
#include <linux/filter.h>
#include <linux/if_ether.h>
#include <linux/if_packet.h>
import atexit
import os
import socket
import subprocess
import shlex
import time
import signal
tcpdump_bin = os.popen('which tcpdump').read().strip()
ss_bin = os.popen('which ss').read().strip()
majek / common.h
Last active Aug 20, 2020
conntrack experiment
View common.h
#define PFATAL(x...) \
do { \
fprintf(stderr, "[-] SYSTEM ERROR : " x); \
fprintf(stderr, "\n\tLocation : %s(), %s:%u\n", __FUNCTION__, __FILE__, \
__LINE__); \
perror(" OS message "); \
fprintf(stderr, "\n"); \
} while (0)
majek /
Created Apr 26, 2012
Passing TCP socket descriptors around

Passing TCP socket descriptors around

In linux, normally, it is impossible to "bind()" to the same TCP port twice. If you try to bind to the same port from second proces unix processes you'll see:

socket.error: [Errno 98] Address already in use