Skip to content

Instantly share code, notes, and snippets.

View AfroThundr3007730's full-sized avatar
🔧
Hacking all the things...

Eddie Carswell AfroThundr3007730

🔧
Hacking all the things...
View GitHub Profile
@AfroThundr3007730
AfroThundr3007730 / hsts-prime
Created April 21, 2019 23:29
Contents of .well-known web directory for dm4productions.com
Dummy HSTS Priming Target
See https://crbug.com/626180
@AfroThundr3007730
AfroThundr3007730 / 01_users
Created April 16, 2019 06:51
Password protect GRUB configuration
#!/bin/sh -e
cat << EOF
if [ -f \${prefix}/user.cfg ]; then
source \${prefix}/user.cfg
if [ -n "\${GRUB2_PASSWORD}" ]; then
set superusers="root"
export superusers
password_pbkdf2 root \${GRUB2_PASSWORD}
fi
fi
@AfroThundr3007730
AfroThundr3007730 / timer.sh
Last active December 9, 2024 07:21
Bash function to record duration, with concurrent timer support
#!/bin/bash
# Record time duration, concurrent timers
timer() {
[[ $1 =~ ^[0-9]+$ ]] && {
[[ $n -gt $1 ]] || n=$1; local i=$1; shift; }
[[ $1 == -n ]] && { n=$(( n + 1 )); shift; }
[[ $1 == -p ]] && { n=$(( n - 1 )); shift; }
[[ $1 == -c ]] && { local i=$n; shift; }
[[ -n $1 ]] || say -n err 'No timer action specified.'
@AfroThundr3007730
AfroThundr3007730 / say.sh
Last active December 9, 2024 07:21
Bash function to log message and print to stdout
#!/bin/bash
# Log message and print to stdout
# shellcheck disable=SC2059
say() {
export TERM=${TERM:=xterm}
if [[ $1 == -h ]]; then
shift; local s=$1; shift
tput setaf 2; printf "$s\\n" "$@"
else
<Directory "/files/">
IndexOptions Charset=UTF-8 DescriptionWidth=* HTMLTable FancyIndexing FoldersFirst IconsAreLinks IconHeight=16 IconWidth=16 IgnoreCase NameWidth=* SuppressHTMLPreamble SuppressRules XHTML VersionSort
IndexStyleSheet "/assets/css/bootstrap-4.1.3.min.css"
IndexOrderDefault Ascending Name
IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t
HeaderName "/assets/html/HEADER.html"
ReadmeName "/assets/html/README.html"
Options Indexes SymlinksIfOwnerMatch
AllowOverride None
@AfroThundr3007730
AfroThundr3007730 / genpw.ps1
Last active March 31, 2024 20:13
bash and powershell functions to generate strong passwords
# Original version
function New-SecurePassword {
<# .SYNOPSIS
Generates high entropy passwords of configurable length #>
[Alias('genpw')]
Param(
# Length of passwords to genereate
[int]$Length = 20,
# How many passwords to generate
[int]$Count = 5,
@AfroThundr3007730
AfroThundr3007730 / sourceable.ps1
Last active February 21, 2023 21:03
Making executable scripts source-friendly
# This file can be sourced and also executed directly
# Definitions and declarations go here
function main () {
# All action happens here
return 0
}
# Only run if not sourced
@AfroThundr3007730
AfroThundr3007730 / borg-auto.service
Last active May 15, 2023 23:33
Borg automatic backup script for user directory.
# Goes in $HOME/.config/systemd/user/borg-auto.service
[Unit]
Description=Borg backup service
[Service]
Type=simple
Restart=no
ExecStart=%h/.local/bin/borg-auto
[Unit]
Description=Splunk Enterprise
After=network.target
Wants=network.target
[Service]
Type=forking
RemainAfterExit=no
Restart=on-failure
RestartSec=30s
@AfroThundr3007730
AfroThundr3007730 / centos_hardening.sh
Last active October 29, 2018 14:50
Notes on hardening a CentOS box (assuming the STIG policy was selected during install)
#!/bin/bash
# If you selected the STIG config during install, some of these will be configured already.
# All of these are mentioned in the STIG, but some of them must be done manually.
# FIPS all the things.
yum install -y dracut-fips
# Regenerate ramdisk (current kernel)
dracut -f "/boot/initramfs-$(uname -r).img" "$(uname -r)"
# Append 'fips=1' to GRUB_CMDLINE_LINUX
grep 'fips=1' /proc/cmdline ||