Skip to content

Instantly share code, notes, and snippets.

@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 / echo.go
Created Dec 3, 2020
echo server in go
View echo.go
package main
import (
"flag"
"fmt"
"net"
"os"
"strings"
)
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 / 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 / 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>
@majek
majek / rungvisor.sh
Last active Dec 16, 2019
gvisor performance with slirp4netns
View rungvisor.sh
#!/bin/bash
set -e
# Dependencies:
# apt install jq
if [ ]; then
GVFLAGS=--network=host
FILESZ=1G
else
FILESZ=16M
@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 / user-timeout-and-syn.py
Created Sep 25, 2019
TCP_USER_TIMEOUT and SYN-SENT
View user-timeout-and-syn.py
import socket
import os
import subprocess
import shlex
import time
import atexit
import signal
tcpdump_bin = os.popen('which tcpdump').read().strip()
def tcpdump_start(port):
@majek
majek / run.sh
Last active Sep 5, 2019
inet-tool demo
View run.sh
#!/bin/bash
set -e
if [ ! -e './venv/bin/doitlive' ]; then
echo "Run ./venv/bin/pip3 install doitlive"
exit 1
fi
if [ `id -u` != '0' ]; then
echo "[!] FATAL: run as root"
@majek
majek / messages.txt
Last active Jul 16, 2019
out of memory in sctp
View messages.txt
a.out invoked oom-killer: gfp_mask=0x2dc0(GFP_KERNEL|__GFP_NOWARN|__GFP_ZERO), order=0, oom_score_adj=0
CPU: 0 PID: 131 Comm: a.out Not tainted 5.2.1+ #31
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014
Call Trace:
dump_header.cold.35+0x11/0x985
? ___ratelimit+0x1c6/0x400
oom_kill_process+0x151/0x850
? lockdep_sys_exit+0x50/0x50
? _raw_spin_unlock+0x1f/0x30
? oom_badness.part.26+0x3e1/0x510