Skip to content

Instantly share code, notes, and snippets.

View SmugZombie's full-sized avatar

Ron Egli SmugZombie

View GitHub Profile
@SmugZombie
SmugZombie / toISO.js
Created December 28, 2022 19:30
Convert Date/TimeStamp to ISO
function toISO(date) {
// If the date is already an ISO string, return it as-is
if (typeof date === 'string' && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(date)) {
return date;
}
// If the date is a number, assume it's a timestamp and convert it to a Date object
if (typeof date === 'number') {
date = new Date(date);
}
<?php
function defangPayload($payload){
$re = '/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w\-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)/im';
preg_match_all($re, $payload, $matches, PREG_SET_ORDER, 0);
foreach ($matches as $key => $value) {
$payload = str_replace($value[0], preg_replace('/\./', "[.]", $value[0]), $payload);
}
return $payload;
}
function defangPayload(payload){
const re = /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w\-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)/img;
const array = [...str.matchAll(re)];
for (let index = 0; index < array.length; index++) {
payload = payload.replace(array[index][0], array[index][0].replace(/\./g, "[.]"));
}
return payload;
}
@SmugZombie
SmugZombie / docker-monitor.sh
Last active August 12, 2022 19:18
Simple cron script to check to see if a docker container is runnign or not and restarts it if not.
#!/bin/bash
# Docker Monitor v1.3
# Simple cron script to check to see if a docker container is runnign or not and restarts it if not.
# Ron Egli <[email protected]>
# Grab the container name from cli argument
CONTAINER_NAME=$1
if [ -z "$CONTAINER_NAME" ]
then
for i in {1..30}
do
domain="ww$i.propodsmax.co"
dns=$(curl -s "https://beta.digdns.com/api/1.0/getDNS.json?type=1&query=$domain" | awk -F "ip" {'print $2'} | awk -F '"' {'print $3'})
echo $domain - $dns
done
@SmugZombie
SmugZombie / usm-keycheck.sh
Created June 2, 2021 20:43
Hacky way that Allows checking validity of USM licences
licenseKey=$1
string="not validate your key"
response=$(curl --location --request POST -s 'https://offlineupdate.alienvault.com/cgi-bin/auth' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'next=/files/md5.txt' \
--data-urlencode 'key='$licenseKey)
#echo $response
#echo $string
if [[ "$response" == *"$string"* ]]; then
echo "INVALID"
@SmugZombie
SmugZombie / AHK MultiGui
Created March 24, 2021 19:44
Pops 9 Guis in appropriately sized proportions to match your screensize
#SingleInstance, Force
Screen_X := Floor(A_ScreenWidth / 3) ;- 2
Screen_Y := Floor(A_ScreenHeight / 3)
;Msgbox % Screen_X
GUI1_X := 0
GUI1_Y := 0
GUI1_H := Screen_Y
<?php
$conn = mysqli_connect($db_host, $db_user, $db_pwd, $db_name);
function mysql_query($query){
global $conn;
return mysqli_query($conn, $query);
}
function mysql_fetch_assoc($query){
global $conn;
@SmugZombie
SmugZombie / WSL_HostUpdater.sh
Created April 8, 2020 17:47
A simple script used to update WSL Ubuntu with host file entries you may not want Windows to have access to. place a .hosts file in the same working dir as the script it should be formatted like a hosts file as to not break your host resolution
#!/bin/bash
# Ron Egli / github.com/smugzombie
# A simple script used to update WSL Ubuntu with host file entries you may not want Windows to have access to
# place a .hosts file in the same working dir as the script
# - it should be formatted like a hosts file as to not break your host resolution
# Version 1.0
rootcheck () {
# A simple check to force sudo if not already root user. If unable quit.
if [ $(id -u) != "0" ]
@SmugZombie
SmugZombie / SiteGrabber.js
Created March 18, 2020 05:55
Simple script to parse a site name and site domain from a Liquid Web Wordpress Admin Page
// Simple script to parse a site name and site domain from a Liquid Web Wordpress Admin Page
// Ron Egli - github.com/smugzombie
var domainArray = document.getElementsByClassName("domain-details")
var sites = []
for(i=0; i < domainArray.length; i ++){
site_name = document.getElementsByClassName("domain-details")[i].children[0].innerText
site_domain = document.getElementsByClassName("domain-details")[i].children[1].children[0].children[1].innerText