Skip to content

Android binary file parser written in golang

License

Notifications You must be signed in to change notification settings

uusense/androidbinary

 
 

Repository files navigation

androidbinary

Build Status GoDoc

Android binary file parser

High Level API

Parse APK files

package main

import (
	"github.com/uusense/androidbinary/apk"
)

func main() {
	pkg, _ := apk.OpenFile("your-android-app.apk")
	defer pkg.Close()

	icon, _ := pkg.Icon(nil) // returns the icon of APK as image.Image
	pkgName := pkg.PackageName() // returns the package name

	resConfigEN := &androidbinary.ResTableConfig{
		Language: [2]uint8{uint8('e'), uint8('n')},
	}
	appLabel, _ = pkg.Label(resConfigEN) // get app label for en translation
}

Low Level API

Parse XML binary

package main

import (
	"encoding/xml"

	"github.com/uusense/androidbinary"
	"github.com/uusense/androidbinary/apk"
)

func main() {
	f, _ := os.Open("AndroidManifest.xml")
	xml, _ := androidbinary.NewXMLFile(f)
	reader := xml.Reader()

	// read XML from reader
	var manifest apk.Manifest
	data, _ := ioutil.ReadAll(reader)
	xml.Unmarshal(data, &manifest)
}

Parse Resource files

package main

import (
	"fmt"
	"github.com/uusense/androidbinary"
)

func main() {
	f, _ := os.Open("resources.arsc")
	rsc, _ := androidbinary.NewTableFile(f)
	resource, _ := rsc.GetResource(androidbinary.ResID(0xCAFEBABE), nil)
	fmt.Println(resource)
}

License

This software is released under the MIT License, see LICENSE.

About

Android binary file parser written in golang

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%