Skip to content

Instantly share code, notes, and snippets.

@defanator
defanator / nokia-router-cfg-tool.py
Created September 9, 2023 16:16 — forked from thedroidgeek/nokia-router-cfg-tool.py
Nokia/Alcatel-Lucent router backup configuration tool
#!/usr/bin/env python3
#
# Nokia/Alcatel-Lucent router backup configuration tool
#
# Features:
# - Unpack/repack .cfg files generated from the backup and restore functionnality
# in order to modify the full router configuration
# - Decrypt/encrypt the passwords/secret values present in the configuration
@defanator
defanator / vagrant-version.txt
Created June 19, 2023 04:29
vagrant version output from vagrant/2.3.7 with virtualbox plugin 0.8.6 on macOS 13.4
INFO global: Vagrant version: 2.3.7
INFO global: Ruby version: 3.1.4
INFO global: RubyGems version: 3.3.26
INFO global: VAGRANT_INSTALLER_ENV="1"
INFO global: VAGRANT_INSTALLER_VERSION="2"
INFO global: VAGRANT_EXECUTABLE="/opt/vagrant/embedded/gems/gems/vagrant-2.3.7/bin/vagrant"
INFO global: VAGRANT_INSTALLER_EMBEDDED_DIR="/opt/vagrant/embedded"
INFO global: VAGRANT_LOG="debug"
WARN global: resolv replacement has not been enabled!
DEBUG global: Loading core plugin: /opt/vagrant/embedded/gems/gems/vagrant-2.3.7/plugins/synced_folders/nfs/plugin.rb
@defanator
defanator / wordsearch.py
Last active June 4, 2023 11:27
word search in python
#!/usr/bin/env python3
# vim:sw=4:ts=4:et:
#
# based on https://www.tutorialspoint.com/word-search-in-python
BOARD = [
['A', 'B', 'C', 'E'],
['S', 'F', 'R', 'S'],
['A', 'D', 'E', 'E'],
['T', 'I', 'G', 'R'],
@defanator
defanator / need-restart.sh
Created October 26, 2022 18:15
find services using deleted libraries
#!/bin/bash
PIDS=$(ps h --ppid 2 -p 2 --deselect | awk '{ print $1}' | xargs)
for P in $PIDS
do
lsof -p $P | grep DEL | egrep -v "/dev/|/\[aio\]|/SYSV|/memfd:"
done
@defanator
defanator / find-images.sh
Last active October 20, 2022 11:38
Find AWS AMI images of popular distros
#!/bin/bash
LIMIT=1
usage() {
echo "usage: $(basename $0) [-l N] distro arch [arch...]" >&2
exit 1
}
rhel() {
@defanator
defanator / signing-gpg-keys.md
Created June 20, 2022 14:34 — forked from F21/signing-gpg-keys.md
Signing someone's GPG key

This is a quick guide of the commands we use to sign someone's GPG key in a virtual key signing party.

Note: The steps cover only the technical aspects of signing someone's key. Before signing someone's key, you must verify their identity. This is usually done by showing government-issued ID and confirming the key's fingerprint

The commands will work for both GPG and GPG2.

I use Julian's key for the examples. His key id is 2AD3FAE3. You should substitute with the appropriate key id when running the commands.

Signing the key

  1. List the keys currently in your keyring: gpg --list-keys.
@defanator
defanator / query-phpfpm-status.sh
Created February 4, 2022 16:00
Query php-fpm status from multiple instances/sockets
#!/bin/bash
# vim:sw=4:ts=4:et:
ENDPOINTS="/run/php/php7.4-fpm1.sock:/status1 /run/php/php7.4-fpm2.sock:/status2 /run/php/php7.4-fpm3.sock:/status3"
ENDPOINTS="$ENDPOINTS /run/php/php8.0-fpm1.sock:/status1 /run/php/php8.0-fpm2.sock:/status2 /run/php/php8.0-fpm3.sock:/status3"
for endpoint in $ENDPOINTS; do
socket=${endpoint%:*}
script=${endpoint##*:}
sudo -u nginx SCRIPT_NAME=${script} SCRIPT_FILENAME=${script} QUERY_STRING=full REQUEST_METHOD=GET cgi-fcgi -bind -connect ${socket}
@defanator
defanator / error.log
Created December 28, 2021 12:55
nginx/1.21.5 and ModSecurity-nginx built with PCRE1 - memory leaks
2021/12/28 12:47:31 [notice] 76906#76906: ModSecurity-nginx v1.0.2 (rules loaded inline/local/remote: 0/1818/0)
2021/12/28 12:47:31 [notice] 76906#76906: using the "epoll" event method
2021/12/28 12:47:31 [notice] 76906#76906: nginx/1.21.5
2021/12/28 12:47:31 [notice] 76906#76906: built by gcc 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)
2021/12/28 12:47:31 [notice] 76906#76906: OS: Linux 5.4.0-91-generic
2021/12/28 12:47:31 [notice] 76906#76906: getrlimit(RLIMIT_NOFILE): 131072:131072
2021/12/28 12:47:31 [notice] 76907#76907: start worker processes
2021/12/28 12:47:31 [notice] 76907#76907: start worker process 76909
2021/12/28 12:50:53 [notice] 76907#76907: signal 1 (SIGHUP) received from 76927, reconfiguring
2021/12/28 12:50:53 [notice] 76907#76907: reconfiguring
@defanator
defanator / error.log
Created December 28, 2021 11:30
nginx/1.21.5 and ModSecurity-nginx built with PCRE2 - memory leaks
This file has been truncated, but you can view the full file.
2021/12/28 11:22:36 [notice] 25136#25136: ModSecurity-nginx v1.0.2 (rules loaded inline/local/remote: 0/1818/0)
2021/12/28 11:22:36 [notice] 25136#25136: using the "epoll" event method
2021/12/28 11:22:36 [notice] 25136#25136: nginx/1.21.5
2021/12/28 11:22:36 [notice] 25136#25136: built by gcc 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)
2021/12/28 11:22:36 [notice] 25136#25136: OS: Linux 5.4.0-91-generic
2021/12/28 11:22:36 [notice] 25136#25136: getrlimit(RLIMIT_NOFILE): 131072:131072
2021/12/28 11:22:36 [notice] 25137#25137: start worker processes
2021/12/28 11:22:36 [notice] 25137#25137: start worker process 25139
2021/12/28 11:23:51 [notice] 25137#25137: signal 1 (SIGHUP) received from 25150, reconfiguring
2021/12/28 11:23:51 [notice] 25137#25137: reconfiguring
@defanator
defanator / Makefile.xpadneo-osmc-aarch64
Last active December 20, 2021 08:43
Building xpadneo kernel driver under OSMC on Raspberry Pi 4
#!/usr/bin/make -f
KERNEL_VERSION=$(shell uname -r)
KERNEL_HEADERS_DIR=/usr/src/rbp464-headers-$(KERNEL_VERSION)
KERNEL_SOURCES_DIR=/usr/src/rbp464-source-$(KERNEL_VERSION)
CHROOT_DIR=/opt/osmc-tc/aarch64-toolchain-osmc
ifeq ($(shell id -u), 0)
SUDO=
OUSER=$(SUDO_USER)