Skip to content

Instantly share code, notes, and snippets.

View gravejester's full-sized avatar

Øyvind Kallstad gravejester

View GitHub Profile
function Show-BinaryFile {
<#
.SYNOPSIS
Binary file viewer.
.DESCRIPTION
This function will read and output a HEX and ASCII representation of a
binary file, similar to hex editors.
.EXAMPLE
Show-BinaryFile -Path 'c:\path\to\binary.file'
This will read and output the entire binary file.
function Invoke-FixedXOR {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true, Position = 0)]
[byte[]] $ByteArrayOne,
[Parameter(Mandatory = $true, Position = 1)]
[byte[]] $ByteArrayTwo
)
$combinedBytes = New-Object System.Collections.ArrayList
Add-Type -MemberDefinition @'
[DllImport("crypt32.dll", CharSet = CharSet.Auto, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CryptStringToBinary(
[MarshalAs(UnmanagedType.LPWStr)] string pszString,
uint cchString,
CRYPT_STRING_FLAGS dwFlags,
byte[] pbBinary,
ref uint pcbBinary,
uint pdwSkip,
function ConvertTo-BinaryString {
[CmdletBinding()]
param (
[Parameter(ValueFromPipeline = $true, Mandatory = $true, Position = 0)]
[array] $InputObject,
[Parameter()]
[switch] $Pad
)
function ConvertTo-HexString {
[CmdletBinding()]
param (
[Parameter(ValueFromPipeline = $true, Mandatory = $true, Position = 0)]
[byte[]] $InputObject
)
BEGIN {
$outString = New-Object -TypeName System.Text.StringBuilder
}
function Invoke-WinMerge {
<#
.SYNOPSIS
Wrapper for WinMerge.
.DESCRIPTION
PowerShell wrapper for WinMerge. Let's you launch file/folder comparison using WinMerge
from the PowerShell console.
.EXAMPLE
Invoke-WinMerge c:\temp\file1.txt c:\temp\file2.txt
Will launch WinMerge to compare file1.txt and file2.txt.
function ConvertTo-StringArray {
<#
.SYNOPSIS
Split a string on newline to produce a string array.
.NOTES
Author: Øyvind Kallstad
Date: 07.01.2016
#>
[CmdletBinding()]
param (
function Get-SteamWishList {
<#
.SYNOPSIS
Get wishlist of Steam user
.DESCRIPTION
Get the wishlist of any public Steam user accounts.
.EXAMPLE
Get-SteamWishList user01
Get the wishlist for Steam user account 'user01'
.NOTES
$iterations = 10000
$saveFile = 'C:\Users\grave\Scripts\OverheadTests\results.txt'
$m1Description = 'Refence: Only doing calculations'
Write-Host 'Starting Measurement 1'
$m1 = Measure-Command {
1..100 | ForEach-Object {
$_ + ($_ * $_)
}
}
function Get-Square {
param([double]$Number)
$n = [math]::Abs($Number)
Write-Output ($n * $n)
}
#https://en.wikipedia.org/wiki/Root_mean_square
function Get-RootMeanSquare {
param ([double[]]$NumberSet)
$squaredNumberSet = New-Object System.Collections.ArrayList