Skip to content

Instantly share code, notes, and snippets.

View akostrikov's full-sized avatar

Александр Костриков akostrikov

View GitHub Profile
@akostrikov
akostrikov / KIT-network-ebpf.md
Created June 26, 2024 07:19
KIT-network-ebpf
# Можно без capabilities пинговать
akostrikov@DESKTOP-2F6SIC8:~$ sudo setcap cap_net_raw=-ep /usr/bin/ping
[sudo] password for akostrikov:
akostrikov@DESKTOP-2F6SIC8:~$ getcap /usr/bin/ping
/usr/bin/ping =
# Причем пинг идёт с ICMP
akostrikov@DESKTOP-2F6SIC8:~$ sudo tcpdump -i any host 1.1.1.1 &
[1] 684
akostrikov@DESKTOP-2F6SIC8:~$ tcpdump: data link type LINUX_SLL2
@akostrikov
akostrikov / links.txt
Created May 8, 2023 12:27
Links to skb and bpf related pages
@akostrikov
akostrikov / drop.bt
Created May 8, 2023 09:38
Print kernel stack for packet drop and consume
#!/usr/bin/env bpftrace
//IP_ADDRESS_DST_TO_CONVERT=127.0.0.3
//IP_ADDRESS_SRC_TO_CONVERT=127.0.0.1
//DST_HTON=$(python3 -c "import ipaddress; import socket;print(socket.htonl(int(ipaddress.ip_address('$IP_ADDRESS_DST_TO_CONVERT'))))")
//SRC_HTON=$(python3 -c "import ipaddress; import socket;print(socket.htonl(int(ipaddress.ip_address('$IP_ADDRESS_SRC_TO_CONVERT'))))")
//sudo ./drop.bt $DST_HTON $SRC_HTON
//ping 127.0.0.3
//curl 127.0.0.3
@akostrikov
akostrikov / links.txt
Created May 11, 2022 06:34
Дополнительные материалы по Kernelshark
@akostrikov
akostrikov / tcp_psh.c
Created January 26, 2022 17:11 — forked from teknoraver/tcp_psh.c
Sample XDP/tc program, sets the TCP PSH flag on some TCP packets
#include <stdint.h>
#include <arpa/inet.h>
#include <asm/byteorder.h>
#include <linux/bpf.h>
#include <linux/if_ether.h>
#include <linux/ip.h>
#include <linux/tcp.h>
#include <linux/pkt_cls.h>
/*