Skip to content

Instantly share code, notes, and snippets.

@BlackOfWorld
BlackOfWorld / NtGet stuff.cpp
Last active February 26, 2023 12:59
This is just a useful meme
#define NtGetCurrentProcess() (HANDLE)-1
#define NtGetCurrentThread() (HANDLE)-2
#ifdef _WIN64
#define NtGetPeb() (PPEB)__readgsqword(0x60)
#define NtGetTeb() (PTEB)__readgsqword(0x30)
#define NtGetPid() (uint32_t)__readgsqword(0x40) /* GetCurrentProcessId() */
#define NtGetTid() (uint32_t)__readgsqword(0x48) /* GetCurrentThreadId() */
#define NtGetErr() (uint32_t)__readgsqword(0x68) /* GetLastError()*/
#define _NtGetSeh() (void**)__readgsqword(0x00)
#define _NtGetStackHigh() (void**)__readgsqword(0x08)
@udf
udf / write_up.md
Last active November 13, 2024 05:44
A Trick To Use mkMerge at The Top Level of a NixOS module

The Setup

I wanted to write a module that generates multiple systemd services and timers to scrub some zfs pools at certain intervals. The default scrub config does not support individual scrub intervals for each pool.

I want the config to look like this:

{
  services.zfs-auto-scrub = {
 tank = "Sat *-*-* 00:00:00";
@vorstrelok
vorstrelok / keepassxc_pam.fish
Created February 2, 2021 15:20
KeePassXC PAM loing manager integration
#!/usr/bin/fish --private
# !!!Security note!!!
# This will give any process running as your user access to your password while
# key has not expired (2 minutes or revocation by service, whatever comes first)
# Proper solution would probably be writing PAM module and transfering key
# straight to KeePassXC's own keyring
set userid (/usr/bin/id -u "$PAM_USER")
if test "$PAM_TYPE" = 'auth'
@ManasJayanth
ManasJayanth / esy.json
Last active May 29, 2020 04:41
Dune 2.3.1 on esy
{
"dependencies": {
"ocaml": "4.6.x",
"@opam/ocaml-lsp-server": "ocaml/ocaml-lsp:ocaml-lsp-server.opam"
},
"resolutions": {
"@opam/dune": {
"source": "https://github.com/ocaml/dune/releases/download/2.5.1/dune-2.5.1.tbz#6c09f4d53e9169498ab017597c4343ceb00f6ead",
"override": {
"buildsInSource": true,
@Hakky54
Hakky54 / openssl_commands.md
Last active December 27, 2024 11:53 — forked from p3t3r67x0/openssl_commands.md
OpenSSL Cheat Sheet

OpenSSL Cheat Sheet 🔐

Install

Install the OpenSSL on Debian based systems

sudo apt-get install openssl
@nh2
nh2 / detect-nix-sandbox.md
Last active March 7, 2024 22:03
How to determine if the nix sandbox is in effect on a system

How to determine if the nix sandbox is in effect on a system

Do the same as the nix-info script, which nix-builds this file and inspects the exit code.

Short version:

nix-build --no-out-link -E 'import <nixpkgs/pkgs/tools/nix/info/multiuser.nix>' 2> /dev/null
@piyusht007
piyusht007 / findIAMUsers.py
Created January 9, 2020 07:21
Python script to find AWS IAM users that has LastActivity/Access Key Age >= 90 days
import boto3
from datetime import datetime, timedelta
client = boto3.client('iam')
users = client.list_users()
flaggedUsers = []
flaggedUserThreshold = 90
for key in users['Users']:
@walduino
walduino / ffchromeCA.yaml
Created January 3, 2020 14:57
Ansible to add cert to CA and make firefox and chrome use the system CA store under linux
---
- name: certauth.yml | Make sure the folder exists (Debian, Ubuntu)
file:
path: /usr/local/share/ca-certificates
state: directory
- name: certauth.yml | Download root CA
get_url:
url: "{{ install_ip }}/xxx.crt"
dest: "/usr/local/share/ca-certificates/xxx.crt"
@mbernat
mbernat / watch.sh
Last active December 23, 2019 00:14
Automatically restart an esy binary after a rebuild
#!/usr/bin/env bash
APP=$1
PID="nope"
inotifywait -q -m -e create _esy/default |
while read -r filename event; do
if [[ "$event" == "CREATE build" ]]; then
if [[ "$(ps -ao '%p' | grep ${PID})" != "" ]]; then
kill -9 ${PID}
fi
@Et7f3
Et7f3 / sizeof.c
Last active October 24, 2019 14:52
strange sizeof behaviour
/******************************************************************************
Online C Compiler.
Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <stdio.h>