Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
import sys
import os
from cryptography import x509
from cryptography.hazmat.backends import default_backend
import pem
from datetime import datetime
try:
@tasoseng
tasoseng / sympa_distribute_new.py
Last active March 26, 2021 22:57
distribute sympa moderated emails
#!/usr/bin/python2
# coding: utf8
import sys
import re
import imaplib
import smtplib
from getpass import getpass
user = raw_input('Username: ')
@tasoseng
tasoseng / dhcpd2aquila.py
Created March 26, 2021 21:33
generate aquila wake on lan xml file from dhcpd.conf hosts
#!/bin/bash
set -eu
if [ $# -ne 1 ]; then
echo "usage: $0 dhcp.conf"
exit 1
fi
[ -f $1 ] || { echo "$1 does not exist" ; exit 2; }
DOMAIN="my.domain.local"
@tasoseng
tasoseng / radios.py
Created March 26, 2021 22:21
generate .m3u playlist for thessaloniki radio stations from radiofono.gr site
#!/usr/bin/env python3
#coding: utf-8
from bs4 import BeautifulSoup
import mechanize
import re
br = mechanize.Browser()
br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:32.0) Gecko/20100101 Firefox/32.0')]
response = br.open("http://www.radiofono.gr/live?city_id=9")
def getLdapAttribute(uid, attribute):
import sys
SERVER=ldapserver.example.com
PORT=636
BIND_DN='uid=binder,dc=example,dc=com'
BIND_PW='changeme'
baseDN = "dc=example,dc=com"
@tasoseng
tasoseng / el2gr.sh
Created March 26, 2021 22:37
elot 743 - Transliteraton of greek characters to latin
#!/usr/local/bin/bash
export IFS='
'
string=$1
SED=gsed
gr='αάβγδεέζηήθιίϊΐκλμνξοόπρσςτυύϋΰφχψωώ'
eng='aavgdeezii.iiiiklmnxooprsstyyyyf..oo'
@tasoseng
tasoseng / exclude_webconf_cidrs.py
Last active March 8, 2023 14:37
exclude zoom, teams, webex cidrs from openvpn routes (split tunnel)
import requests
import re
import ipaddress
with requests.Session() as s:
r = s.get('https://support.zoom.us/hc/en-us/articles/201362683-Network-Firewall-or-Proxy-Server-Settings-for-Zoom%C2%A0%20')
zoom = list(set(re.findall(r'(?:\d{1,3}.){3}\d{1,3}\/\d{1,2}', r.text)))
#r = s.get('https://docs.microsoft.com/en-us/microsoft-365/enterprise/urls-and-ip-address-ranges?view=o365-worldwide#skype-for-business-online-and-microsoft-teams')
#teams = list(set(re.findall(r'(?:\d{1,3}.){3}\d{1,3}\/\d{1,2}', r.text)))
@tasoseng
tasoseng / openbsd_dhcpd_leases.py
Created March 27, 2021 00:12
print active openbsd dhcpd leases
#!/usr/bin/env python
# coding: UTF-8
# for openbsd dhcpd only
# apo dhcpd.leases(5):
# the last declaration is the current
# also, the times are in UTC!
import re
from datetime import datetime
@tasoseng
tasoseng / decode_sms.sh
Created March 27, 2021 00:26
decode greek sms
#!/bin/sh
set -e
if [ -z $1 ]; then
echo "Usage: $0 file"
exit 1
fi
OS=$(uname -s)
@tasoseng
tasoseng / url_decode.sh
Created March 27, 2021 00:28
bash url decode
#!/bin/bash
urldecode() {
arg="$1"
i="0"
while [ "$i" -lt ${#arg} ]; do
c0=${arg:$i:1}
if [ "x$c0" = "x%" ]; then
c1=${arg:$((i+1)):1}
c2=${arg:$((i+2)):1}