-
Notifications
You must be signed in to change notification settings - Fork 139
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
Feature: Search nearest gadgets #76
Feature: Search nearest gadgets #76
Conversation
Returns the names of functions from the given file's global offset table as an array of strings.
Returns a Hash object which maps function names to their offsets.
For every function given as a comma seperated list or for all the functions from a file's global offset table, reorder the found gadgets by their distance to each function and print the result.
Awesome! Thanks for your contribution.
Feel free to comment if you have any questions. |
I'm glad that you liked it! Here is the output of
Why do I get these failures locally? |
bundle is for creating a virtual environment that provides specific version of gems described in Gemfile.lock. Simply execute For the first three failures, I guess it's because you don't have objdump-multiarch installed. Update: the fourth failure is because you are root, you can ignore it as well and I will think how to make the test more robust |
Thank you for clarifying I have made the changes you requested in my local repository. The only thing left is adding tests under spec folder. I have analyzed the existing tests and noticed that you call How should we move forward from this point? |
Bumps [rubocop](https://github.com/rubocop-hq/rubocop) from 0.67.2 to 0.68.0. - [Release notes](https://github.com/rubocop-hq/rubocop/releases) - [Changelog](https://github.com/rubocop-hq/rubocop/blob/master/CHANGELOG.md) - [Commits](rubocop/rubocop@v0.67.2...v0.68.0) Signed-off-by: dependabot[bot] <support@dependabot.com>
You can have the test in bin_spec.rb |
By the way, you were right about objdump multiarch stuff. It was missing in my environment. I thought it would give me a warning if it was missing. Anyway, it is fixed since I installed binutils-multiarch. Now, I am adding tests but in order to test the --near option with a file, I am using /bin/ls. However, the output is too long. Maybe, we should create a test file with a few functions in its got so that the testing code would take less space. What do you think about this? UPDATE: I guess using /bin/ls in test is not a good idea since the file can differ across operating systems etc. |
This commit adds two tests for testing --near feature option. One for testing with a list of functions and the other for testing with a file. Also, it adds a new file called testNearFile.elf for testing purposes.
Please discard the changes of README.md except the help message. |
Bumps [rubocop](https://github.com/rubocop-hq/rubocop) from 0.68.0 to 0.68.1. - [Release notes](https://github.com/rubocop-hq/rubocop/releases) - [Changelog](https://github.com/rubocop-hq/rubocop/blob/master/CHANGELOG.md) - [Commits](rubocop/rubocop@v0.68.0...v0.68.1) Signed-off-by: dependabot[bot] <support@dependabot.com>
I guess everything is okay now. I hope my future contributions will be more efficient. |
Looks good now, I will find a time to test it manually and merge it if I don't find any bugs. |
Looks great! Maybe, we should add some example usage of this feature in |
Yes I'm working on it, no worries :) |
This adds a new option
-n/--near FUNCTIONS/FILE
to implement and close #16. However, it does not work with-b, --build-id BuildID
and only works if the libc file is given since we need to retrieve function offsets. However, it can be implemented later by adding function tables in ruby scripts under lib\builds folder.It also works with both
-l/--level OUTPUT_LEVEL
and-r/--raw
options properly.For now, it just reorders the result and prints the closer gadgets first. However, we can introduce a threshold option in the future to make it print less functions. For example, print only if the distance is less than 0x1000.
This option expects a comma seperated list of function names or a file.
Examples:
one_gadget libc.so.6 --near puts,printf,scanf --level 3
one_gadget libc.so.6 --near "putchar, fscanf" --raw --level 2
one_gadget libc.so.6 --near ./vuln
one_gadget libc.so.6 --near vuln --raw
Screenshots: