Skip to content

Instantly share code, notes, and snippets.

View poizan42's full-sized avatar

Kasper Fabæch Brandt poizan42

View GitHub Profile
@poizan42
poizan42 / MailSend.cs
Last active June 14, 2018 16:15
Demonstration of bad heuristics in som AV products, new-style .csproj edition, see https://poizan.dk/blog/2018/06/14/the-dangerous-mailsend-antivirus-heuristics-fail/
class Program
{
public const string pad =
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" +
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" +
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" +
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" +
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" +
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" +
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" +
private static FrameworkPropertyMetadata CloneFrameworkPropertyMetadata(FrameworkPropertyMetadata src)
{
FrameworkPropertyMetadataOptions options = FrameworkPropertyMetadataOptions.None;
if (src.AffectsArrange)
options |= FrameworkPropertyMetadataOptions.AffectsArrange;
if (src.AffectsMeasure)
options |= FrameworkPropertyMetadataOptions.AffectsMeasure;
if (src.AffectsParentArrange)
options |= FrameworkPropertyMetadataOptions.AffectsParentArrange;
if (src.AffectsParentMeasure)
@poizan42
poizan42 / EwsId_format.txt
Last active October 7, 2021 02:29
EwsId reverse engineered format
IdStorageType (byte):
MailboxItemSmtpAddressBased = 0, // Exchange 2007 (EwsLegacyId)
PublicFolder = 1,
PublicFolderItem = 2,
MailboxItemMailboxGuidBased = 3,
ConversationIdMailboxGuidBased = 4,
ActiveDirectoryObject = 5, // Exchange 2013
MailboxItemMailboxGuidBasedWithFallback = 6 // Exchange 2016
CompressionId (byte):
@poizan42
poizan42 / fix-spinny.py
Last active January 30, 2018 18:54
Update links to Spinnerette comics to current format
import sys
from datetime import datetime
import re
import urllib2
from bs4 import BeautifulSoup
wayback_prefix = 'https://web.archive.org/web/20160824022930/'
newformat_prefix = 'http://www.spinnyverse.com/comic/'
cachef = open('spinny-cache', 'a+')
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@poizan42
poizan42 / MoveAnyFile.ps1
Created November 24, 2017 13:37
PowerShell script for moving / renaming files with otherwise invalid filenames
param([String]$existingFilename, [String]$newFilename)
$signature = @'
[DllImport("kernel32.dll", ExactSpelling=true, CharSet=CharSet.Unicode, SetLastError=true)]
public static extern uint MoveFileW(
string lpExistingFileName, string lpNewFileName);
'@
$type = $null
try
@poizan42
poizan42 / DeleteAnyFile.ps1
Last active November 24, 2017 13:33
PowerShell script for deleting files with otherwise invalid filenames
param([String]$filename)
$signature = @'
[DllImport("kernel32.dll", ExactSpelling=true, CharSet=CharSet.Unicode, SetLastError=true)]
public static extern uint DeleteFileW(
string lpFileName);
'@
$type = $null
try
@poizan42
poizan42 / StreamedXmlReader.cs
Created November 1, 2017 17:27
XmlReader that supports reading a document from a stream with multiple documents
using System.IO;
using System.Xml;
internal class StreamedXmlReader : XmlTextReader
{
private bool eof;
public override bool EOF => base.EOF || eof;
public StreamedXmlReader(TextReader input) : base(input)
{
}
@poizan42
poizan42 / get-dncore-stacks.sh
Created September 19, 2017 20:54
Prints full stack trace of every thread in a dotnet core process out to stdout
lldb --attach-name dotnet -o "plugin load libsosplugin.so" -o "eestack" -o "process detach" -o "exit"
@poizan42
poizan42 / Makefile
Last active January 4, 2020 23:26
Demonstration of running 32-bit code on WSL
call32test: call32test.o call32.o
gcc -g $^ -o $@
call32test.o: call32test.c
gcc -g -c $< -o $@
call32.o: call32.asm
nasm -f elf64 call32.asm -o call32.o