
비-디컴파일링 iOS/Android 앱 취약점 스캐너 (DC25 데모 랩, CB17)
trueseeing은 iOS/Android 앱을 위한 빠르고 정확하며 탄력적인 취약점 스캐너입니다. Android의 Dalvik VM 수준에서 작동합니다. 즉, 대상 앱이 난독화되었는지 여부는 중요하지 않습니다.
현재 다음을 수행할 수 있습니다:
참고:
다음과 같이 바로 사용할 수 있는 컨테이너를 제공합니다. 현재 이 방법이 권장되며 Windows에서 실행하는 유일한 방법입니다:
$ docker run --rm -v $(pwd):/out -v ts2:/cache ghcr.io/alterakey/trueseeing
무상태로 실행하려면 /cache에 볼륨을 마운트하지 않아도 됩니다 (하지만 일상적인 사용에는 권장되지 않음; #254 참조):
$ docker run --rm -v $(pwd):/out ghcr.io/alterakey/trueseeing
또는 uv를 사용하여 패키지를 설치할 수 있습니다. 특히 uv tool install 형식의 설치는 확장 기능(아래 참조)에 가장 큰 자유를 제공하므로 유용할 수 있습니다. JRE와 Android SDK가 필요하다는 점을 기억하세요 (선택 사항; 장치를 다루려면):
$ uvx trueseeing
$ uv tool install trueseeing
$ trueseeing
물론 필요하다면 항상 익숙한 pip를 사용할 수 있습니다:
$ pip install trueseeing
대화형으로 앱을 스캔/분석/패치 등을 할 수 있습니다. 수동 분석에 이상적인 선택입니다:
$ trueseeing target.apk
[+] trueseeing x.y.z
ts[target.apk]> ?
...
ts[target.apk]> i # show generic information
...
ts[target.apk]> pf AndroidManifest.xml # show manifest file
...
ts[target.apk]> a # analyze resources too
...
ts[target.apk]> /s something # search text
...
ts[target.apk]> as # scan
...
[+] done, found 6403 issues (174.94 sec.)
ts[target.apk]> gh report.html
프롬프트를 제공하기 전에 실행할 인라인 명령(-c) 또는 스크립트 파일(-i)을 허용하며, 프롬프트 대신 바로 종료할 수도 있습니다(-q; 이 모드에서는 tty가 필요하지 않습니다!).
다음과 같이 배치 스캔을 수행하는 데 이 기능을 사용할 수 있습니다. 예를 들어 결과를 stderr로 바로 출력하려면:
$ trueseeing -eqc 'as' target.apk
HTML 형식의 보고서 파일을 생성하려면:
$ trueseeing -eqc 'as;gh report.html' target.apk
JSON 형식의 보고서 파일을 생성하려면:
$ trueseeing -eqc 'as;gj report.json' target.apk
최종 g* 명령에서 파일 이름을 생략하면 stdout으로 보고서가 생성됩니다:
$ trueseeing -eqc 'as;gh' target.apk > report.html
$ trueseeing -eqc 'as;gj' target.apk > report.json
전통적으로 다음 명령줄로 앱을 스캔하여 결과를 stderr에 표시할 수 있습니다:
$ trueseeing --scan target.apk
HTML 형식의 보고서를 생성하려면:
$ trueseeing --scan --scan-output report.html target.apk
$ trueseeing --scan --scan-report=html --scan-output report.html target.apk
JSON 형식의 보고서를 생성하려면:
$ trueseeing --scan --scan-report=json --scan-output report.json target.apk
파일 이름으로 '-'를 지정하면 stdout으로 보고서가 생성됩니다:
$ trueseeing --scan --scan-output - target.apk > report.html
$ trueseeing --scan --scan-report=html --scan-output - target.apk > report.html
$ trueseeing --scan --scan-report=json --scan-output - target.apk > report.json
자신만의 명령과 시그니처를 확장 기능으로 작성할 수 있습니다. 확장 기능은 /ext(컨테이너) 또는 ~/.trueseeing2/extensions/(uv/pip)에 배치됩니다. 또는 wheels로 확장 기능을 배포할 수도 있습니다. 타입 정보를 제공하므로 zuban으로 확장 기능의 타입 검사를 할 수 있을 뿐만 아니라 IDE에서 적절한 지원을 받을 수 있습니다. 자세한 내용은 세부 사항 섹션을 참조하세요.
다음과 같이 빌드할 수 있습니다:
$ docker build -t trueseeing https://github.com/alterakey/trueseeing.git#main
wheels를 빌드하려면 flit을 사용하여 다음과 같이 할 수 있습니다:
$ flit build
해킹하려면 적절한 빌드 환경을 만들어야 합니다. uv를 사용하면 다음과 같이 할 수 있습니다:
$ git clone https://github.com/alterakey/trueseeing.git wc
$ uv sync --locked --dev
$ (... hack ...)
$ uv run trueseeing ... # to run
$ uv run zuban check trueseeing && uv run ruff trueseeing # to validate
Success: no issues found in XX source files
$ uv run flit build # to build (wheel)
$ docker build -t trueseeing . # to build (container)
pip를 사용하여 만들려면 먼저 venv를 설정하고, flit과 검증 도구 체인(zuban 및 ruff)을 설치한 다음 flit이 종속성을 가져오도록 합니다. 요약하면 다음과 같이 하십시오:
$ git clone https://github.com/alterakey/trueseeing.git wc
$ python3 -m venv wc/.venv
$ source wc/.venv/bin/activate
(.venv) $ pip install flit zuban ruff
(.venv) $ flit install --deps=develop -s
(.venv) $ (... hack ...)
(.venv) $ trueseeing ... # to run
(.venv) $ zuban check trueseeing && ruff check trueseeing # to validate
Success: no issues found in XX source files
(.venv) $ flit build # to build (wheel)
(.venv) $ docker build -t trueseeing . # to build (container)
현재 다음 취약점 클래스를 감지할 수 있으며, 이는 대부분 OWASP Mobile Top 10 - 2016에 포함된 것입니다:
부적절한 플랫폼 사용 (M1)
안전하지 않은 데이터 (M2)
안전하지 않은 통신 (M3)
부족한 암호화 (M5)
클라이언트 코드 품질 문제 (M7)
코드 변조 (M8)
리버스 엔지니어링 (M9)
확장 API는 trueseeing.api 패키지 아래에 있습니다. 타입 정보를 제공하므로 IDE가 확장 기능을 작성할 때 도움을 줍니다. IDE(또는 해당 언어 서버)의 PYTHONPATH가 패키지가 설치된 venv를 포함하는지 확인하세요. uv tool install로 설치한 경우 uv tool list --show-paths를 참조하십시오. uvx로 설치한 경우 uvx install로 재설치하는 것을 고려하십시오. pip로 설치한 경우 이미 위치를 알고 있을 것입니다.
새 명령을 정의하려면 trueseeing.api.Command를 구현하고 이를 알립니다.
다음 클래스는 t라는 샘플 명령을 제공합니다. 예시:
from typing import TYPE_CHECKING
from trueseeing.api import Command
from trueseeing.core.ui import ui
if TYPE_CHECKING:
from trueseeing.api import CommandMap, CommandPatternMap, ModifierMap, OptionMap, ConfigMap
class MyCommand(Command):
@staticmethod
def create() -> Command:
return MyCommand()
def get_commands(self) -> CommandMap:
return {'t':dict(e=self._test, n='t', d='sample command')}
def get_command_patterns(self) -> CommandPatternMap:
return dict()
def get_modifiers(self) -> ModifierMap:
return dict()
def get_options(self) -> OptionMap:
return dict()
def get_configs(self) -> ConfigMap:
return dict()
async def _test(self) -> None:
ui.info('hello world')
새 시그니처를 정의하려면 trueseeing.api.Signature를 구현하고 이를 알립니다.
다음 클래스는 my-sig라는 샘플 탐지기를 제공합니다. 예시:
from typing import TYPE_CHECKING
from trueseeing.api import Signature
if TYPE_CHECKING:
from trueseeing.api import SignatureMap, ConfigMap
class MySignature(Signature):
@staticmethod
def create() -> Signature:
return MySignature()
def get_sigs(self) -> SignatureMap:
return {'my-sig':dict(e=self._detect, d='sample signature')}
def get_configs(self) -> ConfigMap:
return dict()
async def _detect(self) -> None:
self._helper.raise_issue(
self._helper.build_issue(
sigid='my-sig',
title='hello world',
cvss='CVSS:3.0/AV:P/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N/',
)
)
새 파일 형식을 정의하려면 먼저 형식에 대한 Context(ABC)를 구현한 다음 trueseeing.api.FileFormatHandler를 구현하여 인스턴스를 생성하고 반환한 후 알립니다.
다음 클래스는 apk2라는 유형의 APK 파일 지원을 제공합니다. 예시:
from typing import TYPE_CHECKING
from trueseeing.api import FileFormatHandler
from trueseeing.core.android.context import APKContext
if TYPE_CHECKING:
from typing import Optional, Set
from trueseeing.api import FormatMap, ConfigMap
from trueseeing.core.context import Context, ContextType
class MyAPKContext(APKContext):
# Use a different context type
def _get_type(self) -> Set[ContextType]:
return {'apk2'}
class APKFileFormatHandler(FileFormatHandler):
@staticmethod
def create() -> FileFormatHandler:
return APKFileFormatHandler()
def get_formats(self) -> FormatMap:
return {'apk2':dict(e=self._handle, r=r'\.apk$', d='sample file format', t=None)} # if this handler can suggest device context type, advertise at t
def get_configs(self) -> ConfigMap:
return dict()
def _handle(self, path: str) -> Optional[Context]:
return MyAPKContext(path)
그런 다음 시그니처에서 컨텍스트 유형을 확인하여 지원되지 않는 컨텍스트에서 무시되도록 하십시오:
context = self._helper.get_context().require_type('apk2')
성공적인 확인 시 require_type(...)은 적절한 유형으로 다운캐스트를 시도합니다.
그러나 설계상으로는 알려진 유형(현재는 apk)에서만 작동합니다. apk 유형에서와 같이 새 컨텍스트 클래스에 세부 인터페이스를 정의하는 경우, 여기서 다운캐스트를 수행해야 합니다:
context: MyAPKContext = self._helper.get_context().require_type('apk2') # type:ignore[assignment]
동일한 패턴과 일치하는 여러 형식을 정의할 수 있습니다. 패턴을 가장 엄격한(즉, 긴) 것부터 가장 덜 엄격한 순서로 평가합니다. -F 스위치를 사용하여 대상 파일에 특정 형식을 강제로 적용할 수 있습니다. 예:
$ trueseeing -F apk2 target.apk
확장 기능은 a) /ext(컨테이너) 또는 ~/.trueseeing2/extensions(pip)에 배치된 모든 패키지, 또는 b) trueseeing_ext0_ 접두사로 명명된 설치된 모듈일 수 있습니다.
D&D 주문, True Seeing.