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
@obfusk
obfusk / currencies.groovy
Created June 11, 2023 15:27
Java currency codes & symbols
import java.util.Currency
Currency.availableCurrencies.each {
println "${it.getCurrencyCode()}=${it.getSymbol()}"
}
@obfusk
obfusk / untree.py
Last active March 2, 2023 00:52
flatten output of tree(1)
#!/usr/bin/python3
# encoding: utf-8
# SPDX-FileCopyrightText: 2023 FC Stegerman <flx@obfusk.net>
# SPDX-License-Identifier: GPL-3.0-or-later
from typing import Iterable, Iterator, List, Tuple
INDENT_SPACE = {" ", "│   ", "| "}
INDENT_FINAL = {"└── ", "├── ", "`-- ", "|-- "}
@obfusk
obfusk / andro-arsc-sp.py
Last active February 26, 2023 03:13
show ARSC string pool using androguard
#!/usr/bin/python3
import sys
from androguard.core.bytecodes import apk
with open(sys.argv[1], "rb") as fh:
data = fh.read()
apk.ARSCParser(data).stringpool_main.show()
@obfusk
obfusk / build.gradle
Last active December 4, 2023 12:05
use apksigner instead of signingConfig in build.gradle
// See https://developer.android.com/studio/publish/app-signing#secure-shared-keystore
def keystorePropertiesFile = rootProject.file("keystore.properties")
def keystoreProperties
def signedReleases = keystorePropertiesFile.exists()
if (signedReleases) {
println("Using ${keystorePropertiesFile} for release signingConfig...")
keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
@obfusk
obfusk / HOWTO.md
Last active December 15, 2023 15:08
HOWTO: diff & fix APKs for Reproducible Builds

HOWTO: diff & fix APKs for Reproducible Builds

NB: assumes signed APK from upstream named upstream-release.apk, and unsigned APK from F-Droid CI named fdroiddata-ci.apk.

NB: also assumes a working directory in which it is okay to create temporary files & directories.

Links

[global]
break-system-packages = true
no-index = true
index-url = https://localhost/do-not-use-pypi
@obfusk
obfusk / README.md
Last active June 24, 2023 11:04
apksigcopier: signatures made by older AGP versions cannot be copied

Signatures made by older versions of AGP cannot be copied by apksigcopier because the signing method differs too much from that used by apksigner (and signflinger in newer versions).

It is unlikely that support for these signatures will be added.

ZIP entry ordering differences

The v1 (JAR) signature files are always added at the end of the ZIP file by apksigner and apksigcopier; these older versions add them in a different position and sometimes the order of the ZIP entries in the central directory doesn't match the order of the entries in the file.

v1 (JAR) signature file differences

@obfusk
obfusk / zfe-test.groovy
Last active February 22, 2023 20:01
use zipflinger to add files to an APK w/ a groovy script
import java.util.zip.ZipInputStream
def zis = new ZipInputStream(new FileInputStream(args[0]))
def entryCounter = 0
while (temp = zis.getNextEntry()) {
entryCounter++
if (!temp.name && !temp.size) {
println "Found virtual entry #${entryCounter}"
}
}
@obfusk
obfusk / AndroidManifest-in.xml
Created February 10, 2023 18:58
convert AndroidManifest.xml to binary XML w/ aapt2 link
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1" android:compileSdkVersion="29" android:compileSdkVersionCodename="10.0.0" package="com.example" platformBuildVersionCode="29" platformBuildVersionName="10.0.0">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="29"/>
</manifest>