Objection 튜토리얼

Tip

AWS 해킹 배우기 및 연습하기:HackTricks Training AWS Red Team Expert (ARTE)
GCP 해킹 배우기 및 연습하기: HackTricks Training GCP Red Team Expert (GRTE) Azure 해킹 배우기 및 연습하기: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks 지원하기

소개

objection - 런타임 모바일 탐색

ObjectionFrida에 의해 구동되는 런타임 모바일 탐색 툴킷입니다. jailbroken 또는 rooted 모바일 기기가 필요하지 않고 모바일 애플리케이션과 그 보안 상태를 평가하는 데 도움을 주기 위해 만들어졌습니다.

참고: 이것은 어떤 형태의 jailbreak / root bypass가 아닙니다. objection을 사용하더라도, 당신은 여전히 적용되는 sandbox가 부과하는 모든 제한의 영향을 받습니다.

요약

objection목표는 사용자가 Frida가 제공하는 주요 작업들을 호출할 수 있게 하는 것입니다. 그렇지 않으면, 사용자는 테스트하려는 각 애플리케이션에 대해 단일 스크립트를 만들어야 합니다.

튜토리얼

이 튜토리얼에서는 여기에서 다운로드할 수 있는 APK를 사용하겠습니다:

또는 그 original repository (download app-release.apk)에서 받을 수 있습니다.

설치

pip3 install objection

연결

일반적인 ADB conection을 하고 장치에서 frida 서버를 시작하세요 (클라이언트와 서버 둘 다에서 frida가 작동하는지 확인하세요).

만약 rooted device를 사용 중이라면, –gadget 옵션 안에서 테스트하려는 애플리케이션을 선택해야 합니다. 이 경우:

frida-ps -Uai
objection --gadget asvid.github.io.fridaapp explore

기본 동작

이 튜토리얼에는 objections의 모든 가능한 명령을 나열하지 않습니다. 제가 더 유용하다고 생각한 것들만 포함합니다.

환경

환경 내부에서 (예: passwords 또는 paths)와 같은 흥미로운 정보를 찾을 수 있습니다.

env

Frida 정보

frida

업로드/다운로드

file download <remote path> [<local path>]
file upload <local path> [<remote path>]

frida script 임포트

import <local path frida-script>

SSLPinning

android sslpinning disable #Attempts to disable SSL Pinning on Android devices.

루팅 탐지

android root disable  #Attempts to disable root detection on Android devices.
android root simulate #Attempts to simulate a rooted Android environment.

명령 실행

android shell_exec whoami

스크린샷

android ui screenshot /tmp/screenshot
android ui FLAG_SECURE false  #This may enable you to take screenshots using the hardware keys

Static analysis를 Dynamic하게 적용하기

실제 애플리케이션에서는 objection을 사용하기 전에 이 섹션에서 발견된 모든 정보를 static analysis 덕분에 알고 있어야 합니다. 어쨌든, 여기서는 classes, methods and exported objects의 전체 목록만 제공되므로 이 방법으로는 새로운 것을 발견할 수도 있습니다.

또한 앱의 읽을 수 있는 source code를 얻을 수 없는 경우에도 유용합니다.

activities, receivers and services 나열

android hooking list activities

android hooking list services
android hooking list receivers

Frida는 아무것도 찾지 못하면 오류를 발생시킵니다

현재 activity 가져오기

android hooking get current_activity

클래스 검색

애플리케이션 내부에서 클래스들을 찾아보겠습니다.

android hooking search classes asvid.github.io.fridaapp

클래스의 메서드 검색

이제 클래스 MainActivity: 안에 있는 메서드를 추출해보자.

android hooking search methods asvid.github.io.fridaapp MainActivity

클래스에 선언된 메서드와 해당 매개변수 목록

클래스의 메서드들이 어떤 매개변수를 필요로 하는지 알아보자:

android hooking list class_methods asvid.github.io.fridaapp.MainActivity

클래스 나열

현재 애플리케이션에 로드된 모든 클래스를 나열할 수도 있습니다:

android hooking list classes #List all loaded classes, As the target application gets usedmore, this command will return more classes.

이는 클래스의 이름만 알고 있고 hook the method of a class and you only know the name of the class 하려는 경우에 매우 유용합니다. 이 함수를 사용해 클래스가 어느 모듈에 속하는지 search which module owns the class 를 찾아낸 다음 해당 method를 hook할 수 있습니다.

Hooking being easy

Hooking (watching) a method

From the source code of the application we know that the function sum() from MainActivity is being run every second. Lets try to dump all possible information each time the function is called (arguments, return value and backtrace):

android hooking watch class_method asvid.github.io.fridaapp.MainActivity.sum --dump-args --dump-backtrace --dump-return

Hooking (전체 클래스 감시하기)

사실 MainActivity 클래스의 모든 메소드가 매우 흥미로워서, 전부 hook them all 해보겠습니다. 주의: 이로 인해 애플리케이션이 crash 할 수 있습니다.

android hooking watch class asvid.github.io.fridaapp.MainActivity --dump-args --dump-return

If you play with the application while the class is hooked you will see when each function is being called, its arguments and the return value.

함수의 boolean 반환값 변경

소스 코드를 보면 함수 _checkPin_이 _String_을 인수로 받고 _boolean_을 반환한다는 것을 알 수 있습니다. 이 함수를 항상 true를 반환하도록 만들어보자:

이제 PIN 코드 입력란에 무엇이든 쓰면 모두 유효한 것으로 보일 것입니다:

클래스 인스턴스

특정한 Java class의 live instances를 검색하고 출력합니다(완전한 클래스 이름으로 지정). Out은 발견된 objection에 대해 string 값을 얻으려는 시도의 결과이며, 일반적으로 객체의 property 값들을 포함합니다.

android heap print_instances <class>

키스토어/인텐트

다음 도구를 사용해 keystore와 intents를 조작할 수 있습니다:

android keystore list
android intents launch_activity
android intent launch_service

메모리

덤프

memory dump all <local destination> #Dump all memory
memory dump from_base <base_address> <size_to_dump> <local_destination> #Dump a part

목록

memory list modules

목록 맨 아래에 frida가 보입니다:

frida가 내보내는 항목을 확인해봅시다:

검색/쓰기

objection을 사용해 메모리 내부를 검색하고 쓸 수도 있습니다:

memory search "<pattern eg: 41 41 41 ?? 41>" (--string) (--offsets-only)
memory write "<address>" "<pattern eg: 41 41 41 41>" (--string)

SQLite

sqlite 데이터베이스와 상호작용하려면 sqlite 명령을 사용할 수 있습니다.

종료

exit

Objection에서 아쉬운 점

  • hooking methods는 가끔 애플리케이션을 크래시시킨다(이는 Frida 때문이기도 함).
  • 클래스의 인스턴스를 사용해 그 인스턴스의 함수를 호출할 수 없다. 또한 클래스를 새로 인스턴스화하여 그 인스턴스로 함수를 호출할 수도 없다.
  • 애플리케이션에서 사용되는 일반적인 crypto methods를 모두 훅킹하여 cyphered text, plain text, keys, IVs 및 algorithms을 확인할 수 있는 단축 기능(예: sslpinnin용)은 없다.

References

Tip

AWS 해킹 배우기 및 연습하기:HackTricks Training AWS Red Team Expert (ARTE)
GCP 해킹 배우기 및 연습하기: HackTricks Training GCP Red Team Expert (GRTE) Azure 해킹 배우기 및 연습하기: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks 지원하기