Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add iP command to dsc ##io #23090

Merged
merged 4 commits into from
Jul 4, 2024
Merged

Add iP command to dsc ##io #23090

merged 4 commits into from
Jul 4, 2024

Conversation

mrmacete
Copy link
Collaborator

@mrmacete mrmacete commented Jul 4, 2024

  • Mark this if you consider it ready to merge
  • I've added tests (optional)
  • I wrote some lines in the book (optional)

Description

Add the iP command to the dsc io plugin, to get info about a Pointer. That draws information from the underlying rebase infos which are embedded in the pointer itself (whose semantics potentially changes over different maps), which otherwise gets lost as part of rebasing / pointer cleanup.

This is especially useful for getting info about pointer authentication, like the diversity and the key to use if there's any need to ever re-sign a pointer from the dyld cache.

The usage is :iP [size][@vaddr] if no size is provided defaults to 8, runs at current seek (or virtual seek if provided). The output is JSON only.

Example:

# this is how we see the pointer stored there normally
> pxq 8@0x1f242f210
0x1f242f210  0x00000001b972985c                       \.r.....

# and this digs the hidden metadata
> :iP @0x1f242f210~{}
[
  {
    "paddr": "0x707b7210",
    "raw": "0x8009b5883972985c",
    "format": "v3",
    "has_diversity": true,
    "diversity": 46472,
    "key": "ia"
  }
]

Experimental in the sense that it's quite naive and there's no guard against the user pointing it to an unaligned address for example, where the bits will be interpreted in the wrong way.

@trufae
Copy link
Collaborator

trufae commented Jul 4, 2024

unused vars here and there. but lgtm

Screenshot 2024-07-04 at 17 26 11


pj_end (pj);

char * result = strdup (pj_string (pj));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use pj_drain(pj); so you can avoid the strdup and the pj_free


pj_o (pj);

tmp = r_str_newf ("0x%"PFMT64x, trimmed->slice->start + off_local);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
tmp = r_str_newf ("0x%"PFMT64x, trimmed->slice->start + off_local);
char *tmp = r_str_newf ("0x%"PFMT64x, trimmed->slice->start + off_local);


ut64 raw_value = r_read_le64 (raw_value_buf);

char * tmp;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
char * tmp;

free (tmp);

switch (trimmed_info->info->info->version) {
case 1:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad indentation

Copy link
Collaborator

@trufae trufae left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls fix the few comments

@trufae trufae merged commit 560c02d into master Jul 4, 2024
37 of 39 checks passed
@mrmacete mrmacete deleted the feature/dsc_system_iP branch July 4, 2024 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants