Skip to content

Instantly share code, notes, and snippets.

View nickadam's full-sized avatar

Nick Vissari nickadam

View GitHub Profile
@nickadam
nickadam / ps1_to_cmd.ps1
Created March 31, 2020 16:38
[ps1_to_cmd] Convert a multiline PS1 script to a single line cmd file #PowerShell
$s = Get-Content script.ps1 | Out-String
$j = [PSCustomObject]@{
"Script" = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($s))
} | ConvertTo-Json -Compress
$oneline = "[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String(('" + $j + "' | ConvertFrom-Json).Script)) | iex"
$c = [convert]::ToBase64String([System.Text.encoding]::Unicode.GetBytes($oneline))
("Powershell -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -Encoded " + $c) | Out-File -Encoding Default script.cmd
@nickadam
nickadam / Secret_Server_Launch_List.js
Last active December 19, 2023 12:36
Tampermonkey script for secret server launch list
// ==UserScript==
// @name Secret Server Launch List
// @namespace http://tampermonkey.net/
// @version 1.0.1
// @description Add a list of hosts your can choose from the secret server launcher UI
// @author nickadam
// @match https://*.secretservercloud.com/app/
// @icon https://www.google.com/s2/favicons?sz=64&domain=secretservercloud.com
// @grant none
// ==/UserScript==
@nickadam
nickadam / cya_encrypt_decrypt_example.ps1
Last active November 3, 2023 13:52
Leverage CYA internals for generic encrypting or decrypting of files with a password
# Running this script will install CYA if not already installed,
# load the necessary functions from the private modules directory,
# and finally creates three sample files in the current working directory.
# Install CYA if not installed
if (-not (Get-Module -ListAvailable -Name CYA)) {
Install-Module CYA -Repository PSGallery
}
# Load CYA's private functions from the Modules directory
@nickadam
nickadam / Change-MACAddress.ps1
Created April 2, 2019 13:40
Change MAC Address Windows
# credit to http://www.isolation.se/change-mac-address-with-powershell-of-a-wireless-adapter/
function random-mac {
$mac = "02"
while ($mac.length -lt 12)
{
$mac += "{0:X}" -f $(get-random -min 0 -max 16)
}
$Delimiter = "-"
for ($i = 0 ; $i -le 10 ; $i += 2)
@nickadam
nickadam / get-switch-macs.py
Last active August 26, 2023 17:34
Get switch interface mac addresses via snmp (tested with aruba os, aruba cx, aruba wireless controllers, and cisco)
from pysnmp.carrier.asyncore.dispatch import AsyncoreDispatcher
from pysnmp.carrier.asyncore.dgram import udp
from pyasn1.codec.ber import encoder, decoder
from pysnmp.proto.api import v2c
from pysnmp.proto import api
from time import time
from collections import OrderedDict
import copy
import json
import re
@nickadam
nickadam / duo_phone_setup.md
Created August 16, 2023 14:31
Duo phone setup

Duo phone setup

graph TD
  A[Go to Manage Duo in S/SAM] --> B{Is the toggle greyed out\nor duo not required?}
  B -- Yes --> C[Setup/restore the phone]
  B -- No --> D{Are there MFA methods?}
  D -- Yes --> E{Is one of the methods\nthe hcpss device\nbeing replaced?}
  D -- No --> F[Begin phone setup/restore,\nstop at home screen]
  F --> G{Is the duo app\non the new phone?}
 G -- No --> H[Wait longer\nor install manually]
@nickadam
nickadam / spotify_delay_play.js
Created July 27, 2023 17:48
Tampermonkey script for Spotify delay play for Quest 2 VR
// ==UserScript==
// @name Spotify delay play for Quest 2 VR
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Hits the play button after a delay so you can listen to spotify on Oculus Quest 2. You can sideload firefox android app with sidequest, add the tampermonkey add-on, add this script, and open spotify in desktop mode in firefox, move it to a sidepanel, start playing what you want, pause it, hit "Play in 15s", open your VR game of choice.
// @author Nick Vissari
// @match *://open.spotify.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=spotify.com
// @grant none
// ==/UserScript==
@nickadam
nickadam / Get-GitHubRepos.ps1
Created July 18, 2023 16:11
List Org Repos and Contributors
$org = "Your Org"
$api_key = "Your PAT"
function Get-GitHubApi(){
param($Url)
$Headers = @{Authorization = "Bearer $api_key"}
$wr = Invoke-WebRequest -UseBasicParsing -Headers $Headers $Url
$wr.Content | ConvertFrom-Json -Depth 100
if([string]($wr.Headers.link -split "," -match 'rel="next"') -match "https[^>]+"){
Get-GitHubApi $matches[0]
@nickadam
nickadam / Get-AwsPolicies.ps1
Last active April 20, 2023 03:56
Get AWS policy contents for attached and inline policies associated with Users, Roles, and Groups
Write-Progress -Activity "IAM List (1/2)" -Status ("0% AttachedPolicies") -PercentComplete 0
$AttachedPolicies = & aws iam list-policies --only-attached | ConvertFrom-Json | Select-Object -ExpandProperty Policies
Write-Progress -Activity "IAM List (1/2)" -Status ("25% Users") -PercentComplete 0
$Users = & aws iam list-users | ConvertFrom-Json | Select-Object -ExpandProperty Users
Write-Progress -Activity "IAM List (1/2)" -Status ("50% Roles") -PercentComplete 0
$Roles = & aws iam list-roles | ConvertFrom-Json | Select-Object -ExpandProperty Roles
Write-Progress -Activity "IAM List (1/2)" -Status ("75% Groups") -PercentComplete 0
$Groups = & aws iam list-groups | ConvertFrom-Json | Select-Object -ExpandProperty Groups
$t = ($AttachedPolicies.Length + $Users.Length + $Roles.Length + $Groups.Length)
@nickadam
nickadam / Get-AOVPNSessions.ps1
Created April 5, 2023 13:38
Get session data from Always On VPN
# Connect to windows internal database, remote access account database, and get relevant information for all active sessions
$ConnectionString = 'server=\\.\pipe\MICROSOFT##WID\tsql\query;database=RaAcctDb;trusted_connection=true;'
$SQLConnection= New-Object System.Data.SQLClient.SQLConnection($ConnectionString)
$SQLConnection.Open()
$SQLCommand = $SQLConnection.CreateCommand()
$SQLCommand.CommandText = 'SELECT * FROM dbo.ConnectionTable JOIN dbo.SessionTable ON dbo.ConnectionTable.ConnectionId = dbo.SessionTable.ConnectionId WHERE SessionState = 1'
$SqlDataReader = $SQLCommand.ExecuteReader()
$SQLDataResult = New-Object System.Data.DataTable
$SQLDataResult.Load($SqlDataReader)
$SQLConnection.Close()