Skip to content

Instantly share code, notes, and snippets.

@christoofar
christoofar / main.md
Last active April 21, 2024 22:01
Wrapping a C library call in a defensive Go routine
This study focuses on the strategies used by the "xz backdoor", an extremely
complex piece of malware that contains its own x64 disassembler inside of it 
to find critical locations in your code and hijacks it by swapping out your 
code with its own as it runs.  Because this a machine-code based attack,
all code written in any program language can be attacked and is vulnerable.

Instead of targeting sshd directly, the xz 
backdoor injects itself in the parent systemd process then hijacks the 
GNU Dynamic Linker (ld), before sshd is even started or libcrypto.so is 
@punzik
punzik / print-to-terminal-pts.c
Last active February 19, 2024 17:10
Print to terminal via pts
#define _GNU_SOURCE
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <signal.h>
#include <string.h>
volatile int running = 1;
@odivlad
odivlad / OVN.md
Last active December 29, 2023 07:07
OVN cheat sheet

Manpages

Architecture:

man ovn-architecture

OVN_Northbound:

@yakuter
yakuter / cancel-io-copy.go
Created April 25, 2021 19:25
IO Copy cancellation
// Source: https://ixday.github.io/post/golang-cancel-copy/
import (
"io"
"context"
)
// here is some syntaxic sugar inspired by the Tomas Senart's video,
// it allows me to inline the Reader interface
type readerFunc func(p []byte) (n int, err error)
@wallyqs
wallyqs / wq.go
Created April 16, 2021 00:04
Pull Subscribe + WorkQueuePolicy
package main
import (
"context"
"encoding/json"
"errors"
"math"
"time"
"log"
@fmount
fmount / standalone_destroy.sh
Last active April 4, 2024 21:54
Destroy a cephadm deployed Ceph cluster
#!/bin/bash
set -x
fsid="$1"
cephadm rm-cluster --fsid $fsid --force
source /etc/os-release
sudo systemctl stop tripleo_\*
sudo systemctl stop ceph\*
sudo pcs cluster destroy
if [ $VERSION_ID == "7" ]; then
sudo docker ps -a -q | xargs docker rm -f
@borrrden
borrrden / launch.json
Created January 28, 2021 02:13
VSCode Setup for Debugging PonchoOS
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Kernel",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/kernel/bin/kernel.elf",
"args": [],
"stopAtEntry": false,
@borrrden
borrrden / instructions.sh
Last active November 13, 2023 22:47
Debugging ponchoOS kernel
# INSIDE WSL, install gdb (one-time instruction)
sudo apt install gdb
# Add the following to your kernel Makefile CFLAGS, so that gcc will generate
# debug symbols that the debugger can use
# Note: The thing being added is -g, so as of lesson 12 it should look like this.
# Delete all the contents of the lib folder to force a recompile
CFLAGS = -ffreestanding -fshort-wchar -g
# Add the following to your qemu invocation and start QEmu:
@plembo
plembo / chgkvmnetcfg.md
Last active April 27, 2024 22:48
Changing a KVM network configuration

Changing a KVM (libvirtd) network configuration

The documentation recommends you do this using virsh net update, but you'll need to read it very carefully to figure out exactly how -- because they provide you with only a single example to work with.

Only the following virtual network components can be changed using net-update:

ip-dhcp-host
ip-dhcp-range (add/delete only, no modify)
forward-interface (add/delete only)
@zserge
zserge / guest.S
Created May 10, 2020 08:41
A tiny KVM host to run a 16-bit real mode "kernel"
# A tiny 16-bit guest "kernel" that infinitely prints an incremented number to the debug port
#
# Build it:
#
# as -32 guest.S -o guest.o
# ld -m elf_i386 --oformat binary -N -e _start -Ttext 0x10000 -o guest guest.o
#
.globl _start