Skip to content

Instantly share code, notes, and snippets.

View lietu's full-sized avatar

Janne Enberg lietu

View GitHub Profile
@lietu
lietu / assess_potential.py
Created March 29, 2024 23:50
Scan system for libraries and binaries potentially affected by any unknown liblzma vulnerabilities. Tested on Python 3.11
import asyncio
import os
import shutil
import subprocess
from pathlib import Path
# Base configuration
LIB_DIRS = ["/lib", "/lib32", "/usr/lib", "/usr/lib32"]
BIN_DIRS = [
"/bin",
@lietu
lietu / scan_liblzma.sh
Last active March 29, 2024 20:49
Find libraries and binaries that depend on liblzma.so.5 (or other infected libraries)
#!/usr/bin/env bash
# Likely only works on Linux due to GNU Find, probably needs to be ported for BSD utils
OPTIONAL_FIND_ARGS=-xdev # Remove if you don't have slow remote mounts etc.
# Start with liblzma
LIBS=liblzma.so.5
LIB_DIRS="/usr/lib /lib"
BIN_DIRS="/usr/bin /bin /usr/local/bin"
@lietu
lietu / log.py
Created October 15, 2021 15:36
Conditionally structured JSON logging in Python with loguru
import json
import logging
import random
import string
import sys
import traceback
from os import environ
from loguru import logger
@lietu
lietu / hg-git-sync.sh
Last active September 15, 2019 09:18
Script for unattended sync of a Mercurial (hg) repository to a Git repository
#!/usr/bin/env sh
#
# Unattended sync of Mercurial to Git
#
# You will need to configure GIT_REPO, possibly HG_REPO
# If using SSH you will also need to set up the SSH agent + key
#
# You will also need git-fast-import and git-remote-hg:
# https://github.com/felipec/git-remote-hg
@lietu
lietu / hg-git-sync.sh
Created September 15, 2019 09:05
Sync a Mercurial (hg) repository to a Git repository
#!/usr/bin/env sh
set -exu
# Which Git repo to sync with - change this for sure
GIT_REPO="git@..."
# Paths
HG_REPO="$(pwd -P)" # You might need to change this
GIT_TMP="/tmp/git-sync-$(date +%s)"
@lietu
lietu / freedome_test.rb
Created May 15, 2017 16:09
Reproducible problem with Rubygems when using FREEDOME
# This minimal script seems to reproduce the issue with Rubygems
#
# It seems Ruby DNS resolver does something odd, as when FREEDOME is on, this
# fails with a SocketError, and when FreeDOME is off it fails with a
# Resolv::ResolvError.
#
# This code is built based on Rubygems source code:
# https://github.com/rubygems/rubygems/blob/v2.3.0/lib/rubygems/remote_fetcher.rb#L92-L93
#
# That code is in the backtrace of `gem install --backtrace jekyll` when this error happens.
@lietu
lietu / obs_studio_video_playback.html
Last active September 2, 2016 12:46
Making living with OBS Studio easier
<html><head><!--
OBS Studio video playback tool. To get video to play automatically, and get audio to stream AND desktop so you can hear it as well.
1. Edit the "Configuration" -section below, save this file in the same directory as your video
2. Make sure you have the Browser Source installed in your OBS Studio
3. Add a new BrowserSource -source to your scene of choice
4. Choose "Local File" and point it to this file
5. Set width and height to your streaming resolution
6. Check "Shutdown when not active"
@lietu
lietu / calculate_strength.py
Created May 11, 2016 13:50
Python script to calculate minimum length of a key to achieve a given level of security.
#
# Calculate required key/password length to achieve satisfactory level
# of security. E.g. if you want something to be pretty secure so it can
# handle a week of brute forcing by pretty big hash farms.
#
# License: WTFPL http://www.wtfpl.net/
#
# How long do you want the cracking to take
TARGET_DURATION = 60 * 60 * 24 * 3 # Seconds
@lietu
lietu / install_djbdns.sh
Created May 31, 2014 09:42
Script to automatically install DJBDNS and dependencies on CentOS 6, should be easy to adapt to other OSes easily
#!/usr/bin/env bash
# Temporary directory to work in
TMPDIR="$HOME/tmp/djbdns"
# Where to install daemontools
PACKAGE="/package"
# Version numbers for packages
UCSPI_VERSION="0.88"