Skip to content

Instantly share code, notes, and snippets.

@odzhan
odzhan / zx7_compress.c
Created January 18, 2020 18:30
ZX7 compressor
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_OFFSET 2176 /* range 1..2176 */
#define MAX_LEN 65536 /* range 2..65536 */
typedef struct match_t {
size_t index;
@odzhan
odzhan / lde.h
Created June 1, 2020 17:30
lde.h
#ifndef LDE_H
#define LDE_H
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <dbgeng.h>
#pragma comment(lib, "dbgeng.lib")
@odzhan
odzhan / lde.c
Last active October 18, 2020 03:47
lde.c
#include "lde.h"
LDE::LDE() {
CHAR path[MAX_PATH];
ctrl = NULL;
clnt = NULL;
// create a debugging client
@odzhan
odzhan / inject_dll.c
Last active May 27, 2022 09:43
Inject DLL into remote process using dynamic invocation of system calls.
/**
Copyright © 2019-2020 Odzhan. All Rights Reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
@odzhan
odzhan / nullz.c
Last active February 21, 2021 09:56
PoC for encoding/decoding null bytes in shellcode
//
// A simple PoC for the blog post : Encoding Null Bytes Faster With Escape Sequences
// https://modexp.wordpress.com/2020/06/26/shellcode-encoding-null-bytes-faster/
//
// odzhan, june 2020
//
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@odzhan
odzhan / lsa_extension.md
Last active July 31, 2022 23:10
LSA Extension Internals

LSA Extension Internals

About

I want to use lsasrv!LsaProtectMemory() inside the LSASS process to encrypt a block of memory and return the ciphertext. It's part of the LsapLsasrvIfTable interface in lsasrv.dll, but unless I'm mistaken can only be accessed by another LSA extension using the lsasrv!QueryLsaInterface() function. The following text is some basic information about the internal structures.

LsapLsasrvIfTable:
  dq offset LsaProtectMemory
  dq offset LsaUnprotectMemory

dq offset LsaIFreeReturnBuffer

@odzhan
odzhan / hooks.txt
Created January 9, 2022 20:18
User-mode API hooked by EDR
The following is a list of user-mode API that can sometimes be hooked by an EDR. It's not an extensive list by any means.
ntdll!NtAllocateVirtualMemory
ntdll!ZwFreeVirtualMemory
ntdll!NtMapViewOfSection
ntdll!NtOpenProcess
ntdll!NtUnmapViewOfSection
ntdll!NtWriteVirtualMemory
ntdll!NtProtectVirtualMemory
ntdll!NtLoadDriver
@odzhan
odzhan / gist:49a2b450ede6ddc2323e43188de53467
Created February 11, 2022 14:26 — forked from nicholasmckinney/gist:3d748d6c3d7d52ce37479f7ef96a5478
DynaCall Article Dr Dobbs, November 1998
An Automation Object for Dynamic DLL Calls
Here's an OLE automation object for dynamically declaring and accessing functions in external DLLs 


November 01, 1998
URL:http://www.drdobbs.com/windows/an-automation-object-for-dynamic-dll-cal/210200078 

Jeff Stong has been developing DOS, Windows, and Windows NT based applications for 10 years. Jeff can be contacted at [email protected].
You can access external DLLs from Visual Basic by using the Declare statement to declare the name of the function you want to call and the DLL that it resides in. VBScript, however, doesn't support the Declare statement. This article presents an OLE automation object that lets VBScript (or any other environment that can access automation objects) dynamically declare and access functions in external DLLs.
Using the DynamicWrapper Object
@odzhan
odzhan / charm_hash.c
Created June 1, 2022 09:41
256-Bit Hash using Xoodoo permutation
//
// Charm 256-bit hash ripped from: https://github.com/jedisct1/charm
//
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#define XOODOO_ROUNDS 12
@odzhan
odzhan / tlsclient.cpp
Created June 7, 2022 00:06
C++ SSPI Schannel TLS example
// Compiles with Visual Studio 2008 for Windows
// This C example is designed as more of a guide than a library to be plugged into an application
// That module required a couple of major re-writes and is available upon request
// The Basic example has tips to the direction you should take
// This will work with connections on port 587 that upgrade a plain text session to an encrypted session with STARTTLS as covered here.
// TLSclient.c - SSPI Schannel gmail TLS connection example
#define SECURITY_WIN32