Skip to content

Instantly share code, notes, and snippets.

View maravedi's full-sized avatar
🏒
Slappin' shots

maravedi

🏒
Slappin' shots
View GitHub Profile
@maravedi
maravedi / DecodeHex.ps1
Created November 21, 2019 13:40
Separator for an HTTP Request with combined ASCII and Hex
Param(
[String]$Raw,
$ASCIIColor = 'White',
$HexColor = 'Blue'
)
$Original = $Host.UI.RawUI.ForegroundColor
Write-Host "======================="
$Host.UI.RawUI.ForegroundColor = $ASCIIColor
@maravedi
maravedi / ParseNmap.ps1
Last active October 3, 2019 12:35
PowerShell - Parse Greppable Nmap Output
$Data = [System.Collections.ArrayList]@(); ((cat .\Scan.txt | Select -Skip 1 | Select -SkipLast 1 | %{$Row = ""|Select Host,Status,Ports,OS; $Temp = $_ -Split '\t'; If(($Temp -Join ',') -notlike "*Status:*" -And ($Temp -Join ',') -like "*OS:*"){ $Row.Host = $Temp[0]; $Row.Status = ""; $Row.Ports = $Temp[1]; $Row.OS = $Temp[3]} ElseIf(($Temp -Join ',') -notlike "*Status:*"){$Row.Host = $Temp[0]; $Row.Status = ""; $Row.Ports = $Temp[1]; $Row.OS = $Temp[2]} Else {$Row.Host = $Temp[0]; $Row.Status = $Temp[1]; $Row.Ports = $Temp[2]; $Row.OS = ""}; [Void]$Data.Add($Row)}))
$Data
@maravedi
maravedi / Get-StringHash.ps1
Created September 7, 2019 18:54
PowerShell String-hashing Function
# This is a customized version of the work done by jermity: https://gist.github.com/jermity/d38da10534a7a56af32d
# Examples:
# To List all available algorithms:
# Get-StringHash -List
#
# To hash the string using all available algorithms:
# 'test' | Get-StringHash -All
#
# To do the same as above, but without using the pipeline:
# Get-StringHash -String 'test' -All
@maravedi
maravedi / Get-Base64DecodedString.ps1
Created September 7, 2019 18:48
PowerShell Base64 Decode
# Examples:
# 'dABlAHMAdAA=' | Get-Base64DecodedString
# Get-Base64DecodedString 'dABlAHMAdAA='
# Get-Base64DecodedString -String 'dABlAHMAdAA='
Function Get-Base64DecodedString {
[CmdletBinding()]
Param(
[Parameter(ValueFromPipeline = $True)]
[String]$String
)
@maravedi
maravedi / Get-Base64EncodedString.ps1
Created September 7, 2019 18:45
PowerShell Base64 Encode
# Examples:
# 'Test' | Get-Base64EncodedString
# Get-Base64EncodedString 'Test'
# Get-Base64EncodedString -String 'Test'
Function Get-Base64EncodedString {
[CmdletBinding()]
Param(
[Parameter(ValueFromPipeline = $True)]
[String]$String
)
@maravedi
maravedi / ProfilePath.ps1
Created March 28, 2019 13:18
Change your PowerShell Profile Path
# Keep in mind that this will change the path for shell:personal, which may adversely affect other applications that rely on this.
# Use this with caution, and make sure you remember what it was set to previously so that you can revert it if needed.
$OldValue = Get-ItemProperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\' -Name Personal
# $OldValue
# Personal : C:\Users\maravedi
# You'll want to use the %USERPROFILE% value instead of hardcoding it, just to be consistent with the other entries for this key
$NewValue = '%USERPROFILE%\Box'
@maravedi
maravedi / ExcelExtractUTCTime.txt
Created January 17, 2019 16:44
Formulas to split up a UTC timestamp into date and time
Say you have this timestamp: 2019-01-17T14:04:47.4927812
Say you want to split it up in Excel (you can't use a PowerShell ALL the time, right?), then here's what I figured out.
Assumptions:
The timestamp is in the first column, and has a header. For this example, it's in cell A2.
To get the date:
=LEFT(A2,10)
@maravedi
maravedi / RemoveLinks.gs
Created December 12, 2018 22:24
Remove Links From Google Doc Selected Text
@maravedi
maravedi / Get-NewADAccounts.ps1
Created October 1, 2018 20:48
Get AD Accounts Created Since
<#
.SYNOPSIS
This script takes either a specific date or a number of days, weeks, or months to determine how many and, optionally, which AD accounts were created since that point in time.
.DESCRIPTION
This script has two methods of calculating a date, and it depends on which parameters are used when running it.
The first method is using a relative number of, days, weeks, or months. These can be combined as well.
The second method is using a specific date. If this method is used, then any of the relative date parameters are ignored.
.PARAMETER DaysBack
@maravedi
maravedi / So-Allow.ps1
Created September 28, 2018 13:20
PowerShell Script for Security Onion to Automate so-allow from an Analyst Workstation
<#
.SYNOPSIS
A PowerShell script to automate whitelisting a device on the master Security Onion server.
.DESCRIPTION
If your analyst workstation is constantly changing IPs, it might be a little annoying to SSH into the master Security Onion server every time to interactively whitelist your new IP. Here's a way to cut off a couple of the steps to achieve just that, using PowerShell and Plink.exe. Make sure to modify the parameters according to your environment and analyst workstation's network interface.
.PARAMETER Servers
Specify as many servers as you would like this whitelist command to be run on. However, if the usernames or passwords are different across the servers, then the command will fail to authenticate.
.PARAMETER InterfaceAlias
Specify the network interface to extract the IP address from. This is useful when you know the interfance is always the same, but the IP address is subject to change.
.PARAMETER LocalIP