> For the complete documentation index, see [llms.txt](https://docs.cooku222.kr/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cooku222.kr/security/mobile/owasp-mas-crackme/owasp-mas-crackme-l01.md).

# OWASP MAS Crackme L01

문제 원본 : <https://mas.owasp.org/crackmes/>

***

**AndroidManifest.xml**

```
<?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:versionCode="1"
    android:versionName="1.0"
    package="owasp.mstg.uncrackable1">

    <uses-sdk
        android:minSdkVersion="19"
        android:targetSdkVersion="28" />

    <application
        android:theme="@ref/0x7f070000"
        android:label="@ref/0x7f060001"
        android:icon="@ref/0x7f050000"
        android:allowBackup="true">

        <activity
            android:label="@ref/0x7f060001"
            android:name="sg.vantagepoint.uncrackable1.MainActivity">

            <intent-filter>

                <action
                    android:name="android.intent.action.MAIN" />

                <category
                    android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>
```

* 모바일 리버싱에서 공부하고자 하면 가장 먼저 들어가야할 파일은 AndroidManifest.xml이다. 위 코드는 jadx로 까본 코드이다.&#x20;
* 여기서 문제와 관련된 힌트는 다음 코드 부분이다.

```
<activity
            android:label="@ref/0x7f060001"
            android:name="sg.vantagepoint.uncrackable1.MainActivity">
```

* 액티비티 패키지 명이 쓰여있다. 이 패키지로 들어가본다.

<figure><img src="https://blog.kakaocdn.net/dna/SbQy9/btsPK3ypS2v/AAAAAAAAAAAAAAAAAAAAAGhfi3WyK-t1iOMfLGj2-xcATwPei8H_Ex74jtAOSfLM/img.png?credential=yqXZFxpELC7KVnFOS48ylbz2pIh7yKj8&#x26;expires=1782831599&#x26;allow_ip=&#x26;allow_referer=&#x26;signature=wd%2F%2Bap7xtr4aXF6j4uCxGr%2FXx1E%3D" alt="" height="1024" width="1280"><figcaption></figcaption></figure>

if (c.a() || c.b() || c.c()) { a("Root detected!"); }

* c 클래스는 루팅 탐지를 담당하는 유틸리티 클래스이고, a(), b(), c()는 각각 다른 루팅 탐지 기법을 수행하는 것으로 추정된다.

메서드 가능한 기능

| c.a() | su 명령어나 바이너리 존재 여부 확인 (/system/bin/su) |
| ----- | -------------------------------------- |
| c.b() | 루팅 앱 존재 여부 확인 (Superuser.apk, Magisk)  |
| c.c() | 시스템 속성(build tags) 또는 루팅 흔적 확인         |

→ Frida로 풀려면 c 메서드의 후킹 영역을 우회한다.\
frida 후킹에 쓸 코드는 다음과 같다.

```
console.log("[+] Running Hook");
Java.perform(function() {
    var hook = Java.use("sg.vantagepoint.a.c");
    hook.a.implementation = function() {
        console.log("[+] Hooked a() method");
        return false;
    }
    hook.b.implementation = function() {
        console.log("[+] Hooked b() method");
        return false;
    }
    hook.c.implementation = function() {
        console.log("[+] Hooked c() method");
        return false;
    }
});
```

* hook.js 스크립트를 작성한 후

```
frida -U -f owasp.mstg.uncrackable1 -l C:\\hook.js
```

명령어를 실행해준 후 블루스택으로 apk를 열어주면

<figure><img src="https://blog.kakaocdn.net/dna/omdD9/btsPIpW37Xn/AAAAAAAAAAAAAAAAAAAAAIlNeoE0vmB9mky13iLETqGjMM-IVBoJWqq7w5houC-Q/img.png?credential=yqXZFxpELC7KVnFOS48ylbz2pIh7yKj8&#x26;expires=1782831599&#x26;allow_ip=&#x26;allow_referer=&#x26;signature=lwWOk3PdzB6mn7nDS%2B4p0nuXzkY%3D" alt="" height="758" width="1280"><figcaption></figcaption></figure>

루팅이 탐지되지 않는다.\
이제 저기에 입력할 secret string을 작성해야한다.

```
package sg.vantagepoint.uncrackable1;
import android.util.Base64;
import android.util.Log;
/* loaded from: classes.dex */

public class a {
    public static boolean a(String str) {
        byte[] bArrA;
        byte[] bArr = new byte[0];
        try {
            bArrA = sg.vantagepoint.a.a.a(b("8d127684cbc37c17616d806cf50473cc"), Base64.decode("5UJiFctbmgbDoLXmpL12mkno8HT4Lv8dlat8FxR2GOc=", 0));
        } catch (Exception e) {
            Log.d("CodeCheck", "AES error:" + e.getMessage());
            bArrA = bArr;
        }
        return str.equals(new String(bArrA));
    }

    public static byte[] b(String str) {
        int length = str.length();
        byte[] bArr = new byte[length / 2];
        for (int i = 0; i < length; i += 2) {
            bArr[i / 2] = (byte) ((Character.digit(str.charAt(i), 16) << 4) + Character.digit(str.charAt(i + 1), 16));
        }
        return bArr;
    }
}
```

* 위 코드에 따르면 키 값은 8d127684cbc37c17616d806cf50473cc이고, 5UJiFctbmgbDoLXmpL12mkno8HT4Lv8dlat8FxR2GOc=로 암호화된 값을 가진다.
* 코드를 보면 AES 암호를 쓰고 있는 것을 알 수 있다.

```
from Crypto.Cipher import AES
from base64 import b64decode

key = bytes.fromhex("8d127684cbc37c17616d806cf50473cc")

cipher_text = b64decode("5UJiFctbmgbDoLXmpL12mkno8HT4Lv8dlat8FxR2GOc=")

cipher = AES.new(key, AES.MODE_ECB)
plaintext = cipher.decrypt(cipher_text)

print("Secret String:", plaintext.decode('utf-8'))
```

* I want to believe가 secret string임을 알 수 있다.

<figure><img src="https://blog.kakaocdn.net/dna/EislF/btsPJcwz56n/AAAAAAAAAAAAAAAAAAAAAF-N0Tj1BWZIWqOsPLR1aP_lBCXUPlZOZd80uaFeB271/img.png?credential=yqXZFxpELC7KVnFOS48ylbz2pIh7yKj8&#x26;expires=1782831599&#x26;allow_ip=&#x26;allow_referer=&#x26;signature=rljvW2i5R5Iqgoo7N5QpOgygbW8%3D" alt="" height="1128" width="1968"><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cooku222.kr/security/mobile/owasp-mas-crackme/owasp-mas-crackme-l01.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
