Skip to content

Instantly share code, notes, and snippets.

@alex-bender
alex-bender / Makefile
Created March 14, 2016 19:13
Self-documented Makefile; Require silver searcher aka ag
CFLAGS=-Wall -g
clean: ## Clean directory
rm -f *.o
help: ## Help target
@ag '^[a-zA-Z_-]+:.*?## .*$$' --nofilename $(MAKEFILE_LIST) \
| sort \
| awk 'BEGIN{FS=": ## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
@alex-bender
alex-bender / gist:fd65ae11a66c1388b93a0d3cd392a322
Created May 8, 2016 16:41 — forked from rygorous/gist:e0f055bfb74e3d5f0af20690759de5a7
A bit of background on compilers exploiting signed overflow
Why do compilers even bother with exploiting undefinedness signed overflow? And what are those
mysterious cases where it helps?
A lot of people (myself included) are against transforms that aggressively exploit undefined behavior, but
I think it's useful to know what compiler writers are accomplishing by this.
TL;DR: C doesn't work very well if int!=register width, but (for backwards compat) int is 32-bit on all
major 64-bit targets, and this causes quite hairy problems for code generation and optimization in some
fairly common cases. The signed overflow UB exploitation is an attempt to work around this.
@alex-bender
alex-bender / kvm
Created October 5, 2016 14:34 — forked from leberus/kvm
# aptitude install qemu-kvm libvirt-bin
# create a bridge with your current interface
auto eth1
iface eth1 inet manual
auto br0
iface br0 inet dhcp
bridge_ports eth1
@alex-bender
alex-bender / hastebin.sh
Created October 13, 2016 10:58 — forked from flores/hastebin.sh
hastebin shell client
#!/bin/bash
server='hastebin.com';
usage="$0 pastes into $server
usage: $0 something
example: '$0 pie' or 'ps aufx |$0'"
if [ -z $1 ]; then
str=`cat /dev/stdin`;
@alex-bender
alex-bender / hastebin
Created October 13, 2016 11:01
paste to hastebin
#!/usr/bin/python
import urllib2
import os
import json
URL = 'http://hastebin.com/documents'
def run(*args):
if args:
@alex-bender
alex-bender / get_image_manifest.sh
Last active April 1, 2021 14:17
Docker Registry v2 get manifest and push\pull
#!/bin/bash
#
# Shell scripts for get image manifest from v2 registry
#
# Tested on Debian 8, curl 7.38.0, jq-1.5
#
set -e -u
# Default tag is latest
@alex-bender
alex-bender / sshpass.py
Created July 31, 2017 07:01 — forked from virtuald/sshpass.py
Simple python wrapper to give SSH a password for automation purposes (with output capture)
#!/usr/bin/env python3
import os
import sys
_b = sys.version_info[0] < 3 and (lambda x:x) or (lambda x:x.encode('utf-8'))
def ssh_exec_pass(password, args, capture_output=False):
'''
Wrapper around openssh that allows you to send a password to
@alex-bender
alex-bender / SimpleHTTPServerWithUpload.py
Created July 31, 2017 07:06 — forked from zhangxiaoyang/SimpleHTTPServerWithUpload.py
Simple Python Http Server with Upload
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""
@alex-bender
alex-bender / TrueColour.md
Created September 4, 2017 16:39 — forked from XVilka/TrueColour.md
True Colour (16 million colours) support in various terminal applications and terminals

Colours in terminal

It's a common confusion about terminal colours... Actually we have this:

  • plain ascii
  • ansi escape codes (16 colour codes with bold/italic and background)
  • 256 colour palette (216 colours + 16 ansi + 24 gray) (colors are 24bit)
  • 24bit true colour ("888" colours (aka 16 milion))
printf "\x1b[${bg};2;${red};${green};${blue}m\n"