Python implementation of the Java algorithm for an RFC 2253 conformant string
representation of an X.500 distinguished name with additional canonicalisations
(as used to compare distinguished names in X.509 certificates for equality in
e.g. apksigner
and Android).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import json | |
import zipfile | |
from hashlib import sha1, sha256 | |
from asn1crypto import cms # type: ignore[import-untyped] | |
from cryptography.exceptions import InvalidSignature | |
from cryptography.hazmat.primitives import serialization |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo pipefail | |
zipentry=META-INF/version-control-info.textproto | |
commit_from_zip() { | |
unzip -p -- "$1" "$zipentry" | grep revision | grep -Eo '[0-9a-f]+' | tail -1 | |
} | |
url="${1:-}" | |
if [ -z "$url" ]; then | |
read -r -p 'url> ' | |
url="$REPLY" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Unicode { | |
public static void main(String[] args) { | |
String foo = "🏳️⚧️"; | |
for (String x : foo.split("")) { | |
System.out.println(x.codePointAt(0)); | |
} | |
System.out.println("---"); | |
int n = foo.codePointCount(0, foo.length()); | |
for (int i = 0; i < n; ++i) { | |
int j = foo.offsetByCodePoints(0, i); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[flake8] | |
ignore = E501 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# encoding: utf-8 | |
# SPDX-FileCopyrightText: 2024 FC (Fay) Stegerman <[email protected]> | |
# SPDX-License-Identifier: AGPL-3.0-or-later | |
import os | |
import struct | |
import zipfile | |
from dataclasses import dataclass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.security.cert.CertificateFactory | |
import java.security.cert.X509Certificate | |
def i = new FileInputStream(args[0]) | |
def cert = CertificateFactory.getInstance("X.509").generateCertificate(i) | |
println cert.getIssuerX500Principal().getName(javax.security.auth.x500.X500Principal.CANONICAL) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, stat | |
from contextlib import contextmanager | |
from subprocess import run | |
@contextmanager | |
def fd_context(fd: int): | |
try: | |
yield fd | |
finally: | |
os.close(fd) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
perl -pi -e 's/\b(\d+)\b/$1 - 1/e' file-with-numbers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import dataclasses | |
import json | |
import sys | |
import repro_apk.binres as binres | |
data = {} | |
for apkfile in sys.argv[1:]: | |
try: |