Skip to content

Instantly share code, notes, and snippets.

View castironclay's full-sized avatar

castironclay castironclay

View GitHub Profile
@castironclay
castironclay / wireguard_arm_install.sh
Created November 9, 2019 18:56
Install Wireguard on Debian Buster
#!/bin/bash
echo "deb http://deb.debian.org/debian/ unstable main" | sudo tee --append /etc/apt/sources.list.d/unstable.list
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 04EE7237B7D453EC
printf 'Package: *\nPin: release a=unstable\nPin-Priority: 150\n' | sudo tee --append /etc/apt/preferences.d/limit-unstable
sudo apt update
sudo apt install wireguard -y
@castironclay
castironclay / wg_connect.sh
Last active April 14, 2020 23:54
Connect to remote wireguard server and create tunnel
#!/bin/bash
echo Peer IP Address?
read PEERIP
echo Peer Username?
read PEERUSER
echo Peer Password?
read -s PEERPASS
@castironclay
castironclay / nginx_jail_centos8
Last active April 15, 2020 00:32
This will setup nginx on centos8 to run within a jail and includes the geoip2 module. Have your geoip database .mmdb file and nginx module zip file within the same directory as this script.
#!/bin/bash
# Update
yum update -y
yum install epel-release -y
yum update -y
# Create jail directories
D=/nginx
mkdir -p $D
mkdir -p $D/etc
@castironclay
castironclay / gist:5f58b75c8bac0f8efee1c8328604cd0a
Last active September 30, 2020 04:30
OpenSSL Encrypt / Decrypt
# Done on raspberry pi 4
## Linux pi4-master 5.4.51-v7l+ #1333 SMP Mon Aug 10 16:51:40 BST 2020 armv7l GNU/Linux
## OpenSSL 1.1.1d 10 Sep 2019
# Generate Keys
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
ssh-keygen -p -m PEM -f ~/.ssh/id_rsa
ssh-keygen -f id_rsa.pub -e -m PKCS8 > id_rsa.pem.pub
# Create password string
@castironclay
castironclay / cloud_config_hypriot
Created October 17, 2020 19:14
cloud config for hypriot raspberry pi
#cloud-config
# vim: syntax=yaml
#
# Set your hostname here, the manage_etc_hosts will update the hosts file entries as well
hostname: hostname
manage_etc_hosts: true
# You could modify this for your own user information
users:
certbot certonly --register-unsafely-without-email --agree-tos --standalone -d full.dns.name
# Set viewport cookie with js
<script type="text/javascript">
document.cookie = 'viewport=' + screen.width;
</script>
# Nginx location
location / {
# Proxy only Iphone X
if ($cookie_viewport ~ "375") {
proxy_pass 127.0.0.1:8443;
@castironclay
castironclay / zte_send_public_ip_sms.txt
Last active May 10, 2021 00:34
ZTE Send public IP sms
#!/bin/bash
until ping -I usb0 -c 1 192.168.0.1 >/dev/null 2>&1; do sleep 1; done
generate_pub_ip ()
{
current_ip=$(curl ifconfig.io)
first_octet=$(echo $current_ip | awk -F "." '{print $1}')
second_octet=$(echo $current_ip | awk -F "." '{print $2}')
third_octet=$(echo $current_ip | awk -F "." '{print $3}')
fourth_octet=$(echo $current_ip | awk -F "." '{print $4}')
@castironclay
castironclay / zte_run_command
Created May 9, 2021 18:44
Check SMS messages, validate phone number, then run command
#!/bin/bash
APPROVED_SOURCES=(+18008675309)
SOURCE=$(curl -X $'GET' -H $'Host: 192.168.0.1' -H $'Referer: http://192.168.0.1/index.html' -H $'Connection: close' $'http://192.168.0.1/goform/goform_get_cmd_process?isTest=false&cmd=sms_data_total&page=0&data_per_page=500&mem_store=1&tags=10&order_by=order+by+id+desc&_=1620342672308' | jq -r .messages[0].number)
COMMAND=$(curl -X $'GET' -H $'Host: 192.168.0.1' -H $'Referer: http://192.168.0.1/index.html' -H $'Connection: close' $'http://192.168.0.1/goform/goform_get_cmd_process?isTest=false&cmd=sms_data_total&page=0&data_per_page=500&mem_store=1&tags=10&order_by=order+by+id+desc&_=1620342672308' | jq -r .messages[0].content | awk -F "" '{print $4}')
#SOURCE CHECK
if [[ "${APPROVED_SOURCES[@]}" =~ "${SOURCE}" ]]; then
if [[ "${COMMAND}" =~ "1" ]]; then
systemctl start wg-quick@wg0
@castironclay
castironclay / gsm7_decode
Last active May 16, 2021 17:26
Dictionary in bash to decode GSM7 strings
# Resource https://www.bitarray.io/dictionaries-in-bash/
declare -A associative
# Special characters
associative[0021]="!"
associative[0000]="@"
associative[0023]="#"
associative[0002]="$"
associative[0025]="%"