Skip to content

Instantly share code, notes, and snippets.

View rossigee's full-sized avatar

Ross Golder rossigee

View GitHub Profile
@rossigee
rossigee / gist:a01d16b37cbb17d19dbff46dcdbf294c
Created July 12, 2024 09:50
RouterOS7 Base64 string decoding function
:global int2chr do={
:local symbolsHex {"\00";"\01";"\02";"\03";"\04";"\05";"\06";"\07";"\08";"\09";"\0A";"\0B";"\0C";"\0D";"\0E";"\0F";"\10";"\11";"\12";"\13";"\14";"\15";"\16";"\17";"\18";"\19";"\1A";"\1B";"\1C";"\1D";"\1E";"\1F";"\20";"\21";"\22";"\23";"\24";"\25";"\26";"\27";"\28";"\29";"\2A";"\2B";"\2C";"\2D";"\2E";"\2F";"\30";"\31";"\32";"\33";"\34";"\35";"\36";"\37";"\38";"\39";"\3A";"\3B";"\3C";"\3D";"\3E";"\3F";"\40";"\41";"\42";"\43";"\44";"\45";"\46";"\47";"\48";"\49";"\4A";"\4B";"\4C";"\4D";"\4E";"\4F";"\50";"\51";"\52";"\53";"\54";"\55";"\56";"\57";"\58";"\59";"\5A";"\5B";"\5C";"\5D";"\5E";"\5F";"\60";"\61";"\62";"\63";"\64";"\65";"\66";"\67";"\68";"\69";"\6A";"\6B";"\6C";"\6D";"\6E";"\6F";"\70";"\71";"\72";"\73";"\74";"\75";"\76";"\77";"\78";"\79";"\7A";"\7B";"\7C";"\7D";"\7E";"\7F";"\80";"\81";"\82";"\83";"\84";"\85";"\86";"\87";"\88";"\89";"\8A";"\8B";"\8C";"\8D";"\8E";"\8F";"\90";"\91";"\92";"\93";"\94";"\95";"\96";"\97";"\98";"\99";"\9A";"\9B";"\9C";"\9D";"\9E";"\9F";"\A0";"\A1";"\A2";"\
@rossigee
rossigee / reportDynamicIPChanged.txt
Last active January 10, 2024 13:21
RouterOS raise HTTP event when dynamic IP address changes
:global previousIP 1.2.3.4
:global ipAddressCheckURL "http://ifconfig.me/ip"
# or... :global ipAddressCheckURL "http://icanhazip.com"
:global ipChangedEventURL "https://webhook.site/12345678-9610-4f57-9bfe-a3c5e2551d26"
/system/script/add name=reportDynamicIPChanged source={
:global ipAddressCheckURL
:global ipChangedEventURL
:local result [/tool fetch url=$ipAddressCheckURL mode=http as-value output=user];
:if ($result->"status" = "finished") do={
:local currentIP ($result->"data");
@rossigee
rossigee / wg-watch.sh
Created November 18, 2023 08:54
Bash script to manage Wireguard dynamic IP endpoint
#!/usr/bin/env bash
# Settings
WG_IFACE=wg0
WG_PEER=<peer_id>
WG_PORT=12345
HOSTNAME=yourhostname.dynamicip.example.com
# File to store the last IP
last_ip_file="/tmp/last_ip.txt"
@rossigee
rossigee / custom_parsers.conf
Created October 2, 2023 23:13
Custom fluent-bit parsers for Ubuntu 20.04+
[PARSER]
Name ubuntu-syslog-with-pid
Format regex
Regex /^(?<timestamp>\S+\s+\d{1,2}\s+\d{2}:\d{2}:\d{2})\s(?<hostname>\S+)\s(?<process>\S+)\[(?<pid>\d+)\]:\s(?<message>.*)$/
Time_Key time
Time_Format %b %d %H:%M:%S
Time_Keep On
[PARSER]
Name ubuntu-syslog-without-pid
@rossigee
rossigee / gist:05048dae301864d180773f3d31208c24
Created September 6, 2023 07:42
Fetch Windows Administrator password from EC2 using Terragrunt/Terraform state
#!/usr/bin/env bash
#
# Run this in the Terraform folder for the instance to reconstruct the Administator password.
#
# Example usage:
#
# get-windows-administrator-password
#
INSTANCE_ID=$1
@rossigee
rossigee / gist:052ff68cd59b32df7f78b3b7234b5c3b
Last active August 25, 2023 04:46
Some fluent-bit parsers for RFC3134 parsing of Mikrotik logs
[PARSER]
Name syslog-rfc3164-safe
Format regex
Regex /\<(?<pri>[0-9]+)\>(?<time>\w{3}\s+\d+\s\d{2}:\d{2}:\d{2})\s(?<host>[^ ]*)\s(?<ident>[a-zA-Z0-9_\/\.\-\+,]*)(\[(?<pid>\d+)\])*:?\s(?<message>.*)/
Time_Key time
Time_Format %b %d %H:%M:%S
Time_Keep On
[PARSER]
Name ssh_access_logs_mikrotik
@rossigee
rossigee / gist:7ce48ece0d0c2e28893235579bb48b68
Last active August 24, 2023 03:27
Lua hack for RFC3164 timestamps
-- Hack to workaround lack of precision in RFC3164 dates.
require "os"
function rfc3164_to_timestamp(rfc3164_log)
local month_names = {
Jan = "01", Feb = "02", Mar = "03", Apr = "04",
May = "05", Jun = "06", Jul = "07", Aug = "08",
Sep = "09", Oct = "10", Nov = "11", Dec = "12"
}
import os
import requests
def get_ipam_addresses(api_url, token, ca_cert):
headers = {
'Authorization': f'Token {token}',
'Content-Type': 'application/json'
}
# Fetch all IP addresses from NetBox
@rossigee
rossigee / main.go
Created November 13, 2021 01:56
OpenVPN AS XMLRPC client
package main
import (
"fmt"
"net"
"net/http"
"alexejk.io/go-xmlrpc"
)
@rossigee
rossigee / deploy-docker-and-compose.sh
Last active March 14, 2020 04:14
A quick curlable to deploy docker engine and docker-compose.
#!/bin/bash
export LC_ALL=C
export DEBIAN_FRONTEND=noninteractive
# Install Docker engine
echo "Installing docker engine..."
apt -q install --assume-yes \
apt-transport-https \
ca-certificates \