Skip to content

Instantly share code, notes, and snippets.

View obfusk's full-sized avatar
🏳️‍🌈
hacking ⇒ ¬sleeping 😸

FC (Fay) Stegerman obfusk

🏳️‍🌈
hacking ⇒ ¬sleeping 😸
View GitHub Profile
import java.util.Arrays;
import java.util.List;
class Test {
public static TestClassNoSuper tcns;
public static TestClassExtendsBar tceb;
public static class Foo {}
public static class Bar {
static {
System.out.println("Bar initialiser...");
if (tcns != null) {
@obfusk
obfusk / search.py
Created October 29, 2024 16:27
python script to search for specific class in r8 dumps | https://issuetracker.google.com/issues/366412380
import glob
import os
import sys
import tempfile
import zipfile
classname_str, *search_dirs = sys.argv[1:]
classname_bytes = classname_str.encode()
for search_dir in search_dirs:
@obfusk
obfusk / Test.java
Last active October 22, 2024 20:18
zip4j workaround for spanned archive marker
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
@obfusk
obfusk / cdata.py
Last active September 5, 2024 15:10
#!/usr/bin/python3
import struct
import sys
import zipfile
zfile, entry = sys.argv[1:]
with zipfile.ZipFile(zfile) as zf:
info = zf.getinfo(entry)
with open(zfile, "rb") as fh:
#!/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
#!/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"
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);
@obfusk
obfusk / .flake8
Last active July 21, 2024 18:50
pychk
[flake8]
ignore = E501
#!/usr/bin/python3
# encoding: utf-8
# SPDX-FileCopyrightText: 2024 FC (Fay) Stegerman <[email protected]>
# SPDX-License-Identifier: GPL-3.0-or-later
import os
import struct
import zipfile
from dataclasses import dataclass

x509_canonical_name.py

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).

See the Java documentation.

Caveats