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 / utils.common.sh
Last active April 12, 2024 23:40
Collection of utility functions for bash scripts
#!/bin/bash
# Collection of utility functions for bash scripts
# Version 0.6.4 modified 2024-04-12 by AfroThundr
# SPDX-License-Identifier: GPL-3.0-or-later
#
# For issues or updated versions of this script, browse to the following URL:
# https://gist.github.com/AfroThundr3007730/b761bd1a6b2f32a2e97727c7e049e354
# Take caution sourcing this file in your shell, as it uses strict mode.
#----------------------------------------------------------------------#
@AfroThundr3007730
AfroThundr3007730 / add-dod-certs.sh
Last active April 12, 2024 21:03
Import DoD root certificates into linux CA store
#!/bin/bash
# Import DoD root certificates into linux CA store
# Version 0.3.0 updated 20240304
# SPDX-License-Identifier: GPL-3.0-or-later
add_dod_certs() {
local bundle cert certdir file form tmpdir url update
# Location of bundle from DISA site
url='https://public.cyber.mil/pki-pke/pkipke-document-library/'
bundle=$(curl -s $url | awk -F '"' 'tolower($2) ~ /dod.zip/ {print $2}')
@AfroThundr3007730
AfroThundr3007730 / Rocky_9_STIG_notes.md
Created April 11, 2024 19:15
Notes on getting Rocky 9 compliant with DISA STIGs

Rocky 9 STIG notes

RHEL-09-211045: Red Hat Enterprise Linux 9 Security Technical Implementation Guide :: Version 1, Release: 2 Benchmark Date: 24 Jan 2024

Updated on 2024-04-05

Utilities

All fix and check commands must be run as root.

@AfroThundr3007730
AfroThundr3007730 / sysprep_linux.sh
Last active April 9, 2024 20:35
Cloning preparation script for linux systems.
#!/bin/bash
# Does the equivalent of sysprep for linux boxes to prepare them for cloning.
# Based on https://lonesysadmin.net/2013/03/26/preparing-linux-template-vms/
# For issues or updated versions of this script, browse to the following URL:
# https://gist.github.com/AfroThundr3007730/ff5229c5b1f9a018091b14ceac95aa55
# SPDX-License-Identifier: GPL-3.0-or-later
AUTHOR='AfroThundr'
BASENAME="${0##*/}"
MODIFIED='20240409'
@AfroThundr3007730
AfroThundr3007730 / HelperFunctions.psm1
Last active April 7, 2024 22:16
Collection of helpful bash and powershell functions (most are in my other gists).
# Last updated 20240331 by AfroThundr
# SPDX-License-Identifier: GPL-3.0-or-later
Set-StrictMode -Version Latest
#region Internal Variables
$DefaultPSProfileContent = @'
# Note: This profile stub is automatically overwritten, make changes instead in profile_local.ps1
# Always use strict mode
Set-StrictMode -Version Latest
@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 / Get-StringPermutations.ps1
Last active March 31, 2024 19:45
Gets recursive unique combinations of characters in a string
function Get-StringPermutations {
<# .SYNOPSIS
Calculates the permutations of an input string #>
[Alias('permutate')]
Param(
# String to calculate permutations from
[Parameter(Mandatory)]
[String]$String,
# Return only unique permutations
[Parameter()]
@AfroThundr3007730
AfroThundr3007730 / Logoff-InactiveUsers.ps1
Last active March 31, 2024 19:40
Logoff inactive user sessions after 2 days
# Version 1
$idleDays = 2
$users = (((query user) -replace '^>', '') -replace '\s{2,}', ',').Trim() |
ForEach-Object {
if ($_.Split(',').Count -eq 5) {
Write-Output ($_ -replace '(^[^,]+)', '$1,')
}
else {
Write-Output $_
@AfroThundr3007730
AfroThundr3007730 / Get-RunningTasks.ps1
Created March 25, 2021 20:31
Get a running list of active VITasks
function Get-RunningTasks() {
while ((Get-Task | Where-Object { $_.state -eq 'running' }).count -gt 0) {
Get-Task | Where-Object { $_.state -eq 'running' } |
Sort-Object name, percentcomplete |
Format-Table Name, State, PercentComplete, StartTime,
@{ L = 'Target'; E = { $_.ExtensionData.Info.EntityName } },
@{ L = 'Initiator'; E = { $_.ExtensionData.Info.Reason.UserName } }
Start-Sleep 10
}
}
@AfroThundr3007730
AfroThundr3007730 / Get-ESXiSerials.ps1
Last active March 31, 2024 18:55
Get the serial number and service tags for ESXi hosts
function Get-ESXiSerials {
<#
.SYNOPSIS
Get the serial number and service tags for ESXi hosts
#>
Param(
# Full name of host or a regex
[Parameter(Mandatory = $false)]
[string]$HostSpec
)