decompiler

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrApkNotFoundInXapk = errors.New("apk not found in xapk")

Functions

This section is empty.

Types

type Apk

type Apk struct {
	ManifestXML string
	Dexes       []smali.Dex
	Resources   resource.Table
	// contains filtered or unexported fields
}

func NewApk

func NewApk(reader io.ReaderAt, size int64, opts ...Option) (*Apk, error)

func NewApkFromZip

func NewApkFromZip(r *zip.Reader, opts ...Option) (*Apk, error)

type Option

type Option func(*ParseConfig)

func WithFailOnInvalidDex

func WithFailOnInvalidDex() Option

func WithFailOnInvalidResource

func WithFailOnInvalidResource() Option

func WithSanitizeAnnotations

func WithSanitizeAnnotations() Option

type ParseConfig

type ParseConfig struct {
	/*
		SanitizeAnnotations removes annotations from the dex files.

		If we have a lot of heavy patterns or apk has a lot of annotations
		we might sanitize them to reduce string count.
		Average app returns ~24k strings with sanitization instead of ~34k,
		but since annotation parsing is heavy operation we might want to skip it
		for lightweight patterns sanitization performs 2x slower than without it

		b.Run("without annotations", func(b *testing.B) {
			for i := 0; i < b.N; i++ {
				apk, _ := decompiler.NewApk(data, decompiler.WithSanitizeAnnotations())
				_ = apk.GetConstrStrings()  // hacky method to get all the const strings
			}
		})

		b.Run("with annotations", func(b *testing.B) {
			for i := 0; i < b.N; i++ {
				apk, _ := decompiler.NewApk(data)
				_ = apk.GetConstrStrings()  // hacky method to get all the const strings
			}
		})

		Benchmark on average apk with single pattern:
		BenchmarkExtractStrings/without_annotations-32                 5        1149425920 ns/op
		BenchmarkExtractStrings/with_annotations-32                    9         610055044 ns/op
	*/
	SanitizeAnnotations bool

	/*
		FailOnInvalidDex stops parsing dex files if any of them is invalid.

		Dex file may be invalid only if it's encrypted.
		The most common case of this is when we have a dex file stored in assets folder.

		Example of app with encrypted dex: com.conquer.domino v1.1.8.0
	*/
	FailOnInvalidDex bool

	/*
		FailOnInvalidResource stops parsing apk if .arsc file is invalid in some way
	*/
	FailOnInvalidResource bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL