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 / .flake8
Last active July 21, 2024 18:50
pychk
[flake8]
ignore = E501
#!/usr/bin/python3
# encoding: utf-8
# SPDX-FileCopyrightText: 2024 FC (Fay) Stegerman <flx@obfusk.net>
# SPDX-License-Identifier: GPL-3.0-or-later
import os
import struct
import zipfile
from dataclasses import dataclass
*.der
*.pyc
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)
@obfusk
obfusk / example.sh
Created May 28, 2024 20:05
perl command to decrement numbers in a file
perl -pi -e 's/\b(\d+)\b/$1 - 1/e' file-with-numbers
#!/usr/bin/python3
import dataclasses
import json
import sys
import repro_apk.binres as binres
data = {}
for apkfile in sys.argv[1:]:
try:
import com.android.apksig.ApkSigner
import com.android.apksig.apk.ApkUtils
import com.android.apksig.internal.apk.v1.V1SchemeVerifier
import com.android.apksig.util.DataSource
import com.android.apksig.util.DataSources
def f = new RandomAccessFile(args[0], "r")
def apk = DataSources.asDataSource(f, 0, f.length())
def zipSections = ApkUtils.findZipSections(apk)
def cdRecords = V1SchemeVerifier.parseZipCentralDirectory(apk, zipSections)
@obfusk
obfusk / elf-build-id.py
Last active April 29, 2024 01:52
Get ELF build-id w/ pyelftools
#!/usr/bin/python3
# encoding: utf-8
# SPDX-FileCopyrightText: 2024 FC (Fay) Stegerman <flx@obfusk.net>
# SPDX-License-Identifier: GPL-3.0-or-later
from elftools.elf.elffile import ELFFile # type: ignore[import-untyped]
from elftools.elf.sections import NoteSection # type: ignore[import-untyped]
class Error(Exception):
@obfusk
obfusk / zipdup.py
Last active April 11, 2024 19:19
create a ZIP file with two CD entries pointing to the same file
#!/usr/bin/python3
import sys
import zipfile
# Usage: zipdup.py ZIPFILE ENTRY_NAME ENTRY_DATA
zfile, zentry, data = sys.argv[1:]
with zipfile.ZipFile(zfile, "w") as zf:
info = zipfile.ZipInfo(filename=zentry)
zf.writestr(info, data)
@obfusk
obfusk / detect-apk.py
Last active April 11, 2024 17:04
Detect APK files
#!/usr/bin/python3
# encoding: utf-8
# SPDX-FileCopyrightText: 2024 FC (Fay) Stegerman <flx@obfusk.net>
# SPDX-License-Identifier: AGPL-3.0-or-later
import fnmatch
import os
import struct
import sys