-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
feat: add unsquashfs util to Squashfs #389
base: master
Are you sure you want to change the base?
Conversation
This is mostly a copy from `backhand-cli`'s `unsquashfs`, but with all the args/progress handling removed and more thorough error handling. Due to the dependency on `rayon`, the utility is currently gated behind the `util` feature of `backhand`. I tried also gating the `nix` dependency on the feature, but it was hard due to it showing up in `BackhandError`. Fixes: wcampbell0x2a#354
4faf2cf
to
44169ab
Compare
I made some suggestions with lovesegfault#1. |
Merged into the branch, thanks a bunch @rbran :) I think the remaining issue is MSRV. |
@@ -51,6 +51,27 @@ pub enum BackhandError { | |||
|
|||
#[error("file duplicated in squashfs image")] | |||
DuplicatedFileName, | |||
|
|||
#[error("invalid path filter for unsquashing, path doesn't exist: {0:?}")] |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
|
||
/// Extract the Squashfs into `dest` | ||
#[cfg(feature = "util")] | ||
pub fn unsquashfs( |
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.
This should gated behind #[cfg(unix)]
because it requires std::os::unix::fs::lchown
.
I wonder if limiting the MSVR policy to only |
To avoid the problem, can you use Alternately, add a |
I made some suggestions with rbran@2ed4a52 |
This Christmas I was thinking about this API 😂 Maybe it's better to not access the filesystem directly using That trait will be implemented using std by default, but also allowing the user to implement his way to create a manipulate files. This is especially useful in Bonus this will also allow some cool fuzzing targets. I could not find a crate that does that. This goes beyond this PR, but well.. that's something that I think is pretty usefull. |
I haven't put much thought into this, but yes having a way of creating a "fake" filesystem would be useful for fuzzing |
|
That's almost it, but I was also thinking in something a little bit simpler, maybe something like this: pub trait FsImpl {
type File;
fn read(file: &mut Self::File, buf: &mut [u8]) -> Result<()>;
fn write(file: &mut Self::File, buf: &[u8]) -> Result<()>;
//....
}
struct StdFS;
impl FsImpl for StdFS {
type File = std::fs::File;
fn read(file: &mut Self::File, buf: &mut [u8]) -> Result<()> { file.read(buf) }
//....
}
impl Squashfs<FS: FsImpl = StdFS> {
fn write(&mut self, output: &mut FS::File) { ... }
} If I got more time to work on that I'll try to implement it. Maybe I'll have that added to #366 once I start experimenting with https://github.com/AFLplusplus/LibAFL/ |
@rbran I tried the instructions at https://github.com/AFLplusplus/LibAFL/tree/main/libafl_libfuzzer at some point. But I had issues and didn't have time to file an issue. |
I'm currently using libafl_qemu for other projects, I also had issues with the implementation and had to solve then by submitting PRs/Issues to LibAFL. If you want to spend more time trying, use a example implementation, like: https://github.com/AFLplusplus/LibAFL/tree/main/fuzzers/libfuzzer_libpng |
This is mostly a copy from
backhand-cli
'sunsquashfs
, but with allthe args/progress handling removed and more thorough error handling.
Due to the dependency on
rayon
, the utility is currently gated behindthe
util
feature ofbackhand
.I tried also gating the
nix
dependency on the feature, but it was harddue to it showing up in
BackhandError
.Fixes: #354