Skip to content

Instantly share code, notes, and snippets.

Avatar
🖥️
.

Marius mkorthof

🖥️
.
View GitHub Profile
@mkorthof
mkorthof / ldbdump.py
Last active Nov 26, 2020
ldbdump - dumps LevelDB keys/values
View ldbdump.py
#!/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
@mkorthof
mkorthof / clamav-freshclam
Created Jun 14, 2017
limit freshclam memory usage (cron)
View clamav-freshclam
29 */1 * * * clamav [ -x /usr/bin/freshclam ] && { ulimit -Sm 512000; ulimit -Sv 512000; ulimit -Hm 1024000; ulimit -Hv 1024000; /usr/bin/freshclam --quiet; } > /dev/null
@mkorthof
mkorthof / json2xml.py
Last active Feb 20, 2019
conv json to xml
View json2xml.py
#!/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 / clamwrap.sh
Created Jul 20, 2018
adjust clamscan oom score
View clamwrap.sh
#!/bin/sh
# http://www.oracle.com/technetwork/articles/servers-storage-dev/oom-killer-1911807.html
# https://backdrift.org/oom-killer-how-to-create-oom-exclusions-in-linux
echo 10 > /proc/self/oom_score_adj && /usr/bin/clamscan "$@"
@mkorthof
mkorthof / ipv6test.sh
Last active Jan 19, 2018
ipv6test - test/show your ipv6 addr
View ipv6test.sh
#!/bin/sh
ARGS=""
if [ "$interface" ]; then ARGS="$ARGS --interface $interface"; fi
echo
for i in ipv6.test-ipv6.com/ip/\?callback=\?\&asn=1 whatismyv6.com ipv6-test.com ipv6now.com.au ipv6-speedtest.net testmyipv6.com; do
echo "Testing $i:"
#lynx -connect_timeout=5 -read_timeout=5 -dump http://$i | grep -A 2 "\(Your\? are\|Your IP\|Welcome\)" | grep -v "\(\[.*\]\|FAQ\)" | sed -e '/^$/d' -e 's/ //g'
curl -6 --connect-timeout 5 -s http://$i $ARGS | sed -e 's/<[^>]*>/ /g' | grep -A 1 "\(Your\? are\|Your IP\|Welcome\|callback\)" | grep -v "\(\[.*\]\|FAQ\|[yY]our\ browser\)"
echo
done | sed -e 's/\( *\|[(){}]\|\"[:,]\"\|"\"\)/ /g' -e '/^\( \|\r\|--\)$/d'
@mkorthof
mkorthof / pslog.sh
Last active Jan 18, 2018
logger for apache for use with openvpn + port sharing
View pslog.sh
#!/bin/sh
# pslog.sh - logger for apache for 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
# needs: openvpn server config "port-share 127.0.0.1 10443 portshare"
# this will set journal dir for tmp files (eg. /run/openvpn/portshare if chrooted)
{ test ! -z "$1" && test -w "$1"; } && logfile="$1" || exit 1
@mkorthof
mkorthof / ipset-logpat.sh
Last active Jan 18, 2018
creates ipset sets matching certain patterns in httpd logs
View ipset-logpat.sh
#!/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 / pop3.exp
Created Jan 13, 2018
pop3.exp - connects to pop3 server using telnet
View pop3.exp
#!/usr/bin/expect
proc help {} {
global argv0
puts ""
puts "pop3.exp - connects to pop3 server using telnet"
puts ""
puts "usage: $argv0 <host> <user>"
puts " it will prompt for password"
puts ""