Skip to content

Instantly share code, notes, and snippets.

View hongkongkiwi's full-sized avatar
🤓

Andy hongkongkiwi

🤓
View GitHub Profile
@hongkongkiwi
hongkongkiwi / generate-ssl-certs.sh
Last active April 28, 2023 03:41
Script to generate a Root CA, Intermediate CA and then to sign the Intermediate with the Root.
#!/bin/bash
USER=`id -u -n`
GROUP=`id -g -n`
GENERATE_ROOT_CA_FILE="YES"
GENERATE_CA_DER_FILE="YES"
GENERATE_IM_CA_FILE="YES"
GENERATE_IM_DER_FILE="NO"
GENERATE_DH_FILE="NO"
@hongkongkiwi
hongkongkiwi / download-trust-cert.sh
Last active January 24, 2016 17:28
This script downloads a public certificate from a remote server over SSH and then adds it to the local trust store.
#!/bin/bash
REMOTE_CRT="/etc/ssl/certs/squidCA.crt"
REMOTE_URL="root@192.168.20.1"
FILENAME=`basename "$REMOTE_CRT"`
LOCAL_CRT="/tmp/$FILENAME"
KEYCHAIN="$HOME/Library/Keychains/login.keychain"
# More information about this here:
# http://lists.apple.com/archives/macos-x-server/2008/Feb/msg00187.html
SECURITY_TYPE="trustAsRoot"
@hongkongkiwi
hongkongkiwi / mount_remote
Last active January 28, 2016 14:11
A nice friendly script for mounting a remote linux directory on demand.
#!/bin/bash
VOLUME_NAME="LinuxServer"
REMOTE_USER=`whoami`
REMOTE_SERVER="xx.xx.xx.xx"
MOUNT_DIR="$HOME/$VOLUME_NAME"
REMOTE_DIR="/home/$REMOTE_USER"
SSH_KEY="$HOME/.ssh/id_rsa"
TIMEOUT=5
@hongkongkiwi
hongkongkiwi / import-blacklist-categories.sh
Last active February 3, 2016 07:51
This is a simple script to import many (millions!) of entries from a blacklist file into redis. It first generates the file using redis mass import format, then it pipes that into redis for super fast importing.
#!/bin/bash
FILE="CATEGORIES"
REDIS_KEY="categories"
while read line; do
category=`echo "$line" | cut -f1 -d'-'`
description=`echo "$line" | cut -f2 -d'-'`
redis-cli hset "$REDIS_KEY" "$category" "$description"
done < "$FILE"
var request = require('request');
var url1 = 'http://vanamco.com/ghostlab/';
//var url = 'http://httpbin.org/get';
var proxyUrl = 'http://127.0.0.1:3128';
var proxiedRequest = request.defaults({'proxy': proxyUrl});
console.log('Making a test request to',url1);
proxiedRequest(url1, function (error, response, body) {
#
# Recommended minimum configuration:
#
cache_effective_user squid
cache_effective_group wheel
# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
@hongkongkiwi
hongkongkiwi / open-port-test
Created February 8, 2016 09:45
Simple bash script to test whether a port is open or closed. It's a good alternative to telnet.
#!/bin/ash
NETCAT="netcat"
if [[ "$2" == "" || "$1" == "" ]]; then
echo "Invalid port or ip!"
echo "USAGE: $0 ip port"
exit 0
fi
@hongkongkiwi
hongkongkiwi / firewall-start
Last active April 22, 2023 13:52
Bash script to allow some ports on Asus routers running Merlin firmware. This should be put in your /jffs/scripts and made executable (chmod +x /jffs/scripts/firewall-start). Now handles duplicate rules (it won't add again) and inserting before any final DROP in the INPUT chain. Quite useful ;)
#!/bin/sh
DEBUG="NO"
LOGGER_NAME="firewall"
PORTS="tcp:9443"
WAN="$1"
log() {
if [ "$DEBUG" == "YES" ]; then
echo "$1"
@hongkongkiwi
hongkongkiwi / shadowsocks-ddns
Last active April 25, 2018 11:25
A wrapper script to setup shadowsocks using a ddns host. This sort of requires that your domain is reachable using the non-relayed DNS servers.
#!/bin/bash
USAGE="USAGE: $0 server config.json"
SERVER="$1"
CONFIG="$2"
PID_DIR="/var/run"
SS_LOCAL_PID="$PID_DIR/ss-local.pid"
SS_TUNNEL_PID="$PID_DIR/ss-tunnel.pid"
DNS_FORWARD_REMOTE="8.8.8.8:53"
@hongkongkiwi
hongkongkiwi / generate-ssh-key
Last active December 18, 2023 07:45
Simple one liner to generate an SSH key without a password in the default place with the comment as hostname then print out the public key for copy and paste.
HOSTNAME=`hostname` ssh-keygen -t rsa -C "$HOSTNAME" -f "$HOME/.ssh/id_rsa" -P "" && cat ~/.ssh/id_rsa.pub