Skip to content

Instantly share code, notes, and snippets.

Avatar

Maximilian Thoma lanbugs

View GitHub Profile
@lanbugs
lanbugs / teampass_shell_exporter.php
Last active Oct 5, 2022
Teampass shell exporter - Export all secrets from encrypted teampass database in cleartext
View teampass_shell_exporter.php
<?php
// Teampass Shell Exporter
// Written by Maximilian Thoma 2022
// Variables
// **************************************************
// Path to sources directory of teampass
$path = "/var/www/html/sources";
// Salt from teampass-seckey.txt
$salt = "<salt>";
@lanbugs
lanbugs / install_docker.sh
Created Jun 24, 2022
Script to install docker-ce and docker-compose on Ubuntu 18.04/20.04/22.04
View install_docker.sh
#!/bin/bash
GREEN="\e[32m"
ENDCOLOR="\e[0m"
echo -e " ${GREEN}Welcome to Docker-CE installer for Ubuntu 18.04/20.04/22.04 ...${ENDCOLOR} "
echo -e " ${GREEN}---------------------------------------------------------------${ENDCOLOR} "
echo -e " ${GREEN}You will be asked for your sudo password if set.${ENDCOLOR} "
echo -e " ${GREEN}>>> Get repo update ...${ENDCOLOR} "
@lanbugs
lanbugs / flask_oidc_check_resource_access.py
Created Jun 18, 2022
Flask OIDC / Keycloak Check resource access
View flask_oidc_check_resource_access.py
#!/usr/bin/env python3
#
# flask_oidc_check_resource_access.py
# Written by Maximilian Thoma 2022
# Visit https://www.lanbugs.de
# Free to use for everyone, without any warranty :-)
#
# Manual / Remarks
# I use it together with flask-oidc and Keycloak to give permission to API endpoint only to defined role.
# Its a wrapper function you can use together with @oidc.accept_token
@lanbugs
lanbugs / ripe_cidr.py
Last active Mar 2, 2022
Ripe CIDR collapsed network list generator with country filter
View ripe_cidr.py
#!/usr/bin/env python3
# ----------------------------------------------------------------------------------------------------------------------
# Ripe CIDR list generator with country filter
# --------------------------------------------
# Version 1.0
# Written by Maximilian Thoma 2022
#
# Parts used from: https://github.com/FireFart/network_info
# Only python3 required, no additional libraries
@lanbugs
lanbugs / gitea_webhook_auth.py
Created Oct 8, 2021
Gitea Webhook Auth Flask
View gitea_webhook_auth.py
#!/usr/bin/env python3
from flask import Flask, request, abort
from pprint import pprint
import json
import hmac
app = Flask(__name__)
@app.route("/", methods=['POST'])
@lanbugs
lanbugs / mail_with_attachment.py
Created Apr 20, 2021
Mail with attachment (python3)
View mail_with_attachment.py
# Source: https://stackoverflow.com/questions/3362600/how-to-send-email-attachments
import smtplib
from pathlib import Path
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email.mime.text import MIMEText
from email.utils import COMMASPACE, formatdate
from email import encoders
@lanbugs
lanbugs / SQLiteToMemory.py
Last active Aug 26, 2019
SQLiteDB from file to memory and back to file
View SQLiteToMemory.py
#!/usr/bin/env python3
#
# SQLiteToMemory
# Python class to load sqlite3 database to memory and back to file
# Written by Maximilian Thoma 2019
# Version 0.1
#
import sqlite3
@lanbugs
lanbugs / read_postfix_db.py
Created Jul 5, 2018
Read postfix databases / lookup tables with python
View read_postfix_db.py
#!/usr/bin/env python
from bsddb3 import db
filename = "/var/spool/postfix/plesk/virtual.db"
target = "smtp:[backend_plesk_server]:25"
postfix_db = db.DB()
postfix_db.open(filename, None, db.DB_HASH, db.DB_DIRTY_READ)
@lanbugs
lanbugs / transport_generator.py
Created Jul 5, 2018
Export email aliases and domains from plesk backend database to build own transport map for Postfix
View transport_generator.py
#!/usr/bin/env python
import mysql.connector
cnx = mysql.connector.connect(user='psa_readonly', password='securepassword', host='127.0.0.1', database='psa')
target = "smtp:[plesk_beckend_server.xxxx.xxx]:25"
buffer = ""
@lanbugs
lanbugs / flask_write_put_to_file.py
Created Jun 27, 2018
Backup Cisco configuration by write event to external server - Example for Flask
View flask_write_put_to_file.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# write config to file with cisco archive command
# see more in blog article: https://lanbugs.de/netzwerktechnik/hersteller/cisco/cisco-python-backup-der-konfiguration-bei-write-event-auf-externen-server/
from flask import Flask
from flask import request
app = Flask(__name__)