zoukankan      html  css  js  c++  java
  • 20145307陈俊达_安卓逆向分析_APKtools分析smail

    20145307陈俊达_安卓逆向分析_APKtools分析smail

    引言

    真刺激呢!到了第二篇博客了,难度开始加大,之前是简单的dex2jar和有图形界面的jd-gui,现在来隆重介绍强大的反汇编工具apktool,这次开始将使用汇编的知识了

    直接开始

    创建一个安卓程序,emptyactivity就行,主java代码和xml布局代码如下:

    public class MainActivity extends Activity {  
      
        private final String ACCOUNT="jclemo";  
        private final String PASSWORD="123456";  
        private EditText etAccount, etPassword;  
        private Button btnLogin;  
      
        @Override  
        protected void onCreate(Bundle savedInstanceState) {  
            super.onCreate(savedInstanceState);  
            setContentView(R.layout.activity_main);  
      
            etAccount=(EditText)findViewById(R.id.et_account);  
      
            etPassword=(EditText)findViewById(R.id.et_password);  
      
            btnLogin=(Button)findViewById(R.id.btn_login);  
      
            btnLogin.setOnClickListener(new View.OnClickListener() {  
                @Override  
                public void onClick(View v) {  
                    if(isOK(etAccount.getText().toString(), etPassword.getText().toString())){  
                        Toast.makeText(MainActivity.this, "登录成功", Toast.LENGTH_SHORT).show();  
                    }else{  
                        Toast.makeText(MainActivity.this, "登录失败", Toast.LENGTH_SHORT).show();  
                    }  
      
                }  
            });  
        }  
      
        private boolean isOK(String account, String password){  
            if(account.equals(ACCOUNT) && password.equals(PASSWORD))  
                return true;  
            else  
                return false;  
        }  
      
    }  
    

    xml布局

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
        xmlns:tools="http://schemas.android.com/tools"  
        android:layout_width="match_parent"  
        android:layout_height="match_parent">  
      
        <LinearLayout  
            android:layout_width="match_parent"  
            android:layout_height="wrap_content"  
            android:orientation="vertical"  
            android:layout_centerInParent="true">  
      
            <LinearLayout  
                android:layout_width="match_parent"  
                android:layout_height="wrap_content"  
                android:gravity="center_horizontal"  
                android:orientation="horizontal">  
      
                <TextView  
                    android:layout_width="wrap_content"  
                    android:layout_height="wrap_content"  
                    android:text="帐号:"/>  
      
                <EditText  
                    android:id="@+id/et_account"  
                    android:layout_width="100dp"  
                    android:layout_height="wrap_content" />  
      
            </LinearLayout>  
      
            <LinearLayout  
                android:layout_width="match_parent"  
                android:layout_height="wrap_content"  
                android:gravity="center_horizontal"  
                android:orientation="horizontal">  
      
                <TextView  
                    android:layout_width="wrap_content"  
                    android:layout_height="wrap_content"  
                    android:text="密码:"/>  
      
                <EditText  
                    android:id="@+id/et_password"  
                    android:layout_width="100dp"  
                    android:layout_height="wrap_content" />  
      
            </LinearLayout>  
      
            <Button  
                android:id="@+id/btn_login"  
                android:layout_width="wrap_content"  
                android:layout_height="wrap_content"  
                android:layout_gravity="center_horizontal"  
                android:text="登录"/>  
      
        </LinearLayout>  
      
    </RelativeLayout>  
    

    签名运行:

    之后下载apktool,我是在cdsn下载的,要收费,我就不放链接了,大家有免费的可以自己去下载试试看。

    cmd进入解压apktool的目录,输入apktool d xxx.apk,回车进入反汇编,这样就会在当前文件夹下生成一个smail文件。

    用visual code打开mainactivity.smail,当然你用记事本打开也行,打开后发现这是个啥?仔细一看应该是汇编语言,这时候怕是要用到之前学习的汇编语言了。

    但这个是基于dalvik虚拟机的汇编文件,安卓SDK 4.4就开始使用ART(ANDROID run time)环境了,开始抛弃Dalvik虚拟机了,不过没关系,我们照样用

    开始修改smail语句,之后在回改成.apk

    我们想要实现的是不管输入什么id和pwd都能登陆,那么我们先看看汇编语言吧。

    a函数为原来的isOK(字符,字符)函数,用来登录,那我们就要攻击他啊!
    if-eqz =0,寄存器v0等于0的时候,跳转!我们可以修改返回值的t/f对错来进行破解

    修改返回值 让他至返回0x1,也就是true!

    行了,重新打包把,变回.apk,cmd,cd到apktool.jar当前的位置,输入apktool b 刚刚反编译生成文件夹的路径,在dist文件夹下找到apk

    这里注意,反汇编会破坏签名,推荐auto-sign来签名使用,推荐下载地址 http://download.csdn.net/detail/qq_18870023/9547292

    回到安卓studio,启动安卓模拟器,输入.apk验证!

    nice!

    总结,下次博客放大招,介绍最刺激的Xposed神器!我手机里下载了xposed后阻止运行加绿色守护双xposed架构待机一天一晚并不是问题!

  • 相关阅读:
    POI中文API文档
    接口
    JDK中的URLConnection参数详解
    RPC远程过程调用概念及实现
    tkinter 打包成exe可执行文件
    PHP 的命令行模式
    php CLI SAPI 内置Web Server
    ppython的移位操作
    HAProxy基础
    HAProxy用法详解
  • 原文地址:https://www.cnblogs.com/Jclemo/p/6984709.html
Copyright © 2011-2022 走看看