Skip to content

Instantly share code, notes, and snippets.

View lowleveldesign's full-sized avatar

Sebastian Solnica lowleveldesign

View GitHub Profile
@lowleveldesign
lowleveldesign / Show-File.ps1
Created October 27, 2022 08:01
A script coloring the content of a binary file
param (
[Parameter(Position = 1, Mandatory = $True)]
[ValidateScript({ Test-Path $_ })]
[String]$Path,
[Int64]$Offset = 0
)
$ErrorActionPreference = "Stop"
$Colors = @(
@lowleveldesign
lowleveldesign / ChangeDomainPassword.ps1
Last active February 12, 2023 13:25
Change domain password in PowerShell
$DllImport = '[DllImport("netapi32.dll", CharSet = CharSet.Unicode)] public static extern int NetUserChangePassword(string d, string u, string oldpass, string newpass);'
$NetApi32 = Add-Type -MemberDefinition $DllImport -Name 'NetApi32' -Namespace 'Win32' -PassThru
Write-Host -NoNewLine "Full domain name (for example, example.com): "
$Domain = Read-Host
$Context = [System.DirectoryServices.ActiveDirectory.DirectoryContext]::new([System.DirectoryServices.ActiveDirectory.DirectoryContextType]::Domain, $Domain)
$DomainController = ([System.DirectoryServices.ActiveDirectory.DomainController]::FindOne($Context)).Name
Write-Host -NoNewLine "Old password: "
$OldPass = Read-Host
@lowleveldesign
lowleveldesign / Print-FileHashes.ps1
Created July 26, 2021 07:31
A script to compute cryptographic hashes for the provided path (used for VERIFICATION.txt)
param ([Parameter(Mandatory = $True, ValueFromPipeline = $True, Position = 0)][string]$FilePath)
$algs = "MD5","SHA1","SHA256"
$hashes = $algs | % { Get-FileHash -Algorithm $_ $FilePath }
for ($i = 0; $i -lt $hashes.Length; $i++) {
$hash = $hashes[$i]
"$($hash.Algorithm) = $($hash.Hash)"
}
@lowleveldesign
lowleveldesign / Update-AssemblyInfoVersionFiles.ps1
Last active April 11, 2024 22:53
A script to update version numbers in .NET builds, based on the tag name, date, and GitHub action run number. Creates unique version strings for each build.
$ErrorActionPreference = "Stop"
function Update-AssemblyInfoVersionFiles ([string]$versionIdentifier)
{
$srcPath = $pwd
$today = [DateTime]::Today
$ghref = [System.IO.Path]::GetFileName("$env:GITHUB_REF")
if ($ghref -match "^(\d+\.\d+)(\-.+)?$") {
$buildNumber = "{0:yy}{1}.{2}" -f $today,$today.DayOfYear,($env:GITHUB_RUN_NUMBER % [int16]::MaxValue)
$version = "$($Matches[1]).$buildNumber"
@lowleveldesign
lowleveldesign / .vimrc
Last active January 19, 2021 17:35
My .vimrc
set background=dark
" do not keep a backup file, use versions instead
set nobackup
" keep 50 lines of command line history
set history=50
" show the cursor position all the time
set ruler
" display incomplete commands
set showcmd
@lowleveldesign
lowleveldesign / snk.bt
Created March 6, 2017 19:42
StrongNameKey (.snk) file template for 010 editor
//------------------------------------------------
//--- 010 Editor v7.0.2 Binary Template
//
// File:
// Authors: Sebastian Solnica (@lowleveldesign)
// Version:
// Purpose: .snk files
// Category:
// File Mask: *.snk
// ID Bytes:
@lowleveldesign
lowleveldesign / AppDomainListning.cs
Created August 23, 2016 15:06
Code which enumerates appdomains in a remote process using ETW
using Microsoft.Diagnostics.Tracing;
using Microsoft.Diagnostics.Tracing.Session;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
namespace ClrDacManaged
{
class Program
@lowleveldesign
lowleveldesign / UpdateChocolatey.bat
Last active November 5, 2023 11:41
Scripts to automatically update all Chocolatey packages installed on your system
@echo off
powershell -NoProfile -ExecutionPolicy ByPass -File "%~d0%~p0%~n0.ps1"
@lowleveldesign
lowleveldesign / network-stats-from-sysmon.md
Created November 2, 2015 18:23
Network connection statistics from Sysmon logs

Make sure you have network connections monitoring enabled:

PS temp> sysmon -c

Sysinternals Sysmon v3.11 - System activity monitor
Copyright (C) 2014-2015 Mark Russinovich and Thomas Garnier
Sysinternals - www.sysinternals.com