Skip to content

Instantly share code, notes, and snippets.

View tiran's full-sized avatar

Christian Heimes tiran

View GitHub Profile
@tiran
tiran / importwiki.py
Created March 30, 2020 10:33
Dump FreeIPA wiki pages as restructured text
#!/usr/bin/env python3
"""Dump FreeIPA wiki pages as restructured text
Example:
python3 importwiki.py V4/Kerberos_PKINIT V4/Healthcheck
"""
import argparse
import os
import subprocess
@tiran
tiran / python_import.stp
Created August 30, 2019 11:43
Python import time SystemTap
# Christian Heimes <[email protected]>
# https://docs.python.org/3/howto/instrumentation.html?highlight=dtrace#c.import__find__load__start
# https://speakerdeck.com/tiran/europython-2019-introduction-to-low-level-profiling-and-tracing?slide=64
global depths = 0;
global timing
probe process("python3").library("libpython3.7m.so.1.0").mark("import__find__load__start") {
modname = user_string($arg1);
@tiran
tiran / badserial.py
Created January 8, 2019 23:16
Generate X.509 cert with bad serial number encoding
#!/usr/bin/env python3
"""Generate X.509 cert with bad serial number encoding
Christian Heimes
"""
from asn1crypto.x509 import Certificate
from asn1crypto.core import Integer
from asn1crypto.pem import armor, unarmor
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import padding
@tiran
tiran / 99-pkiuser-pcsc.rules
Created August 22, 2018 10:39
NitroHSM support for Dogtag
/* polkit rule to allow 'pkiuser' to access NitroHSM PCSC interface
*
* file name: /etc/polkit-1/rules.d/99-pkiuser-pcsc.rules
*
* Resources:
* - https://access.redhat.com/blogs/766093/posts/1976313
* - https://raymii.org/s/articles/Get_Started_With_The_Nitrokey_HSM.html
*
* Installation:
* # dnf install opensc pcsc-lite pcsc-tools
@tiran
tiran / shutdown.py
Last active May 14, 2018 21:00
TLS 1.3 shutdown reproducer
#! ./python
"""TLS 1.3 shutdown issue reproducer
./configure -C --with-pydebug
make
./python Tools/ssl/multissltests.py --openssl 1.1.1-pre6 --steps modules
./python shutdown.py --server
./python shutdown.py
"""
0000000000000000 <siphash24>:
0: 48 b8 61 72 65 6e 65 movabs $0x6c7967656e657261,%rax
7: 67 79 6c
a: 53 push %rbx
b: 48 bb 75 65 73 70 65 movabs $0x736f6d6570736575,%rbx
12: 6d 6f 73
15: 48 31 fb xor %rdi,%rbx
18: 49 89 c9 mov %rcx,%r9
1b: 48 31 c7 xor %rax,%rdi
1e: 49 bb 6d 6f 64 6e 61 movabs $0x646f72616e646f6d,%r11
@tiran
tiran / openssl_distros.md
Created January 13, 2018 12:30
OpenSSL / LibreSSL versions in Linux and BSD (2018-01-12)

OpenSSL / LibreSSL versions in Linux and BSD distributions

Major distributions

  • alpine 3.2.2 (OpenSSL 1.0.2d)
  • alpine 3.6.2 (LibreSSL 2.5.4)
  • alpine 3.7.0 (LibreSSL 2.6.3)
@tiran
tiran / ipa-custodia-regen.py
Created December 1, 2017 10:54
Regenerate ipa-custodia config and keys
#!/usr/bin/env python
"""Regenerate Custodia server.keys and config
Christian Heimes <[email protected]>
"""
import argparse
import os
from ipalib import api
from ipaplatform.paths import paths
@tiran
tiran / getcert.py
Created November 2, 2017 10:06
ssl.get_server_certificate with cert type
#!/usr/bin/env python3
# see https://bugs.python.org/issue31892
from socket import create_connection
from ssl import (
_create_stdlib_context, DER_cert_to_PEM_cert, PROTOCOL_TLS,
CERT_REQUIRED, CERT_NONE
)
CERT_TYPE = {
@tiran
tiran / pythonimport.txt
Last active September 29, 2017 20:08
Python import blocking
$ mkdir a
$ touch a/__init__.py
$ touch a/b.py
$ python2
Python 2.7.13 (default, Sep 5 2017, 08:53:59)
[GCC 7.1.1 20170622 (Red Hat 7.1.1-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import a
>>> a