• 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架构待机一天一晚并不是问题!

  • 相关阅读:
    php 构造函数支持不同个数参数的方法
    浅谈管理系统操作日志设计(附操作日志类)
    PHP 远程文件下载的进度条实现
    PHP处理大文件下载
    c语言线性表
    c语言题目:找出一个二维数组的“鞍点”,即该位置上的元素在该行上最大,在该列上最小。也可能没有鞍点
    c语言:从一组数据中选出可以组成三角形并且周长最长的三个数(简单)
    关于Staruml与powerdesigner启动使用中的问题
    Win7下安装Apache+PHP+MySQL
    <转>java编译问题:使用了未经检查或不安全的操作
  • 原文地址:https://www.cnblogs.com/Jclemo/p/6984709.html
Copyright © 2020-2023  润新知