├── CommandLine.md ├── CommandLineAPKAnalysis.md ├── README.md └── images ├── 1 Open File.png ├── 2 Browse components ├── 3 Browse Method count ├── 4 Search.png ├── 5 ClassesDexData.png └── 6 Native Suggestions.png /CommandLine.md: -------------------------------------------------------------------------------- 1 | # Command Line 2 | 3 | Together with a stylish UI ClassyShark provides a rich API and command line functionality. In this part we are 4 | going to explore what ClassyShark can do for you from the command line. In the upcoming API section we see how 5 | ClassyShark provides APIs to every data in String form. One can use the export Java APIs as part of one’s build 6 | and continuous integration pipeline. Here are the command line services. 7 | 8 | **Open APK with ClassyShark** 9 | ```bash 10 | java -jar ClassyShark.jar -open 11 | ``` 12 | 13 | **Open your APK in ClassyShark and show a specific class in GUI** 14 | ```bash 15 | java -jar ClassyShark.jar -open 16 | ``` 17 | Opens the ClassyShark GUI with the specific class showing in the UI plane. 18 | 19 | **Export APK** 20 | ```bash 21 | java -jar ClassyShark.jar -export 22 | ``` 23 | 24 | ClassyShark will analyze the APK and dump out the following files, in a grep friendly fashion: 25 | * all_classes.txt - list of all classes 26 | * all_methods.txt - all the method names and signatures from all the dexes 27 | * all_strings.txt - all the string tables from all the dexesall_strings.txt - all the string tables from all the dexes 28 | * AndroidManifest.xml_dump - goes without saying 29 | 30 | **Export a specific class from APK** 31 | ```bash 32 | java -jar ClassyShark.jar -export 33 | ``` 34 | ClassyShark generates and dumps a text file, which is a human readable representation of the class, passed as parameter. 35 | 36 | **Dump all packages with their method counts** 37 | ```bash 38 | java -jar ClassyShark.jar -methodcounts 39 | ``` 40 | ClassyShark dumps all the packages tree with packages method counts. 41 | 42 | **Inspect APK(experimental)** 43 | ```bash 44 | java -jar ClassyShark.jar -inspect 45 | ``` 46 | Dumps out to command prompt all the classes that have test as their class names, native and abstract methods. 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /CommandLineAPKAnalysis.md: -------------------------------------------------------------------------------- 1 | # Command Line APK Analysis 2 | This doc explains how to analyse an APK with ClassyShark using command line only. This fits for working on remote machines, Pixel Books or just from the terminal :). 3 | 4 | ## (Optional) Get Java & create a working folder 5 | * Get Java - as you need it to run ClassyShark 6 | * $ sudo apt-get install default-jdk 7 | * Create a test folder (to keep all the stuff per APK) $ mkdir testCS 8 | 9 | ## Install tools 10 | * Use the [script](https://github.com/borisf/effective-bash/blob/master/dev/install.sh) 11 | * Wget from github 12 | * Make it chmod 777 13 | * run 14 | 15 | Or the script steps 16 | * // Install fzf - incremental filter 17 | * $ wget https://github.com/junegunn/fzf-bin/releases/download/0.17.5/fzf-0.17.5-linux_amd64.tgz 18 | * tar xvzf fzf-0.17.5-linux_amd64.tgz 19 | * chmod 777 ./fzf 20 | * // Install ClassyShark 21 | * $ wget https://github.com/google/android-classyshark/releases/download/8.2/ClassyShark.jar 22 | 23 | ## Get the APK 24 | * Call ClassyShark export with the APK 25 | $ java -jar ClassyShark.jar -export test.apk 26 | 27 | Let’s examine the files by the order of importance: 28 | 29 | ```bash 30 | AndroidManifest.xml_dump - cat AndroidManifest.xml_dump | ./fzf 31 | Package tree - cat all_methods 32 | all_classes.txt - all classes names sorted, could be useful for understanding the packages & dependencies cat all_classes.txt | ./fzf 33 | 34 | Browse the relevant class 35 | Mostly if will not need it as it is the most advanced feature 36 | ``` 37 | Use the [script](https://github.com/borisf/effective-bash/blob/master/dev/class.sh) 38 | wget from github 39 | Make it chmod 777 40 | run 41 | 42 | Or the script steps 43 | ```bash 44 | $ cat all_classes.txt | fzf 45 | Select the relevant class and press Enter 46 | FZF will dump the class name 47 | $ java -jar ClassyShark.jar -export test.apk com.google.x ⇐ note no ending 48 | $tac com.google.x_dump | fzf 49 | ``` 50 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Classyshark User Guide 2 | 3 | [ClassyShark](https://github.com/google/android-classyshark) is under current and heavy development, so remember to check this page frequently :snowflake:. 4 | 5 | ## About ClassyShark 6 | 7 | We developed this software because we needed something lighting fast and incredibly lightweight for browsing Android `APK`s, so that we could check right away if everything we wanted was right inside the final executable. And this is where the story begins - be sure to checkout the blogpost [Intro to ClassyShark](https://medium.com/@BorisFarber/welcome-classyshark-b632ae8488b4#.4zcdc3kwd) to understand the problem it solves. 8 | 9 | ## Open an archive 10 | Before we can start browsing anything, we need to open it. And this is pretty straight forward: you can do it by clicking on the 11 | folder icon in the top bar, as in this screenshot. 12 | 13 | ![alt text](https://github.com/borisf/classyshark-user-guide/blob/master/images/1%20Open%20File.png) 14 | 15 | Remember that **ClassyShark** does not stop to Android `APK`, but you actually see the content of `.dex` files, as well as `.class`, `.jar` and `.aar`s. 16 | 17 | ## Browse components 18 | Right after **ClassyShark** loads your executable, you will see, in the left panel, the list of the root components of the archive. 19 | In the example, we are using the Google IO Android app, and you can notice right away that we see the `AndroidManifest.xml` file and the `classes` and `res` folders 20 | at the very top of the tree, as we just opened the `APK` file. 21 | 22 | ![alt text](https://github.com/borisf/classyshark-user-guide/blob/master/images/2%20Browse%20components) 23 | 24 | By clicking on the folders, we will see the tree expand and, when we reach a leaf (that would be a Java file, in this case), by clicking on it, we would see its content 25 | on the right pane, where the **ClassyShark** logo is. Easy! 26 | 27 | Now, what if we find, for instance, a class that extends `Activity` and we want to see what's in there? Well, we are just a double click away from knowing it! 28 | In fact, by clicking twice on a type, **ClassyShark** will bring on the source for that type, so that you can browse the code freely. How cool is that? 29 | 30 | ## Inspect package method counts (multidex) 31 | Raise your hand if you found yourself in the situation of counting the number of methods in your APK. We found ourselves in that critical situation while we tried to 32 | reduce the size of the project we were working on and that is why we built a method counter interface inside **ClassyShark**. 33 | 34 | See the method count, that your runtime sees 35 | 36 | ![alt text](https://github.com/borisf/classyshark-user-guide/blob/master/images/5%20ClassesDexData.png) 37 | 38 | You can activate the view by simply clicking on the *Methods count* tab on top of the navigation tree. In a blink of an eye, you will have a browsable chart of the methods used by everything in you APK, with the possibility of navigate even further by using the same mechanisms we saw in the previous paragraph. 39 | 40 | ![alt text](https://github.com/borisf/classyshark-user-guide/blob/master/images/3%20Browse%20Method%20count) 41 | 42 | ## Incremental Search 43 | *Why do I have to click all the navigation to my class?* Well, you **do not have to**! 44 | **ClassyShark** ships with a handy search field, that you can use to filter the classes by writing a matching query, that will be automagically applied to the content of the archive and the AndroidManifest. 45 | 46 | ![alt text](https://github.com/borisf/classyshark-user-guide/blob/master/images/4%20Search.png) 47 | 48 | You can also use the arrows on top to navigate back and forth the history of the app! 49 | 50 | ## Native Code 51 | With the release of the new Android Nougat, new [code stability restrictions](http://android-developers.blogspot.co.uk/2016/06/improving-stability-with-private-cc.html) have been introduced, and **ClassyShark** is ready to welcome them! 52 | 53 | ![alt text](https://github.com/borisf/classyshark-user-guide/blob/master/images/6%20Native%20Suggestions.png) 54 | 55 | **ClassyShark** currently inspects the archive and shows this additional data: 56 | 57 | - Dynamic Symbol Errors (*missing SONAME* errors and text relocations in binary files) 58 | - Native libraries and dependencies (list of the *.so* native libraries linked in your APK) 59 | 60 | ## Export 61 | The *export* button, that will give you a report with all the relevant information about the archive and, on its side, you will find the *history* one, that will help you restoring previously loaded archives (they will persist upon application closing). 62 | 63 | ## Scenarios 64 | 1. Obfuscation 65 | 2. Dependencies 66 | 3. Dex Numbers 67 | 4. Native Code 68 | 69 | ## Command line 70 | * [Command line reference](https://github.com/google/android-classyshark/blob/master/CommandLine.pdf) 71 | 72 | ## Learn more 73 | * [APK Dashboard in ClassyShark](https://medium.com/@BorisFarber/apk-dashboard-in-classyshark-9346318bf5c6#.tv22uvr6n) 74 | * [Dealing with 65K method limit](http://bytes.schibsted.com/dealing-65k-methods-limit-android/?utm_source=Android+Weekly&utm_campaign=30733096d0-Android_Weekly_224&utm_medium=email&utm_term=0_4eb677ad19-30733096d0-337257757) 75 | * [Android Tools - Chinese](http://geek.csdn.net/news/detail/86457) 76 | * [Android Digest 17 - Russian](https://dou.ua/lenta/digests/android-digest-17/) 77 | * [App Diets are not a Fad](http://blog.nimbledroid.com/2016/06/15/app-diets-not-a-fad.html) 78 | * [ClassyShark verrät, was sich im APK versteckt - German](http://www.heise.de/developer/artikel/ClassyShark-verraet-was-sich-im-APK-versteckt-3217655.html) 79 | * [Tim Melor's multidex](https://github.com/tmelz/multidex_notes) 80 | * [Droidcon IT 2016 recap](http://jeroenmols.com/blog/2016/04/08/droidconit/) 81 | * [To infinity and 65K](https://speakerdeck.com/dextor/to-65k-and-beyond) 82 | * [Smaller APKs with ClassyShark](http://blog.jimbaca.com/2016/04/04/smaller-apks-with-classy-shark/) 83 | * [Jianshu - Chinese](http://www.jianshu.com/p/8e8b88ea2197) 84 | * [Shrinking your build with no rules](https://medium.com/@_tiwiz/shrinking-your-build-with-no-rules-8d9fb88281ac#.fiiqi3v3a) 85 | * [Native code browsing with ClassyShark](https://medium.com/@BorisFarber/classyshark-supports-native-code-browsing-a4985e7126b1#.kkw2lt4wz) 86 | * [Inspecting multidex APK with ClassyShark](https://medium.com/@BorisFarber/inspecting-your-apk-f53fb90136da#.d4os6nqdp) 87 | * [Intro to ClassyShark](https://medium.com/@BorisFarber/welcome-classyshark-b632ae8488b4#.4zcdc3kwd) 88 | 89 | ## Future development 90 | We are constantly looking for new features to make **ClassyShark** a better product, if you think we should add something, open an issue on the **ClassyShark** repo and we'll be happy to discuss about it! 91 | -------------------------------------------------------------------------------- /images/1 Open File.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/borisf/classyshark-user-guide/a5d41619ae07aafa47f6f03e44cb632fa7faca86/images/1 Open File.png -------------------------------------------------------------------------------- /images/2 Browse components: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/borisf/classyshark-user-guide/a5d41619ae07aafa47f6f03e44cb632fa7faca86/images/2 Browse components -------------------------------------------------------------------------------- /images/3 Browse Method count: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/borisf/classyshark-user-guide/a5d41619ae07aafa47f6f03e44cb632fa7faca86/images/3 Browse Method count -------------------------------------------------------------------------------- /images/4 Search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/borisf/classyshark-user-guide/a5d41619ae07aafa47f6f03e44cb632fa7faca86/images/4 Search.png -------------------------------------------------------------------------------- /images/5 ClassesDexData.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/borisf/classyshark-user-guide/a5d41619ae07aafa47f6f03e44cb632fa7faca86/images/5 ClassesDexData.png -------------------------------------------------------------------------------- /images/6 Native Suggestions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/borisf/classyshark-user-guide/a5d41619ae07aafa47f6f03e44cb632fa7faca86/images/6 Native Suggestions.png --------------------------------------------------------------------------------