question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pwndbg breaks w/ trace-commands enabled

See original GitHub issue

Description

pwndbg breaks with trace-commands enabled, I have a use case where I want to dynamically save user input to a file which trace-commands allows, however this breaks the pwndbg functionality.

+r
Starting program: /home/parallels/example/demo 
The bare metal debugging is enabled since gdb's osabi is '++show osabi' which is not 'GNU/Linux'.
Ex. the page resolving and memory de-referencing ONLY works on known pages.
This option is based on gdb client compile arguments (by default) and will be corrected if you load an ELF with a '.note.ABI-tag' section.            
If you are debugging a program that runs on the Linux ABI, please select the correct gdb client.

Breakpoint 1, main (argc=1, argv=0xfffffffff088) at demo.c:6
6               func_0_args();
Warning: Skipping auxv entry '++info auxv'
Traceback (most recent call last):
  File "/home/parallels/pwndbg/pwndbg/events.py", line 165, in caller
    func()
  File "/home/parallels/pwndbg/pwndbg/strings.py", line 33, in update_length
    length = int(message)                      
ValueError: invalid literal for int() with base 10: 'elements'

Traceback (most recent call last):
  File "/home/parallels/pwndbg/pwndbg/events.py", line 169, in caller
    raise e
  File "/home/parallels/pwndbg/pwndbg/events.py", line 165, in caller
    func()
  File "/home/parallels/pwndbg/pwndbg/strings.py", line 33, in update_length
    length = int(message)
ValueError: invalid literal for int() with base 10: 'elements'
Traceback (most recent call last):
  File "/home/parallels/pwndbg/pwndbg/events.py", line 165, in caller
    func()
  File "/home/parallels/pwndbg/pwndbg/strings.py", line 33, in update_length
    length = int(message)
ValueError: invalid literal for int() with base 10: 'elements'

Traceback (most recent call last):
  File "/home/parallels/pwndbg/pwndbg/prompt.py", line 30, in prompt_hook
    pwndbg.events.after_reload(start=cur is None)
  File "/home/parallels/pwndbg/pwndbg/events.py", line 216, in after_reload
    f()                                        
  File "/home/parallels/pwndbg/pwndbg/events.py", line 169, in caller
    raise e
  File "/home/parallels/pwndbg/pwndbg/events.py", line 165, in caller
    func()
  File "/home/parallels/pwndbg/pwndbg/strings.py", line 33, in update_length
    length = int(message)                      
ValueError: invalid literal for int() with base 10: 'elements'

Steps to reproduce

before running binary, enable trace-commands

gdb <binary>
set trace-commands on
r

My setup

+version Gdb: 9.2 Python: 3.8.10 (default, Mar 15 2022, 12:22:08) [GCC 9.4.0] Pwndbg: 1.1.0 build: 44286af Capstone: 4.0.1024 Unicorn: 1.0.3

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
claflinnatecommented, May 23, 2022

So i dug into the error message and hack-fixed it locally which might work fine for me, in strings.py

 30     if message == 'unlimited':
 31         length = 0
 32     else:
 33         try:
 34             length = int(message)
 35         except:
 36             length = 0

adding the try/except there just forces the length to 0 if there’s any kind of failure. obviously not a good production fix but i think i can at least make forward progress and haven’t seen any bad functionality yet from this

0reactions
claflinnatecommented, Aug 20, 2022

I think default gdb logging can do that, just not the commands that were input which was all I really needed

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exploiting with pwndbg - Solving PlaidCTF 2016 SmartStove
One of the tools I've been hearing good things about is pwndbg, an open source plugin for GDB which aims to help with...
Read more >
2020q2.txt - sourceware.org
I had hoped that "set debug timestamp 1" woudl help, but this appears to maybe be broken and/or not interact properly with CU...
Read more >
Tut02: Pwndbg, Ghidra, Shellcode - CS6265
Let's test pwndbg with a tutorial binary, tut02-shellcode/target . ... you will be shown with multiple subviews of the program enabled by Ghidra....
Read more >
Issues-pwndbg/pwndbg - PythonTechWorld - Python 博客
Exploit Development and Reverse Engineering with GDB Made Easy. ... Description pwndbg breaks with trace-commands enabled, I have a use case where I...
Read more >
GDB and PWNDBG Cheat Sheet (DRAFT) by cactuarnation
A cheatsheet for debugging 64-bit binaries with GDB and PWNDBG. ... GDB and PWNDBG Cheat Sheet (DRAFT) by cactuarnation ... Enable breakpoint 2....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found