/smalidea

smalidea is a smali language plugin for IntelliJ IDEA

Primary LanguageJavaOtherNOASSERTION

smalidea is a smali language plugin for IntelliJ IDEA/Android Studio

It is currently very experimental, and you will likely run into issues.

News

  • 2021-03-02 - v0.06 is out. This brings smalidea back up to snuff with regards to modern versions of IDEA/Android Studio

    • This force updates the smali file type to be associated with this plugin instead of the built-in smali plugin in Android Studio
    • This adds support for the new synaxes (hidden api restrictions, spaces in identifiers, etc.)
    • This fixes a problem with how registers were mapped on art while debugging (thanks @bet4it)
    • Structure view for smali files (thanks @Donlon)
  • 2020-02-23 - smalidea has been migrated to a separate repository. This new repository is a filtered copy of the original smali repository in order to maintain the git history. However, any versions prior to this migration are not expected to actually build. If you need to build an old version for some reason, you should check out and build from the smali repository.

  • 2016-02-27 - v0.03 is out. This is mostly a stability/bug fix release, with no significant new functionality.

Features

Current Features

  • Syntax Highlighting/Syntax Errors
  • Bytecode level debugging
    • Breakpoints
    • Instruction level single stepping
    • Adding watches for arbitrary (non-named) registers
    • Full java-style expression support in locals window, etc. while debugging
  • Go to Definition
  • Find Usages
  • Renaming
  • Referencing smali classes from java code (except it can't actually be compiled, yet)
  • Issue reporting - easily create a new github issue from the error dialog

Possible Future Features

  • Auto-complete (instruction names, class/method/field references, etc.)
  • Compile support for smali-only projects
  • Robust error detection (e.g. full bytecode verification)
  • Smoother project import process
    • Automatic detection of source directory
    • Choosing sdk
  • Wizard for importing an apk as a new project
  • "Smali Class" entry in "New..." context menu
  • Show all registers with a value in "locals" pane
  • Ability to set the value of a register in "watch" pane

"Stretch" Features

  • Compile support for mixed smali+java projects
  • "Introduce new register" intention
  • Import (and deodex) device framework as new module (or new sdk??)
  • Expose register type analysis data
    • Show the expected type of a register at any point
    • Find locations where the register's value could have been set

Installation

  1. Download the latest smalidea zip file from the Bitbucket download page
  2. In IDEA/AS, go to Settings->Plugins and click the "Install plugin from disk" button, selecting the downloaded smalidea zip file
  3. Click "Apply" and restart IDEA/AS
  4. ???
  5. Profit!

Debugging an application

Note: Single-instruction stepping is only supported in IDEA 14.1 and greater, and any future version of Android Studio based on IDEA 14.1 or greater. In earlier versions, attempting to single step will step to the next .line directive, instead of stepping to the next instruction.

  1. Manually disassemble an application using baksmali into a "src" subdirectory of a new project directory, e.g. baksmali d myapp.apk -o ~/projects/myapp/src
  2. In IDEA, import a new project, and select the project directory. e.g. ~/projects/myapp
  3. Use the "Create project from existing sources" option when importing the project
  4. Once the project has been created, right click on the src directory and select "Mark Directory As->Sources Root"
  5. Open the project settings and select/create an appropriate JDK
  6. Install/start the application on the device
  7. Run adb shell ps | grep <package-name> and take note of the pid of the application process
  8. run adb forward tcp:8700 jdwp:<pid>
  9. In IDEA, Create a new "Remote" debug configuration (Run->Edit Configurations), and change the debug port to 8700
  10. Run->Debug
  11. The application should pause if/when the breakpoint is hit, at which point you can single step, add watches, etc.

or do the following in recent Android Studio 3.2:

  1. Manually disassemble an application using baksmali into a "src" subdirectory of a new project directory, e.g. baksmali d myapp.apk -o ~/projects/myapp/src
  2. In Android Studio, close your current project and select "Open an existing Android Studio project".
  3. Once the project has been created, right click on the src directory and select "Mark Directory As->Sources Root"
  4. Make sure your app has android:debuggable="true" in Android Manifest. Turn on "USB debugging" and use "Select debug app" to select your app in "Developer options" on Android device
  5. Install/start the application on the device
  6. Run adb shell ps | grep <package-name> and take note of the pid of the application process
  7. run adb forward tcp:8700 jdwp:<pid>
  8. In Android Studio, Create a new "Remote" debug configuration (Run->Edit Configurations), and change the debug port to 8700
  9. In Android Studio, select Run -> Debug
  10. The application should pause if/when the breakpoint is hit, at which point you can single step, add watches, etc.