Skip to content

expkit: Add or Document better the way to put PushIndirect pivot into Payload. #34

Open

Description

@artmetla

In order to port exp65 for lts-6.1.36 to use Expkit I had to construct a Payload buffer with PushIndirect pivot being stored in first 8 bytes of the Payload.

NOTE: If you need more details on why we need to do so, check description of stack pivot provided in Issue #33

Right now, in I'm achieving this in a following way:

        Payload payload(512);
        payload.Reserve(0, 8);

        PivotFinder pivot_finder(target.pivots, Register::RSI, payload);
        auto rop_pivot = pivot_finder.PivotToRop(rop);
        rop_pivot.PrintDebugInfo();

        // Put PushIndirect at the very beginning of Payload
        payload.Release(0, 8);
	payload.Set(0, kernel_base + rop_pivot.pivot.GetGadgetOffset());

        printf("[+] Payload:\n");
        HexDump::Print(payload.GetUsedData());

in essence I have to Release() first 8 bytes before trying to put PushIndirect gadget there as Set() method is aware of Reserved bytes. At the same time I could not skip Reserving bytes as it'll take those 8 bytes by the rest of Stack Pivot as a result of generation with pivot_finder.PivotToRop(rop);

It would be nice to have some easier way to add PushIndirect into Payload.

NOTE: Ported exploit code: https://github.com/google/kernel-research/blob/main/expkit/samples/exp65/exploit.cpp

Activity

  1. koczkatamas commented on Apr 9, 2025

    @koczkatamas
    Collaborator

    Currently it's a documentation issue as there is no layout planner implemented which would be aware of the fake structures, Qdisc in this case and its enqueue pointer, so you have to handle that manually as you did with Reserve'ing the first 8 bytes.

    But you don't have to Release and then Set, the Reserve function already supports setting the reserved pointer as you can see in the sample exploit: reserving the slot then setting it.

    And for payload.Reserve(0, 8) I would use the offset (0) and size (8) of Qdisc.enqueue from the structs data, as the intention is more visible that way and in theory you cannot be sure that the enqueue ptr is at offset 0x00 in all kernel releases.

  2. chanijindal1 commented on Apr 21, 2025

    @chanijindal1
    Collaborator

    Merging my payload builder should help handling this.

  3. added this to the Milestone 1 milestone on Jun 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions