Skip to content

Instantly share code, notes, and snippets.

View jrelo's full-sized avatar

hed0rah jrelo

View GitHub Profile
@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);
@jrelo
jrelo / c-pointers-demo.c
Created July 26, 2024 19:52
C Pointers Demo
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// demonstrate pointer basics
void pointerBasics() {
int a = 42;
int *ptr = &a;
printf("Pointer Basics:\n");
@jrelo
jrelo / find_large_heap.sh
Created July 25, 2024 18:21
Find processes with large heap regions
#!/bin/bash
get_heap_size() {
local pid=$1
local heap_size=0
# Read the /proc/[pid]/maps file
while read -r line; do
if [[ "$line" == *"heap"* ]]; then
local start_addr=$(echo "$line" | awk '{print $1}' | cut -d'-' -f1)
@jrelo
jrelo / iptables_flush.sh
Created July 21, 2024 19:25
iptables full flush
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -t nat -F
iptables -t mangle -F
iptables -F
iptables -X
@jrelo
jrelo / tcpdump_stdout_file.sh
Created July 20, 2024 19:39
tcpdump stdout and file simultaneously
tcpdump -i wlan0 host 192.168.1.201 -w - -U | tee tama_`date +%F`.pcap | tcpdump -r -