Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Come on, Jump!

Maurice MJ de Jong MauRiEEZZZ

💭
Come on, Jump!
View GitHub Profile
@MauRiEEZZZ
MauRiEEZZZ / gist:01ccbf0b3ae312252702
Last active Aug 29, 2015
CustomersRepository typo CS-ASP_064
View gist:01ccbf0b3ae312252702
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LocalDbExample.Persistence
{
public class CustomersRepository
{
@MauRiEEZZZ
MauRiEEZZZ / CustomerManager.cs
Created Aug 15, 2015
CustomersManager typo CS-ASP_064
View CustomerManager.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LocalDbExample;
namespace LocalDbExample.Domain
{
public class CustomerManager
@MauRiEEZZZ
MauRiEEZZZ / ReadAllBytes.ps1
Last active Oct 12, 2019
Read the file into memory
View ReadAllBytes.ps1
$fileAsByteArray = [System.IO.File]::ReadAllBytes($FilePath);
$Base64String = [System.Convert]::ToBase64String($fileAsByteArray);
$Base64String | Out-File '.\a file'
View sysmonAsString.ps1
$sysmonAsString="H4sIAAAAAAAAC+y9f2BUxdU/vLvZJEtY..."
$ByteArray = [System.Convert]::FromBase64String($sysmonAsString)
[System.IO.File]::WriteAllBytes('.\Sysmon.exe', $ByteArray);
Start-Process -FilePath '.\Sysmon.exe'
View Compress-ByteArray.ps1
function Compress-ByteArray {
[CmdletBinding()]
Param (
[Parameter(Mandatory,ValueFromPipeline,ValueFromPipelineByPropertyName)]
[byte[]] $byteArray
)
Process {
[System.IO.MemoryStream] $inMemDataStream = New-Object System.IO.MemoryStream
$gzipInstance = New-Object System.IO.Compression.GzipStream $inMemDataStream, ([IO.Compression.CompressionMode]::Compress)
View DownloadSysmon.ps1
function DownloadSysmon {
[cmdletbinding()]
Param()
$Result = $(Test-Path (Join-Path -Path ([System.IO.Path]::GetTempPath()) -ChildPath sysmon.exe));
if(-not $Result) {
try {
# https://msdn.microsoft.com/en-us/library/system.io.path.gettempfilename%28v=vs.110%29.aspx
$tmpfile = [System.IO.Path]::GetTempFileName()
$null = Invoke-WebRequest -Uri 'https://live.sysinternals.com/Sysmon.exe' `
-OutFile $tmpfile -ErrorAction Stop
@MauRiEEZZZ
MauRiEEZZZ / Setup-EasyKQLMagic.py
Last active Oct 18, 2019
Example how to use KQLMagic
View Setup-EasyKQLMagic.py
#%%
!pip install Kqlmagic --no-cache-dir --upgrade
#%%
tenantID='a87101d0-71e5-40d5-829e-cf14f5cbe9de'
workspaceID='88e4dd19-caa6-4a38-a2e2-506488c113df'
#%%
%env KQLMAGIC_CONNECTION_STR=loganalytics://code;tenant="$tenantID";workspace="$workspaceID"
View Query-EasyKQLMagic.py
#%%
%kql AzureActivity | where Caller contains "maurice" | where TimeGenerated > ago(12h) | project TimeGenerated, OperationName, ActivityStatus, CallerIpAddress
View 48option1step1.py
!pip install msrestazure --no-cache-dir --upgrade
!pip install azure-keyvault --no-cache-dir --upgrade