Skip to content

Instantly share code, notes, and snippets.

View teknoraver's full-sized avatar
🖥️
coding

Matteo Croce teknoraver

🖥️
coding
View GitHub Profile
@teknoraver
teknoraver / libertus.sh
Last active September 22, 2020 10:59
easily switch the default GIT branch from master to main
#!/bin/sh -e
# Switch the default GIT branch from `master` to `main`
# for GitHub users, it can do the remote change too, but:
# 1. assumes that the name of the current directory name is the repo name
# 2. you must provide valid user and token to authenticate
user=
token=
@teknoraver
teknoraver / rxmastree.go
Last active December 9, 2019 01:16
tool to find reverse Xmas tree declarations in a source tree
/*
* rxmastree - tool to find reverse Xmas tree declarations in a source tree
* Copyright (C) 2019 Matteo Croce <mcroce@redhat.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
#!/bin/sh
lip=192.168.0.1
rip=192.168.0.2
ip netns add peer
ip link add name vethov type veth peer name vethov netns peer
ip addr add ${lip}/24 dev vethov
ip -n peer addr add ${rip}/24 dev vethov
ip link set vethov up
#!/bin/sh
lip=192.168.0.1
rip=192.168.0.2
lip2=192.168.1.1
rip2=192.168.1.2
wg genkey >wg1.priv
wg pubkey <wg1.priv >wg1.pub
wg genkey >wg2.priv
@teknoraver
teknoraver / sctprank.c
Last active November 6, 2019 09:28
[CVE-2019-3874] a tool to fill the kernel memory using SCTP network buffers
/*
* SCTPrank - a tool to fill the kernel memory using SCTP network buffers
* its main purpose was to test CVE-2019-3874
* Copyright (C) 2019 Matteo Croce <mcroce@redhat.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*

Raspberry Pi4 temperature

Naked

Idle

root@rpi4:~# uptime 
 00:16:11 up 3 min,  2 users,  load average: 0,09, 0,27, 0,13
root@rpi4:~# vcgencmd measure_temp
temp=61.0'C
@teknoraver
teknoraver / numbers.c
Last active October 23, 2019 22:19
number formatting library
/*
* numbers.c - number formatting library
* Copyright (C) 2019 Matteo Croce <mcroce@redhat.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
@teknoraver
teknoraver / gitshare
Last active March 18, 2024 06:20
Share objects between git repositories
#!/bin/sh
if [ $# -ne 2 ]; then
echo "usage: ${0##*/} <source> <target>"
echo " alias shared objects from repository 'source' to 'target'"
exit 1
fi
for i; do
if ! [ -d "$i/.git/objects" ]; then
@teknoraver
teknoraver / maintainers.go
Created October 1, 2019 23:26
convert MAINTAINERS file from plain text to JSON
/*
* maint.go - convert MAINTAINERS file from plain text to JSON
* Copyright (C) 2018 Matteo Croce <mcroce@redhat.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
@teknoraver
teknoraver / tcp_psh.c
Created August 5, 2019 10:13
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>
/*