Skip to content

Instantly share code, notes, and snippets.

View larsks's full-sized avatar

Lars Kellogg-Stedman larsks

View GitHub Profile
@larsks
larsks / ax25_relase_uaf.txt
Last active April 17, 2024 13:39
Linux AX.25 Bugs
Apr 17 09:38:03 radio1.local kernel: ------------[ cut here ]------------
Apr 17 09:38:03 radio1.local kernel: WARNING: CPU: 0 PID: 3750 at lib/refcount.c:28 ax25_release+0x358/0x36c [ax25]
Apr 17 09:38:03 radio1.local kernel: refcount_t: underflow; use-after-free.
Apr 17 09:38:03 radio1.local kernel: Modules linked in: tun tcp_diag inet_diag mkiss overlay cmac algif_hash aes_arm_bs crypto_simd cryptd algif_skcipher af_alg bnep vc4 snd_soc_hdmi_codec drm_display_helper cec drm_dma_helper drm_kms_helper brcmfmac_wcc snd_soc_core hci_uart btbcm bluetooth brcmfmac cp210x snd_compress usbserial raspberrypi_hwmon snd_pcm_dmaengine snd_usb_audio bcm2835_codec(C) v4l2_mem2mem brcmutil snd_hwdep snd_usbmidi_lib bcm2835_v4l2(C) bcm2835_isp(C) cfg80211 bcm2835_mmal_vchiq(C) videobuf2_dma_contig videobuf2_vmalloc videobuf2_memops snd_rawmidi snd_bcm2835(C) videobuf2_v4l2 binfmt_misc snd_seq_device videodev snd_pcm snd_timer snd videobuf2_common ecdh_generic ecc rfkill mc vc_sm_cma(C) raspberrypi_gpiomem uio_pdrv_genirq
#!/bin/bash
# Split a certificate bundle into individual certificates.
#
# This will produce files named `cert-000.crt`, `cert-001.crt`, .etc.
read -r count < <(csplit -z "$1" -f cert- -b '%03d.crt' '/^-----BEGIN CERTIFICATE-----/' '{*}' | wc -l)
echo "split $count certificates"
@larsks
larsks / boot.sh
Created September 6, 2022 02:24
Booting raspberry pi 64 bit using qemu
#!/bin/sh
SERIAL1=( -chardev stdio,id=uart1 -serial chardev:uart1 -monitor none )
SERIAL2=( -serial vc -serial vc )
SERIAL3=( -nographic -serial mon:stdio )
EMU_RASPI=( -M raspi3 )
EMU_VIRT=( -M virt -cpu cortex-a72 )
NET_TAP=(
@larsks
larsks / README.md
Last active January 29, 2024 16:49
CS50 PS2 solution with tests

A couple of solutions to CS50 problem 2 ("vanity plates") along with a simple test suite.

# extlinux.conf generated by anaconda
ui menu.c32
menu autoboot Welcome to Fedora. Automatic boot in # second{,s}. Press a key for options.
menu title Fedora Boot Options.
menu hidden
timeout 50
#totaltimeout 9000
@larsks
larsks / windows-core-setup.md
Created November 2, 2012 02:13
Setting up Windows Server Core

Initial configuration

  • Set the timezone

      tzutil /s "Eastern Standard Time"
    
  • Enable automatic updates:

      cscript \windows\system32\scregedit.wsf /AU 4
    
@larsks
larsks / Makefile
Created April 14, 2023 00:58
Embedding binary data in C programs
CFLAGS = -g
example: example.o rom.o
$(CC) -o $@ $^
rom.o: rom.S rom.bin
rom.bin:
echo -n -e '\x09\x08\x07\x06\x05\x04\x03\x02\x01\x00' > $@
#!/bin/bash
# Create the substitute of C
git update-ref refs/heads/main $(git log -1 --pretty=%B $C | GIT_AUTHOR_NAME=$(git log -1 --pretty=%an $C) \
GIT_AUTHOR_DATE=$(git log -1 --pretty=%ad --date=iso $C) \
GIT_COMMITTER_NAME=$(git log -1 --pretty=%cn $C) \
GIT_COMMITTER_DATE=$(git log -1 --pretty=%cd --date=iso $C) \
git commit-tree -p $A -p $B -F - $C^{tree})
git update-ref refs/heads/main $(git log -1 --pretty=%B $D | GIT_AUTHOR_NAME=$(git log -1 --pretty=%an $D) \
@larsks
larsks / create-bridge-network.md
Last active February 15, 2023 12:58
podman-bridge-network

This will work if you have an existing bridge or if you don't: if the bridge referenced in this config doesn't exist, it will be created when you start a container attached to the network.

  1. Create the CNI network configuration in /etc/cni/net.d/99-example.conflist:
{
  "cniVersion": "0.4.0",
  "name": "example",
  "plugins": [
{
@larsks
larsks / fibtrace.bt
Last active November 11, 2022 04:44
Track routing decisions made by fib_validate_source
kprobe:fib_validate_source {
$skb = (struct sk_buff*) arg0;
@skb[tid] = $skb;
@ipheader[tid] = ((struct iphdr *) ($skb->head + $skb->network_header));
}
kretprobe:fib_validate_source {
$skb = @skb[tid];
$ipheader = @ipheader[tid];
$version = $ipheader->version;