Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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;
/* LZSS encoder-decoder (Haruhiko Okumura; public domain) */
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#define EI 11 /* typically 10..13 */
#define EJ 4 /* typically 4..5 */
#define P 1 /* If match length <= P then output one character */
#define N (1 << EI) /* buffer size */
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <inttypes.h>
#include <fcntl.h>
#ifdef TEST
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <inttypes.h>
#include <fcntl.h>
@odzhan
odzhan / rtlcompress.c
Last active March 1, 2026 19:34
Compression using NT Layer DLL API
/**
BSD 3-Clause License
Copyright (c) 2019 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:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.