-
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.
- Loading branch information
Vojtech Bocek
committed
Jun 21, 2016
1 parent
2bb2803
commit f064347
Showing
4 changed files
with
782 additions
and
784 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 |
---|---|---|
@@ -1,74 +1,74 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"fmt" | ||
"io" | ||
"encoding/xml" | ||
"flag" | ||
"encoding/xml" | ||
"flag" | ||
"fmt" | ||
"io" | ||
"os" | ||
|
||
"binxml" | ||
"strings" | ||
"binxml" | ||
"strings" | ||
) | ||
|
||
func main() { | ||
isApk := flag.Bool("a", false, "The input file is an apk") | ||
isApk := flag.Bool("a", false, "The input file is an apk") | ||
|
||
flag.Parse() | ||
flag.Parse() | ||
|
||
if len(flag.Args()) != 1 { | ||
fmt.Printf("%s INPUT\n", os.Args[0]) | ||
os.Exit(1) | ||
} | ||
if len(flag.Args()) != 1 { | ||
fmt.Printf("%s INPUT\n", os.Args[0]) | ||
os.Exit(1) | ||
} | ||
|
||
var r io.Reader | ||
input := flag.Args()[0] | ||
var r io.Reader | ||
input := flag.Args()[0] | ||
|
||
if strings.HasSuffix(input, ".apk") { | ||
*isApk = true | ||
} | ||
if strings.HasSuffix(input, ".apk") { | ||
*isApk = true | ||
} | ||
|
||
if input == "-" { | ||
r = os.Stdin | ||
} else if *isApk { | ||
zr, err := binxml.OpenZip(input) | ||
if err != nil { | ||
fmt.Fprintln(os.Stderr, err) | ||
os.Exit(1) | ||
} | ||
defer zr.Close() | ||
if input == "-" { | ||
r = os.Stdin | ||
} else if *isApk { | ||
zr, err := binxml.OpenZip(input) | ||
if err != nil { | ||
fmt.Fprintln(os.Stderr, err) | ||
os.Exit(1) | ||
} | ||
defer zr.Close() | ||
|
||
zrf := zr.File["AndroidManifest.xml"] | ||
if zrf == nil { | ||
fmt.Fprintln(os.Stderr, "Failed to find manifest") | ||
os.Exit(1) | ||
} | ||
zrf := zr.File["AndroidManifest.xml"] | ||
if zrf == nil { | ||
fmt.Fprintln(os.Stderr, "Failed to find manifest") | ||
os.Exit(1) | ||
} | ||
|
||
if err := zrf.Open(); err != nil { | ||
fmt.Fprintln(os.Stderr, err) | ||
os.Exit(1) | ||
} | ||
defer zrf.Close() | ||
if err := zrf.Open(); err != nil { | ||
fmt.Fprintln(os.Stderr, err) | ||
os.Exit(1) | ||
} | ||
defer zrf.Close() | ||
|
||
zrf.Next() | ||
r = zrf | ||
} else { | ||
f, err := os.Open(input) | ||
if err != nil { | ||
fmt.Fprintln(os.Stderr, err) | ||
os.Exit(1) | ||
} | ||
defer f.Close() | ||
r = f | ||
} | ||
zrf.Next() | ||
r = zrf | ||
} 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("", " ") | ||
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) | ||
} | ||
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
Oops, something went wrong.