Skip to content

Instantly share code, notes, and snippets.

View milankragujevic's full-sized avatar

Milan Kragujević milankragujevic

View GitHub Profile

Introduction

Sometimes you may want to use a DNS server for specific domain requests and another DNS server for all other requests. This is helpful, for instance, when connected to a VPN. For hosts behind that VPN you want to use the VPN's DNS server but all other hosts you want to use Google's public DNS. This is called "DNS splitting."

Here, we run dnsmasq as a background service on macOS. The dnsmasq configuration described below implements DNS splitting.

Install

brew install dnsmasq
@milankragujevic
milankragujevic / enable_sshd.py
Created April 25, 2023 10:32 — forked from andyboeh/enable_sshd.py
Enable SSHD on the Aclatel HH40V (modify backup file)
#!/usr/bin/env python
import os
import sys
import subprocess
import tempfile
import struct
import shutil
import hashlib
@milankragujevic
milankragujevic / reboot.sh
Created May 27, 2022 13:42
Reboot CGA2121 modem via Web UI
#!/bin/bash
SEC=$(curl -s -v 'http://192.168.0.1/goform/logon' -H 'Content-Type: application/x-www-form-urlencoded' --data-raw 'username_login=&password_login=&language_selector=en' --insecure 2>&1 | grep 'Set-Cookie' | cut -d '=' -f 2 | cut -d ';' -f 1)
CSRF=$(curl -s 'http://192.168.0.1/ad_restart_gateway.html' -H "Cookie: sec=${SEC}" --insecure | grep csrftoken | cut -d '"' -f 6)
curl -s 'http://192.168.0.1/goform/ad_restart_gateway' -H "Cookie: sec=${SEC}" --data-raw "csrftoken=${CSRF}&tch_devicerestart=0x00" --insecure >/dev/null 2>&1
echo "Done!"
@milankragujevic
milankragujevic / hpscan.sh
Created October 23, 2021 16:54
Scan over network via SSH on RPI
#!/bin/bash
PAGE_ID="$(date +%Y-%m-%d_%H-%M-%S)"
FILENAME="scan_$PAGE_ID.jpg"
FILENAME_PDF="scan_$PAGE_ID.pdf"
FILENAME_PDF_1="scan_$PAGE_ID.1.pdf"
mkdir -p /home/milan/Documents/Scanned\ Documents/
ssh root@10.25.250.211 "scanimage --mode Gray --resolution 200 --format=jpeg -l 4 -t 4 -x 207.9 -y 289.011 >/tmp/$FILENAME"
scp root@10.25.250.211:/tmp/$FILENAME /home/milan/Documents/Scanned\ Documents/$FILENAME
chmod 0777 /home/milan/Documents/Scanned\ Documents/$FILENAME
chown milan:milan /home/milan/Documents/Scanned\ Documents/$FILENAME
@milankragujevic
milankragujevic / proxy.php
Created July 1, 2021 13:19
PHP streaming proxy with support for Range requests (perfect for proxying video files with progressive download MP4 streaming)
<?php
error_reporting(0);
set_time_limit(0);
ob_end_clean();
$url = $_GET['url'];
if(isset($_SERVER['HTTP_RANGE'])) {
stream_context_set_default([
'http' => [
@milankragujevic
milankragujevic / _update.sh
Last active May 8, 2021 10:53 — forked from lg/angry_wifi.sh
Auto disconnect WiFi clients with a low Received Signal Power on OpenWRT 19.07
rm /root/roaming_assistant.sh; wget http://10.25.100.10/roaming_assistant.sh -O /root/roaming_assistant.sh; chmod +x /root/roaming_assistant.sh
rm /root/monitor-ra.sh; wget http://10.25.100.10/monitor-ra.sh -O /root/monitor-ra.sh; chmod +x /root/monitor-ra.sh
rm /root/restart-ra.sh; wget http://10.25.100.10/restart-ra.sh -O /root/restart-ra.sh; chmod +x /root/restart-ra.sh
/root/restart-ra.sh
@milankragujevic
milankragujevic / iptables.sh
Last active July 18, 2023 11:19
Hijack DNS on OpenWrt to another DNS server
iptables -I FORWARD ! -s 192.168.100.242 -p tcp --dport 53 -j ACCEPT
iptables -I FORWARD ! -s 192.168.100.242 -p udp --dport 53 -j ACCEPT
iptables -t nat -A PREROUTING ! -s 192.168.100.242 -p tcp --dport 53 -j DNAT --to 192.168.100.242:53
iptables -t nat -A PREROUTING ! -s 192.168.100.242 -p udp --dport 53 -j DNAT --to 192.168.100.242:53
iptables -I FORWARD ! -s 192.168.100.242 -p tcp --dport 5353 -j ACCEPT
iptables -I FORWARD ! -s 192.168.100.242 -p udp --dport 5353 -j ACCEPT
iptables -t nat -A PREROUTING ! -s 192.168.100.242 -p tcp --dport 5353 -j DNAT --to 192.168.100.242:53
iptables -t nat -A PREROUTING ! -s 192.168.100.242 -p udp --dport 5353 -j DNAT --to 192.168.100.242:53
@milankragujevic
milankragujevic / block-dot.sh
Created October 13, 2020 09:04
Block DNS-over-TLS (Android Private DNS) traffic on LAN with OpenWrt
iptables -I FORWARD -p tcp --dport 853 -j DROP
iptables -I FORWARD -p udp --dport 853 -j DROP
@milankragujevic
milankragujevic / install-ookla-speedtest.sh
Last active April 26, 2021 23:35
Install Ookla Speedtest script
curl -s https://install.speedtest.net/app/cli/install.deb.sh | sudo bash
sudo apt install -y speedtest
@milankragujevic
milankragujevic / zte-mf238v-reboot.sh
Created September 16, 2020 01:49
Reboot ZTE MF283V from shell
#!/usr/bin/expect
# to enable telnet, log in via web browser then run this command:
# curl "http://192.168.0.1/goform/goform_set_cmd_process" -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "Referer: http://192.168.0.1/index.html" --data "isTest=false&goformId=URL_FILTER_ADD&addURLFilter=http%3A%2F%2Ffakeurl%2F%26%26telnetd%26%26"
# the command is needed to be run only once!
# to disable telnet, factory reset the modem
set timeout 20
set hostName "192.168.0.1"
set port "4719"