-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add binxml package to handle AndroidManifest.xml extraction
- Loading branch information
Vojtech Bocek
committed
Feb 15, 2016
0 parents
commit bd5247d
Showing
9 changed files
with
1,987 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"fmt" | ||
"io" | ||
"encoding/xml" | ||
"flag" | ||
|
||
"binxml" | ||
"strings" | ||
) | ||
|
||
func main() { | ||
isApk := flag.Bool("a", false, "The input file is an apk") | ||
|
||
flag.Parse() | ||
|
||
if len(os.Args) != 2 { | ||
fmt.Printf("%s INPUT\n", os.Args[0]) | ||
os.Exit(1) | ||
} | ||
|
||
var r io.Reader | ||
input := os.Args[1] | ||
|
||
if strings.HasSuffix(input, ".apk") { | ||
*isApk = true | ||
} | ||
|
||
if input == "-" { | ||
r = os.Stdin | ||
} else if *isApk { | ||
zr, err := binxml.OpenFileInZip(input, "AndroidManifest.xml") | ||
if err != nil { | ||
fmt.Fprintln(os.Stderr, err) | ||
os.Exit(1) | ||
} | ||
defer zr.Close() | ||
r = zr | ||
} else { | ||
f, err := os.Open(input) | ||
if err != nil { | ||
fmt.Fprintln(os.Stderr, err) | ||
os.Exit(1) | ||
} | ||
defer f.Close() | ||
r = f | ||
} | ||
|
||
enc := xml.NewEncoder(os.Stdout) | ||
enc.Indent("", " ") | ||
|
||
err := binxml.Parse(r, enc) | ||
fmt.Println() | ||
if err != nil { | ||
fmt.Fprintln(os.Stderr, err) | ||
os.Exit(1) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
An archive/zip package that doesn't care as much about the ZIP being correct, because APKs can be damaged as fuck | ||
and still installable. Every change should be commented with prefix "CARELESS ZIP CHANGE:" | ||
|
||
Changes: | ||
* in reader.go func readDirectoryHeader() |
Oops, something went wrong.