Skip to content

Instantly share code, notes, and snippets.

@CodeShane
CodeShane / log.sh
Created November 30, 2021 17:10
Timestamped Journal in bash
#!/usr/bin/env bash
# Copyright (c) 2021 Shane Robinson
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
@CodeShane
CodeShane / windows_hardening.cmd
Created September 7, 2021 01:34 — forked from mackwage/windows_hardening.cmd
Script to perform some hardening of Windows OS
:: Windows 10 Hardening Script
:: This is based mostly on my own personal research and testing. My objective is to secure/harden Windows 10 as much as possible while not impacting usability at all. (Think being able to run on this computer's of family members so secure them but not increase the chances of them having to call you to troubleshoot something related to it later on). References for virtually all settings can be found at the bottom. Just before the references section, you will always find several security settings commented out as they could lead to compatibility issues in common consumer setups but they're worth considering.
:: Obligatory 'views are my own'. :)
:: Thank you @jaredhaight for the Win Firewall config recommendations!
:: Thank you @ricardojba for the DLL Safe Order Search reg key!
:: Thank you @jessicaknotts for the help on testing Exploit Guard configs and checking privacy settings!
:: Best script I've found for Debloating Windows 10: https://github.com/Sycnex/Windows10Debloater
:

Unofficial Bash Strict Mode

Sometimes a programming language has a "strict mode" to restrict unsafe constructs. E.g., Perl has use strict, Javascript has "use strict", and Visual Basic has Option Strict. But what about bash? Well, bash doesn't have a strict mode as such, but it does have an unofficial strict mode:

set -euo pipefail

set -e

@CodeShane
CodeShane / unit.sh
Created June 24, 2021 21:27 — forked from tvlooy/unit.sh
Bash test: get the directory of a script
#!/bin/bash
function test {
MESSAGE=$1
RECEIVED=$2
EXPECTED=$3
if [ "$RECEIVED" = "$EXPECTED" ]; then
echo -e "\033[32m✔︎ Tested $MESSAGE"
else
@CodeShane
CodeShane / unit.sh
Created June 24, 2021 21:26 — forked from ptc-mrucci/unit.sh
Bash test: get the directory of a script
#!/bin/bash
tmp=$(python -c "import os, sys; print(os.path.realpath('/tmp'))")
function test {
MESSAGE=$1
RECEIVED=$2
EXPECTED=$3
if [ "$RECEIVED" = "$EXPECTED" ]; then
@CodeShane
CodeShane / iptables-reload.sh
Created July 14, 2020 17:37 — forked from tehmoon/iptables-reload.sh
IPtables and docker reload!
#!/bin/sh
set -e
## SEE https://medium.com/@ebuschini/iptables-and-docker-95e2496f0b45
CWD=$(cd "$(dirname "${0}")"; pwd -P)
FILE="${CWD}/$(basename "${0}")"
chown root:root "${FILE}"
chmod o-rwx "${FILE}"
@CodeShane
CodeShane / svn.md
Created May 25, 2020 22:24 — forked from kidpixo/svn.md
Subversion Cheatsheet in Multimardkdown
@CodeShane
CodeShane / ca.md
Created May 13, 2020 16:37 — forked from soarez/ca.md
How to setup your own CA with OpenSSL

How to setup your own CA with OpenSSL

For educational reasons I've decided to create my own CA. Here is what I learned.

First things first

Lets get some context first.

@CodeShane
CodeShane / devops_best_practices.md
Created February 16, 2020 18:44 — forked from jpswade/devops_best_practices.md
Devops Best Practices Checklist

Find the original here article here: Devops Best Practices

DevOps started out as "Agile Systems Administration". In 2008, Andrew Shafer did a talk called "Agile Infrastucture" addressing issues around involving more of the company in the same disciplines as programmers.

In 2009, Patrick Debois created "DevOpsDays" conference to help to bring it to light. However, it wouldn't begin to trend until about 2010, when people would begin to describe it as a standalone discipline.

Today, DevOps goes beyond just developers, systems administration and infrastructure, its about [dev, ops, agile, cloud