Skip to content

Instantly share code, notes, and snippets.

Marek majek

View GitHub Profile
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 Dec 31, 2019
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 Oct 11, 2019
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
@majek
majek / result.txt
Created Jul 15, 2019
available setsockopts
View result.txt
[SETSOCKOPT(SOL_ICMPV6, 1)]: {.bytes = 32}
[SETSOCKOPT(SOL_IP, IP_BIND_ADDRESS_NO_PORT)]: {.min = 0, .max = 1}
[SETSOCKOPT(SOL_IP, IP_CHECKSUM)]: {.min = 0, .max = 1}
[SETSOCKOPT(SOL_IP, IP_FREEBIND)]: {.min = 0, .max = 1}
[SETSOCKOPT(SOL_IP, IP_HDRINCL)]: {.min = 0, .max = 1}
[SETSOCKOPT(SOL_IP, IP_MINTTL)]: {.min = 0, .max = 255}
[SETSOCKOPT(SOL_IP, IP_MTU_DISCOVER)]: {.min = 0, .max = 6}
[SETSOCKOPT(SOL_IP, IP_MULTICAST_ALL)]: {.min = 0, .max = 1}
// [SETSOCKOPT(SOL_IP, IP_MULTICAST_IF)]: # not settable ??
// [SETSOCKOPT(SOL_IP, IP_MULTICAST_IF)]: # only single value 0
@majek
majek / reflect_test.py
Created Jul 9, 2019
Flow label reflection doesn't work for RST
View reflect_test.py
#!/usr/bin/python3
# Before you start you need to either enable flow label reflection
# sysctl -w net.ipv6.flowlabel_reflect = 1
# or disable flow label consistency
# sysctl -w net.ipv6.flowlabel_consistency = 0
import socket
import struct
IPV6_FL_A_GET = 0
You can’t perform that action at this time.