Skip to content

Instantly share code, notes, and snippets.

View tg12's full-sized avatar
🏠
Working from home

tg12 tg12

🏠
Working from home
  • 36Hs6atY4XDwS8AK6qcSLtyVLCqX85fm1w
  • Earth
  • 00:32 (UTC +01:00)
  • LinkedIn in/jamessawyer12
View GitHub Profile
@tg12
tg12 / RouteOptima.ps1
Created March 7, 2024 19:51
A PowerShell script that identifies the interface with the default Internet route, sets it to the highest priority, and verifies connectivity by pinging Google.
# Identify the interface with the default route to the Internet (0.0.0.0 route)
$defaultRoute = Get-NetRoute -DestinationPrefix "0.0.0.0/0" | Sort-Object -Property RouteMetric | Select-Object -First 1
$interfaceIndex = $defaultRoute.InterfaceIndex
# Retrieve all network interfaces
$interfaces = Get-NetIPInterface -AddressFamily IPv4
# Set the priority for the interface with the default route to the highest (lowest metric)
foreach ($interface in $interfaces) {
if ($interface.InterfaceIndex -eq $interfaceIndex) {
@tg12
tg12 / Dockerfile Template
Created January 17, 2024 15:00
Dockerfile Template
# Use Python 3.12 slim image
FROM python:3.12.1-slim
# Set Environment Variables
ENV PYTHONUNBUFFERED=1 \
TZ=Europe/London
ENV PYTHONOPTIMIZE=TRUE
ENV PYTHONMALLOC=malloc
@tg12
tg12 / remove_expiredcerts.ps1
Created April 15, 2021 08:20
Remove all Expired Certs on a Windows Machine
# """THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
# NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE
# DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY,
# WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE."""
# Bitcoin Cash (BCH) qpz32c4lg7x7lnk9jg6qg7s4uavdce89myax5v5nuk
@tg12
tg12 / dscp-class ef
Created January 30, 2021 10:05
iptables -t mangle -A OUTPUT -p udp -j DSCP --set-dscp-class ef
iptables -t mangle -A OUTPUT -p udp -j DSCP --set-dscp-class ef
root@raspberrypi:~# iptables -t nat -L
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
Chain INPUT (policy ACCEPT)
target prot opt source destination
@tg12
tg12 / new_setup.sh
Last active May 20, 2022 21:09
New Install of Ubuntu or similar
apt update
apt upgrade -y
apt install linux-xanmod-edge -y
apt install glances htop nmap bleachbit git python3-pip iperf3 easy-rsa iptables-persistent tuned neofetch net-tools fail2ban ntpdate ntp ntpstat -y
service tuned start
tuned-adm list
tuned-adm profile throughput-performance
service tuned restart
apt autoclean -y
@tg12
tg12 / ntp.conf
Created August 10, 2019 13:47
My ntp.conf
# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help
driftfile /var/lib/ntp/ntp.drift
logfile /var/log/ntp.log
# Enable this if you want statistics to be logged.
#statsdir /var/log/ntpstats/
statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
@tg12
tg12 / samba_shares.txt
Created August 9, 2019 13:39
samba shares
sudo fdisk -l
sudo mkdir /media/USBHDD
sudo mkdir /media/USBHDD/share
sudo chmod -R 777 /media/USBHDD/share
sudo mount -t auto /dev/sda1 /media/USBHDD
sudo apt-get install samba samba-common-bin
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.old
sudo nano /etc/samba/smb.conf
@tg12
tg12 / reddit_crosspost_bot.py
Last active July 5, 2021 10:10
Crosspost the best to the best on Reddit
import time
import praw
import sqlite3
from random import randint
from time import sleep
# FROMSUB = "cyber" # The subreddit you want to take posts from
# TOSUBS = ["cyber_security", "cyberlaws", "security", "privacy",
# "netsec", "technology", "computerforensics", "ComputerSecurity"] # The
# subreddits you want to post to
@tg12
tg12 / margin_req_notes.txt
Created May 22, 2019 13:14
Margin Requirement Notes vs Average Price
Avg Price Mar Req 1/pt 2/pt 3/pt
20 4.2 4.2 8.4 12.6
30 6.3 6.3 12.6 18.9
50 10.5 10.5 21 31.5
70 14.7 14.7 29.4 44.1
85 17.85 17.85 35.7 53.55
102 21.42 21.42 42.84 64.26
119 24.99 24.99 49.98 74.97
136 28.56 28.56 57.12 85.68
153 32.13 32.13 64.26 96.39
@tg12
tg12 / ftp_check.py
Last active August 27, 2019 19:51
Fast Multi-threaded FTP Scanner
from datetime import datetime
import time
import threading
###########################
from multiprocessing import Process
import random
###########################
import dns.resolver
import dns.reversename
import ftplib