Skip to content

Instantly share code, notes, and snippets.

@mooware
mooware / ld-preload-intercept-method.cpp
Last active April 9, 2023 03:13
Intercept C++ methods with LD_PRELOAD
View ld-preload-intercept-method.cpp
// this file is an example of how to intercept a C++ method by using the
// LD_PRELOAD environment variable of the GNU dynamic linker.
//
// it works like this:
//
// 1) define a method that will have the same symbol as the intercepted
// method when compiled. For example, the method Foo::getValue()
// defined here has the mangled symbol "_ZNK3Foo8getValueEv".
// tools like nm, objdump or readelf can display the symbols of
// binaries. note that depending on compiler and linker options,
@mooware
mooware / srl.html
Last active January 14, 2023 01:13
HTML page to list SRL races and link to multitwitch and similar services
View srl.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>SRL Races</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script>
@mooware
mooware / outlook-disable-encryption.py
Created October 23, 2019 00:51
Python script to monitor the Windows registry and ensure that Outlook email encryption by default stays off
View outlook-disable-encryption.py
import ctypes, ctypes.wintypes
advapi32 = ctypes.windll.advapi32
# LSTATUS RegOpenKeyExA(HKEY hKey, LPCSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
RegOpenKeyExA = advapi32.RegOpenKeyExA
RegOpenKeyExA.argtypes = (ctypes.wintypes.HKEY, ctypes.wintypes.LPCSTR, ctypes.wintypes.DWORD, ctypes.wintypes.DWORD, ctypes.wintypes.PHKEY)
# LSTATUS RegCloseKey(HKEY hKey)
RegCloseKey = advapi32.RegCloseKey
@mooware
mooware / donordrive-display.html
Last active November 4, 2021 19:20
Donordrive Display
View donordrive-display.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
<style>
/* local css here */
@mooware
mooware / gnu-libc-print-stacktrace.c
Last active October 15, 2021 06:17
Print a stacktrace on Linux with GNU libc
View gnu-libc-print-stacktrace.c
// this code fragment shows how to print a stack trace (to stderr)
// on Linux using the functions provided by the GNU libc
#include <execinfo.h>
#define MAX_STACK_LEVELS 50
// helper-function to print the current stack trace
void print_stacktrace()
{
@mooware
mooware / srlmulti.py
Last active January 17, 2021 01:08
Simple bottle.py application to open a multitwitch (or similar site) for an SRL race
View srlmulti.py
from bottle import *
from urllib.request import urlopen
import json
import re
DEFAULT_HOSTS = ['multitwitch.tv', 'multistre.am', 'kadgar.net/live']
SRL_API = "https://api.speedrunslive.com/races/"
SANITY_RE = re.compile('[0-9a-z]+')
RACE_STATE_COMPLETE = 4 # from the SRL API
@mooware
mooware / jollymania.py
Created November 15, 2020 04:25
Download games2jolly games for Flashpoint
View jollymania.py
import os.path
import sqlite3
import urllib.request
def main():
db = sqlite3.connect(os.path.join('Data', 'flashpoint.sqlite'))
cur = db.execute("SELECT launchCommand FROM game WHERE launchCommand LIKE '%games2jolly%'")
urls = [s for (s,) in cur.fetchall()]
for index, url in enumerate(urls):
print('{}/{} {}'.format(index + 1, len(urls), url))
@mooware
mooware / colorstreamhandler.py
Last active October 19, 2020 13:36
Colored log output for Python logging framework. Works on Windows, Linux, and probably Mac as well.
View colorstreamhandler.py
# colored stream handler for python logging framework (use the ColorStreamHandler class).
#
# based on:
# http://stackoverflow.com/questions/384076/how-can-i-color-python-logging-output/1336640#1336640
# how to use:
# i used a dict-based logging configuration, not sure what else would work.
#
# import logging, logging.config, colorstreamhandler
#
@mooware
mooware / codepage_unzip.py
Created June 21, 2020 07:04
A little script to extract old japanese zip files with the correct text encoding for filenames. Most applications assume a US text codepage for old zip formats, which is not always correct.
View codepage_unzip.py
# A little script to extract old japanese zip files
# with the correct text encoding for filenames.
# Most applications assume a US text codepage for
# old zip formats, which is not always correct.
import os
import shutil
import sys
import zipfile
from datetime import datetime
@mooware
mooware / twitch_redirect.py
Last active February 2, 2020 00:58
Simple bottle.py application to play twitch.tv streams through HTML5 video
View twitch_redirect.py
# uses bottle.py as web framework, streamlink for getting the stream URL
# and hls.js to play the HLS stream in an HTML5 video tag
from bottle import *
from streamlink import Streamlink
from urllib.request import urlopen, Request
import sys, re, json
def u(s):
if isinstance(s, str):