Skip to content

Instantly share code, notes, and snippets.

Avatar

Georg Sauthoff gsauthof

View GitHub Profile
@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]
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 / futex_demo.c
Created Oct 25, 2019
Fix deadlock, busy waiting and comments in futex example from http://man7.org/linux/man-pages/man2/futex.2.html
View futex_demo.c
/* futex_demo.c
Usage: futex_demo [nloops]
(Default: 5)
Demonstrate the use of futexes in a program where parent and child
use a pair of futexes located inside a shared anonymous mapping to
synchronize access to a shared resource: the terminal. The two
processes each write 'num-loops' messages to the terminal and employ
a synchronization protocol that ensures that they alternate in
@gsauthof
gsauthof / redact_env.c
Created Jul 27, 2019
Redact environment variable under Linux
View redact_env.c
/* Demonstrate how to overwrite the original value of
an environment variable in the original environment vector
that is easily observable from other processes
(with sufficient permissions, i.e. same user or root).
*/
/** {{{ MIT No Attribution
Copyright 2019 Georg Sauthoff <mail@georg.so>
View vfork.c
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
int main()
{
int pid = vfork();
if (pid == 0) {
_exit(0);
}
@gsauthof
gsauthof / last_lines.py
Created Oct 31, 2017
asyncssh compatible file-like object for capturing the most recent lines
View last_lines.py
class Last_Lines:
def __init__(self, n, binary=True):
self.n = n
self.binary = binary
self.lines = []
# asyncssh calls fstat() on fileno() and checks if it is a regular file
# thus we open any regular file to fake it ...
self.dev_null = open('/etc/resolv.conf')
def write(self, s):
lines = s.splitlines(True)