Skip to content

Instantly share code, notes, and snippets.

/* From the 'musl-tools' package:
*
* $ musl-gcc -Wall -Os -static -o test test.c
*/
#include <signal.h>
#include <sys/wait.h>
#include <unistd.h>
void nothing(int signum) {}
@ayosec
ayosec / README.md
Created January 29, 2012 11:55
GDB commands to trace calls to malloc/free

Attach to a running process with

  gdb -x trace-dyn-mem -p $PID

After every malloc the returned value (the allocated address) will be read from the RAX (64 bits) register.

After every free the last item in the backtrace (the free itself) will be shown. With the libc6-dbg package installed you can see the address passed as the first argument of free.

8.2.3. HTTP log format
----------------------
The HTTP format is the most complete and the best suited for HTTP proxies. It
is enabled by when "option httplog" is specified in the frontend. It provides
the same level of information as the TCP format with additional features which
are specific to the HTTP protocol. Just like the TCP format, the log is usually
emitted at the end of the session, unless "option logasap" is specified, which
generally only makes sense for download sites. A session which matches the
"monitor" rules will never logged. It is also possible not to log sessions for
@ayosec
ayosec / Makefile
Created January 27, 2012 12:37
Wrap ioctls
all: fakeioctl.so
CFLAGS=-D_GNU_SOURCE -g -Wall
fakeioctl.so: fakeioctl.c
gcc $(CFLAGS) -fPIC -shared -ldl -o fakeioctl.so fakeioctl.c
.PHONY: all clean
@ayosec
ayosec / playerctl-fast.sh
Created October 5, 2020 04:45
playerctl: skip metada to control music
#!/bin/bash
set -euo pipefail
case "${1:-}" in
next)
MEMBER=Next
;;
previous)
@ayosec
ayosec / query-athena
Created January 29, 2020 17:25
Script to send queries to AWS Athena
#!/bin/bash
#
# This program sends a query to Athena, and download the results in CSV when
# the execution is completed. It expects the database name and the query as
# arguments:
#
# $ query-athena -d mydb 'select ...'
#
# The CSV file is downloaded in /tmp/QUERYID.csv by default. To use a different
# file, use -w:
@ayosec
ayosec / content.md
Created July 16, 2012 10:13
Why Lisp macros are cool, a Perl perspective
@ayosec
ayosec / list-images.sh
Last active July 14, 2022 23:49
Show image thumbnails using Sixel graphics.
#!/bin/bash
#
# Usage:
#
# $ list-images [files]*
#
# This script is a demo to show how to use hyperlinks with images in Alacritty.
# It can be used on any terminal emulator with Sixel support, but it is not
# intended to be used for regular use, mostly because it lacks a proper way to
# handle errors (it just dies).
@ayosec
ayosec / clear-sixel-reg.rb
Created July 14, 2022 22:02
Clear pixels on a specific color register in a Sixel image.
#!/usr/bin/env ruby
#
# Usage:
#
# $ clear-sixel-reg register? files*
#
# The script reads Sixel images, are replaced every pixel using the
# specified color register with holes. The output is always sent to stdout.
#
# The `background selector` parameter of the protocol selector is forced
import os, sys
from ctypes import CDLL
libc = CDLL("libc.so.6")
CLONE_NEWNS = 0x00020000
CLONE_NEWCGROUP = 0x02000000
CLONE_NEWUTS = 0x04000000
CLONE_NEWIPC = 0x08000000
CLONE_NEWUSER = 0x10000000