Skip to content

Instantly share code, notes, and snippets.

@gingerBill
gingerBill / defer.cpp
Last active November 20, 2022 17:45
Golang Defer in C++
////////////////////////////////////////////////////////////////
//
// Defer statement
// - Akin to D's SCOPE_EXIT or similar to Go's defer but scope-based
//
////////////////////////////////////////////////////////////////
#if defined(__cplusplus)
extern "C++" {
// NOTE(bill): Stupid fucking templates
template <typename T> struct gbRemove_Reference { typedef T Type; };
@alirobe
alirobe / reclaimWindows10.ps1
Last active July 3, 2024 09:36
This Windows 10 Setup Script turns off a bunch of unnecessary Windows 10 telemetery, bloatware, & privacy things. Not guaranteed to catch everything. Review and tweak before running. Reboot after running. Scripts for reversing are included and commented. Fork of https://github.com/Disassembler0/Win10-Initial-Setup-Script (different defaults). N.…
###
###
### UPDATE: For Win 11, I recommend using this tool in place of this script:
### https://christitus.com/windows-tool/
### https://github.com/ChrisTitusTech/winutil
### https://www.youtube.com/watch?v=6UQZ5oQg8XA
### iwr -useb https://christitus.com/win | iex
###
###
#define _CRT_SECURE_NO_WARNINGS
#include <string.h>
#include <stdio.h>
#include <windows.h>
#pragma warning (disable: 4146)
#include <stdint.h>
#ifdef _DEBUG
#define Assert(x) \
if (!(x)) { MessageBoxA(0, #x, "Assertion Failure", MB_OK); __debugbreak(); }

Exploiting Lua 5.1 on x86_64

The following Lua program generates a Lua bytecode program called lua-sandbox-rce.luac, which in turn spawns a shell from within Lua 5.1 sandbox. The remainder of this document attempts to explain how this program works by a whirlwind tour of relevent bits of the Lua 5.1 virtual machine.

function outer()
  local magic -- In bytecode, the stack slot corresponding to this local is changed
  local function middle()
    local co, upval
    local ub1 = {[0] = -- Convert uint8_t to char[1]
//
// Author: Jonathan Blow
// Version: 1
// Date: 31 August, 2018
//
// This code is released under the MIT license, which you can find at
//
// https://opensource.org/licenses/MIT
//
//
@mmozeiko
mmozeiko / go_aeshash.h
Created November 14, 2018 07:34
Go's AES-NI based hash
#include <stddef.h>
#include <stdint.h>
#include <intrin.h>
// see aeshashbody in https://github.com/golang/go/blob/master/src/runtime/asm_amd64.s
// this is initialized on process startup with random from system
static __declspec(align(16)) uint8_t aeskeysched[128];
static __declspec(align(16)) const uint8_t masks[16][16] =
@thebirk
thebirk / annotations.go
Last active February 7, 2019 16:44
Odin annotations proposal
// This example has some faults, the most important one is how are you gonna know what data
// the annotation actually annotates. The best way would probably be to tag it with
// {entity_id: typeid, entity_ptr: rawptr}, this would allow you to switch on the type
// and cast the ptr. That way you can ensure the annotation was added to the correct type
// and not some random entity
package main
// Proposed change for existing compiler attributes
@gingerBill
gingerBill / create_vulkan_odin_wrapper.py
Last active August 24, 2021 15:00
create_vulkan_odin_wrapper.py
import re
import urllib.request as req
from tokenize import tokenize
from io import BytesIO
import string
import os.path
import math
if not os.path.isfile("vulkan_core.h"):
src = req.urlopen("https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/master/include/vulkan/vulkan_core.h").read().decode('utf-8')
@gingerBill
gingerBill / odin_syntax.ebnf
Last active March 17, 2021 04:37
Odin EBNF
/*
Production = production_name "=" [ Expression ] "." .
Expression = Alternative { "|" Alternative } .
Alternative = Term { Term } .
Term = production_name | token [ "…" token ] | Group | Option | Repetition .
Group = "(" Expression ")" .
Option = "[" Expression "]" .
Repetition = "{" Expression "}" .