Skip to content

Instantly share code, notes, and snippets.

View jrelo's full-sized avatar

hed0rah jrelo

View GitHub Profile
@jrelo
jrelo / netstat_stat.sh
Created October 10, 2025 15:47
netstat -s colors stat
while true; do netstat -s | awk '/^[[:space:]]+[0-9]+/{num=$1; $1=""; desc=$0; print num"|"desc}' > /tmp/ns_new; if [ -f /tmp/ns_old ]; then clear; echo "=== Network Stats Delta ($(date +%T)) ==="; awk -F'|' 'NR==FNR{old[$2]=$1; next} {if(old[$2] && $1-old[$2]!=0) printf " \033[92m%+8d\033[0m %s\n", $1-old[$2], $2}' /tmp/ns_old /tmp/ns_new; fi; cp -f /tmp/ns_new /tmp/ns_old 2>/dev/null; sleep 1; done
@jrelo
jrelo / mcp_example.py
Created September 21, 2025 14:46
MCP example
#!/usr/bin/env python3
from mcp.server.fastmcp import FastMCP
from mcp.server.sse import sse_app # SSE transport ASGI app
import uvicorn
import subprocess
# Create MCP server
mcp = FastMCP("Pi-MCP-Server")
@mcp.tool()
@jrelo
jrelo / blocked_kill_signals.sh
Created March 25, 2025 16:58
List blocked signals based on hex bitmask in /proc/$PID/status
#!/bin/bash
function blocked_signals {
# convert the hexadecimal input to a binary string, ensuring uppercase
local hex_mask=$(echo "$1" | tr '[:lower:]' '[:upper:]')
local binary_mask=$(echo "obase=2; ibase=16; $hex_mask" | bc)
# calculate the number of bits (signals) to process, typically 64 for Linux
local num_bits=64
local padded_binary=$(printf "%0${num_bits}s" $binary_mask | sed 's/ /0/g')
@jrelo
jrelo / traffic_machine.c
Created December 3, 2024 17:50
traffic light state machine example
#include <stdio.h>
enum TrafficLightState {
RED,
GREEN,
YELLOW
};
void transition(enum TrafficLightState *state) {
switch (*state) {
@jrelo
jrelo / swap_usage.py
Created September 3, 2024 20:52
swap usage per process
#!/usr/bin/env python3
import os
import re
import psutil
import tempfile
def get_swap_usage():
swap_data = []
total_swap = 0
@jrelo
jrelo / dns_tcpdumps.txt
Created August 21, 2024 17:48
dns tcpdumps
DNS error responses:
sudo tcpdump -vv -i any port 53 and '(udp[10] & 0x80 != 0) and (udp[11] & 0x0F > 0)'
SPecific query types:
sudo tcpdump -vv -i any port 53 and 'udp[12:2] = 0x0100'
Long response times:
sudo tcpdump -vv -i any port 53 and greater 500
Malicious UDP traffic
sudo tcpdump -vv -i any not port 53 and 'udp[12:2] = 0x0100'
Specific domains:
sudo tcpdump -vv -i any port 53 and host example.com
@jrelo
jrelo / .vimrc
Created August 20, 2024 04:20
my vimrc (mostly clang-format stolen)
filetype plugin indent on
" show existing tab with 4 spaces width
set tabstop=4
" when indenting with '>', use 4 spaces width
set shiftwidth=4
" On pressing tab, insert 4 spaces
set expandtab
" VIM Configuration File
" Description: Optimized for C/C++ development, but useful also for other things.
" Author: Gerhard Gappmeier
@jrelo
jrelo / bitmask_logic.c
Created August 7, 2024 14:05
bitmask logic
#include <stdio.h>
/*
Common bitmask operators and logic:
1. AND (&)
Purpose: Clear (set to 0) specific bits or only show bits that are already set.
Example: result = value & mask;
Keeps bits that are 1 in both value and mask.
2. OR (|)
@jrelo
jrelo / exiftool_safe.sh
Created July 30, 2024 14:40
exiftool remove metadata without altering image
exiftool -overwrite_original -EXIF:GPS* -EXIF:DateTimeOriginal= -EXIF:CreateDate= -EXIF:ModifyDate= -IPTC:Byline= -IPTC:BylineTitle= -IPTC:City= -IPTC:Sub-location= -IPTC:Province-State= -IPTC:Country-PrimaryLocationName= -XMP:Creator= -XMP:Description= ./*.jpg
exiftool -all= -tagsfromfile @ -icc_profile -ColorSpace -overwrite_original -ext jpg ./*
#include <stdio.h>
int main() {
int value = 10;
int *pointer = &value;
// print the address of the variable and the pointer value
printf("Address of 'value': %p\n", (void *)&value);
printf("Value of 'pointer': %p\n", (void *)pointer);