diff --git a/src/mobile-pentesting/android-app-pentesting/drozer-tutorial/exploiting-content-providers.md b/src/mobile-pentesting/android-app-pentesting/drozer-tutorial/exploiting-content-providers.md index 06468bff4..48707ae8a 100644 --- a/src/mobile-pentesting/android-app-pentesting/drozer-tutorial/exploiting-content-providers.md +++ b/src/mobile-pentesting/android-app-pentesting/drozer-tutorial/exploiting-content-providers.md @@ -12,7 +12,7 @@ _Manifest.xml_ 파일에서는 content provider의 선언이 필요합니다. ``` -`content://com.mwr.example.sieve.DBContentProvider/Keys`에 접근하려면 `READ_KEYS` 권한이 필요합니다. 흥미롭게도, `/Keys/` 경로는 개발자가 `/Keys`는 보호했지만 `/Keys/`를 선언하는 실수로 인해 다음 섹션에서 접근할 수 있습니다. +`content://com.mwr.example.sieve.DBContentProvider/Keys`에 접근하려면 `READ_KEYS` 권한이 필요합니다. 흥미롭게도, `/Keys/` 경로는 개발자가 `/Keys`를 보호했지만 `/Keys/`를 선언하는 실수로 인해 보호되지 않는 다음 섹션에서 접근할 수 있습니다. **아마도 개인 데이터에 접근하거나 일부 취약점(SQL Injection 또는 Path Traversal)을 악용할 수 있습니다.** @@ -65,7 +65,7 @@ content://com.mwr.example.sieve.DBContentProvider/Passwords/ ## **데이터베이스 기반 Content Providers** 대부분의 Content Providers는 **데이터베이스**의 **인터페이스**로 사용됩니다. 따라서, 접근할 수 있다면 **정보를 추출, 업데이트, 삽입 및 삭제**할 수 있을 것입니다.\ -민감한 정보에 **접근할 수 있는지** 확인하거나 이를 변경하여 **인증** 메커니즘을 **우회**해 보십시오. +민감한 정보에 **접근할 수 있는지** 확인하거나 **권한 우회** 메커니즘을 변경해 보십시오. Content Provider의 코드를 확인할 때 **_query, insert, update 및 delete_**와 같은 이름의 **함수**도 확인하십시오: @@ -87,13 +87,13 @@ email: incognitoguy50@gmail.com ``` ### Insert content -데이터베이스를 쿼리하면 **열의 이름**을 알게 되고, 그 후 DB에 데이터를 삽입할 수 있습니다: +데이터베이스를 쿼리하면 **열의 이름**을 알 수 있으며, 그 후 DB에 데이터를 삽입할 수 있습니다: ![](<../../../images/image (98).png>) ![](<../../../images/image (173).png>) -_삽입 및 업데이트 시 --string을 사용하여 문자열을 나타내고, --double을 사용하여 더블을 나타내며, --float, --integer, --long, --short, --boolean을 사용할 수 있습니다._ +_삽입 및 업데이트 시 --string을 사용하여 문자열을 나타내고, --double로 더블을 나타내며, --float, --integer, --long, --short, --boolean을 사용할 수 있습니다._ ### Update content @@ -173,10 +173,61 @@ Vulnerable Providers: content://com.mwr.example.sieve.FileBackupProvider/ content://com.mwr.example.sieve.FileBackupProvider ``` -## References +## 2023-2025 업데이트 및 최신 팁 + +### Drozer 3.x (Python 3) 출시 + +WithSecure는 2022년에 drozer의 유지 관리를 재개하고 프레임워크를 **Python 3**(최신 **3.1.0 – 2024년 4월**)로 포팅했습니다. 호환성 수정 외에도 Content Providers 작업 시 특히 유용한 새로운 모듈이 포함되어 있습니다: + +* `scanner.provider.exported` – `android:exported="true"`인 제공자만 나열합니다. +* `app.provider.grant` – `grantUriPermission()`을 자동으로 호출하여 Android 12+에서 `FLAG_GRANT_READ_URI_PERMISSION` / `FLAG_GRANT_WRITE_URI_PERMISSION`을 기대하는 제공자와 통신할 수 있습니다. +* **Scoped Storage**의 더 나은 처리로 Android 11+에서 파일 기반 제공자에 여전히 접근할 수 있습니다. + +업그레이드(호스트 및 에이전트): +```bash +pipx install --force "git+https://github.com/WithSecureLabs/drozer@v3.1.0" +adb install drozer-agent-3.1.0.apk +``` +### 내장된 `cmd content` 헬퍼 사용 (ADB ≥ 8.0) + +모든 최신 Android 기기는 **에이전트를 설치하지 않고** 프로바이더를 쿼리/업데이트할 수 있는 CLI를 제공합니다: +```bash +adb shell cmd content query --uri content://com.test.provider/items/ +adb shell cmd content update --uri content://com.test.provider/items/1 \ +--bind price:d:1337 +adb shell cmd content call --uri content://com.test.provider \ +--method evilMethod --arg 'foo' +``` +`run-as ` 또는 루팅된 셸과 결합하여 내부 전용 제공자를 테스트합니다. + +### Content Providers를 악용한 최근 실제 CVE + +| CVE | 연도 | 구성 요소 | 버그 클래스 | 영향 | +|-----|------|-----------|-----------|--------| +| CVE-2024-43089 | 2024 | MediaProvider | `openFile()`에서의 경로 탐색 | 모든 앱의 개인 저장소에서 임의 파일 읽기 | +| CVE-2023-35670 | 2023 | MediaProvider | 경로 탐색 | 정보 유출 | + +취약한 빌드에서 CVE-2024-43089 재현: +```bash +adb shell cmd content read \ +--uri content://media/external_primary/file/../../data/data/com.target/shared_prefs/foo.xml +``` +### API 30+에 대한 보안 강화 체크리스트 + +* 제공자가 **공개**되어야 하는 경우가 아니라면 `android:exported="false"`를 선언하십시오. API 31부터 이 속성은 필수입니다. +* 전체 제공자를 내보내는 대신 **권한**을 강제 적용하거나 `android:grantUriPermissions="true"`를 사용하십시오. +* 허용된 `projection`, `selection` 및 `sortOrder` 인수를 화이트리스트에 추가하십시오 (예: `SQLiteQueryBuilder.setProjectionMap`으로 쿼리 빌드). +* `openFile()`에서 요청된 경로를 정규화하고 (`FileUtils`) `..` 시퀀스를 거부하여 탐색을 방지하십시오. +* 파일을 노출할 때는 **Storage Access Framework** 또는 `FileProvider`를 선호하십시오. + +최근 Android 버전의 이러한 변경 사항은 많은 레거시 익스플로잇 원시 기능이 여전히 작동하지만, 업데이트된 drozer 모듈이나 `cmd content` 도우미가 자동으로 적용할 수 있는 추가 플래그/권한이 필요함을 의미합니다. + +## 참조 - [https://www.tutorialspoint.com/android/android_content_providers.htm](https://www.tutorialspoint.com/android/android_content_providers.htm) - [https://manifestsecurity.com/android-application-security-part-15/](https://manifestsecurity.com/android-application-security-part-15/) - [https://labs.withsecure.com/content/dam/labs/docs/mwri-drozer-user-guide-2015-03-23.pdf](https://labs.withsecure.com/content/dam/labs/docs/mwri-drozer-user-guide-2015-03-23.pdf) +- [https://github.com/WithSecureLabs/drozer/releases/tag/3.1.0](https://github.com/WithSecureLabs/drozer/releases/tag/3.1.0) +- [https://source.android.com/security/bulletin/2024-07-01](https://source.android.com/security/bulletin/2024-07-01) {{#include ../../../banners/hacktricks-training.md}} diff --git a/theme/ai.js b/theme/ai.js index 68d091923..a376d751b 100644 --- a/theme/ai.js +++ b/theme/ai.js @@ -4,9 +4,10 @@ (() => { - const KEY = 'htSummerDiscountDismissed'; - const IMG = '/images/discount.jpeg'; - const TXT = 'HT Summer Discount, Last Days!'; + const KEY = 'htSummerDiscountsDismissed'; + const IMG = '/images/discount.jpeg'; + const TXT = 'Click here for HT Summer Discounts, Last Days!'; + const URL = 'https://training.hacktricks.xyz'; /* Stop if user already dismissed */ if (localStorage.getItem(KEY) === 'true') return; @@ -32,13 +33,37 @@ display: flex; flex-direction: column; align-items: stretch; `); - /* --- Title bar (separate, over image) --- */ + /* --- Title bar (link + close) --- */ const titleBar = $('div', ` - padding: 1rem; text-align: center; + position: relative; + padding: 1rem 2.5rem 1rem 1rem; /* room for the close button */ + text-align: center; background: #222; color: #fff; font-size: 1.3rem; font-weight: 700; `); - titleBar.textContent = TXT; + + const link = $('a', ` + color: inherit; + text-decoration: none; + display: block; + `); + link.href = URL; + link.target = '_blank'; + link.rel = 'noopener noreferrer'; + link.textContent = TXT; + titleBar.appendChild(link); + + /* Close "X" (no persistence) */ + const closeBtn = $('button', ` + position: absolute; top: .25rem; right: .5rem; + background: transparent; border: none; + color: #fff; font-size: 1.4rem; line-height: 1; + cursor: pointer; padding: 0; margin: 0; + `); + closeBtn.setAttribute('aria-label', 'Close'); + closeBtn.textContent = '✕'; + closeBtn.onclick = () => overlay.remove(); + titleBar.appendChild(closeBtn); /* --- Image --- */ const img = $('img'); @@ -62,14 +87,15 @@ modal.append(titleBar, img, label); overlay.appendChild(modal); - (document.readyState === 'loading' - ? () => document.addEventListener('DOMContentLoaded', () => document.body.appendChild(overlay), { once: true }) - : () => document.body.appendChild(overlay))(); + if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', () => document.body.appendChild(overlay), { once: true }); + } else { + document.body.appendChild(overlay); + } })(); - /** * HackTricks AI Chat Widget v1.16 – resizable sidebar * ---------------------------------------------------