This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
csc test.cs | |
ildasm /OUT=test.il test.exe | |
type moduleinititalizer.il >> test.il | |
ilasm /EXE /OUTPUT=test.exe test.il |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo -----BEGIN CERTIFICATE----- > encoded.txt | |
echo Just Base64 encode your binary data | |
echo TVoAAA== >> encoded.txt | |
echo -----END CERTIFICATE----- >> encoded.txt | |
certutil -decode encoded.txt decoded.bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-DellFoundationServicesWmiObject { | |
<# | |
.SYNOPSIS | |
Performs a WMI query on a Dell Foundation Services server. | |
Author: Matthew Graeber (@mattifestation) | |
License: BSD 3-Clause | |
.DESCRIPTION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-AssociatedClassRelationship { | |
param ( | |
[String] | |
$Namespace = 'root/cimv2' | |
) | |
Get-CimClass -Namespace $Namespace | ? { $_.CimClassQualifiers['Association'] -and (-not $_.CimClassQualifiers['Abstract']) } | % { | |
$KeyQualifiers = @($_.CimClassProperties | ? { $_.Qualifiers['key'] }) | |
if ($KeyQualifiers.Count -eq 2) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#region Scriptblocks that will execute upon alert trigger | |
$LateralMovementDetected = { | |
$Event = $EventArgs.NewEvent | |
$EventTime = [DateTime]::FromFileTime($Event.TIME_CREATED) | |
$MethodName = $Event.MethodName | |
$Namespace = $Event.Namespace | |
$Object = $Event.ObjectPath | |
$User = $Event.User |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############# | |
### SETUP ### | |
############# | |
# Set up remote session | |
$Credential = Get-Credential TestUser | |
$AdminCred = Get-Credential Administrator | |
$SessionOption = New-CimSessionOption -Protocol Dcom | |
$CimSession = New-CimSession -Credential $Credential -ComputerName TestPC -SessionOption $SessionOption | |
$AdminCimSession = New-CimSession -Credential $AdminCred -ComputerName TestPC -SessionOption $SessionOption |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define the signature - i.e. __EventFilter | |
$EventFilterArgs = @{ | |
EventNamespace = 'root/cimv2' | |
Name = 'LateralMovementEvent' | |
Query = 'SELECT * FROM MSFT_WmiProvider_ExecMethodAsyncEvent_Pre WHERE ObjectPath="Win32_Process" AND MethodName="Create"' | |
QueryLanguage = 'WQL' | |
} | |
$InstanceArgs = @{ | |
Namespace = 'root/subscription' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This code could be used to remotely enable and launch AT jobs regardless of the fact that AT is deprecated in Win8+. | |
$HKLM = [UInt32] 2147483650 | |
# Check to see if EnableAt is set | |
$Result = Invoke-CimMethod -Namespace root/default -ClassName StdRegProv -MethodName GetDWORDValue -Arguments @{ | |
hDefKey = $HKLM | |
sSubKeyName = 'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\Configuration' | |
sValueName = 'EnableAt' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-WmiNamespace { | |
<# | |
.SYNOPSIS | |
Returns a list of WMI namespaces present within the specified namespace. | |
.PARAMETER Namespace | |
Specifies the WMI repository namespace in which to list sub-namespaces. Get-WmiNamespace defaults to the ROOT namespace. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$EventFilterArgs = @{ | |
EventNamespace = 'root/cimv2' | |
Name = 'DriveChanged' | |
Query = 'SELECT * FROM Win32_VolumeChangeEvent' | |
QueryLanguage = 'WQL' | |
} | |
$Filter = Set-WmiInstance -Namespace root/subscription -Class __EventFilter -Arguments $EventFilterArgs | |
$CommandLineConsumerArgs = @{ |
OlderNewer