Skip to content

Instantly share code, notes, and snippets.

@Demonslay335
Demonslay335 / QueryQNAPUpdate-PS2.ps1
Created September 20, 2018 21:33
Query a QNAP for any available updates using the API (PowerShell 2)
# Ignore self-certs
if (-not ([System.Management.Automation.PSTypeName]'ServerCertificateValidationCallback').Type)
{
$certCallback = @"
using System;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
public class ServerCertificateValidationCallback
{
@Demonslay335
Demonslay335 / Sosemanuk.cs
Created July 23, 2020 16:52
Sosemanuk cryptographic algorithm in C#.
// Adapted from https://www.seanet.com/~bugbee/crypto/sosemanuk/
public class Sosemanuk
{
public Sosemanuk(byte[] key, byte[] iv)
{
BuildAlphas();
SetKey(key);
SetIV(iv);
}
@Demonslay335
Demonslay335 / gen_id.py
Last active August 12, 2020 00:07
DarkSide Ransomware ID Generation
import zlib, sys
def get_id(mac):
mac = int(mac, 16).to_bytes(6, 'big')
return checksum(mac, True)
def checksum(input, compression=False):
v3 = zlib.crc32(input, 0xDEADBEEF)
v4 = zlib.crc32(input, v3)
@Demonslay335
Demonslay335 / aplib.cs
Created November 1, 2021 18:17
Depack aPLib in pure C#
using System.Collections.Generic;
using System.IO;
// https://github.com/snemes/aplib/blob/master/aplib.py
public class APLib
{
protected uint Tag;
protected int BitCount;
protected uint GetBit(Stream source)
@Demonslay335
Demonslay335 / FixProfile.bat
Created February 13, 2020 19:35
FixProfile
@ECHO OFF
SETLOCAL EnableDelayedExpansion
FOR /F "tokens=1,2 delims=#" %%A IN ('"prompt #$H#$E# & ECHO ON & FOR %%B IN (1) DO REM"') DO SET "DEL=%%A"
:: Elevation does not work in XP
VER | FIND /I "XP" > NUL
IF ERRORLEVEL 1 CALL :CHECK-ELEVATE
:: Process arguments
@Demonslay335
Demonslay335 / blackmatter_checksum.py
Last active May 28, 2022 23:52
Generate BlackMatter checksum
import sys, struct, base64, argparse
def gen_id_from_guid(guid: str) -> str:
checksum = checksum_string(guid + '\0')
b64 = base64.b64encode(checksum.to_bytes(8, 'little'))[0:9]
return b64.decode('utf-8').replace('+', 'x').replace('/', 'i').replace('=', 'z')
def gen_checksum_from_bytes(blob: str) -> str:
blob = bytearray.fromhex(blob)
return checksum(blob, len(blob))
@Demonslay335
Demonslay335 / globeimposter_config.py
Last active January 16, 2023 14:49
Extract GlobeImposter ransomware config
"""
Extract GlobeImposter 2.0 Ransomware Config
Author: @demonslay335
"""
import os
import sys
import binascii
import re
import hashlib
@Demonslay335
Demonslay335 / dump.py
Last active March 1, 2024 08:01
Dumps a PE from VirtualAlloc/VirtualProtect
import os
import sys
import time
import winappdbg
import traceback
class MyEventHandler(winappdbg.EventHandler):
last_alloc_memory = 0