omtg 첫번째 문제 badencryption이다.

제목처럼, 문제가 쉽다.

package sg.vp.owasp_mobile.OMTG_Android;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Base64;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.google.common.base.Ascii;
import sg.vp.owasp_mobile.omtg_android.C0000R;

public class OMTG_DATAST_001_BadEncryption extends AppCompatActivity {
    Button btnVerify;
    EditText passwordEditText;

    /* access modifiers changed from: protected */
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView((int) C0000R.layout.activity_omtg__datast_001__bad_encryption);
        setSupportActionBar((Toolbar) findViewById(C0000R.id.toolbar));
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        this.passwordEditText = (EditText) findViewById(C0000R.id.BadEnryptionPassword);
        this.btnVerify = (Button) findViewById(C0000R.id.BadEnryptionButton);
        this.btnVerify.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                boolean unused = OMTG_DATAST_001_BadEncryption.verify(OMTG_DATAST_001_BadEncryption.this.passwordEditText.getText().toString());
                OMTG_DATAST_001_BadEncryption.this.result(Boolean.valueOf(OMTG_DATAST_001_BadEncryption.verify(OMTG_DATAST_001_BadEncryption.this.passwordEditText.getText().toString())));
            }
        });
    }

    /* access modifiers changed from: private */
    public void result(Boolean result) {
        if (result.booleanValue()) {
            Toast.makeText(this, "Congratulations, this is the correct password", 1).show();
        } else {
            Toast.makeText(this, "Try again!", 1).show();
        }
    }

    /* access modifiers changed from: private */
    public static boolean verify(String str) {
        byte[] encryptedDecoded = Base64.decode("vJqfip28ioydips=", 0);
        byte[] userPass = encrypt(str);
        if (userPass.length != encryptedDecoded.length) {
            return false;
        }
        for (int i = 0; i < userPass.length; i++) {
            if (userPass[i] != encryptedDecoded[i]) {
                return false;
            }
        }
        return true;
    }

    private static byte[] encrypt(String str) {
        byte[] bytes = str.getBytes();
        for (int i = 0; i < bytes.length; i++) {
            bytes[i] = (byte) (bytes[i] ^ Ascii.DLE);
            bytes[i] = (byte) ((bytes[i] ^ -1) & 255);
        }
        return bytes;
    }
}

 

 

주어진 문자열 [vJqfip28ioydips=]을 해독하면 된다.

암호화 방식을 보면, 간단한 xor연산으로 이루어져 있다.

xor은 두번하면 역연산이 이루어지므로, 간단한 파이썬 코드를 작성해본다.

import base64

word = 'vJqfip28ioydips='
text = bytearray(base64.b64decode(word))
for i in range(len(text)):
	text[i] = (text[i] ^ -1) & 255
	text[i] = text[i] ^ 16

print(text.decode())
    

    

(첫번째 for 구문은 1바이트 확인용 연산이고, 없어도 상관없긴 하지만 넣어주자.)

 

 

간단하게 풀렸다.

'Android' 카테고리의 다른 글

[twrp] sm-g610l android 8.1.0 (odin)  (0) 2020.10.05
cSploit 분석 계획  (0) 2020.08.18
Uncrackable_1(작성중)  (0) 2020.07.11

UnCrackable-Level1.apk
0.06MB

Frida 를 이용한 UnCrackable_Level1 후킹.

 

우선 후킹 환경을 만드는게 꽤 귀찮다.

안드로이드 환경이 필요하므로 Nox를 다운받아 주자.

https://kr.bignox.com/

 

녹스 앱플레이어

모바일 게임을 키보드와 마우스로? 클릭 한 번으로 가상키보드 실행이 가능하며 PC버전의 게임도 간편하게 체험할 수 있습니다. 키보드와 마우스로 컨트롤하여 뛰는 자에서 나는 자가 되어볼 수

kr.bignox.com

Uncrackable 앱은 root권한을 탐지하는 함수가 들어가있으므로 Nox도 root권한을 활성화 시켜주자.

 

frida는 리눅스 환경에서 [pip install frida]명령어를 통하여 다운받을수 있다.

 

nox와 컴퓨터를 연결해주기 위해 nox에서 usb디버깅 옵션을 켜준 다음,  adb명령어를 이용한다.

[adb connect 127.0.0.1:62001][powershell]

adb를 실행하려면 SDK부터 다운받아야 하는데, 이는 구글에다가 'adb다운받는법' 이라고 쳐보는걸 추천

 

이제 frida를 설치해보자.

frida 설치
frida-tools 설치

여기서, frida의 버전을 잘 확인해야 한다.

내가 다운받은 버전은 12.10.4버전이고, 이에 맞는 frida-server를 다운받아야 한다.

 

/여기서 frida 와 frida-server 가 뭘까?/

>>frida는 무선마우스이고 frida-server는 수신기라 생각하면 될것같다.

 

https://github.com/frida/frida/releases

 

Releases · frida/frida

Clone this repo to build Frida. Contribute to frida/frida development by creating an account on GitHub.

github.com

구글에다가 자신이 다운받은 frida버전에 맞는 서버를 검색하면 github에 다 있으니깐 여기서 다운받아라.

여기서, 자신의 기기의 (녹스 환경 또는 안드로이드 기기 환경)

프로세서의 종류에 따라서 다운받아야 하는 파일이 다른데, 보통 arm 또는 arm64 이지만, 

adb에서 확인해보자.

 

이상하게 abi2는 나오질 않는다. 뭐 일단 x86서버를 넣어서 돌려보겠다.

녹스안에 /data/local/tmp 경로로 넣어주고, [ ./fridaserver & ] 라는 명령어를 넣어주면, 백그라운드로 돌아간다.

fridaserver의 파일권한을 변경해주고 싶으면, adb를 이용해도 되긴 하지만, 그냥 녹스안에서 상위파일관리자를 이용하여 권한을 수정해주면 편하다. 

내가 쓴 앱은 유료이지만, 구글에 널려있기 때문에 알아서 잘 찾아보거라

(여기에는 못올릴듯)

 

이제 Uncrackable_1 을 설치해주고, 실행시키면 다음과 같은 창이 나온다.

루트권한을 탐지했단다. 와우

 

이제 어떤 원리로 이 앱이 루트권한을 탐지하는지 알아보자.

우선 apkmanager로 디컴파일 한 후 ㅎ

 

'Android' 카테고리의 다른 글

[twrp] sm-g610l android 8.1.0 (odin)  (0) 2020.10.05
cSploit 분석 계획  (0) 2020.08.18
OMTG-DATAST-001-BadEncryption  (0) 2020.07.23

+ Recent posts