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
  • 23:07 (UTC +01:00)
  • LinkedIn in/jamessawyer12
View GitHub Profile
import socket
class Server(object):
def __init__(self,host,port):
self._host = host
self._port = port
def __enter__(self):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR,1)
sock.bind((self._host,self._port))
@tg12
tg12 / ubuntu_privacy.txt
Created October 4, 2018 13:30
From NCSC Hardening Guide
Ubuntu Privacy
sudo systemctl stop apport.service
sudo systemctl disable apport.service
sudo systemctl mask apport.service
gsettings set com.ubuntu.update-notifier show-apport-crashes false
ubuntu-report -f send no
sudo systemctl stop whoopsie.service
sudo systemctl disable whoopsie.service
sudo systemctl mask whoopsie.service
@tg12
tg12 / basic_iptables.sh
Last active January 9, 2019 20:12
Basic set of IP Table rules for Basic Functionality
# Remove previous rules
iptables -F
iptables -X
iptables -Z
# Set default policies
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -A INPUT -p tcp --dport 22 -m limit --limit 25/minute --limit-burst 100 -j ACCEPT
iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
@tg12
tg12 / merge_ips.py
Last active January 30, 2019 21:00
Start of a lovely script to create iptables
#!/usr/bin/env python
import re
import socket, struct
from ipwhois import IPWhois
from ipaddress import ip_network, ip_address
ips = []
with open("merged-file3") as f:
@tg12
tg12 / create_iptables_rules.py
Last active January 31, 2019 18:59
Create massive firewall with iptables
#!/usr/bin/env python
import re
import socket, struct
import datetime
ips = []
with open("merged-file3") as f:
for line in f:
@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 / 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 / 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 / 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
@tg12
tg12 / sysadmin_script.sh
Last active March 7, 2020 15:39
Ultimate Sysadmin Script, run on fresh install of Ubuntu
#!/bin/bash
#If possible, add something in for choosing [1] Configure Basics [2] Configure Security [3] Configure VMware Tools [4] Configure All. This might require Perl.
#set -x
#read -p "Configure this server to be on 192.168.1.3/24?" yn
#while true; do
#case $yn in
# [Yy]* )
# echo "What IP address will be assigned to this server?"