Skip to content

Instantly share code, notes, and snippets.

Avatar

Georg Sauthoff gsauthof

View GitHub Profile
@gsauthof
gsauthof / compare_version.py
Created Jul 14, 2022
distutils.version.LooseVersion replacement
View compare_version.py
import operator
import re
split_version_re = re.compile('[.+-]')
class LooseVersion:
def __init__(self, s):
self.vs = split_version_re.split(s)
self.n = max(len(x) for x in self.vs)
def cmp(self, other, op):
@gsauthof
gsauthof / http_dump.py
Last active Jul 11, 2022
Listen for and dump HTTP requests to STDOUT
View http_dump.py
#!/usr/bin/env python3
# 2022, Georg Sauthoff
import argparse
import http.server
import json
import sys
class Dumper(http.server.BaseHTTPRequestHandler):
@gsauthof
gsauthof / pwm_ir_send.ino
Created Feb 6, 2022
Arduino sketch for transmitting a raw IR remote control code without dependencies
View pwm_ir_send.ino
// 2022, Georg Sauthoff <mail@gms.tf>
void setup() {
Serial.begin(9600);
Serial.println("Ready.");
cli(); // atomic section
// set Arduino Pin 3 low
PORTD &= ~ _BV(PORTD3);
@gsauthof
gsauthof / samsung-860-evo-kern.log
Last active Aug 10, 2021
Samsung 860 EVO kernel errors
View samsung-860-evo-kern.log
Dec 20 21:24:24 sos.lru.li kernel: ata3.00: exception Emask 0x10 SAct 0xffffffff SErr 0x440100 action 0x6 frozen
Dec 20 21:24:24 sos.lru.li kernel: ata3.00: irq_stat 0x08000000, interface fatal error
Dec 20 21:24:24 sos.lru.li kernel: ata3: SError: { UnrecovData CommWake Handshk }
Dec 20 21:24:24 sos.lru.li kernel: ata3.00: failed command: READ FPDMA QUEUED
Dec 20 21:24:24 sos.lru.li kernel: ata3.00: cmd 60/00:00:00:50:42/01:00:13:00:00/40 tag 0 ncq dma 131072 in
res 40/00:08:00:51:cf/00:00:0f:00:00/40 Emask 0x10 (ATA bus error)
Dec 20 21:24:24 sos.lru.li kernel: ata3.00: status: { DRDY }
Dec 20 21:24:24 sos.lru.li kernel: ata3.00: failed command: WRITE FPDMA QUEUED
Dec 20 21:24:24 sos.lru.li kernel: ata3.00: cmd 61/00:08:00:51:cf/01:00:0f:00:00/40 tag 1 ncq dma 131072 out
res 40/00:08:00:51:cf/00:00:0f:00:00/40 Emask 0x10 (ATA bus error)
View samsung-860-evo-smart.log
smartctl 7.1 2019-12-30 r5022 [x86_64-linux-5.8.18-300.fc33.x86_64] (local build)
Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Model Family: Samsung based SSDs
Device Model: Samsung SSD 860 EVO 250GB
Serial Number: [..]
LU WWN Device Id: [..]
Firmware Version: RVT04B6Q
User Capacity: 250,059,350,016 bytes [250 GB]
@gsauthof
gsauthof / xclipshow.cpp
Created Jan 27, 2016
Simplified, shortened version of http://unix.stackexchange.com/a/163115/1131, a clipboard dump tool
View xclipshow.cpp
// source: http://unix.stackexchange.com/a/163115/1131
// GS, 2016-01-27, simplify the code a little bit
#include <QApplication>
#include <QTimer>
#include <QClipboard>
#include <QMimeData>
#include <QDebug>
#include <string>
#include <iostream>
View ptp-offset-ioctl.log
# I218-V rev 4, e1000e, Core i5 Haswell, CentOS 7
ptp-clock-offset /dev/ptp0
## Testing PTP_SYS_OFFSET ioct (1128283397)
PTP_SYS_OFFSET no 1: -710924824 ns, delay: 6734 ns
PTP_SYS_OFFSET no 2: -710922059 ns, delay: 3873 ns
PTP_SYS_OFFSET no 3: -710922092 ns, delay: 3889 ns
PTP_SYS_OFFSET no 4: -710922078 ns, delay: 3888 ns
PTP_SYS_OFFSET no 5: -710922096 ns, delay: 3939 ns
## Testing PTP_SYS_OFFSET_EXTENDED ioctl (3300932873)
View enter_chroot.sh
# assuming /mnt/root/{root,home} are mounts of anothers system root+home filesystems
cd /mnt/root/root
mount --bind /proc proc
mount --bind /sys sys
mount --bind /dev dev
cp /etc/resolv.conf etc/
cd /mnt/root
mount --bind home root/home
chroot root /usr/bin/zsh
@gsauthof
gsauthof / filter_env.c
Created Feb 6, 2020
Remove environment variable from /proc/$pid/environ under Linux
View filter_env.c
/* Demonstrate how to remove an environment variable from /proc/$pid/environ,
under Linux.
This pseudo file is accessible by other processes with sufficient privileges
(i.e. same user or root) and exposes the original environment vector.
Removing sensitive variables from it can be part of a defense in depth
strategy (i.e. to make it harder for a casual attacker to access it).
*/
/** {{{ MIT No Attribution
@gsauthof
gsauthof / orphan.c
Created Nov 27, 2016
Illustrating how orphaned children aren't necessarily adopted 2 by PID 1
View orphan.c
/* For illustrating how orphaned children aren't necessarily adopted
by PID 1.
See also: http://stackoverflow.com/questions/284325/how-to-make-child-process-die-after-parent-exits/36945270#36945270
2016, Georg Sauthoff <mail@georg.so>
*/
#include <unistd.h>