HelloWorld of Android Anti-compile code injection

Source: Internet
Author: User

To salute the classic "Hello, World," we also start with a simple program Helloworld.apk. When you install the APK on your phone, a line of text "Hello, world!"is displayed on the screen. Now we want to inject the "Hello world~!" into the way Change to "Hello World" in Chinese.

 

1. Anti-compilation

Dos command Prompt line input apktool.bat d helloworld.apk

When this command finishes running, a directory named Helloactivity is generated under the current directory .
The structure of the directory is ( name followed / indicates this is a directory ):

helloworld/
|--------------androidmanifest.xml
|--------------apktool.yml
|--------------res/
|--------------smali/

2. Code injection

Open The Smaili directory to find the code that needs to be injected,Mainactivity.smali. Open the file with a text editor. Search the keyword "Hello world" to find the code

Change to "Hello World". (Here we can also insert our code, interested friends can learn the next Smali syntax:http://pallergabor.uw.hu/androidblog/dalvik_opcodes.html)

3. RePack The build 1.APK

Save the file. Command line Apktool.bat b HelloWorld 1.apk build apk file.

4. Sign the newly generated apk file

Since we repackaged the apk file, the signature has been lost, so we have to re-sign the app before it can be installed. Here we use the jdk/bin/jarsigner.exe.

Command line input jarsigner-keystore e:\\keystore\1.keystore-storepass 123123-verbose 1.apk zs.keystore

Description Jarsigner-keystore [ signature file path ] -storepass [ password ] -verbose [ requires signature file path ] [ signature file alias ]

5. Delete the original HelloWorldon the phoneand reinstall our modified apk file.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.