
암호화, 파일 시스템, 데이터베이스, 네트워크 통신 및 프로세스 작업 전반에 걸쳐 애플리케이션 동작에 후킹하여 포괄적인 런타임 프로필을 생성하는 Android 멀웨어 분석 도구입니다.
Android 바이너리 API 추적기
Dexray Intercept는 동적 샌드박스 Sandroid의 일부입니다. 그 목적은 Android 애플리케이션의 동작을 추적하기 위한 런타임 프로파일을 생성하는 것입니다. 이는 frida를 활용하여 수행됩니다.
pip로 설치하기만 하면 됩니다:
python3 -m pip install dexray-intercept
이렇게 하면 Dexray Intercept가 명령줄 도구 ammm 또는 dexray-intercept로 설치됩니다.
또한 dexray_intercept 패키지도 제공합니다. 패키지 사용 방법에 대한 자세한 내용은 아래를 참조하세요.
Android 기기가 루팅되어 있는지 확인하세요. frida-server가 자동으로 최신 버전으로 설치됩니다. 그런 다음 다음 명령을 실행하여 Dexray Intercept를 사용할 수 있습니다:
dexray-intercept <target app>
# 또는 이전 이름 사용:
ammm <target app>
모든 훅은 최적의 성능을 위해 기본적으로 비활성화되어 있습니다. 분석 필요에 따라 훅을 활성화하세요:
# 특정 훅 활성화
dexray-intercept --enable-aes <app_name> # AES 암호화 훅 활성화
dexray-intercept --enable-web <app_name> # 웹/HTTP 훅 활성화
dexray-intercept --enable-aes --enable-web <app_name> # 여러 훅 활성화
# 훅 그룹 활성화
dexray-intercept --hooks-crypto <app_name> # 모든 암호화 훅 활성화
dexray-intercept --hooks-network <app_name> # 모든 네트워크 훅 활성화
dexray-intercept --hooks-filesystem <app_name> # 모든 파일 시스템 훅 활성화
# 모든 훅 활성화 (성능 영향)
dexray-intercept --hooks-all <app_name> # 사용 가능한 모든 훅 활성화
# 앱 이름 대신 패키지 식별자 사용
dexray-intercept -s com.example.package --hooks-crypto
--hooks-crypto (AES, 인코딩, 키스토어, 인증서)--hooks-network (HTTP, 소켓, SSL/TLS)--hooks-filesystem (파일 작업, 데이터베이스, 공유 환경설정)--hooks-ipc (인텐트, 브로드캐스트, 바인더, 공유 환경설정)--hooks-process (DEX 언패킹, 네이티브 라이브러리, 런타임)--hooks-services (카메라, 위치, 전화, 블루투스)다음은 AVD에서 chrome 앱을 모니터링하는 예입니다:
dexray-intercept Chrome
Dexray Intercept
⠀⠀⠀⠀⢀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣀⣀⣀⣀⡀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠙⢷⣤⣤⣴⣶⣶⣦⣤⣤⡾⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⠾⠛⢉⣉⣉⣉⡉⠛⠷⣦⣄⠀⠀⠀⠀
⠀⠀⠀⠀⠀⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⠋⣠⣴⣿⣿⣿⣿⣿⡿⣿⣶⣌⠹⣷⡀⠀⠀
⠀⠀⠀⠀⣼⣿⣿⣉⣹⣿⣿⣿⣿⣏⣉⣿⣿⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⠁⣴⣿⣿⣿⣿⣿⣿⣿⣿⣆⠉⠻⣧⠘⣷⠀⠀
⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⡇⢰⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠀⠀⠈⠀⢹⡇⠀
⣠⣄⠀⢠⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⣠⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡇⢸⣿⠛⣿⣿⣿⣿⣿⣿⡿⠃⠀⠀⠀⠀⢸⡇⠀
⣿⣿⡇⢸⣿⣿⣿Sandroid⣿⣿⣿⡇⢸⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣷⠀⢿⡆⠈⠛⠻⠟⠛⠉⠀⠀⠀⠀⠀⠀⣾⠃⠀
⣿⣿⡇⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢸⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⣧⡀⠻⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣼⠃⠀⠀
⣿⣿⡇⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢸⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢼⠿⣦⣄⠀⠀⠀⠀⠀⠀⠀⣀⣴⠟⠁⠀⠀⠀
⣿⣿⡇⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢸⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⣠⣾⣿⣦⠀⠀⠈⠉⠛⠓⠲⠶⠖⠚⠋⠉⠀⠀⠀⠀⠀⠀
⠻⠟⠁⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠈⠻⠟⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠉⠉⣿⣿⣿⡏⠉⠉⢹⣿⣿⣿⠉⠉⠀⠀⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣿⣿⣿⡇⠀⠀⢸⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⣾⣿⣿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣿⣿⣿⡇⠀⠀⢸⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⢀⣄⠈⠛⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠈⠉⠉⠀⠀⠀⠀⠉⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
[*] starting app profiling
[*] press Ctrl+C to stop the profiling ...
[*] Filesystem profiling informations:
[*] [Libc::read] Read FD (anon_inode:[eventfd],0x7ac6b67540,8)
[*] Filesystem profiling informations:
[*] [Libc::read] Read FD (anon_inode:[eventfd],0x7fcb41c990,8
Dexray Intercept를 패키지로 설치하고 새로운 모듈식 아키텍처를 사용하세요:
from dexray_intercept import AppProfiler, setup_frida_device
from dexray_intercept.services.hook_manager import HookManager
# Connect to device and get process
device = setup_frida_device()
process = device.attach("com.example.app")
# Configure hooks (all disabled by default for performance)
hook_config = {
'aes_hooks': True,
'web_hooks': True,
'file_system_hooks': True,
'keystore_hooks': True
}
# Create profiler with new architecture
profiler = AppProfiler(
process,
verbose_mode=True,
output_format="JSON",
hook_config=hook_config,
enable_stacktrace=True
)
# Start profiling
script = profiler.start_profiling()
# ... let app run and collect data ...
# Get results
profile_data = profiler.get_profile_data()
json_output = profiler.get_profiling_log_as_json()
# Runtime hook management
profiler.enable_hook('socket_hooks', True) # Enable more hooks at runtime
enabled_hooks = profiler.get_enabled_hooks() # Check what's enabled
# Stop profiling
profiler.stop_profiling()
분석 필요에 따라 특정 훅 그룹을 활성화하세요:
# Crypto hooks
hook_config = {
'aes_hooks': True,
'encodings_hooks': True,
'keystore_hooks': True
}
# Network hooks
hook_config = {
'web_hooks': True,
'socket_hooks': True
}
# File system hooks
hook_config = {
'file_system_hooks': True,
'database_hooks': True
}
# Enable all hooks (performance impact)
profiler.enable_all_hooks()
# Enable hook groups
profiler.enable_hook_group('crypto') # Enable all crypto-related hooks
이전 API는 하위 호환성을 위해 여전히 사용할 수 있습니다:
from dexray_intercept import AppProfilerLegacy
# OR use environment variable: DEXRAY_FORCE_OLD_ARCH=true
profiler = AppProfilerLegacy(process_session, verbose=True, output_format="CMD",
base_path=None, deactivate_unlink=False)
profiler.instrument() # Old method name
# ...
profiler.finish_app_profiling() # Old method name
Sandroid에서 패키지로 실행하려면 AndroidFridaManager에서 JobManager도 설치했는지 확인하세요. 이를 통해 여러 스레드에서 여러 frida 세션을 실행할 수 있습니다.
다음 코드를 실행하기만 하면 됩니다:
from AndroidFridaManager import JobManager
from dexray_intercept import AppProfiler
job_manager = JobManager()
app_package = "net.classwindexampleyear.bookseapiececountry"
profiler = AppProfiler(job_manager.process_session, True, output_format="JSON", base_path=None, deactivate_unlink=False)
frida_script_path = profiler.get_frida_script()
job_manager.setup_frida_session(app_package, profiler.on_appProfiling_message)
job = job_manager.start_job(frida_script_path, custom_hooking_handler_name=profiler.on_appProfiling_message)
# close only the job and the frida session keeps active to run other frida scripts
# job_manager.stop_job_with_id(job.job_id)
job_manager.stop_app_with_closing_frida(app_package) # stops the frida session and the app and all frida jobs
profiler.write_profiling_log() # write the log data to profile.json
# instead of writing it to a file the JSON output will just be returned
# profiler.get_profiling_log_as_JSON()
코드의 다른 부분이 frida 서버에 연결하려고 시도하지 않는지 확인하세요 (다른 frida 세션이 없어야 함).
이를 테스트하려면 다음 샘플을 시도해 볼 수 있습니다: catelites_2018_01_19.apk. 패키지 이름은 net.classwindexampleyear.bookseapiececountry입니다. 샘플이 악성 코드의 모든 것을 실행할 수 있도록 AVD가 Android 9에서 실행 중인지 확인하세요. 이 샘플은 adb install samples/unpacking/catelites_2018_01_19.apk로 간단히 설치할 수 있습니다.
이 프로젝트를 컴파일하려면 npm과 frida-compile이 시스템에서 실행되고 PATH에 설치되어 있는지 확인하세요. frida 버전 17.0부터 frida-compile은 pip install frida-tools를 통해 설치됩니다.
그런 다음 다음 명령을 실행하여 최신 frida 에이전트를 컴파일하세요:
$ cd <AppProfiling-Project>
> Dexray [email protected] build
> frida-compile agent/hooking_profile_loader.ts -o src/dexray_intercept/profiling.js
$ npm install frida-java-bridge@latest --save
$ npm install --save-dev @types/frida-gum@latest
> Dexray [email protected] prepare
> npm run build
up to date, audited 75 packages in 6s
19 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
이렇게 하면 최신 frida 스크립트/훅이 dexray-intercept에서 사용됩니다.
Python 코드를 조정하려면 편집 가능 모드를 사용하여 pip로 dexray-intercept를 설치하는 것이 좋습니다:
python3 -m pip install -e .
이렇게 하면 패키지의 새 버전을 만들지 않고도 Python 코드의 로컬 변경 사항이 반영됩니다.
설치, 사용법, API 참조 및 개발을 다루는 포괄적인 문서를 사용할 수 있습니다:
이 디렉터리에서 다음 명령을 실행하기만 하면 setup.py가 dexray-intercept를 로컬 Python 패키지로 시스템에 설치합니다:
python3 -m pip install .
TypeScript frida 훅을 컴파일하려면 frida-compile (링크) 프로젝트가 필요합니다. 이는 frida-tools와 함께 번들로 제공됩니다.
python3 -m pip install frida-tools
이 외에도 frida-java-bridge와 내부 frida 타입에 대한 지원이 필요합니다:
npm install frida-java-bridge@latest --save
npm install --save-dev @types/frida-gum@latest
언패킹할 때 애플리케이션은 이전에 별개의 메모리 블록을 가리키던 DexCode를 실행 중인 코드를 나타내는 DexFile로 로드할 수 있습니다. 예를 들어, 일부 애플리케이션은 실행 직전에 명령을 복원할 수 있습니다. 이러한 경우 Sandroid는 명령을 DexFile로 되돌릴 수 없습니다. 이 문제를 해결하려면 추가 연구가 필요합니다
Dexray Intercept는 Android 보안 및 동적 분석 커뮤니티의 다양한 오픈 소스 프로젝트와 연구자들의 훌륭한 작업을 기반으로 합니다. 우리의 구현에 영감을 주거나 기여한 다음 프로젝트에 감사를 표합니다:
Android 보안 분석의 발전과 커뮤니티에 작업을 공개한 이 프로젝트와 유지 관리자들에게 감사를 표합니다.