This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# the netfilter uses the 'token bucket algorithm' | |
# it sometimes can be a bit 'unintuitive' how this rate-limit-algorithm works | |
# the algorithm expects the packets, as defined by the limit, to be somewhat spread over the whole timewindow (second/minute/..) | |
# token bucket punishes short-term overages beyond the burst capacity | |
# limit source code: https://github.com/torvalds/linux/blob/master/net/netfilter/nft_limit.c | |
# this script provides a way to easily test "rate-limit + burst" configurations | |
# to get practical data you can simply run "tcpdump" on your target system and extract the packet-times from its output |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
NOTE: | |
These are not perfect, but good enough for frontend-validation. | |
A exact validation needs to be done on the backend anyways.. | |
*/ | |
const REGEX_IP4 = /^([1-2]?)[0-9]{1,2}\.([1-2]?)[0-9]{1,2}\.([1-2]?)[0-9]{1,2}\.([1-2]?)[0-9]{1,2}$/ | |
/* | |
tested: | |
10.0.0.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ -z "$1" ] | |
then | |
echo 'Provide a hostname of a website to check!' | |
exit 1 | |
fi | |
if [ -z "$2" ] | |
then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ -z "$1" ] | |
then | |
echo 'Provide the target hostname!' | |
exit 1 | |
fi | |
TARGET="$1" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from sys import exit as sys_exit | |
from pathlib import Path | |
from argparse import ArgumentParser | |
from ipaddress import IPv4Address, IPv6Address, IPv4Network, IPv6Network, AddressValueError, NetmaskValueError | |
def _load_ip_list(ip_list_file: str) -> (list, list): | |
safe_ips = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
IP="1.1.1.1" | |
ip4="$(python3 -c "from ipaddress import IPv4Address; from sys import argv; ip=argv[1]; print(ip) if IPv4Address(ip).is_global else print('1')" "$IP" 2>/dev/null || echo '0')" | |
if [[ "$ip4" == '0' ]] | |
then | |
ip6="$(python3 -c "from ipaddress import IPv6Address; from sys import argv; ip=argv[1]; print(ip) if IPv6Address(ip).is_global else print('1')" "$IP" 2>/dev/null || echo '0')" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
LOG_DIR='/var/log/ps/' | |
TOP_N=5 | |
TOP_N_H=$(( TOP_N + 1 )) | |
mkdir -p "$LOG_DIR" | |
date >> "${LOG_DIR}/mem.log" | |
ps -eo rss,pid,user,command --sort -rss | head -n "$TOP_N_H" | tail -n "$TOP_N" >> "${LOG_DIR}/mem.log" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body.light { | |
--darkVisible: hidden; | |
--darkDisplay: none; | |
--lightVisible: unset; | |
--lightDisplay: inline-block; | |
} | |
body.dark { | |
--darkVisible: unset; | |
--darkDisplay: inline-block; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# this is handy if you need to pass secrets between two processes | |
# the secrets are not written to disk and can only be read once | |
from os import mkfifo | |
from pathlib import Path | |
from os import remove as remove_file | |
from threading import Thread |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var bindTo = "/tmp/test.sock" | |
// check if socket file exists and remove it | |
if _, err := os.Stat(bindTo); err == nil { | |
if err := os.Remove(bindTo); err != nil { | |
globalLogger.Fatal().Err(err).Msg("Failed to remove existing socket-file") | |
} | |
} | |
// listen on socket-file |
NewerOlder