Skip to content

Instantly share code, notes, and snippets.

View Ferdi265's full-sized avatar

Ferdinand Bachmann Ferdi265

View GitHub Profile
@Ferdi265
Ferdi265 / test.cpp
Created June 2, 2020 17:22
virtual_base_union -- a union class that functions as a smart pointer to a polymorphic type
#include <iostream>
#include <string>
#include "virtual_base_union.h"
class Screen {
public:
virtual ~Screen() = default;
virtual void draw() = 0;
};
@Ferdi265
Ferdi265 / ignored.md
Last active October 16, 2020 15:04
GNU ld.so ignored ELF fields

Fields ignored by GNU ld.so in ELF data structures for shared objects

This file documents which fields can be safely corrupted, overlapped, or filled with code, while still being loadable by GNU ld.so via LD_PRELOAD. Information gathered via experimentation. This list may be incomplete.

A checkmark means this field is ignored, a plus means part of the field is ignored. offsets are in hex.

Elf64_Ehdr:

  • 00-10: e_ident
@Ferdi265
Ferdi265 / golf.so.s
Created April 26, 2020 23:47
PlaidCTF golf.so challenge - LosFuzzys
bits 64
org 0x0
ehdr:
db 0x7f, "ELF" ; e_ident[0:4] = ELFMAG
db 2 ; e_ident[4] = ELFCLASS64
db 1 ; e_ident[5] = ELFDATA2LSB
db 1 ; e_ident[6] = EV_CURRENT
db 0 ; e_ident[7] = ELFOSABI_SYSV
db 0 ; e_ident[8] = EI_ABIVERSION
@Ferdi265
Ferdi265 / cenum.sh
Last active February 6, 2019 14:26
Script to expand macros and enums from C headers
#!/bin/bash
CC=${CC:-gcc}
# check usage
if [[ $# -eq 0 ]]; then
echo "usage: cenum [headers..] ENUM" >&2
exit 1
fi
@Ferdi265
Ferdi265 / cmacro.sh
Created December 28, 2018 18:32
Script to expand macros from C headers
#!/bin/bash
# check usage
if [[ $# -eq 0 ]]; then
echo "usage: cmacro [headers..] MACRO" >&2
exit 1
fi
# generate temporary file
f=$(mktemp --suffix=.c)
@Ferdi265
Ferdi265 / slidername.html
Created September 24, 2018 18:25
Name Slider Thingy
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Name Slider Thingy</title>
<style type="text/css">
#name {
margin-left: 1em;
}
.content {
@Ferdi265
Ferdi265 / anews.py
Last active September 14, 2022 04:02
anews - Arch Linux news python script
#!/usr/bin/env python3
import os
import sys
import time
import termcolor
import feedparser
# Usage:
# anews [number of headlines (optional)]
# e.g. "anews 6" or "anews"
@Ferdi265
Ferdi265 / xlmode
Created October 14, 2015 21:06
xautolock control wrapper script
#!/bin/bash
xlenable() {
echo enabled > /tmp/xlmode-$DISPLAY
[[ "$1" != "-quiet" ]] && notify-send "xautolock" "Automatic locking enabled"
xautolock -enable
}
xldisable() {
echo disabled > /tmp/xlmode-$DISPLAY
@Ferdi265
Ferdi265 / rc
Created October 14, 2015 20:56
i3 rc script
#!/bin/bash
# set i3 to default mode, creates /tmp/i3mode-$DISPLAY if neccessary
i3mode default
# enable xautolock if disabled, creates /tmp/xlmode-$DISPLAY if neccessary
xlmode enable -quiet
# do autostart (needs dex to run .desktop files)
if test -d /etc/xdg/autostart; then
shopt -s nullglob
#!/bin/bash
echo $1 > /tmp/i3mode-$DISPLAY
exec i3-msg mode $1