Kye0m's Security

[injuredandroid.apk] Flag Seven - SQLITE 본문

앱 모의해킹/Injuredandroid.apk

[injuredandroid.apk] Flag Seven - SQLITE

Kye0m 2022. 9. 12. 16:50

Injuredandroid.apk - Flag Seven -SQLITE

이 문제는 플래그와 패스워드를 입력하여 통과하는 문제이다.

 

문제풀이

public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(2131427369);
        C(findViewById((int) i.toolbar));
        j.g.a(this);
        H();
        findViewById((int) i.fab).setOnClickListener(new a());
        
        SQLiteDatabase writableDatabase = this.u.getWritableDatabase();
        //데이터베이스 생성
        ContentValues contentValues = new ContentValues();
        contentValues.put("title", Base64.decode("VGhlIGZsYWcgaGFzaCE=", 0));
        contentValues.put("subtitle", Base64.decode("MmFiOTYzOTBjN2RiZTM0MzlkZTc0ZDBjOWIwYjE3Njc=", 0));
        //sql의 title과 subtitle에 base64로 값을 인코딩하여 넣어준다
        // title -> The flag hash!
        // subtitle -> 2ab96390c7dbe3439de74d0c9b0b1767
        
        writableDatabase.insert("Thisisatest", null, contentValues);
        contentValues.put("title", Base64.decode("VGhlIGZsYWcgaXMgYWxzbyBhIHBhc3N3b3JkIQ==", 0));
        //title에 base64로 디코딩한 값을 넣음
        // title -> The flag is also a password!
        contentValues.put("subtitle", h.c());
        //subtitle에 h클래스 c의 리턴값을 넣어준다.
        writableDatabase.insert("Thisisatest", null, contentValues);
    }

 

 

 

값이 나온다. flag값을 알아냈고

이제 h클래스의 c의 리턴값을 알아보면

 

public void onDestroy() {

        this.u.close();

        deleteDatabase("Thisisatest.db");

        l lVar = this.E;

 

onDestory()의 일부를 보면 SQLite의 데이터베이스 파일이름이 thisisatest.db 인것을 알 수 있습니다.

adb shell을이용하여, 에뮬레이터에 접근한 후, grep 명령어를 이용해서 데이터베이스의 위치를 찾습니다.

 

find | grep "Thisisatest.db"

이후 adb pull 명령어를 이용하여 데이터 베이스를 가져옵니다.

 

adb pull "데이터베이스 위치"

 

이후 sqlite를 통해서 "Thisisatest.db"를 열어줍니다.

 

 

 

2ab96390c7dbe3439de74d0c9b0b1767을 md5로 복호화 해주고,

9EEADi^^:?;FC652?5C@:5]7:C632D6:@]4@>^DB=:E6];D@? 를 ROT47로 인코딩해주면 아래와 같은 주소가 나오게 되는데, 주소에 들어가면 패스워드를 얻어낼 수 있다.