Skip to content

Instantly share code, notes, and snippets.

@saudiqbal
saudiqbal / add-multiple-ipv6.sh
Last active December 18, 2023 16:39
Add multiple IPv6 address on prefix change.
#!/bin/bash
IPv6PrefixFile=$HOME/IPv6Prefix.txt
IPv6Prefix=$(cat $IPv6PrefixFile)
__rfc5952_expand () {
read addr mask < <(IFS=/; echo $1)
quads=$(grep -oE "[a-fA-F0-9]{1,4}" <<< ${addr/\/*} | wc -l)
grep -qs ":$" <<< $addr && { addr="${addr}0000"; (( quads++ )); }
grep -qs "^:" <<< $addr && { addr="0000${addr}"; (( quads++ )); }
@saudiqbal
saudiqbal / gist:61a0eee2faf9e675ed29474ff9530582
Created November 10, 2023 02:42
Dynamic DNS IPv6 prefix
IPv6 home server with dynamic prefix for VPN, Web Server, RDP and Firewall setup guide
IPv6 is the new successor to legacy IPv4 which overcomes the shortages of IPv4 addresses since it only contains 4,294,967,296 IP addresses where as the smallest IPv6 block which is a /64 has 18,446,744,073,709,551,616 IPv6 addresses. The world is running out of IPv4 addresses and more and more ISPs are moving towards CGNAT (Carrier Grade Network Address Translation) which means instead of a public IPv4 address a private IPv4 address is assigned to users where services hosted on home does not work. If you are planning on setting up a server or remote access to your home or office using IPv6 then this guide is for you.
Preparing your device.
Windows
Windows uses IPv6 privacy extension where it uses a temporary IPv6 address which changes every couple of hours. To force Windows to use a static address create a new file as disable_temp_ipv6.bat and paste these lines
netsh interface ipv6 set global randomizeidentifiers=disabl
@saudiqbal
saudiqbal / gist:fb567cf058f4b2b87c7b4e78ea7b9e66
Last active November 13, 2023 01:49
Dynamic DNS bash script for IPv6 prefix using DHCPv6
#!/bin/bash
# Create an empty file first at $HOME/ddns-ipv6-address.txt with a 0 in it.
ADDRSTORE=$HOME/ddns-ipv6-address.txt
__rfc5952_expand () {
read addr mask < <(IFS=/; echo $1)
quads=$(grep -oE "[a-fA-F0-9]{1,4}" <<< ${addr/\/*} | wc -l)
grep -qs ":$" <<< $addr && { addr="${addr}0000"; (( quads++ )); }
grep -qs "^:" <<< $addr && { addr="0000${addr}"; (( quads++ )); }
[ $quads -lt 8 ] && addr=${addr/::/:$(for (( i=1; i<=$(( 8 - quads )) ; i++ )); do printf "0000:"; done)}
@saudiqbal
saudiqbal / gist:9adbaa44a40a02cc4f0cdf28c62c56c8
Last active November 13, 2023 01:49
Dynamic DNS bash script for IPv6 prefix using token
#!/bin/bash
# Create an empty file first at $HOME/ddns-ipv6-address.txt with a 0 in it.
SUFFIX="::71c6:b34f:8e2a:54f5"
ADDRSTORE=$HOME/ddns-ipv6-address.txt
STOREDIPV6=$(cat $ADDRSTORE)
__rfc5952_expand () {
read addr mask < <(IFS=/; echo $1)
quads=$(grep -oE "[a-fA-F0-9]{1,4}" <<< ${addr/\/*} | wc -l)
grep -qs ":$" <<< $addr && { addr="${addr}0000"; (( quads++ )); }
@saudiqbal
saudiqbal / password-protected-page.php
Last active November 10, 2023 17:50
PHP password protect single page script with multiple users
<?php
$user_info=[
'admin'=>['adminpassword','ynNYKWngfgW8gI0WX72g1tRq0RLpDiNz'],
'root'=>['rootpassword','16n2VZKFLI3inP3xS1dfdoY60pCOhFIZ'],
'manager'=>['managerpassword','ML7IZ0updvFCKtcdEECBf6qCmnX8u4lB']
];
if (!isset($_COOKIE['token']))
{
$login = true;
}
@saudiqbal
saudiqbal / nftables.conf
Last active May 26, 2024 16:39
Ocserv OpenConnect VPN firewall rules for Nftables
#!/usr/sbin/nft -f
flush ruleset
# ----- IPv4 -----
table ip filter {
chain input {
type filter hook input priority 0;
# accept traffic originated from us
ct state {established, related} accept
@saudiqbal
saudiqbal / port-check.php
Created August 24, 2020 22:23
PHP Port Checker
<!DOCTYPE html>
<html>
<head>
<title>Port Scanner</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="user-scalable=yes, initial-scale=1, width=device-width" />
<style>
body {
background: #f4f4f4;
width:100%;
@saudiqbal
saudiqbal / dynamic_ipv6_update.sh
Created March 12, 2019 00:07 — forked from Callumpy/dynamic_ipv6_update.sh
Dynamic IPv6 Firewall Update Script for OpenWRT
#!/bin/sh
# CONFIGURABLE PARAMETER: PREFIX
# Set the prefix to the name of the rules that need to be updated. (Can update multiple rules with same name)
PREFIX=Web-ServerIPv6
PREFIX_LEN=${#PREFIX}
# CONFIGURABLE PARAMETER: getIP
# Set your method of getting IPv6 address in here
# Current method is through ip neighbor with MAC address (Lowercase, :)(getIP=$(ip neighbor | grep "Your MAC Here" | grep -v "STALE" | cut -d" " -f1))
@saudiqbal
saudiqbal / port_scanner.php
Created June 3, 2018 05:58 — forked from akalongman/port_scanner.php
Port scanner on PHP
<?php
ini_set('max_execution_time', 0);
ini_set('memory_limit', -1);
$host = 'google.com';
$ports = array(21, 25, 80, 81, 110, 143, 443, 587, 2525, 3306);
foreach ($ports as $port)
{
$connection = @fsockopen($host, $port, $errno, $errstr, 2);