-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add a flatten
argument to ssh.libs
#2268
Conversation
This option makes us able to avoid getting the file tree of the remote server and just downloads the desired files in the output folder
We should emit a warning on duplicate files when the filename is equal but the remote path was different. |
Do you think it should just emit a warning and skip the download ? Or should it renames the file to something like |
I guess renaming them is better instead of discarding used libraries, but I'd switch to the unflattened structure anyways if this happens. We should log a warning in any case. I don't know how stable the order of the loaded libraries is in ldd and if you can be sure you always want the first matching library on every run. |
Can you document that fallback behaviour in the argument description please? |
Yep, I just did it, sorry I forgot that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, it would be awesome if you could add tests for the function testing withflatten
on and off and with and without duplicates.
We're using doctests, check out other examples in the function docs comments of other functions in the file!
I just tried to create unit tests for this functionnality, but I was wondering what design did you like better ? |
I think adding another small binary to the |
This commit adds: - The `no_duplicate` binary that depends on - `a/lib.so` - `b/lib2.so` - The `duplicate` binary that depends on - `a/lib.so` - `b/lib.so` Then, the doctest tries to pull the libs from both binaries with different `flatten` values.
Can you check that I added the tests correctly ? It says all tests passed but I'm not even sure the tests were run .. 😅 |
I think it's saner to abort on duplicate libraries instead of silently falling back to unflattened output. The locations would be different than what the script expects and it would break anyways.
I was talking about me using this feature, not how I'd imagine it to behave automatically. Sorry for the confusion. You can test if the tests are run by adding something obviously broken and see if it breaks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, the CI ran now and revealed some problems with your tests. Can you strip
the binaries to reduce size please?
pwnlib/tubes/ssh.py
Outdated
|
||
Examples: | ||
>>> s = ssh(host='example.pwnme') | ||
>>> s.cwd = f'{pwnlib.data.elf.path}/ssh_libs' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please create an __init__.py
file and use pwnlib.data.elf.ssh_libs.get("duplicate")
etc. below. Check the the __init__.py
in one of the other sub folders. The cwd has to be writeable and it apparently isn't in CI, when you change to the pwnlib data directory.
Apparently, the elf I pushed are corrupted (I can't run |
Sorry for all the commits, I can't run the tests on my computer (it doesn't work, I don't know why) |
@Arusekk can you have a look please? |
Bleh, I've tried to get the tests to work nicely but don't want to wrestle with -rpath $ORIGIN and friends anymore. I'll add this now and deal with the test again later. |
This option makes us able to avoid getting the file tree of the remote server and just downloads the desired files in the output folder: