一個小程序的解析(未完待續(xù))

會用到Android Killer,JEB,以及Android Studio進行動態(tài)調試smali匯編(如何搭建環(huán)境使用這些工具請看之前寫的幾個博客:
http://www.reibang.com/p/7ca677fea8c3
http://www.reibang.com/p/a6d472af3edf
http://www.reibang.com/p/2c9ba6a13b2d
http://www.reibang.com/p/10994a7fccd4
)蚤蔓;
先將這個apk拖入Android Killer中反編譯,解析:
拋出了一個異常:

image.png

又拋出了一個異常:
image.png

Android killer中反匯編出來的java

M.class
package ctf.bobbydylan;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;
import java.io.PrintStream;

public class M
  extends T
{
  public void check(String paramString)
  {
    int i = 0;
    if (paramString.length() != 16) {
      throw new RuntimeException();
    }
    try
    {
      str1 = get?ey();
      arrayOfInt = new int[16];
      arrayOfInt[0] = 0;
      arrayOfInt[12] = 14;
      arrayOfInt[10] = 7;
      arrayOfInt[14] = 15;
      arrayOfInt[15] = 42;
      arrayOfInt[1] = 3;
      arrayOfInt[5] = 5;
    }
    catch (Exception localException1)
    {
      try
      {
        String str1;
        System.out.println();
        arrayOfInt[6] = 15;
        arrayOfInt[2] = 13;
        arrayOfInt[3] = 19;
        arrayOfInt[11] = 68;
        arrayOfInt[4] = 85;
        arrayOfInt[13] = 5;
        arrayOfInt[9] = 7;
        arrayOfInt[7] = 78;
        arrayOfInt[8] = 22;
        if (i < paramString.length()) {
          if ((arrayOfInt[i] & 0xFF) != ((paramString.charAt(i) ^ str1.charAt(i % str1.length())) & 0xFF))
          {
            throw new RuntimeException();
            localException1 = localException1;
            String str2 = getKey();
            System.arraycopy(str2, 0, paramString, 5, 5);
          }
        }
      }
      catch (Exception localException2)
      {
        for (;;)
        {
          int[] arrayOfInt;
          arrayOfInt[5] = 37;
          arrayOfInt[1] = 85;
          continue;
          i += 1;
        }
      }
    }
  }
  
  public String getKey()
  {
    return "bobbydylan";
  }
  
  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(2130903040);
    startService(new Intent(this, P.class));
    ((Button)findViewById(2131099649)).setOnClickListener(new a(this, (TextView)findViewById(2131099648)));
  }
  
  protected void onPause()
  {
    stopService(new Intent(this, P.class));
    super.onPause();
  }
}

要想上面兩個異常都不成立,必須滿足:
if ((arrayOfInt[i] & 0xFF) != ((paramString.charAt(i) ^ str1.charAt(i % str1.length())) & 0xFF))中

arrayOfInt[i] & 0xFF) == ((paramString.charAt(i) ^ str1.charAt(i % str1.length())) & 0xFF

以及:
if (paramString.length() != 16)中:
paramString.length() == 16

再看看下面的一個類a;


image.png

查看Android killer反編譯出來的源代碼:

package ctf.bobbydylan;

import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

class a
  implements View.OnClickListener
{
  a(M paramM, TextView paramTextView) {}
  
  public void onClick(View paramView)
  {
    try
    {
      paramView = this.a.getText().toString();
      this.b.check(paramView);
      new AlertDialog.Builder(this.b).setMessage("正確").setNeutralButton("OK", null).create().show();
      return;
    }
    catch (Exception paramView)
    {
      new AlertDialog.Builder(this.b).setMessage("錯誤").setNeutralButton("OK", null).create().show();
    }
  }
}

這個應該是最后點擊時候彈出了相應窗口

再看看jeb里面的反匯編源代碼:

M類:
package ctf.bobbydylan;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

public class M extends T {
    public M() {
        super();
    }

    public void check(String arg10) {
        String v0_1;
        int v7 = 15;
        int v6 = 7;
        int v1 = 0;
        int v5 = 5;
        if(arg10.length() != 16) {
            throw new RuntimeException();
        }

        try {
            v0_1 = this.get?ey();
        }
        catch(Exception v0) {
            v0_1 = this.getKey();
            System.arraycopy(v0_1, 0, arg10, v5, v5);
        }

        int[] v2 = new int[16];
        v2[0] = 0;
        v2[12] = 14;
        v2[10] = v6;
        v2[14] = v7;
        v2[v7] = 42;
        int v4 = 3;
        try {
            v2[1] = v4;
            v2[5] = 5;
            System.out.println();
        }
        catch(Exception v3) {
            v2[v5] = 37;
            v2[1] = 85;
        }

        v2[6] = v7;
        v2[2] = 13;
        v2[3] = 19;
        v2[11] = 68;
        v2[4] = 85;
        v2[13] = v5;
        v2[9] = v6;
        v2[v6] = 78;
        v2[8] = 22;
        while(v1 < arg10.length()) {
            if((v2[v1] & 255) != ((arg10.charAt(v1) ^ v0_1.charAt(v1 % v0_1.length())) & 255)) {
                throw new RuntimeException();
            }

            ++v1;
        }
    }

    public String getKey() {
        return "bobbydylan";
    }

    public void onCreate(Bundle arg4) {
        super.onCreate(arg4);
        this.setContentView(2130903040);
        this.startService(new Intent(((Context)this), P.class));
        this.findViewById(2131099649).setOnClickListener(new a(this, this.findViewById(2131099648)));
    }

    protected void onPause() {
        this.stopService(new Intent(((Context)this), P.class));
        super.onPause();
    }
}



P類:
package ctf.bobbydylan;

import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.IBinder;

public class P extends Service {
    MediaPlayer a;

    public P() {
        super();
    }

    public IBinder onBind(Intent arg2) {
        return null;
    }

    public void onDestroy() {
        if(this.a != null) {
            this.a.stop();
            this.a = null;
        }

        super.onDestroy();
    }

    public int onStartCommand(Intent arg3, int arg4, int arg5) {
        try {
            if(this.a != null) {
                goto label_10;
            }

            this.a = MediaPlayer.create(((Context)this), 2130968576);
            this.a.start();
            this.a.setLooping(true);
        }
        catch(Exception v0) {
        }

    label_10:
        return super.onStartCommand(arg3, arg4, arg5);
    }
}

a類:

package ctf.bobbydylan;

import android.app.AlertDialog$Builder;
import android.content.DialogInterface$OnClickListener;
import android.view.View$OnClickListener;
import android.view.View;
import android.widget.TextView;

class a implements View$OnClickListener {
    a(M arg1, TextView arg2) {
        this.b = arg1;
        this.a = arg2;
        super();
    }

    public void onClick(View arg5) {
        DialogInterface$OnClickListener v3 = null;
        try {
            this.b.check(this.a.getText().toString());
            new AlertDialog$Builder(this.b).setMessage("正確").setNeutralButton("OK", null).create().show();
        }
        catch(Exception v0) {
            new AlertDialog$Builder(this.b).setMessage("錯誤").setNeutralButton("OK", v3).create().show();
        }
    }
}


T類:

package ctf.bobbydylan;

import android.app.Activity;

public abstract class T extends Activity {
    public T() {
        super();
    }

    public String get?ey() {
        return "bobdylan";
    }
}



還要需要動態(tài)調試smali匯編

小結:一般先找onClick()相關的函數(shù)(即:最后的對話框),然后從中找出一些關鍵點,再猜((lll¬ω¬))
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市辱志,隨后出現(xiàn)的幾起案子色罚,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 222,865評論 6 518
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件侈玄,死亡現(xiàn)場離奇詭異,居然都是意外死亡深啤,警方通過查閱死者的電腦和手機拗馒,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 95,296評論 3 399
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來溯街,“玉大人诱桂,你說我怎么就攤上這事〕饰簦” “怎么了挥等?”我有些...
    開封第一講書人閱讀 169,631評論 0 364
  • 文/不壞的土叔 我叫張陵,是天一觀的道長堤尾。 經常有香客問我肝劲,道長,這世上最難降的妖魔是什么郭宝? 我笑而不...
    開封第一講書人閱讀 60,199評論 1 300
  • 正文 為了忘掉前任辞槐,我火速辦了婚禮,結果婚禮上粘室,老公的妹妹穿的比我還像新娘榄檬。我一直安慰自己,他們只是感情好衔统,可當我...
    茶點故事閱讀 69,196評論 6 398
  • 文/花漫 我一把揭開白布鹿榜。 她就那樣靜靜地躺著,像睡著了一般锦爵。 火紅的嫁衣襯著肌膚如雪舱殿。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 52,793評論 1 314
  • 那天险掀,我揣著相機與錄音沪袭,去河邊找鬼。 笑死樟氢,一個胖子當著我的面吹牛枝恋,可吹牛的內容都是我干的。 我是一名探鬼主播嗡害,決...
    沈念sama閱讀 41,221評論 3 423
  • 文/蒼蘭香墨 我猛地睜開眼焚碌,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了霸妹?” 一聲冷哼從身側響起十电,我...
    開封第一講書人閱讀 40,174評論 0 277
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后鹃骂,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體台盯,經...
    沈念sama閱讀 46,699評論 1 320
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 38,770評論 3 343
  • 正文 我和宋清朗相戀三年畏线,在試婚紗的時候發(fā)現(xiàn)自己被綠了静盅。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 40,918評論 1 353
  • 序言:一個原本活蹦亂跳的男人離奇死亡寝殴,死狀恐怖蒿叠,靈堂內的尸體忽然破棺而出,到底是詐尸還是另有隱情蚣常,我是刑警寧澤市咽,帶...
    沈念sama閱讀 36,573評論 5 351
  • 正文 年R本政府宣布,位于F島的核電站抵蚊,受9級特大地震影響施绎,放射性物質發(fā)生泄漏。R本人自食惡果不足惜贞绳,卻給世界環(huán)境...
    茶點故事閱讀 42,255評論 3 336
  • 文/蒙蒙 一谷醉、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧冈闭,春花似錦孤紧、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,749評論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽臭猜。三九已至躺酒,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間蔑歌,已是汗流浹背羹应。 一陣腳步聲響...
    開封第一講書人閱讀 33,862評論 1 274
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留次屠,地道東北人园匹。 一個月前我還...
    沈念sama閱讀 49,364評論 3 379
  • 正文 我出身青樓,卻偏偏與公主長得像劫灶,于是被迫代替她去往敵國和親裸违。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 45,926評論 2 361

推薦閱讀更多精彩內容

  • Android 自定義View的各種姿勢1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 172,336評論 25 707
  • afinalAfinal是一個android的ioc本昏,orm框架 https://github.com/yangf...
    passiontim閱讀 15,441評論 2 45
  • 近日供汛,影視界的盛典不斷,中國電視劇品質盛典一天后,舉行奧斯卡頒獎典禮怔昨。二者相遇雀久,小編不禁想問,為什么在如此盛產影視...
    小蔡一蝶閱讀 620評論 2 0
  • 今天忙忙碌碌在三亞趁舀,原本我應該很開心啊赖捌,這里有我喜歡美景、美食矮烹,而且還是免費的越庇,但是我卻開心不起來。我感覺到自己好...
    ohon閱讀 181評論 -1 0
  • 還記得阿桑那句歌詞么擂送?孤單是一個人的狂歡悦荒,狂歡是一群人的孤單。 每個人終其一生都要面對孤獨嘹吨,那是一種不被理解搬味,不被...
    薩布麗娜閱讀 1,830評論 18 45