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 / 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>
@obfusk
obfusk / sigblock.md
Last active September 19, 2025 08:22
APK Signing Block considerations

APK Signing Block considerations

Some considerations regarding the APK Signing Block and how F-Droid handles Reproducible Builds.

Block types

APK Signature Scheme Block

The signature part of the APK Signing Block can contain more than one signature.
AFAIK android and apksigner (unlike apksigtool) only check the one with the strongest supported signature algorithm ID, not all of them.

@obfusk
obfusk / VENV.md
Last active February 19, 2023 05:47
global venv

PEP 668 breaks --user

As a workaround, you can create a global venv that acts a lot like --user does now.

NB: this works for scripts that are part of the packages installed in the venv, but scripts that use e.g. #!/usr/bin/python3 will not be able to access the modules from the venv, only scripts called via ~/.venv/bin/python3 (or ~/.venv/bin/python, ~/.venv/bin/python3.11 etc.) will be able to access those.

Create venv

python3 -mvenv --system-site-packages --without-pip ~/.venv
@obfusk
obfusk / check-apk-signing-block.py
Last active November 11, 2024 23:41
check APK Signing Block for Google/unknown blocks
#!/usr/bin/python3
# encoding: utf-8
# SPDX-FileCopyrightText: 2024 FC (Fay) Stegerman <[email protected]>
# SPDX-FileCopyrightText: 2024 Izzy
# SPDX-License-Identifier: GPL-3.0-or-later
import argparse
import logging
import os
import sys
@obfusk
obfusk / add_zfe.py
Last active February 1, 2023 17:51
add zipflinger virtual entry to unsigned APK
#!/usr/bin/python3
# encoding: utf-8
# SPDX-FileCopyrightText: 2023 FC Stegerman <[email protected]>
# SPDX-License-Identifier: GPL-3.0-or-later
import argparse
from apksigcopier import copy_apk
@obfusk
obfusk / LICENSE.GPLv3
Last active February 15, 2025 20:43
-> https://github.com/obfusk/gradle-wrapper-verify | check gradle wrapper checksums
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
@obfusk
obfusk / README.md
Last active January 28, 2023 04:17
check RB by comparing sha256sum of unsigned APK against upstream

Remove

gradle:
  - yes

Add

@obfusk
obfusk / build.gradle
Last active October 11, 2024 00:21
NB: fixed in Android Gradle Plugin >= 8.1.0 | sort baseline.profm in build.gradle using com.android.tools.profgen
// NB: Android Studio can't find the imports; this does not affect the
// actual build since Gradle can find them just fine.
import com.android.tools.profgen.ArtProfileKt
import com.android.tools.profgen.ArtProfileSerializer
import com.android.tools.profgen.DexFile
project.afterEvaluate {
tasks.each { task ->
if (task.name.startsWith("compile") && task.name.endsWith("ReleaseArtProfile")) {
// NB: assumes reproducible-apk-tools is a submodule in the app repo's
// root dir; adjust the path accordingly if it is found elsewhere
project.afterEvaluate {
tasks.compileReleaseArtProfile.doLast {
outputs.files.each { file ->
if (file.toString().endsWith(".profm")) {
exec {
commandLine(
"../reproducible-apk-tools/inplace-fix.py",
"sort-baseline", file
#!/usr/bin/python3
# encoding: utf-8
# SPDX-FileCopyrightText: 2023 FC Stegerman <[email protected]>
# SPDX-License-Identifier: GPL-3.0-or-later
import struct
import zlib
from typing import Any, BinaryIO, Tuple