Skip to content

Implement LoggerType#dump#85

Merged
hanhanW merged 8 commits into
masterfrom
feature/log.dump
Jan 30, 2018
Merged

Implement LoggerType#dump#85
hanhanW merged 8 commits into
masterfrom
feature/log.dump

Conversation

@david942j
Copy link
Copy Markdown
Collaborator

@david942j david942j commented Jan 25, 2018

Implement #62

libc = 0xdead000
stack = 0xbeef000
log.dump libc.hex, stack.hex
# [DUMP] libc.hex = "0xdead000", stack.hex = "0xbeef000"

Hacky methods are used:

  1. Get the source code from file (using gem method_source)
  2. Parse the source code to Sexp (using ruby_parser)
  3. Traverse the sexp to find the block/arguments when calling dump
  4. Convert the sexp of block/arguments back to Ruby code (using gem ruby2ruby)
  5. Show the result

Therefore, some unusual usages will fail, such as:

  • log.dump(&a_proc) # nil will be logged
  • log.dump { 1 }; log.dump { 2 } # will log 1 two times

Two new dependencies are added:

  • method_source
  • ruby2ruby

This change is Reviewable

Comment thread lib/pwnlib/logger.rb Outdated
# This method do the following things:
# 1. Get the source code from file (using gem `method_source`)
# 2. Parse the source code to Sexp using `ruby_parser`
# 3. Traverse the sexp and find the block argument when calling `:dump`
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

to find

Comment thread lib/pwnlib/logger.rb Outdated
# This method doesn't work in a REPL shell.
#
# @note
# The source code in block will be parsed using +ruby_parser+,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

will be parsed by using +ruby_parser+

@hanhanW
Copy link
Copy Markdown
Collaborator

hanhanW commented Jan 26, 2018

Support log.dump(x+y) instead of log.dump('x+y') would have better user experience.

@hanhanW
Copy link
Copy Markdown
Collaborator

hanhanW commented Jan 30, 2018

:lgtm:

@hanhanW hanhanW merged commit 867091f into master Jan 30, 2018
@hanhanW hanhanW deleted the feature/log.dump branch January 30, 2018 12:53
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