Skip to content

Instantly share code, notes, and snippets.

View mkorthof's full-sized avatar
⌨️
cli connoisseur

Marius mkorthof

⌨️
cli connoisseur
View GitHub Profile
@mkorthof
mkorthof / httpd.md
Last active November 16, 2019 13:56
Python SimpleHTTPServer - Moved to: https://github.com/mkorthof/httpyd
@mkorthof
mkorthof / pslog.sh
Last active September 10, 2022 21:48
Piped logger for Apache to use with OpenVPN port_share (logs real client ip)
#!/bin/sh
# pslog.sh - Piped logger for Apache to use with OpenVPN + port sharing
# Replaces remote ip in logs with real client ip
#
# USAGE: ErrorLog "|/usr/local/bin/pslog.sh ${APACHE_LOG_DIR}/error.log"
# CustomLog "|/usr/local/bin/pslog.sh ${APACHE_LOG_DIR}/access.log" combined
#
# REQUIRES: openvpn server config "port-share 127.0.0.1 10443 portshare"
# where 'portshare' is journal dir for tmp files (e.g. /run/openvpn/portshare if chrooted)
@mkorthof
mkorthof / ipset-country.md
Last active May 5, 2023 00:28
Block countries using iptables + ipset + ipdeny.com -> moved to https://github.com/mkorthof/ipset-country
@mkorthof
mkorthof / ipset-logpat.sh
Last active December 20, 2023 19:48
creates ipset sets matching certain patterns in httpd logs
#!/bin/bash
# ipset-logpat
# searches httpd access logs for pattern, whoises matching ip's and uses
# ip blocks to create ipset set. also adds iptables rules to log and reject
# requires: iptables, ipset, aggregate (optional)
# other useful ipset commands: ipset list [-terse], ipset destroy
# more info:
@mkorthof
mkorthof / json2xml.py
Last active December 20, 2023 19:49
conv json to xml
#!/usr/bin/python3
# Source: https://github.com/quandyfactory/dicttoxml/blob/master/README.markdown
# page = urllib.urlopen('http://quandyfactory.com/api/example')
import json
import urllib
import dicttoxml
import sys
@mkorthof
mkorthof / ldbdump.py
Last active March 21, 2024 13:58
ldbdump - dumps LevelDB keys/values
#!/usr/bin/python3
# ldbdump - dumps LevelDB keys/values
#
# a LevelDB is a dir with files such a these:
# 000050.ldb 000100.log CURRENT LOCK LOG MANIFEST-000099
#
# sources: https://github.com/tos-kamiya/levelobjdb dump()
import os