Skip to content

Instantly share code, notes, and snippets.

@anthonyprintup
anthonyprintup / .clang-format
Created October 2, 2023 13:06
Personal Clang-Format Style
# Generated from CLion C/C++ Code Style settings
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: None
AlignOperands: Align
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: true
@anthonyprintup
anthonyprintup / ida.hpp
Created September 12, 2023 14:26
A compile-time byte pattern matcher designed to match IDA patterns.
// Created by Anthony Printup on 4/21/2023.
#pragma once
#include <algorithm>
#include <bitset>
#include <cstdint>
#include <exception>
#include <functional>
#include <ranges>
@anthonyprintup
anthonyprintup / event.hpp
Created October 19, 2022 10:26
Event listener (signals) implementation.
#pragma once
namespace events {
struct Event {};
}
@anthonyprintup
anthonyprintup / codewars_cpp_bypass.cpp
Last active October 15, 2022 19:26
Pass any C++ Kata by replacing the test listener's virtual functions.
[[gnu::naked]] int mprotect_syscall(void *const, const size_t, const int) noexcept {
asm volatile(".intel_syntax;"
"mov rax, 10;" // syscall id
"syscall;"
"ret" ::: "memory", "cc");
}
int mprotect(void *address, const size_t length, const int protection) noexcept {
constexpr auto page_size = 4096ul;
address = reinterpret_cast<void*>(reinterpret_cast<std::uintptr_t>(address) & -page_size);
@anthonyprintup
anthonyprintup / exit_codes.py
Last active September 15, 2022 08:01
Script for managing a matrix-synapse server
from __future__ import annotations
from enum import IntEnum, auto as _enum_auto
# noinspection PyArgumentList
class ExitCode(IntEnum):
# No errors occurred
SUCCESS: ExitCode = 0
# Certificate related errors
@anthonyprintup
anthonyprintup / main.cpp
Created August 5, 2022 16:11
API resolution using software breakpoints
#include <cstdio>
#include <cstdint>
#include <Windows.h>
constexpr auto instruction_bytes_to_skip {1z}; // sizeof(int 3)
constexpr auto first_magic_value {1234z}, second_magic_value {5678z}, magic_return_value {0xABCDz};
using HashType = std::uint64_t;
[[gnu::always_inline, gnu::pure, nodiscard]] std::uint64_t resolve_api(const HashType module_hash, const HashType api_hash) {
std::uint64_t first_register {}, second_register {}, return_value {};