Skip to content

Instantly share code, notes, and snippets.

View NotoriousPyro's full-sized avatar

NotoriousPyro

View GitHub Profile
@NotoriousPyro
NotoriousPyro / factorio-server.sh
Last active May 11, 2017 17:45
Place anywhere, then edit the file to configure it. Then run it like so: ./factorio-server.sh [update|start|stop|restart]
#!/bin/bash
# Config
working_dir="/opt/factorio-server"
factorio="bin/x64/factorio"
start_cmd="systemctl start factorio-server"
stop_cmd="systemctl stop factorio-server"
# End config
# Variables
@NotoriousPyro
NotoriousPyro / iptables-spamhaus.sh
Last active May 11, 2017 17:43
Spam IP blocker for iptables and bash (list by spamhaus.org). See how to use this here: https://pyronexus.com/2017/01/11/blocking-spammers-with-bash-and-iptables/
#!/usr/bin/env bash
# List variables
blocklist_name="Spamhaus" # MUST BE UNIQUE IN IPTABLES
blocklist="http://www.spamhaus.org/drop/drop.lasso"
# No more variables. Edit below here at your own risk.
PATH="/sbin:$PATH"
printf "Retrieving block list: %s... " "$blocklist"
list=`curl -sSL "$blocklist" | cut -d ";" -f 1 | grep -v "^$"`
#!/usr/bin/env bash
blocklist="http://pgl.yoyo.org/adservers/serverlist.php?hostformat=squid-dstdom-regex&showintro=0&startdate%5Bday%5D=&startdate%5Bmonth%5D=&startdate%5Byear%5D=&mimetype=plaintext"
blocklist_savefile="/etc/squid/adblock.list"
printf "Retrieving block list... "
curl -sSL "$blocklist" > $blocklist_savefile && printf "Done\n\n"
printf "Reloading squid... "
squid -k reconfigure && printf "Done\n"
@NotoriousPyro
NotoriousPyro / openvpn-dnsupdate.sh
Last active June 3, 2017 18:22
OpenVPN DNS update (learn-address) for OpenWrt (Can be changed to support others) - Requires knot-nsupdate and knot-dig
#!/usr/bin/env ash
# For use with OpenVPN learn-address (and other things you adapt it to)
# Takes the following as paramters:
# openvpn-dnsupdate.sh operation address hostname
# Example: openvpn-dnsupdate.sh update 10.8.1.50 test.pyronexus.lan
# This creates an A record and a PTR for the IP 10.8.1.50 to test.pyronexus.lan
# This will replace any hostname provided by OpenVPN and will rewrite it to your FWDZONE specified below.
# E.g. test.test.pyronexus.com would be rewritten to test.vpn.pyronexus.lan with the config below.
@NotoriousPyro
NotoriousPyro / server.conf
Last active June 12, 2017 20:14
OpenVPN Server Configuration for pkcs12, tlsauth, SHA256 and AES-256-CBC/GCM, client address pool, address reservation, client-to-client, domain and DNS
# Service
mode server
proto udp
port 1194
persist-key 1
fast-io 1
float 1
verb 3
mute-replay-warnings 1
script-security 3
client
remote gateway.pyronexus.com 1194
proto udp
dev tun0
resolv-retry infinite
pkcs12 MyClientCertificate.p12
verify-x509-name 'C=GB, ST=Merseyside, L=Liverpool, O=PyroNexus, OU=PyroNexus.com, CN=gateway.pyronexus.com, emailAddress=craigcrawford1988@gmail.com'
cipher AES-256-CBC
auth SHA256
nobind
@NotoriousPyro
NotoriousPyro / session-shadow.bat
Last active December 9, 2021 12:01
RDP Session Shadow Batch file. Accepts --noping as a parameter. Works well with RDP Wrapper. Should only be used with Windows 10 onwards.
@ECHO OFF
MODE CON:COLS=80 LINES=40
COLOR 1A
SETLOCAL EnableDelayedExpansion
:ENTRY
CLS
CALL :PRINTBAR
ECHO ^| RDP Session Shadow Version 2.0 ^|
ECHO ^| By Craig Crawford ^|
ECHO ^|------------------------------------------------------------------------------^|
@NotoriousPyro
NotoriousPyro / ProfilesCMD.bat
Last active August 18, 2017 18:59
This is a pretty dirty way to delete local profiles but it works. It copies the Default and Public profiles to C:\Users.Default\, then wipes the whole registry keys out and re-creates the defaults. Then it copies the Default and Public folders back into a new Users folder. Robocopy ensures that the permissions and attributes are set the same, bu…
@ECHO OFF
echo Batch profile deleter
set /p PCNAME="PC:"
psexec \\%PCNAME% -s robocopy "C:\Users\Default" "C:\Users.Default\Default" /XJ /E
psexec \\%PCNAME% -s robocopy "C:\Users\Public" "C:\Users.Default\Public" /XJ /E
reg delete "\\%PCNAME%\HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileGuid" /f
reg delete "\\%PCNAME%\HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" /f
@NotoriousPyro
NotoriousPyro / ProfilesPS.bat
Last active August 18, 2021 09:54
This is a PowerShell script I developed to delete all local profiles off the target PC that aren't: loaded, special (system profiles), have never been logged into, and that have not been used for more than 1 day. The last parameter is configurable via -lt (Get-Date).AddDays(-1)). It will safely delete profiles to avoid system issues such as loca…
@ECHO OFF
echo Powershell profile deleter
set /p PCNAME="PC:"
Powershell -Mta -NoProfile -Command "& {Get-WmiObject Win32_UserProfile -Computer %PCNAME% | Where {(!$_.Special) -and (!$_.Loaded) -and ($_.LastUseTime -ne $null) -and ($_.ConvertToDateTime($_.LastUseTime) -lt (Get-Date).AddDays(-1))} | Remove-WmiObject -Verbose}"
pause
@NotoriousPyro
NotoriousPyro / SQLite-to-MariaDB-TS3fixes.sh
Last active September 15, 2017 15:46
Fixes a few problems when converting SQLite to MariaDB/MySQL DB using the script at https://github.com/NotoriousPyro/SQLite-to-MariaDB-MySQL-perl-script
#!/usr/bin/env bash
file="$1"
if [ -z "$file" ]; then
echo "No filename specified. Aborted."
exit 1
fi
sed -i '/TABLE channel_properties/,/);/d' $file