Skip to content

Conversation

hugsy
Copy link
Owner

@hugsy hugsy commented Apr 23, 2024

Description/Motivation/Screenshots

How Has This Been Tested ?

"Tested" indicates that the PR works and the unit test (i.e. make test) run passes without issue.

  • x86-32
  • x86-64
  • ARM
  • AARCH64
  • MIPS
  • POWERPC
  • SPARC
  • RISC-V

Checklist

  • My code follows the code style of this project.
  • My change includes a change to the documentation, if required.
  • If my change adds new code,
    adequate tests have been added.
  • I have read and agree to the
    CONTRIBUTING document.

@therealdreg therealdreg self-requested a review April 27, 2024 09:25
@therealdreg therealdreg added this to the 2024.05 milestone Apr 27, 2024
Copy link
Collaborator

@therealdreg therealdreg left a comment

Choose a reason for hiding this comment

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

The documentation refers to the alias "cs," but the alias being registered in the code is "cs-dis"

image

https://hugsy.github.io/gef-extras/commands/capstone-disassemble/

image

image

@@ -182,7 +182,7 @@ def do_invoke(self, _: List[str], **kwargs: Any) -> None:
args = kwargs["arguments"]
show_opcodes = args.show_opcodes
length = args.length or gef.config["context.nb_lines_code"]
location = parse_address(args.location)
location = int(gdb.parse_and_eval(args.location).address)
Copy link
Collaborator

@therealdreg therealdreg Apr 27, 2024

Choose a reason for hiding this comment

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

Suggested change
location = int(gdb.parse_and_eval(args.location).address)
location = parse_address(args.location)

@hugsy int(gdb.parse_and_eval(args.location).address) is not working on my setup (GDB 13.1 Python engine 3.11), with this suggestion cs-dis command works again:

image

image

Copy link
Collaborator

@therealdreg therealdreg left a comment

Choose a reason for hiding this comment

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

The value from the configuration file is not taken into account.

So, capstone-disassemble.use-capstone is always False (on every boot)

here my conf file:

[capstone-disassemble]
use-capstone = True
gef➤  gef config capstone-disassemble.use-capstone 
──────────────────────────────────────── GEF configuration setting: capstone-disassemble.use-capstone ────────────────────────────────────────
capstone-disassemble.use-capstone (bool) = False

Description:
	Replace the GDB disassembler in the `context` with Capstone
gef➤  

@hugsy Is it possible that this issue is happening with more plugins?

@hugsy
Copy link
Owner Author

hugsy commented Apr 27, 2024

The value from the configuration file is not taken into account.

So, capstone-disassemble.use-capstone is always False (on every boot)

here my conf file:

[capstone-disassemble]
use-capstone = True
gef➤  gef config capstone-disassemble.use-capstone 
──────────────────────────────────────── GEF configuration setting: capstone-disassemble.use-capstone ────────────────────────────────────────
capstone-disassemble.use-capstone (bool) = False

Description:
	Replace the GDB disassembler in the `context` with Capstone
gef➤  

@hugsy Is it possible that this issue is happening with more plugins?

This is what I explained to you and partially fixed in #1090

image

All gef-extras settings are impacted

@therealdreg
Copy link
Collaborator

therealdreg commented Apr 27, 2024

The value from the configuration file is not taken into account.
So, capstone-disassemble.use-capstone is always False (on every boot)
here my conf file:

[capstone-disassemble]
use-capstone = True
gef➤  gef config capstone-disassemble.use-capstone 
──────────────────────────────────────── GEF configuration setting: capstone-disassemble.use-capstone ────────────────────────────────────────
capstone-disassemble.use-capstone (bool) = False

Description:
	Replace the GDB disassembler in the `context` with Capstone
gef➤  

@hugsy Is it possible that this issue is happening with more plugins?

This is what I explained to you and partially fixed in #1090

image

All gef-extras settings are impacted

And what can we do to fix this? I wouldn’t like to release the next version with this issue... And I know you don’t like dirty hacks

@hugsy
Copy link
Owner Author

hugsy commented Apr 27, 2024

And what can we do to fix this?

gef restore

But I think this should not happen with the latest change to gef because now loading gef-extras with on_changed callback should result in a config reloading.

@therealdreg
Copy link
Collaborator

And what can we do to fix this?

gef restore

But I think this should not happen with the latest change to gef because now loading gef-extras with on_changed callback should result in a config reloading.

I am using the last version (GEF+EXTRAS) and the problem is still here :\

@gordonmessmer gordonmessmer mentioned this pull request May 6, 2024
12 tasks
@hugsy hugsy force-pushed the fix_capstone_disass_switch branch from 0d773f0 to 0b7041f Compare June 3, 2024 16:52
@therealdreg
Copy link
Collaborator

therealdreg commented Jun 4, 2024

The command works fine, and the alias is fixed!

image


But on each run capstone is set to false!

image

image

Copy link
Collaborator

@therealdreg therealdreg left a comment

Choose a reason for hiding this comment

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

on each run capstone is set to false!


dreg@rootkit:~/.config/gef-extras$ git log
commit 0b7041f (HEAD -> fix_capstone_disass_switch, origin/fix_capstone_disass_switch)
Author: hugsy crazy.hugsy@outlook.com
Date: Mon Jun 3 09:51:40 2024 -0700

make dreg happy

commit 296049f (tag: 2024.06, origin/main, origin/HEAD, main)
Author: MinatoTW shaks19jais@gmail.com
Date: Thu May 16 08:39:56 2024 +0530

64bit libc table generator had $r10 as 4th argument (#113)

## Description/Motivation/Screenshots

Fixes `scripts/libc_function_args/tables/generator.py` which was wrong using `$r10` as 4th argument

GEF: (Standalone)
Blob Hash(/home/dreg/.gef-2024.06.py): 88981e223320723f9df39bd8714ea2d56da4dbee
SHA256(/home/dreg/.gef-2024.06.py): 764738509912bea65f67927691d5fa0421444d1969678208095733fdbf0dd83d
GDB: 15.0.50.20240403-git
GDB-Python: 3.12


So Dreg is only partially happy @hugsy :D

@hugsy
Copy link
Owner Author

hugsy commented Jun 5, 2024

This is a different problem to what this PR fixes (and again it can be worked around by doing gef restore in your gdbinit)
In GEF you can do a PR that will execute gef restore if load_plugins_from_directory() return > 0

Different problems.

@hugsy hugsy requested a review from therealdreg June 5, 2024 02:40
@hugsy hugsy removed this from the 2024.05 milestone Jun 5, 2024
@therealdreg
Copy link
Collaborator

This is a different problem to what this PR fixes (and again it can be worked around by doing gef restore in your gdbinit) In GEF you can do a PR that will execute gef restore if load_plugins_from_directory() return > 0

Different problems.

Okay, we'll fix it in another PR. Thanks for your patience :D

@therealdreg
Copy link
Collaborator

hugsy/gef#1118 fixes the problem! thx!

image

@hugsy hugsy merged commit 07cadff into main Jun 5, 2024
@hugsy hugsy deleted the fix_capstone_disass_switch branch June 5, 2024 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants