티스토리 뷰

CTF/App

[2016 SECCON] Rock Paper Scissors

Notchicken 2017. 4. 11. 17:40
[2016 SECCON] Rock Paper Scissors

이 문제에서 주어진 apk는 단순히 가위바위보를 하는 앱이었다.
MainActivity 코드를 보면

MainActivity.class

package com.example.seccon2015.rock_paper_scissors;
import android.widget.TextView;
class MainActivity$1
  implements Runnable
{
  MainActivity$1(MainActivity paramMainActivity) {}

  public void run()
  {
    TextView localTextView = (TextView)this.this$0.findViewById(2131492946);
    MainActivity localMainActivity;
    if (this.this$0.n - this.this$0.m == 1)
    {
      localMainActivity = this.this$0;
      localMainActivity.cnt += 1;
      localTextView.setText("WIN! +" + String.valueOf(this.this$0.cnt));
    }
    for (;;)
    {
      if (1000 == this.this$0.cnt) {
        localTextView.setText("SECCON{" + String.valueOf((this.this$0.cnt + this.this$0.calc()) * 107) + "}");
      }
      this.this$0.flag = 0;
      return;
      if (this.this$0.m - this.this$0.n == 1)
      {
        this.this$0.cnt = 0;
        localTextView.setText("LOSE +0");
      }
      else if (this.this$0.m == this.this$0.n)
      {
        localTextView.setText("DRAW +" + String.valueOf(this.this$0.cnt));
      }
      else if (this.this$0.m < this.this$0.n)
      {
        this.this$0.cnt = 0;
        localTextView.setText("LOSE +0");
      }
      else
      {
        localMainActivity = this.this$0;
        localMainActivity.cnt += 1;
        localTextView.setText("WIN! +" + String.valueOf(this.this$0.cnt));
      }
    }
  }
}

이기면 cnt + 1
비기면 cnt + 0
지면 cnt 초기화를 하고, 
cnt가 1000이 되었을 때
SECCON((cnt + calc()) * 107} 형태로 Flag를 출력해주는 것을 알 수 있다.

그래서 Smali 코드에서 카운트 값이 1000인지 확인하는 부분을
1과 비교하도록 수정하여 한번 이겼을 때 Flag값을 출력하도록 바꿔보았다.


.line 49
    :goto_0
    const/16 v1, 0x1 // 0x3e8과 비교하는 값을 0x1로 변경
    iget-object v2, p0, Lcom/example/seccon2015/rock_paper_scissors/MainActivity$1;->this$0:Lcom/example/seccon2015/rock_paper_scissors/MainActivity;
    iget v2, v2, Lcom/example/seccon2015/rock_paper_scissors/MainActivity;->cnt:I
    if-ne v1, v2, :cond_0
    .line 50
    new-instance v1, Ljava/lang/StringBuilder;
    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
    const-string v2, "SECCON{"


수정한 APK를 다시 실행하니 한번 이겼을 때 SECCON{856} 이라는 Flag를 출력하였다.
SECCON((cnt + calc()) * 107) 에서 카운트 값이 1이므로, calc() 값은 7임을 알 수 있다.

원래의 APK는 카운트 값이 1000일 때 Flag를 출력해주니
SECCON((1000+7)*107)이 Flag가 되는것을 알 수 있다.

Flag : SECCON{107749}


'CTF > App' 카테고리의 다른 글

[CodeEngn] SmartApp 03  (0) 2017.04.22
[CodeEngn] SmartApp 02  (0) 2017.04.20
[CodeEngn] SmartApp 01  (0) 2017.04.20
[2016 HolyShield] SoundMeter  (0) 2017.04.11
댓글
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday