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 / Get-GHRepoList.ps1
Last active March 31, 2024 18:24
Gets a list of repositories of a GitHub user
Set-StrictMode -Version Latest
function Get-GHRepoList {
<# .SYNOPSIS
Gets a list of repositories of a GitHub user. #>
Param(
# User to enumerate
[string]$User,
# Page size to request
[int]$Size = 100
@AfroThundr3007730
AfroThundr3007730 / xdg_dirs.sh
Last active March 30, 2024 23:20
Profile snippet to redirect $HOME clutter to the proper XDG directory
#!/bin/sh
#/etc/profile.d/xdg_dirs.sh
# SPDX-License-Identifier: GPL-3.0-or-later
###############################################################################
# XDG variables
###############################################################################
export XDG_CACHE_HOME="${XDG_CACHE_HOME:-${HOME}/.cache}"
export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-${HOME}/.config}"
export XDG_DATA_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}"
@AfroThundr3007730
AfroThundr3007730 / Invoke-GithubFileRequest.ps1
Created April 3, 2023 18:41
Powershell function to retrieve a file from a Github repository
Set-StrictMode -Vesion Latest
function Invoke-GithubFileRequest {
<# .SYNOPSIS
Retrieves a file from a Github repository. #>
[Alias('gh_curl')]
Param(
# URL of file to download
[Parameter(Mandatory)]
[Uri]$URL,
@AfroThundr3007730
AfroThundr3007730 / draw_grid.py
Created March 14, 2023 01:49
Draws a grid of conigurable size
#!/usr/bin/python
from PIL import Image
def draw_grid(size_x=1920, size_y=1080, grid_x=3, grid_y=3, border=2, img_x=0, img_y=0):
if img_x == 0 or img_y == 0:
img_x, img_y = size_x, size_y
img = Image.new('RGB', (img_x, img_y), 'white')
pixels = img.load()
@AfroThundr3007730
AfroThundr3007730 / Get-ArpEntry.ps1
Last active March 7, 2024 23:19
PowerShell wrapper of C# function to retrieve system ARP table entries
Set-StrictMode -Version Latest
function Get-ArpEntry {
<# .SYNOPSIS
Retrieve system ARP table entries #>
Param(
# Retrieve all entries (not just learned)
[switch]$All
)
@AfroThundr3007730
AfroThundr3007730 / Check-Elevation.ps1
Last active February 21, 2023 21:13
Guard functions for powershell version and elevation level
# Only run if elevated as administrator
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
$admin = [Security.Principal.WindowsBuiltInRole]::Administrator
if (!([Security.Principal.WindowsPrincipal]$identity).IsInRole($admin)) {
Write-Output 'We are not elevated, launching elevated powershell...'
Start-Process -FilePath powershell.exe -Verb RunAs -ArgumentList $MyInvocation.MyCommand.Source
Start-Sleep 10
exit 0
}
@AfroThundr3007730
AfroThundr3007730 / Edit-VMDKHeader.ps1
Created October 24, 2022 20:12
Edit the metadata header of a VMDK file
Set-StrictMode -Version Latest
function Edit-VMDKHeader {
<# .SYNOPSIS
Edit the metadata header of a VMDK file #>
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
Param(
# The VMDK file to edit
[Parameter(Mandatory)]
[string]$VMDKFile
@AfroThundr3007730
AfroThundr3007730 / dmsetup-vdo
Last active October 17, 2022 03:07
Automount a VDO device at boot (useful when root is on the VDO)
#!/bin/bash
[[ $1 == start && ! -b /dev/mapper/$2 ]] && {
[[ -d /sys/module/kvdo ]] || modprobe kvdo
target=$(readlink -f $(awk -v dev=$2 '$1~dev && $4~"vdo" {print $6}' /etc/dmsetup.table))
[[ $target =~ /dev/dm- ]] && target=$(find /dev/mapper -type l -lname "*${target##*/}")
table=$(awk -v dev=$2 -v target=$target '$1~dev && $4~"vdo" {sub($1FS,""); sub($5,target); print $0}' /etc/dmsetup.table)
echo dmsetup create $2 --table "$table"
[[ -b /dev/mapper/$2 ]] || exit 1
}
@AfroThundr3007730
AfroThundr3007730 / get_stream_stats.sh
Last active August 18, 2023 17:13
Parses chatterino logs to get stream income from bits and subscriptions
#!/bin/bash
# Parses chatterino logs to get stream income from bits and subscriptions
get_stream_stats() {
local f=${1##*/}; f=${f%.*}
printf 'Channel: %s Date: %s\n' "${f%%-*}" "${f#*-}"
awk '/[Cc]heer/ {
for (i = 1; i <= NF; i++) {
if ($i ~ /^[Cc]heer$/) {
j = i + 1
token = $i $j
@AfroThundr3007730
AfroThundr3007730 / Resolve-DnsRecordAllDCs.ps1
Last active March 31, 2024 18:24
Resolves a DNS record on all active DCs in a domain
function Resolve-DnsRecordAllDCs {
<# .SYNOPSIS
Resolves a DNS record on all active DCs in a domain #>
[Alias('nslookup_all')]
Param(
# Name to resolve
[Parameter(Mandatory, ValueFromPipeline)]
[string]$Name,
# Type of record
[Parameter(ValueFromPipelineByPropertyName)]