DIVA.apk - ACCESS CONTROL ISSUES PART 1 ~ 3

Gunter·2024년 2월 6일
0

DIVA.apk

목록 보기
5/7

DIVA.apk는 flag를 찾아서 문제를 푸는 형식이 아닌 취약점을 확인하는 것.

.
.
.

Access Control Issues Part 1

objective : You are able to access the API credentials when you click the button. Now, try to access the API credentials from outside the app.

Hint : Components of an app can be accessed from other apps or users if they are not properly protected. Components such as activities, services, content providers are prone to this.

목적 : 버튼을 클릭하면 API credential에 액세스할 수 있다. 이제 앱 외부환경에서 API credential에 액세스해 보아라.

힌트 : 앱의 구성 요소가 적절하게 보호되지 않으면 다른 앱 또는 사용자로부터 액세스 할 수 있다. 활동, 서비스, 콘텐츠 제공자와 같은 구성 요소는 이러한 경향이 있다.


VIEW API CREDENTIALS 버튼을 눌러보았더니 다음과 같이 떴다.
이제 목적에서 말한 것 과 같이 앱을 이용하지 않고 위 화면을 뜨게 해야 한다.

adb를 이용하면 될 것 같다.


androidmanifest.xml을 살펴보았을 때, 이 액티비티를 강제호출 해주면 된다.

abd를 사용한 명령어는

adb shell am start -n [패키지명]/[액티비티명] 이다.


패키지명도 androidmanifest.xml 에서 찾을 수 있다.

adb shell am start -n jakhar.aseem.diva/jakhar.aseem.diva.APICredsActivity

라고 입력하면


위와 같은 API 정보 화면을 띄울 수 있다.

참조 https://tkdrms568.tistory.com/m/258
.
.
.
.
.

Access Control Issues Part 2

Objective : You are able to access the Third Party app TVEETER API credentials after you have registerd with Tveeter. The App requests you to register online and the vendor gives you a pin, which you can use to register with the app. Now, try to access the API credentials from outside the app without knowing the PIN. This is a business logic problem so you may need to see the code.

Hint : Components of an app can be accessed from other apps or users if they are not properly protected and some may also accept external inputs. Components such as activities, services, content providers are prone to this.

목표 : Tveeter에 등록한 후 서드파티 앱 TVEETER API 자격 증명에 액세스한다. 앱이 온라인 등록을 요청하면 공급업체가 핀을 제공하여 앱에 등록하는 데 사용할 수 있다. 이제 PIN을 모른 채 앱 외부에서 API 자격 증명에 액세스해 보아라. 이는 비즈니스 논리 문제이므로 코드를 확인해야 할 수도 있다.

힌트 : 앱의 구성 요소가 적절하게 보호되지 않으면 다른 앱 또는 사용자로부터 액세스할 수 있으며 일부는 외부 입력을 수락할 수도 있다. 활동, 서비스, 콘텐츠 제공자와 같은 구성 요소는 이러한 경향이 있다.


Register now를 누르고 View tveeter api credentials 버튼을 누르면 다음과 같이 PIN을 입력하라고 뜬다.

임의의 번호를 입력했더니 잘못된 PIN이라고 뜬다.


alredy register를 누르고 view를 누르면


이미 등록한 걸로 떠서 바로 API Credentials이 나온다.

목표에서 말한 것 과 같이 코드를 확인해보러 갔다.

androidmanifest.xml 을 보면 이번 문제는
AccessControl2Activity, APICreds2Activity 두개의 액티비티를 확인해야 할 것 같았다.


AccessControl2Activity를 먼저 살펴보면,
boolean 데이터 타입의 chk_pin 변수가 Intent i 와 함께 사용되는것을 확인하였다.


또 APICreds2Acitivity를 살펴보면, 25번째 줄 if에 !가 있으므로 (Not을 뜻함. true와 비교. 즉 거짓) 조건이 거짓일 경우 API에 접근할 수 있게 된다.

즉, chk_pin 변수가 거짓이라면 API 자격증명을 얻을 수 있다.

adb shell am start -n jakhar.aseem.diva/.APICreds2Activity -a jakhar.aseem.diva.action.VIEW_CREDS2 --ez check

part1과 비슷한 형태이지만, '--ez'를 넣어주어 chk_pin 변수를 거짓 상태로 실행시킨다.

위와 같은 코드를 사용하면,

API Credentials을 앱을 사용하지 않고 확인할 수 있다.

  • adb command

.
.
.
.
.

Access Control Issues Part 3

Objective : This is a priate notes application. You can create a PIN once and access your notes after entering the correct pin. Now, try to access the private notes from outside the app without knowing the PIN

Hint : Components of an app can be accessed from other apps or users if they are not properly protected and some may also accept external inputs. Components such as activities, services, content providers are prone to this.

목적 : 개인 노트 어플리케이션이다. 한 번 PIN을 생성하고 올바른 핀을 입력한 후 노트에 액세스할 수 있다. 이제 PIN을 모른 채 앱 외부에서 개인 노트에 액세스해보아라.

힌트 : 앱의 구성 요소가 적절하게 보호되지 않으면 다른 앱 또는 사용자로부터 액세스할 수 있으며 일부는 외부 입력을 수락할 수도 있다. 활동, 서비스, 콘텐츠 제공자와 같은 구성 요소는 이러한 경향이 있다.


임의의 네자리 숫자(4848)을 입력하고 Create 버튼을 누르면 다음과 같이 PIN이 생성되었다고 뜨며 private note로 갈 수 있는 버튼이 뜬다.


아까 생성했던 네자리 숫자를 입력해주면

Private note에 접근할 수 있다.

이제 이걸 앱을 사용하지 않고 외부에서 시도해야 한다.


androidmanifest.xml을 보았더니 위와 같이 provider가 exported=true 상태임을 확인하였다.
즉, prodiver의 경로만 알면 앱을 시도하지 않고 외부에서 private note에 접근할 수 있다.

apk tool을 이용해 디컴파일을 진행한다.
https://apktool.org/docs/install

(ls -l 후 smali 확인)

디컴파일을 하면 smail 코드가 생성되는데, provider는 "content://" 스킴을 이용하여 접근하기 때문에 해당 스킴을 이용해야 한다.

direct methods
.method static constructor <clinit>()V
	.locals 4
    
    .prologue
    .line 41
    const-string v0, "content://jakhar.aseem.diva.provider.notesprovider/notes"

NotesProvider.smail을 확인하면 위와 같이 뜨는데, provider의 전체 경로를 확인할 수 있다.

adb shell content query --uri content://jakhar.aseem.diva.provider.notesprovider/notes

adb에서 위와 같이 입력하면 private notes의 내용을 바로 확인할 수 있다.

0개의 댓글