Skip to content

Instantly share code, notes, and snippets.

View castironclay's full-sized avatar

castironclay castironclay

View GitHub Profile
@castironclay
castironclay / ansible_MCT.txt
Created January 15, 2023 03:43
ansibe hosts using master control sockets
- name: Add frontend host
hosts: localhost
tasks:
- name: Create master control socket
shell:
cmd: "sshpass -p '{{ backend_password }}' ssh -fN -M -S /tmp/{{ backend_ip }} {{ backend_username }}@{{ backend_ip }}"
executable: /bin/bash
- name: Add frontend
add_host:
@castironclay
castironclay / files
Last active December 13, 2022 02:29
5 containers split between networks
## .env
IMAGE=debian:buster
## docker-compose.yml
services:
container1:
image: $IMAGE
command: /bin/bash -c "while true; do echo 'alive' && sleep 60; done"
networks:
network1:
@castironclay
castironclay / commands.txt
Last active August 26, 2021 21:26
GL-MiFi commands
# Get admin token
SERVER_IP=X.X.X.X
PASS=root_password
TARGET_NUMBER=number_without_country_code
WIREGUARD_SERVER=Home
TOKEN=$(curl -s -k -X POST --data-binary pwd=${PASS} "https://${SERVER_IP}/cgi-bin/api/router/login" | jq -r .token)
echo $TOKEN
# List messages
#!/bin/bash
##
# Color Variables
##
green='\e[32m'
blue='\e[34m'
clear='\e[0m'
##
FROM debian:stable-slim
MAINTAINER castironclay
ARG TERRAFORM=1.0.0
ARG CLOUDFLARED=2021.5.10
# Backports
RUN echo 'deb http://deb.debian.org/debian buster-backports main contrib non-free' > /etc/apt/sources.list.d/buster-backports.list
# Install deps and Wireguard
@castironclay
castironclay / setup.sh
Last active May 21, 2021 20:59
Raspberry pi waveshare gsm/gprs/gnss/bluetooth
# Pi Setup
apt update -y
apt upgrade -y
## Install Dependencies
apt install gpsd gpsd-clients wget curl screen vim wireguard
## Modify /etc/default/gpsd
DEVICES="/dev/ttyUSB0"
@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]="%"
@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 / 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}')
# 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;