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 / Get-Employee.ps1
Created April 5, 2020 02:03
PowerShell function to get specific details for an AD user
function Get-Employee {
param(
[String]$Username,
[String]$ProxyAddressesFilter
)
If($Username) {
Get-ADUser -Identity $Username -Properties Department, Title, Manager, Office, LockedOut, officePhone, telephoneNumber
} Else {
Get-ADUser -Filter "proxyAddresses -like `"*$($ProxyAddressesFilter)*`"" -Properties Department, Title, Manager, Office, LockedOut, officePhone, telephoneNumber
@maravedi
maravedi / sqlite-output.nse
Last active February 27, 2020 01:02
Nmap Sqlite Output Script with cpe and OS
description = [[
This script stores the following nmap output into a sqlite3 database: Hostname, IP, port number, protocol (tcp/udp), service, version, cpe, and OS (if it can be determined)
Both, database file name and table name can be passed to the script via arguments (see @args or @example), data will always be appended to an existing table. Non-existant database files or table
s are created during the scan. Nmap's regular output (-o) will not be modified in any way.
Dependencies: luasql (http://keplerproject.org/luasql)
For Debian-based distributions:
sudo apt-get install lua-sql-sqlite3
@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