CrackMe on Android

Honor To 《Android 软件安全与逆向分析》

学习本文需要的一些知识:初步android开发能力,懂少量smali语法,或者有阅读其他平台的汇编代码的能力,apktool的使用,利用私钥对android程序的签名,windows命令行基本知识

这些知识也可以边看边学,本文使用的是eclipse,apktool2.0,jarsigner 

好,进入正题


1.先写一个android小程序

	public void onRegister(View e) {
		EditText username=(EditText)findViewById(R.id.edit_user);
		EditText password=(EditText)findViewById(R.id.edit_pwd);
		if(checkReg(username.getText().toString(),password.getText().toString())){
			Toast.makeText(this, "pl!", Toast.LENGTH_SHORT).show();
		}else{
			Toast.makeText(this, R.string.unsuccessed, Toast.LENGTH_SHORT).show();
		}
	}
	
	public boolean checkReg(String username,String password){
		if(username.equals(password)){
			return true;
		}return false;
	}
 <TextView
        android:id="@+id/CrackMe1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:text="Android CrackMe1"
        android:textSize="30sp" />

    <TextView
        android:id="@+id/password"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/user"
        android:layout_below="@+id/user"
        android:layout_marginTop="50dp"
        android:textSize="30sp"
        android:text="密码" />

    <TextView
        android:id="@+id/user"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/CrackMe1"
        android:layout_marginLeft="28dp"
        android:layout_marginTop="50dp"
        android:text="用户名"
        android:textSize="30sp" />

    <EditText
        android:id="@+id/edit_user"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/user"
        android:layout_toRightOf="@id/user"
        android:ems="10"
        android:inputType="number"
        android:maxLength="10"
        android:singleLine="true" >

        <requestFocus />

    </EditText>

    <EditText
        android:id="@+id/edit_pwd"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@id/password"
        android:layout_alignLeft="@id/edit_user"
        android:layout_alignRight="@+id/edit_user"
        android:layout_toRightOf="@id/password"
        android:ems="10"
        android:inputType="number"
        android:singleLine="true" >

    </EditText>

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="246dp"
        android:onClick="onRegister"
        android:text="注册"
        android:textSize="30sp" />
代码链接: http://download.csdn.net/detail/fbgefoiff/6663323

界面如下



输入一些数字按注册发现显示“注册失败”

然后开始破解之路

先将apktool加入path路径

 在CrackMe.apk同一文件夹下打开命令行 :apktool d CrackMe.apk

会生成一个CrackMe文件夹


打开文件夹并找到smali文件夹,打开MainActivity.smali

将37行最后的0改为1



保存,依旧使用apktool编译:apktool b CrackMe


打开CrackMe文件夹寻找到CrackMe.apk


现在这个apk还不能安装,因为android的应用的安装还需要签名

SET outfile=debug%2
if %1==debug (
goto a1
)
jarsigner -verbose -keystore G:\android\eclipse\keystore\puyr.keystore -digestalg SHA1 -sigalg MD5withRSA -signedjar apkunaligned.apk %1 puyr
zipalign -v 4 apkunaligned.apk %2
goto a2
:a1
jarsigner -verbose -keystore C:\Users\hp\.android\debug.keystore -storepass android -keypass android -digestalg SHA1 -sigalg MD5withRSA -signedjar apkunaligned.apk %2 androiddebugkey
zipalign -v 4 apkunaligned.apk %outfile%
:a2

del apkunaligned.apk
这是我写的bat文件,为没签名的apk签名对齐用的,:a1是用自带的debug.keystore签名,在每个人的机器上可能存放的位置不同,也可以用自己的私钥签名,详细大家可以上网查,我也给几个链接

1.http://hi.baidu.com/gaogaf/item/8757c356ef718e9408be1777

2.http://blog.csdn.net/xiaotian15/article/details/8528751

3.http://www.cnblogs.com/qianxudetianxia/archive/2011/04/09/2010468.html

生成的新的文件就是可以安装并使用的。

大家看我最上面的源码应该知道,我只是简单判断了用户名和密码是否一致,而在smali文件中我修改的地方就是讲不一致的情况下返回值也改为true,所以无论如何程序都会显示为“pl!”


好像没什么可以写的啦,吃晚饭去了~~~

                                                   ----http://blog.csdn.net/pickupyourrevolution


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值