Read-only APK (ZIP) container parser: entry index and raw bytes, v1/v2/v3/v3.1 signature verification, resources.arsc and ELF recon, for Android package tooling.
pub trait ContainerIndex {
fn entry(Self, String) -> Bytes raise ApkError
fn entries(Self) -> Array[ZipEntryRef]
}pub suberror ApkError {
UnexpectedEof(Int)
NotAZip(String)
BadCentralDirectory(Int, String)
Zip64Unsupported(String)
EntryNotFound(String)
BadSigningBlock(Int, String)
UnsupportedSignatureScheme(String)
BadAlignment(String, Int)
BadResourceTable(Int, String)
BadElf(Int, String)
} derive(Debug)impl ContainerIndex for Apkpub(all) struct CertificateInfo {
version : Int
serial_hex : String
issuer : String
subject : String
not_before : String
not_after : String
signature_algo_oid : String
public_key_algo_oid : String
public_key_bits : Int
sha256_fingerprint_hex : String
}pub(all) struct DartSnapshotRef {
marker : String
offset : UInt64
in_section : String
}pub(all) struct ElfSymbol {
name : String
defined : Bool
}pub(all) struct IntegrityCheck {
name : String
declared_size : UInt64
actual_size : UInt64?
crc32_expected : UInt
crc32_actual : UInt?
ok : Bool
aligned : Bool
error : String
}pub(all) struct ManifestRef {
entry_name : String
raw : Bytes
}pub(all) struct ResConfig {
size : Int
mcc : Int
mnc : Int
language : String
country : String
orientation : Int
touchscreen : Int
density : Int
keyboard : Int
navigation : Int
input_flags : Int
screen_width : Int
screen_height : Int
sdk_version : Int
screen_layout : Int
ui_mode : Int
smallest_screen_width_dp : Int
screen_width_dp : Int
screen_height_dp : Int
locale_script : String
color_mode : Int
raw : Bytes
}pub(all) enum ResDataType {
Null
Reference
Attribute
String
Float
Dimension
Fraction
DynamicReference
DynamicAttribute
IntDec
IntHex
IntBoolean
IntColorArgb8
IntColorRgb8
IntColorArgb4
IntColorRgb4
Unknown(Int)
}pub(all) struct ResPackage {
id : Int
name : String
type_id_offset : Int
type_strings : Array[String]
key_strings : Array[String]
types : Array[ResTypeSpec]
}pub(all) struct ResTable {
global_strings : Array[String]
packages : Array[ResPackage]
package_count : Int
}pub(all) struct ResTypeSpec {
id : Int
types_count : Int
entry_count : Int
spec_flags : Array[UInt]
configs : Array[ResTypeConfig]
}pub(all) struct ResourceTableRef {
entry_name : String
raw : Bytes
global_string_pool : Bytes
}pub(all) struct SignatureCheck {
scheme : SignatureScheme
structure_ok : Bool
digest_ok : Bool
digest_algorithm : String
entries_checked : Int
entries_failed : Int
signature_verified : Bool
detail : String
}pub(all) struct SignatureInfo {
scheme : SignatureScheme
block_id : UInt
certificates : Array[Bytes]
verified : Bool
}pub(all) enum SignatureScheme {
V1
V2
V3
V31
}pub(all) struct SignatureVerification {
scheme : SignatureScheme
structure_ok : Bool
digest_ok : Bool
crypto_verified : Bool
algo : String
detail : String
}pub(all) struct VerityInfo {
block_id : UInt
version : Int
hash_algorithm : String
block_size : Int
salt_hex : String
root_hash_hex : String
tree_size : UInt64
tree_recomputed_ok : Bool
} derive(Debug)pub(all) struct VerityTreeCheck {
block_id : UInt
hash_algorithm : String
block_size : Int
salt_hex : String
declared_root_hash_hex : String
recomputed_root_hash_hex : String
tree_recomputed_ok : Bool
source_len : UInt64
}pub(all) struct ZipEntryRef {
name : String
compressed_size : UInt64
uncompressed_size : UInt64
crc32 : UInt
compression_method : Int
local_header_off : UInt64
is_aligned : Bool
}fn ecdsa_verify_raw(curve : EcCurve, pubkey_x_hex : String, pubkey_y_hex : String, msg_hash_hex : String, sig_r_hex : String, sig_s_hex : String) -> Booltest {
// P-256 / SHA-256("sample"),RFC 6979 A.2.5 标准向量(真签名验签通过)。
assert_true(
ecdsa_verify_raw(
EcCurve::P256,
"60fed4ba255a9d31c961eb74c6356d68c049b8923b61fa6ce669622e60f29fb6",
"7903fe1008b8bc99a41ae9e95628bc64f2f1b20c2d7e9f5177a3c294d4462299",
"af2bdbe1aa9b6ec1e2ade1d694f41fc71a831d0268e9891562113d8a62add1bf",
"efd48b2aacb6a8fd1140dd9cd45e81d69d2c877b56aaf991c34d0ea84eaf3716",
"f7cb1c942d657c41d436c7a1b6e29f65f3e900dbb9aff4064dc4ab2f843acda8",
),
)
}Install
Download zipRead-only APK (ZIP) container parser: entry index and raw bytes, v1/v2/v3/v3.1 signature verification, resources.arsc and ELF recon, for Android package tooling.