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

fix tube's debug output of same byte compression #2011

Merged
merged 4 commits into from
Jan 8, 2022
Merged

fix tube's debug output of same byte compression #2011

merged 4 commits into from
Jan 8, 2022

Conversation

tkmikan
Copy link
Contributor

@tkmikan tkmikan commented Dec 22, 2021

The tube will compress same byte in debug output, however it prints data[0], which is int.
And send still prints * 0x1, while recv omits it.

from pwn import *
context.log_level = 'debug'

t = tube()
t.recv_raw = lambda n: b'a'
t.recv()
t.recv_raw = lambda n: b'a' * 4
t.recv()
t.send_raw = lambda x: None
t.send(b'a')
t.send(b'aaaa')

before pr:

[DEBUG] Received 0x1 bytes:
    b'a'
[DEBUG] Received 0x4 bytes:
    97 * 0x4
[DEBUG] Sent 0x1 bytes:
    97 * 0x1
[DEBUG] Sent 0x4 bytes:
    97 * 0x4

after pr:

[DEBUG] Received 0x1 bytes:
    b'a'
[DEBUG] Received 0x4 bytes:
    b'a' * 0x4
[DEBUG] Sent 0x1 bytes:
    b'a'
[DEBUG] Sent 0x4 bytes:
    b'a' * 0x4

@tkmikan tkmikan changed the base branch from stable to dev December 22, 2021 14:11
@tkmikan
Copy link
Contributor Author

tkmikan commented Dec 22, 2021

One more thing: previously when recv a single unprintable byte, its hexdump is printed, while compression never print hexdump (now send behaves the same).
My question is, is hexdumping single byte necessary?

@Arusekk
Copy link
Member

Arusekk commented Dec 27, 2021

Wow, I was annoyed by it too, but was unaware that it was not intended. This exposes some code duplication we have here. Could this logic be moved to a new function, say, maybe_hexdump?

@Arusekk Arusekk merged commit 1573957 into Gallopsled:dev Jan 8, 2022
gogo2464 pushed a commit to gogo2464/pwntools that referenced this pull request Sep 10, 2023
* fix tube's debug output of same byte compression

* Update CHANGELOG.md

* move code to `log.maybe_hexdump`

* update doc string
gogo2464 pushed a commit to gogo2464/pwntools that referenced this pull request Sep 10, 2023
* fix tube's debug output of same byte compression

* Update CHANGELOG.md

* move code to `log.maybe_hexdump`

* update doc string
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.

None yet

2 participants