Skip to content

Instantly share code, notes, and snippets.

#include <linux/hrtimer.h>
#include <linux/module.h>
#include <linux/kernel.h>
static struct hrtimer timer;
enum hrtimer_restart yell_rick( struct hrtimer *timer )
{
ktime_t time;
printk(KERN_INFO "I turned myself into a logger morty! I'm dmesg RIIIICK!\n");
@hashbrowncipher
hashbrowncipher / build.sh
Created December 22, 2017 16:44
builds a gof3r-based image installer
#!/bin/bash
set -x
set -o errexit
set -o nounset
set -o pipefail
readonly INITRD_DIR=initrd
base() {
debootstrap \
@hashbrowncipher
hashbrowncipher / s3_imager
Last active December 30, 2017 12:01
An imager based on s3gof3r, for reimaging EC2 nodes without losing their instance store
#!/bin/bash
set -x
set -o errexit
set -o nounset
set -o pipefail
#------- end of header (relevant for root/kernel.sh, below)
readonly INITRD_DIR=initrd
readonly SSH_KEY="ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIyK5qcNzv65trF8pdiLZbnBS6NLJqiHhGSQo6veOswH"
@hashbrowncipher
hashbrowncipher / hfsc-shape.sh
Created January 13, 2018 00:44 — forked from eqhmcow/hfsc-shape.sh
HFSC - linux traffic shaping's best kept secret
#!/bin/bash
# As the "bufferbloat" folks have recently re-discovered and/or more widely
# publicized, congestion avoidance algorithms (such as those found in TCP) do
# a great job of allowing network endpoints to negotiate transfer rates that
# maximize a link's bandwidth usage without unduly penalizing any particular
# stream. This allows bulk transfer streams to use the maximum available
# bandwidth without affecting the latency of non-bulk (e.g. interactive)
# streams.
@hashbrowncipher
hashbrowncipher / hfsc-shape.sh
Created January 13, 2018 00:44 — forked from eqhmcow/hfsc-shape.sh
HFSC - linux traffic shaping's best kept secret
#!/bin/bash
# As the "bufferbloat" folks have recently re-discovered and/or more widely
# publicized, congestion avoidance algorithms (such as those found in TCP) do
# a great job of allowing network endpoints to negotiate transfer rates that
# maximize a link's bandwidth usage without unduly penalizing any particular
# stream. This allows bulk transfer streams to use the maximum available
# bandwidth without affecting the latency of non-bulk (e.g. interactive)
# streams.
#include <time.h>
int main() {
struct timespec start;
struct timespec end;
clock_gettime(CLOCK_REALTIME, &start);
for(int i = 0; i < 5000000; i++) {
clock_gettime(CLOCK_REALTIME, &end);
}
printf("%lu %lu\n", end.tv_sec - start.tv_sec, end.tv_nsec - start.tv_nsec);
@hashbrowncipher
hashbrowncipher / multicore_server.py
Last active September 21, 2018 09:00
Multiprocess WSGI server using gevent==1.3.6, demonstrating sendfile
#!/usr/bin/python3
"""
Copyright 2018 Josh Snyder
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@hashbrowncipher
hashbrowncipher / unlambda.py
Created October 22, 2018 20:30
Disassembles simple Python lambdas
import dis
from itertools import chain
from types import CodeType
def _get_func_args(stack, count):
return reversed([stack.pop() for i in range(count)])
def visit_func(stack, isn):
@hashbrowncipher
hashbrowncipher / CGroupThreads.java
Created January 10, 2019 22:14
a java PoC for launching threads into CGroups
import java.io.IOException;
import java.lang.Runnable;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.concurrent.Executors;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadFactory;
public class CGroupThreads {
static class CGThread extends Thread {
@hashbrowncipher
hashbrowncipher / init
Created April 21, 2019 16:42
load a squashfs and run it
#!/bin/bash
set -x
set -o errexit
set -o nounset
set -o pipefail
function poweroff_before_panic {
poweroff -f
}
trap poweroff_before_panic EXIT