1
0
mirror of https://github.com/avast/apkparser.git synced 2024-11-10 21:29:18 +00:00
APK manifest & resources parsing in Golang.
Go to file
2024-07-29 11:26:10 +02:00
.github/workflows Update deps, try to add github actions 2022-11-01 14:36:40 +01:00
axml2xml feat: update apkverifier 2023-10-31 12:37:41 +01:00
testdata Add some tests 2018-11-02 10:35:34 +01:00
apkparser_test.go Add option to print all signature version from axml2xml 2020-02-17 12:43:02 +01:00
apkparser.go Add *Reader methods to allow processing of in-memory-only files 2019-10-31 13:49:17 +01:00
attributes.go Add targetSandboxVersion attribute 2018-06-27 14:49:05 +02:00
binxml.go fix: handle more malformed APKs 2024-07-29 11:26:10 +02:00
common.go Fix parsing of APKs with extra data after XML attributes 2023-06-14 11:15:18 +02:00
encoder.go Add ErrEndParsing to enable early exit during parsing 2018-06-27 14:49:29 +02:00
go.mod feat: update apkverifier 2023-10-31 12:37:41 +01:00
go.sum feat: update apkverifier 2023-10-31 12:37:41 +01:00
LICENSE Add LICENSE 2017-12-06 14:28:57 +01:00
README.md Raise minimal required go to 1.9 2020-09-24 12:30:28 +02:00
resources.go Fix parsing of APKs with extra data after XML attributes 2023-06-14 11:15:18 +02:00
runtests.sh Don't run tests on Windows in travis 2019-05-16 12:12:50 +02:00
stringtable.go Fix parsing of some malformed string tables 2022-10-12 10:01:51 +02:00
zipreader.go Add ReadAll to ZipReaderFile 2021-02-23 11:05:16 +01:00

apkparser

GoDoc Build Status

APK AndroidManifest.xml and resources.arsc parsing.

Works with Go 1.9 or higher.

Documentation on GoDoc

go get github.com/avast/apkparser

ZipReader

Because Android can handle even broken ZIP archives, this packages has it's own zip reader, based on archive/zip.

axml2xml

A tool to extract AndroidManifest.xml and verify APK signature is also part of this repo.

go get github.com/avast/apkparser
go install github.com/avast/apkparser/axml2xml
./axml2xml -v application.apk

Example

package main

import (
	"encoding/xml"
	"fmt"
	"github.com/avast/apkparser"
	"os"
)

func main() {
	enc := xml.NewEncoder(os.Stdout)
	enc.Indent("", "\t")
	zipErr, resErr, manErr := apkparser.ParseApk(os.Args[1], enc)
	if zipErr != nil {
		fmt.Fprintf(os.Stderr, "Failed to open the APK: %s", zipErr.Error())
		os.Exit(1)
		return
	}

	if resErr != nil {
		fmt.Fprintf(os.Stderr, "Failed to parse resources: %s", resErr.Error())
	}
	if manErr != nil {
		fmt.Fprintf(os.Stderr, "Failed to parse AndroidManifest.xml: %s", manErr.Error())
		os.Exit(1)
		return
	}
	fmt.Println()
}