You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/mobile-pentesting/android-app-pentesting/android-task-hijacking.md
+8-2Lines changed: 8 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,14 +30,20 @@ The `launchMode` attribute directs the handling of activity instances within tas
30
30
1.**Malicious App Installation**: The victim installs the attacker's app on their device.
31
31
2.**Initial Activation**: The victim first opens the malicious app, setting up the device for the attack.
32
32
3.**Target App Launch Attempt**: The victim attempts to open the target app.
33
-
4.**Hijack Execution**: Due to the matching task affinity, the malicious app is launched in place of the target app.
33
+
4.**Hijack Execution**: At some point the app tries to open the **singleTask** view. Due to the matching task affinity, the malicious app is launched in place of the target app.
34
34
5.**Deception**: The malicious app presents a fake login screen resembling the target app, tricking the user into entering sensitive information.
35
35
36
+
> [!TIP]
37
+
> Note that for this attack to work the vulnerable view **doesn't need to have exported to true** nor it needs to be the Main activity.
38
+
36
39
For a practical implementation of this attack, refer to the Task Hijacking Strandhogg repository on GitHub: [Task Hijacking Strandhogg](https://github.com/az0mb13/Task_Hijacking_Strandhogg).
37
40
38
41
### Prevention Measures
39
42
40
-
To prevent such attacks, developers can set `taskAffinity` to an empty string and opt for the `singleInstance` launch mode, ensuring their app's isolation from others. Customizing the `onBackPressed()` function offers additional protection against task hijacking.
43
+
To prevent such attacks, developers can:
44
+
- Set **`**taskAffinity`** of the **singleTask** view to an empty string (`android:taskAffinity=""`)
45
+
- Opt for the **`singleInstance`** launch mode, ensuring their app's isolation from others.
46
+
- Customize the **`onBackPressed()`** function offers additional protection against task hijacking.
Copy file name to clipboardExpand all lines: src/mobile-pentesting/android-app-pentesting/react-native-application.md
+58-6Lines changed: 58 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,19 +10,27 @@ To confirm if the application was built on the React Native framework, follow th
10
10
11
11
3. Use the command `find . -print | grep -i ".bundle$"` to search for the JavaScript file.
12
12
13
-
To further analyze the JavaScript code, create a file named `index.html` in the same directory with the following code:
13
+
## Javascript Code
14
+
15
+
If checking the contents of the `index.android.bundle` you find the JavaScript code of the application (even if minified), you can **analyze it to find sensitive information and vulnerabilities**.
16
+
17
+
As the bundle contains actually all the JS code of the application it's possible to **divide it in different files** (potentially making easier its reverse engineering) using the **tool [react-native-decompiler](https://github.com/numandev1/react-native-decompiler)**.
18
+
19
+
### Webpack
20
+
21
+
To further analyze the JavaScript code, you can upload the file to [https://spaceraccoon.github.io/webpack-exploder/](https://spaceraccoon.github.io/webpack-exploder/) or follow these steps:
22
+
23
+
1. Create a file named `index.html` in the same directory with the following code:
14
24
15
25
```html
16
26
<scriptsrc="./index.android.bundle"></script>
17
27
```
18
28
19
-
You can upload the file to [https://spaceraccoon.github.io/webpack-exploder/](https://spaceraccoon.github.io/webpack-exploder/) or follow these steps:
20
-
21
-
1. Open the `index.html` file in Google Chrome.
29
+
2. Open the `index.html` file in Google Chrome.
22
30
23
-
2. Open the Developer Toolbar by pressing **Command+Option+J for OS X** or **Control+Shift+J for Windows**.
31
+
3. Open the Developer Toolbar by pressing **Command+Option+J for OS X** or **Control+Shift+J for Windows**.
24
32
25
-
3. Click on "Sources" in the Developer Toolbar. You should see a JavaScript file that is split into folders and files, making up the main bundle.
33
+
4. Click on "Sources" in the Developer Toolbar. You should see a JavaScript file that is split into folders and files, making up the main bundle.
26
34
27
35
If you find a file called `index.android.bundle.map`, you will be able to analyze the source code in an unminified format. Map files contain source mapping, which allows you to map minified identifiers.
28
36
@@ -34,9 +42,53 @@ To search for sensitive credentials and endpoints, follow these steps:
34
42
35
43
3. It was fortunate that sensitive hard-coded credentials were found in the JavaScript code during the recon process.
36
44
45
+
### Change JS code and rebuild
46
+
47
+
In this case changing the code is easy. You just need to rename the app to use the extension `.zip` and extract it. Then you can **modify the JS code inside this bundle and rebuild the app**. This should be enough to allow you to **inject code** in the app for testing purpses.
48
+
49
+
50
+
## Hermes bytecode
51
+
52
+
If the bundle contains **Hermes bytecode**, you **won't be able to access the Javascript code** of the app (not even to the minified version).
53
+
54
+
You can check if the bundle contains Hermes bytecode by running the following command:
55
+
56
+
```bash
57
+
file index.android.bundle
58
+
index.android.bundle: Hermes JavaScript bytecode, version 96
59
+
```
60
+
61
+
However, you can use the tools **[hbctool](https://github.com/bongtrop/hbctool)**, **[hermes-dec](https://github.com/P1sec/hermes-dec)** or **[hermes_rs](https://github.com/Pilfer/hermes_rs)** to **disassemble the bytecode** and also to **decompile it to some pseudo JS code**. To do this, for example these commands:
Ideally you should be able to modify the dissasembled code (changing a comparison, or a value or whatever you need to modify) and then **rebuild the bytecode** and then rebuild the app.
71
+
72
+
The tool **[hbctool](https://github.com/bongtrop/hbctool)** supports dissasembling the bundle and building it back after the changes have been performed, however it **only supports old versions** of Hermes bytecode.
73
+
74
+
The tool **[hermes-dec](https://github.com/P1sec/hermes-dec)** doesn't support rebuilding the bytecode.
75
+
76
+
The tool **[hermes_rs](https://github.com/Pilfer/hermes_rs)** supports rebuilding the bytecode, but it's actually a library and nto a CLI tool.
77
+
78
+
## Dyanmic Analysis
79
+
80
+
You could try to dynamically analyze the app would be to use Frida to enable the developer mode of the React app and use **`react-native-debugger`** to attach to it. However, for this you need the source code of the app apparently. You can find more info about this in [https://newsroom.bedefended.com/hooking-react-native-applications-with-frida/](https://newsroom.bedefended.com/hooking-react-native-applications-with-frida/).
Copy file name to clipboardExpand all lines: src/mobile-pentesting/android-app-pentesting/tapjacking.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,8 @@ In effect, it is **blinding the user from knowing they are actually performing a
12
12
13
13
In order to detect apps vulnerable to this attacked you should search for **exported activities** in the android manifest (note that an activity with an intent-filter is automatically exported by default). Once you have found the exported activities, **check if they require any permission**. This is because the **malicious application will need that permission also**.
14
14
15
+
You can also check the minimum SDK version of the app, checking the value of **`android:minSdkVersion`** in the **`AndroidManifest.xml`** file. If the value is **lower than 30**, the app is vulnerable to Tapjacking.
0 commit comments