intent

A messaging object you can use to request an action from another app component.

Intents exploitation

Basic Intent

This code defines an onClick event that creates an explicit Intent to launch Flag1Activity within the io.hextree.attacksurface package when triggered.

public void onClick(View v) {
    Intent intent = new Intent();
    intent.setComponent(new ComponentName("io.hextree.attacksurface", "io.hextree.attacksurface.activities.Flag1Activity"));
    startActivity(intent);
}

Intent with extras

This onClick event creates an explicit Intent to launch Flag2Activity within the io.hextree.attacksurface package, setting the action to "io.hextree.action.GIVE_FLAG" before starting the activity.

public void onClick(View v) {
    Intent intent = new Intent();
    intent.setComponent(new ComponentName("io.hextree.attacksurface", "io.hextree.attacksurface.activities.Flag2Activity"));
    intent.setAction("io.hextree.action.GIVE_FLAG");
    startActivity(intent);
}

Intent with data URI

This onClick event creates an explicit Intent to launch Flag3Activity within the io.hextree.attacksurface package, setting the action to "io.hextree.action.GIVE_FLAG" and providing a data URI pointing to "https://app.hextree.io/map/android" before starting the activity.

Multiple Intent calls

This onClick event sequentially launches Flag4Activity multiple times with different actions ("PREPARE_ACTION", "BUILD_ACTION", "GET_FLAG_ACTION", "INIT_ACTION"), pausing for one second between each launch. Each Intent explicitly targets Flag4Activity within the io.hextree.attacksurface package to execute distinct actions in a specific order.

Nested Intents (Intent in Intent)

This onClick event creates a chain of nested Intents to launch Flag5Activity in the io.hextree.attacksurface package. The primary mainIntent contains a nested Intent (nestedIntent1) with an extra key "return" set to 42. Inside nestedIntent1, another Intent (nestedIntent2) is nested with an extra "reason" set to "back". This structured setup initiates Flag5Activity with a chain of Intents for conditional processing.

Intent Redirect (Intent Forwarding)

This onClick event constructs a series of nested Intents to initiate Flag5Activity in the io.hextree.attacksurface package. The main Intent, mainIntent, includes a nested Intent (nestedIntent1) with an extra key "return" set to 42. Inside nestedIntent1, a secondary nested Intent (nestedIntent2) is configured to start Flag6Activity, with extras "reason" set to "next" and the flag FLAG_GRANT_READ_URI_PERMISSION. This layered structure directs Flag5Activity to process nestedIntent1 and, conditionally, initiate Flag6Activity.

Intent activity lifecycle

This onClick event sequentially launches Flag7Activity in the io.hextree.attacksurface package with two distinct actions. First, it starts Flag7Activity with the "OPEN" action. After a one-second pause, it launches Flag7Activity again with the "REOPEN" action, adding the FLAG_ACTIVITY_SINGLE_TOP flag to prevent creating a new instance if Flag7Activity is already at the top of the activity stack.

Intent returning Activity results

HextreeLauncherActivity displays a button that, when clicked, launches Flag8Activity using startActivityForResult to enable it to verify the calling activity’s identity. If Flag8Activity returns a result, onActivityResult can optionally handle it.

Intent returning Activity results + conditions

HextreeLauncherActivity displays a button that, when clicked, launches Flag9Activity to request a flag. Once Flag9Activity returns, HextreeLauncherActivity retrieves and displays the flag via a Toast message if the result is successful.

Hijack Implicit Intents

Manifest.xml

SecondActivity listens for an implicit intent with the action "io.hextree.attacksurface.ATTACK_ME". When launched, it retrieves a flag from the intent’s extras, displays it with a Toast, and returns a result if needed before finishing.

Hijack Implicit Intents (+ respond a specific result)

SecondActivity listens for an implicit intent with the action "io.hextree.attacksurface.ATTACK_ME". Upon receiving it, the activity creates a result intent containing a specific token (1094795585) and returns it to the calling activity, then finishes.

Utils

Java class for debug

References

Last updated

Was this helpful?