Skip to content

Instantly share code, notes, and snippets.

@JustinGrote
JustinGrote / Select-StringMatch.ps1
Last active October 24, 2022 14:56
A companion to Select-String to more easily retrieve the results of capture groups, similar to $matches but pipeline friendly.
filter Select-StringMatch {
<#
.SYNOPSIS
A companion to select-string to quickly fetch the value of a capture group, named or indexed
.DESCRIPTION
With -replace or -match we have the simple $matches['group'] syntax, but this doesn't really exist for Select-String
and the typical options are not pipeline friendly. The default object returned from Select-String is not that friendly
either if all you want is the value(s) of a capture group to then pipe to another command. This is basically a pipeline
friendly version of $matches.
@DanielLarsenNZ
DanielLarsenNZ / reclaim-windows-11.ps1
Last active June 13, 2024 23:29
reclaim-windows-11.ps1
##########
# Tweaked Win11 Initial Setup Script
# Primary Author: Disassembler <disassembler@dasm.cz>
# Modified by: alirobe <alirobe@alirobe.com> based on my personal preferences.
# Modified by: @DanielLarsenNZ - based on my personal preferences. Some additions for Windows 11
# Version: 2.12.2, 2021-12-11
# Primary Author Source: https://github.com/Disassembler0/Win10-Initial-Setup-Script
# Tweaked Source: https://gist.github.com/alirobe/7f3b34ad89a159e6daa1/
# Tweak difference:
#
@SwitHak
SwitHak / 20211210-TLP-WHITE_LOG4J.md
Last active July 22, 2024 18:44
BlueTeam CheatSheet * Log4Shell* | Last updated: 2021-12-20 2238 UTC

Security Advisories / Bulletins / vendors Responses linked to Log4Shell (CVE-2021-44228)

Errors, typos, something to say ?

  • If you want to add a link, comment or send it to me
  • Feel free to report any mistake directly below in the comment or in DM on Twitter @SwitHak

Other great resources

  • Royce Williams list sorted by vendors responses Royce List
  • Very detailed list NCSC-NL
  • The list maintained by U.S. Cybersecurity and Infrastructure Security Agency: CISA List
@joshooaj
joshooaj / profile.ps1
Last active October 9, 2021 16:11
My hosts file display and manipulation functions for my profile script
class HostsFileEntry {
[IPAddress] $IP
[string[]] $Hosts
[string] ToString() {
return "$($this.IP) $([string]::Join(' ', $this.Hosts))"
}
}
function Get-HostsFileEntry {
@paolobasso99
paolobasso99 / restic-backup.sh
Last active March 3, 2024 15:35
Restic backup script
#!/bin/bash
# This script will run a restic backup and remove snapshots according to a policy.
# In order for this script to work two environment vaiables must be set:
# RESTIC_PASSWORD which is the restic repository password (or read https://restic.readthedocs.io/en/latest/faq.html#how-can-i-specify-encryption-passwords-automatically)
# MY_RESTIC_LOGS_PATH which is the path where to save logs. For example: /home/paolo/restic/logs
#
# WARNING: This script prunes ond backups! Be careful not to delete backups that you need.
# Customize the removing policy according to https://restic.readthedocs.io/en/latest/060_forget.html#removing-snapshots-according-to-a-policy
#
@pedrolamas
pedrolamas / docker-iptables-fix.sh
Created August 18, 2020 19:32
Script to fix Docker iptables on Synology NAS
#!/bin/bash
currentAttempt=0
totalAttempts=10
delay=15
while [ $currentAttempt -lt $totalAttempts ]
do
currentAttempt=$(( $currentAttempt + 1 ))
echo "Attempt $currentAttempt of $totalAttempts..."
@rordi
rordi / root-password-MariaDB-docker-compose.md
Last active July 12, 2024 13:18
Change root password in MariaDB Docker container running with docker-compose

Change root password in MariaDB Docker container running with docker-compose

Override the entrypoint in docker-compose.yml for the MariaDB Docker container by adding:

entrypoint: mysqld_safe --skip-grant-tables --user=mysql

The start up the Docker Compose stack:

$> docker-compose up -d
@JustinGrote
JustinGrote / AutoMock.ps1
Last active November 2, 2021 21:16
AutoMock: Record Powershell Command Output to Replay in Pester Tests Offline
#requires -module Indented.StubCommand
function Enable-AutoMockRecord ([Switch]$Append) {
$env:AUTOMOCK_RECORD = $true
if ($Append) {$env:AUTOMOCK_APPEND = $true}
}
function Disable-AutoMockRecord {
Remove-Item env:AUTOMOCK_RECORD -ErrorAction SilentlyContinue
Remove-Item env:AUTOMOCK_APPEND -ErrorAction SilentlyContinue
}
function Get-WebExceptionBody
{
param(
[int]$Last
)
if(-not $PSBoundParameters.ContainsKey('Last')){
$Last = 1
}
@coltenkrauter
coltenkrauter / fix-wsl2-dns-resolution
Last active July 24, 2024 17:10
Fix DNS resolution in WSL2
More recent resolution:
1. cd ~/../../etc (go to etc folder in WSL).
2. echo "[network]" | sudo tee wsl.conf (Create wsl.conf file and add the first line).
3. echo "generateResolvConf = false" | sudo tee -a wsl.conf (Append wsl.conf the next line).
4. wsl --terminate Debian (Terminate WSL in Windows cmd, in case is Ubuntu not Debian).
5. cd ~/../../etc (go to etc folder in WSL).
6. sudo rm -Rf resolv.conf (Delete the resolv.conf file).
7. In windows cmd, ps or terminal with the vpn connected do: Get-NetIPInterface or ipconfig /all for get the dns primary and
secondary.