Skip to content

Instantly share code, notes, and snippets.

@mborgerson
mborgerson / pycrypto-aes-demo.py
Created March 29, 2014 03:06
A little Python tool that demonstrates how to set up an AES cipher using the PyCrypto library.
#!/usr/bin/env python
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
#
# In jurisdictions that recognize copyright laws, the author or authors
@mborgerson
mborgerson / mesa-offscreen-sw-demo.md
Last active March 9, 2022 17:18
Mesa Offscreen Software Rendering

Build Mesa Off-Screen Software Renderer

Last tested on October 6th, 2020, using a fresh Ubuntu 20.04 Docker image. Works with latest version of mesa (20.2.0), at time of writing.

# Install build dependencies
apt update
apt install build-essential git python3 python3-setuptools python3-mako bison flex meson pkg-config wget
@mborgerson
mborgerson / rail_fence_cipher.py
Created March 9, 2018 20:23
Little rail fence cipher
#!/usr/bin/env python
# Minified rail fence cipher (https://en.wikipedia.org/wiki/Rail_fence_cipher)
# Matt Borgerson, 2018
import argparse
# Iterative approach where we step through the input and add
# each character to the corresponding rail, then combine the
# rails in the end.
def encode(msg, n):
rm,l = list(range(n))+list(range(n-2,0,-1)),['']*n
@mborgerson
mborgerson / find_patchset_base.sh
Last active April 2, 2018 18:31
Find Patchset Base
#!/bin/bash
#
# This script will try to apply a patch set to a range of commits and stop
# once one is successfully identified. Useful for identifying the applicable
# patch base for an old patch set in a rapidly changing repository.
#
TAG_FROM='v2.8.1.1'
TAG_TO='v2.9.0'
@mborgerson
mborgerson / fatcat.py
Created February 4, 2020 01:42
Concatenate a lot of files
#!/usr/bin/env
# Copyright (c) 2020 Matt Borgerson
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
@mborgerson
mborgerson / deploy.sh
Created October 16, 2020 03:01
FTP deployment script
$ cat deploy_to_xbox.sh
#!/bin/bash
set -e
set -x
ftp -n -v 192.168.1.2 <<END
quote USER xbox
quote PASS xbox
binary
cd /E/
@mborgerson
mborgerson / gist:69c0ac554db245e1073152dae049e2a1
Last active June 18, 2021 01:33
Installing Windows 10 on Apple MBP early 2013 (UEFI)

Boot camp assistant works great, but it will install Windows in legacy boot mode and will prevent access to integrated graphics. If you want to install with native UEFI access and permit integrated graphics, do this instead.

Mostly follow this guide: https://fgimian.github.io/blog/2016/03/12/installing-windows-10-on-a-mac-without-bootcamp/

EXCEPT: Do not use unetbootin to create your Windows USB image. Instead, use a Windows machine and create your bootable USB with Microsoft's USB installer tool. This will grab necessary installation files from the web, so don't bother with downloading an ISO ahead of time. After using the tool to prepare your USB drive, copy your 'Windows Support Software' to the USB drive.

@mborgerson
mborgerson / find_printer.py
Created March 9, 2022 07:56
Find Python print culprit
# Hook the `print` built-in to find out where a print statement is coming from
import inspect
_print = print
def print(*vargs, **kwargs):
s = inspect.stack()[1]
_print(f'Printing from {s.filename}:{s.lineno}')
_print(*vargs, **kwargs)
import builtins
builtins.print = print
@mborgerson
mborgerson / angr-stub-demo.py
Last active January 26, 2023 00:58
angr: custom hook lookup
#!/usr/bin/env python
"""
angr demo: stub out all functions that are not in the main object's .text
section. Because we are just stubbing out all functions, simulation may not be
very meaningful. This could be extended though, for example to provide some
mock data.
Example target.c:
/* gcc -o target target.c */