Skip to content

Instantly share code, notes, and snippets.

View genothomas's full-sized avatar
🎯
Focusing

Geno Thomas genothomas

🎯
Focusing
View GitHub Profile
@genothomas
genothomas / generate_directory_index_caddystyle.py
Created March 24, 2022 16:27 — forked from glowinthedark/generate_directory_index_caddystyle.py
Generate directory index (recurse subfolders with `-r` or `--recursive`). Use `-h` or `--help` for all options
#!/usr/bin/env python3
# ---
# Copyright 2020 glowinthedark
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
#
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
@genothomas
genothomas / http_multithreaded.py
Created March 24, 2022 16:26 — forked from glowinthedark/http_multithreaded.py
Multi-threaded Python3 HTTP Server
#!/usr/bin/env python3
import sys, os, socket
from socketserver import ThreadingMixIn
from http.server import SimpleHTTPRequestHandler, HTTPServer
HOST = socket.gethostname()
class ThreadingSimpleServer(ThreadingMixIn, HTTPServer):
pass
@genothomas
genothomas / private_fork.md
Created March 10, 2022 22:47
Create a private fork of a public repository

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.

The correct way of creating a private frok by duplicating the repo is documented here.

For this assignment the commands are:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)

git clone --bare [email protected]:usi-systems/easytrace.git

#!/bin/bash
sudo mkdir -p /etc/pki/tls/certs
sudo chmod 755 /etc/pki/tls/certs
sudo apt-get install libssl1.0.0 -y
cd /etc/pki/tls/certs
export FQDN=`hostname -f`
echo -------------------
echo FQDN is $FQDN
#!/bin/bash
#
# using sed begin and end range
#
# then using awk to get Nth match
#
echo "***get only certificate data..."
openssl s_client -showcerts -servername www.google.com -connect www.google.com:443 < /dev/null 2>/dev/null | sed -n '/-----BEGIN CERTIFICATE-----/,/-----END CERTIFICATE-----/p'
#!/bin/bash
#
# Shows how awk can have use embedded bash variable
#
thedir="/tmp"
ls $thedir | awk -v thedir=$thedir '{ printf "directory %s has file %s\n",thedir,$1 }'
#!/bin/bash
#
# validates if key and cert are matched
#
openssl rsa -noout -modulus -in $1 | openssl md5
openssl x509 -noout -modulus -in $2 | openssl md5
echo "if the md5 matches, the key matches the cert"
@genothomas
genothomas / sockping.sh
Created June 22, 2021 06:38 — forked from khmarochos/sockping.sh
To establish a TCP-connection and be keeping it alive
#!/bin/bash
function log {
echo $(date) ' >> ' $* >&2
}
function die {
echo $* >&2
exit 1
}
for dir in $(find /export/secondary2/snapshots -wholename '/export/secondary2/snapshots/*/*' -type d); do { files=$(ls "${dir}" | wc -l); if [[ "${files}" -gt 2 ]]; then echo $dir; ls -tl "${dir}"; for file in $(ls -t "${dir}" | tail --lines +3); do { read -p "Remove ${file}?" -n 1 -r; if [[ "${REPLY}" =~ ^[Yy]$ ]]; then echo " ... removing ${dir}/${file}"; rm "${dir}/${file}"; else echo " ... skipping ${dir}/${file}"; fi; } done; fi; } done
for dir in $(find /export/secondary2/snapshots -wholename '/export/secondary2/snapshots/*/*' -type d -mtime +21); do { if [[ "$(ls ${dir} | wc -l)" -lt 1 ]]; then continue; fi; ls -tl "${dir}"; read -p "Remove ${dir}?" -n 1 -r; if [[ "${REPLY}" =~ ^[Yy]$ ]]; then echo " ... removing ${dir}"; rm -rf "${dir}"; else echo " ... skipping ${dir}"; fi; } done
@genothomas
genothomas / servers
Created June 22, 2021 06:37 — forked from khmarochos/servers
To run a command on a bunch of servers, so you can say: spread.sh --command 'rm -rf / &' --grep-criteria '#centos|#msdos'
#
# The format is following:
# hostname:username:port:ssh-key #comments #tags
# All parameters besides of the first are optional
#
# Regular servers
host1
host2
host3
# The servers where we shall use an alternative username to log in