Skip to content

Instantly share code, notes, and snippets.

@majek
majek / disassm.py
Last active Jul 19, 2021
msp430 disassembler
View disassm.py
#!/usr/bin/env python
import collections
import itertools
import sys
import string
import array
def load_memory(filename):
regs = {}
@majek
majek / udp_server.py
Created Feb 8, 2012
Simple python udp server
View udp_server.py
import logging
import socket
log = logging.getLogger('udp_server')
def udp_server(host='127.0.0.1', port=1234):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
@majek
majek / Makefile
Created Dec 13, 2018
TCP splice with splice() experimentation
View Makefile
all:
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
majek / compile-kernel.sh
Created Feb 1, 2021
repro for kvm gvisor
View compile-kernel.sh
rm .config
make tinyconfig
make kvm_guest.config
make kvmconfig
./scripts/config \
-e EARLY_PRINTK \
-e 64BIT \
-e BPF -d EMBEDDED -d EXPERT \
-e INOTIFY_USER
@majek
majek / netstack4netns.go
Last active Apr 16, 2021
netstack from gvisor 4 netns
View netstack4netns.go
package main
import (
"flag"
"fmt"
"math/rand"
"net"
"os"
"os/signal"
"runtime"
@majek
majek / echo.go
Created Dec 3, 2020
echo server in go
View echo.go
package main
import (
"flag"
"fmt"
"net"
"os"
"strings"
)
@majek
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>
View test_tcp_halfopen.py
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
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"); \
exit(EXIT_FAILURE); \
} while (0)
@majek
majek / README.md
Created Apr 26, 2012
Passing TCP socket descriptors around
View README.md

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