Android 直接修改dex破解


  直接修改dex破解

一.編寫一個簡單的驗證程序

(1)MainActivity:

 protected void onCreate(BundlesavedInstanceState) {
               super.onCreate(savedInstanceState);
               setContentView(R.layout.activity_main);
               Buttonbutton ;
               finalEditText text1,text2;
               button=(Button)findViewById(R.id.button1);
               //獲取兩個輸入框的數據
               text1= (EditText)findViewById(R.id.editText1);
               text2=(EditText)findViewById(R.id.editText2);
               button.setOnClickListener(newOnClickListener() {
               @Override
               public void onClick(View v) {
               //TODO Auto-generated method stub
               //對輸入框的書進行判斷
                 if(text1.getText().toString().equals("CHINA")&&text2.getText().toString().equals("302")){
                         StringcontentToShow = "Hi,"+text1.getText().toString();
                         Toast.makeText(MainActivity.this,contentToShow,Toast.LENGTH_LONG).show();
                 }else{
                      StringcontentToShow = "NO."+text1.getText().toString()+"it isincorrect";      
                      Toast.makeText(MainActivity.this,contentToShow,Toast.LENGTH_LONG).show();
              }
       }
   });
 }

(2)activity_main.xml

<RelativeLayoutxmlns: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"

   android:paddingBottom="@dimen/activity_vertical_margin"

   android:paddingLeft="@dimen/activity_horizontal_margin"

   android:paddingRight="@dimen/activity_horizontal_margin"

   android:paddingTop="@dimen/activity_vertical_margin"

   tools:context="com.example.toast.MainActivity" >



   <Button

        android:id="@+id/button1"

       android:layout_width="wrap_content"

       android:layout_height="wrap_content"

       android:layout_alignLeft="@+id/editText1"

       android:layout_alignParentTop="true"

        android:layout_marginLeft="63dp"

       android:layout_marginTop="204dp"

        android:text="點擊" />



   <TextView

        android:id="@+id/textView2"

       android:layout_width="wrap_content"

       android:layout_height="wrap_content"

        android:layout_alignParentTop="true"

       android:layout_marginRight="22dp"

       android:layout_marginTop="44dp"

       android:layout_toLeftOf="@+id/editText1"

        android:text="請輸入:" />

   <EditText 
        android:id="@+id/editText1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignTop="@+id/textView2"
        android:layout_marginRight="61dp"
        android:ems="10" />

   <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/editText1"
        android:layout_marginTop="65dp"
        android:text="數字密碼:" />

   <EditText
          android:id="@+id/editText2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignLeft="@+id/editText1"
          android:layout_alignTop="@+id/textView1"
          android:ems="10"
          android:inputType="numberPassword" >
        <requestFocus />
   </EditText>
</RelativeLayout>

二.利用IDAPro及Winhex進行破解

1.解壓得到classesdex文件

(1)打開IDAPro,將classes.dex拖放到IDAPro的主窗口,會彈出加載新文件的對話框,IDAPro解析出了該文件屬於“Android DEX File”,保持默認的選項

(2)跳轉到區段

通過第三種方法來判斷方法的功能,我們知道low.apk的主類為MainActivity,於是在Export選項卡輸入Main,代碼會自動重新定位到以Main頭所在行。 

(3)找到變量

三、修改變量。

使用Winhe打開classes.dex文件

(1) 將CHINA變量改為DIJOB

(2) 將密碼302改為524

四.修復classes.dex文件

用Dexfixer將classes.dex文件checksum值修復 

五、重新打包為cracked.apk,刪除META-INT,並重新簽名apk

簽名成功后得到一個singed.apk的文件 

六、adb 進行安裝測試

安裝命令:

七、測試

輸入用戶名:DIJOB

輸入密碼:524

成功彈出 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM