Skip to content

Instantly share code, notes, and snippets.

View u1735067's full-sized avatar

Alexandre L. u1735067

View GitHub Profile
@u1735067
u1735067 / scrapy-icinga-exchange-plugins.py
Last active January 16, 2021 21:53
Icinga Exchange scrapper (scrapy), because the (dumb) search engine doesn't allow sorting by views or downloads
import scrapy, urllib.parse, re
# Python36\Scripts\scrapy.exe runspider .\icinga-exchange-plugins.py -o plugins.json
# jq ". |= sort_by(.views) | reverse | .[0:30]" plugins.json > plugins-top30views.json
FEED_EXPORT_ENCODING = 'utf-8'
class IcingaExchangeSpider(scrapy.Spider):
name = 'scrapy-icinga-exchange-plugins'
allowed_domains = ['exchange.icinga.com']
@u1735067
u1735067 / zoneidentifier_dump.py
Last active December 24, 2020 14:13
This script scan files for the Zone.Identifier stream (ADS : Alternate Data Streams) and prints the referrer + host URLs if available
#!/usr/bin/env python
# Help with Powershell encoding:
# [Console]::InputEncoding = [Console]::OutputEncoding = [Text.UTF8Encoding]::new()
# $env:PYTHONIOENCODING="utf-8"
import argparse, pathlib
parser = argparse.ArgumentParser(description='This script scan files for the Zone.Identifier stream (ADS : Alternate Data Streams) and prints the referrer + host URLs if available')
parser.add_argument('path', metavar='PATH', type=pathlib.Path, help='Path (file or directory) to scan')
parser.add_argument('-r', '--recurse', action='store_true', help='Recurse subdirectories')
parser.add_argument('-ia', '--include-about', action='store_true', help='Include about:client, about:internet entries')
@u1735067
u1735067 / radius.ksy
Created August 24, 2020 16:02
Quick & dirty Radius Kaitai format
meta:
id: radius
file-extension: radius
endian: be
doc-ref: "https://www.iana.org/assignments/radius-types/radius-types.xhtml"
doc-ref: "https://tools.ietf.org/html/rfc2865"
doc-ref: "https://wiki.wireshark.org/SampleCaptures#RADIUS_.28RFC_2865.29"
seq:
- id: code
type: u1
@u1735067
u1735067 / dark-custom.md
Last active January 26, 2020 15:43
Original Trilium (https://github.com/zadam/trilium) dark theme with a bit more contrast

image

In Trilium, select dark theme, create a CSS note with the code and add the atttribute @appCss (yes, that's hacky / not a full theme, but it works).

Code (v2.1 for v0.40):

/*
https://github.com/zadam/trilium/wiki/Themes
https://developer.mozilla.org/en-US/docs/Web/CSS/var
https://css-tricks.com/hsl-hsla-is-great-for-programmatic-color-control/
@u1735067
u1735067 / paramiko.channel.monkey-patch.py
Last active June 17, 2021 07:32
Patch Paramiko channel.py to add channel logging (to debug SCP for example)
import paramiko
def patch_paramiko():
from paramiko.common import DEBUG
recv_ori = paramiko.channel.Channel.recv
send_ori = paramiko.channel.Channel.send
exec_command_ori = paramiko.channel.Channel.exec_command
def patched_exec_command(self, command):
self._log(DEBUG, 'Executing command: {}'.format(command))
@u1735067
u1735067 / extract-android-tabs.bat
Created January 5, 2020 20:04
Script to extract opened tabs from Android (Chromium-based browsers)
@echo off
:: https://android.stackexchange.com/questions/56635/how-can-i-export-the-list-of-open-chrome-tabs
echo Waiting for device ..
Z:\Dev\Android\adb.exe wait-for-device
echo Connected to device, open Chrome and wait a bit
pause
Z:\Dev\Android\adb.exe forward tcp:9222 localabstract:chrome_devtools_remote
chcp 65001 > nul
Z:\Utils\curl.exe -s http://127.0.0.1:9222/json/list | Z:\Utils\jq.exe -r "sort_by(.id) | .[] | ""-" [\(if (.title ^| length) ^> 0 then .title ^| gsub(""^'""";"""'""")" else .url end)](\(.url))"""
Z:\Dev\Android\adb.exe kill-server
@u1735067
u1735067 / 01-php-fpm_source_handler.conf
Created November 28, 2019 02:43
Apache 2.4 conf to display .phps (or any file type marked with handler `application/x-httpd-php-source`) as highlighted, like with mod_php. Thanks VBart for the original nginx idea (Apache is a bit more tricky ..). There's 2 files.
### PHP-FPM Source (.phps) type handler ; conditions are taken from CentOS8 php.conf
# https://stackoverflow.com/questions/11085086/php-fpm-is-parsing-phps-instead-of-showing-code-hilighted
<IfModule !mod_php5.c>
<IfModule !mod_php7.c>
<Directory "/real/path/to/">
Require all granted
# https://httpd.apache.org/docs/2.4/en/expr.html
<If "%{REQUEST_URI} == '/php-fpm/highlight.php'">
Redirect 404
</If>
@u1735067
u1735067 / borg_chroot.sh
Last active October 20, 2019 15:59
Workaround to convert simple tar backup to borg backup, without leading path, using ratarmount (should works with archivemount too) and mergerfs
mkdir -p /chroot_tmp/{logs,mnt,archive_mnt,bins_mnt/dev,bins_mnt/lib,bins_mnt/lib64,bins_mnt/tmp/repo}
cd /chroot_tmp
wget https://github.com/borgbackup/borg/releases/download/1.1.10/borg-linux64 -O /bins_mnt/tmp/borg
chmod +x /chroot_tmp/bins_mnt/tmp/borg
wget https://www.busybox.net/downloads/binaries/1.31.0-defconfig-multiarch-musl/busybox-x86_64 -O /bins_mnt/tmp/busybox
chmod +x /chroot_tmp/bins_mnt/tmp/busybox
wget https://github.com/mxmlnkn/ratarmount/raw/master/ratarmount.py -O ratarmount.py
wget https://github.com/fusepy/fusepy/raw/master/fuse.py -o fuse.py
@u1735067
u1735067 / open_chardet.py
Created September 18, 2019 15:46
Chardet (https://github.com/chardet/chardet) automatic open (from CLI example)
from chardet.universaldetector import UniversalDetector
def open_chardet(file, *args, **kwargs):
detector = UniversalDetector()
with open(file, mode='rb') as fh:
for line in fh:
line = bytearray(line)
detector.feed(line)
if detector.done:
@u1735067
u1735067 / Vagrantfile
Last active February 16, 2021 16:06
CentOS + Cockpit + Docker + Portainer
Vagrant.configure("2") do |config|
# https://www.vagrantup.com/docs/other/environmental-variables.html#vagrant_checkpoint_disable
# rundll32 sysdm.cpl,EditEnvironmentVariables
# set CHECKPOINT_DISABLE=1
#config.vm.box_check_update = false
config.vm.box = "centos/7"
config.vm.provider "virtualbox" do |vb|
#vb.cpus = 2
vb.memory = "768"
vb.default_nic_type = "virtio"