Skip to content

Instantly share code, notes, and snippets.

@Aikhjarto
Aikhjarto / convert_forward_spec_to_openwrt.py
Created September 14, 2021 11:27
Convert dd-wrt's forward_spec to OpenWrt's redirct rules suitable for /etc/network/firewall
"""
Convert dd-wrt's forward_spec from 'nvram get forward_spec' to OpenWrt's
redirect rules suitable for /etc/network/firewall
"""
from io import StringIO
import re
# example forward line taken from 'nvram get forward_spec' on a dd-wrt router
forward_spec=r"https:on:tcp:443>192.168.1.201:443 ssh:on:tcp:22>192.168.1.202:22 ssh2:off:tcp:23>192.168.1.117:22"
@Aikhjarto
Aikhjarto / convert_dnsmasq_conf_to_openwrt.py
Created September 14, 2021 11:26
Convert dnsmasq.conf to config entries suitable for /etc/config/dhcp in OpenWrt
"""
Converts cname, host-records, and dhcp-host entries from a dnsmasq config file
called dnsmasq.conf in the current working directory to corresponding lines
suitable for OpenWrt's /etc/config/dhcp config file.
"""
import re
from io import StringIO
def convert_dnsmasq_conf(filename):
@Aikhjarto
Aikhjarto / webrtc_build_with_python3.7.patch
Created May 16, 2020 16:38
webrtc build with python 3.7 patch
diff --git a/android/gyp/create_apk_operations_script.py b/android/gyp/create_apk_operations_script.py
index a39752bcf..c5306dc55 100755
--- a/android/gyp/create_apk_operations_script.py
+++ b/android/gyp/create_apk_operations_script.py
@@ -87,7 +87,7 @@ def main(args):
'TARGET_CPU': repr(args.target_cpu),
}
script.write(SCRIPT_TEMPLATE.substitute(script_dict))
- os.chmod(args.script_output_path, 0750)
+ os.chmod(args.script_output_path, 0o750)
@Aikhjarto
Aikhjarto / vdr_demux
Created May 27, 2017 11:40
Automatically demux VDR recordings
#!/bin/bash
# This script searched for *.ts files recursivly in $SRC_DIR. Then it demuxes the files with ProjectX to $DST_DIR whilest maintaining the folder structure.
# This us useful if mpeg files are post-processed with ttcutter or cuttermaran
# TODO: projectx.sh doesn't work with spaces in filenames. I found no way to espace them to make it work.
# Thomas Wagner 2014 wagner-thomas@gmx.at
# for loop only breaks at linefeed (otherwise space in filename won't work)
IFS=$'\012'
@Aikhjarto
Aikhjarto / DD_WRT_nvram_tricks.txt
Last active February 28, 2024 13:46
DD-WRT nvram tricks
This file provides some nifty command-line tools around DD-WRT's nvram command.
https://www.dd-wrt.com/wiki/index.php/Hardware#NVRAM
USE WITH CAUTION: fiddling with nvram can wipe your settings and you may loose access to your router.
Hint 1: Different version of DD-WRT might use different nvram variables. Thus, be carefull when updating.
Hint 2: The commands listed below should be issued via a ssh-connection since the webinterface for issuing commands might time out for the longer commands.
Background
==========
Extracting the content of configuration variables with nvram would provide an easy way of selective backup/restore of settings. However, listing the content of the nvram via
nvram show
#/bin/sh
# extract bytes needed for decryption of Petya
if [ -z $1 ]; then
DEVPART=sdc
else
DEVPART=$1
fi
# extract sector 55
@Aikhjarto
Aikhjarto / block_badips.sh
Last active April 8, 2021 15:54
Fetch a list of known brute force attackers from badips.com and apply/update iptables DROP rules
#!/bin/bash
# This script downloads a list of IPs known for brute force attacking within the last two weeks.
# The fetched IPs get blocked with iptables with the special comment "BADIP". This script only
# modifies iptables rules with that comment. This measure makes it well compatible with other firewall
# scripts like the SUSEFirewall.
# The iptables rules are updated every time this script is executed. Additionally this script is
# quiet on stdout, which makes it well suited for being executed as a cronjob.
#
# Please also use fail2ban with the badips modification and help to maintain the list of attackers.
# See also: fail2ban and http:///www.badips.com
@Aikhjarto
Aikhjarto / update_DNS_A_hosteurope.sh
Created April 17, 2014 19:33
DNS A update script for hosteurope
#!/bin/bash
# Script for automatically update a DNS-A entry for domains hosted by http://hosteurope.de
# The purpose of this script is to have a DNS update functionality similar to dyndns, no-ip, or afraid.org.
DOMAIN="my.domain" # Domain name
HOST="updatetest" # Host Name
#NEW_IP="3.2.1.2" # Desired IP address (if not set, external IP will be used)
HOSTEUROPE_kdnummer="123456" # Hosteurope "Kundennmmer"
HOSTEUROPE_passwd="xgeheimx" # Hosteurope password (must be urlencoded)