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

Add / (search) commands to newshell + rewrite of rz_search #4742

Draft
wants to merge 14 commits into
base: dev
Choose a base branch
from

Conversation

wargio
Copy link
Member

@wargio wargio commented Nov 25, 2024

Your checklist for this pull request

  • I've read the guidelines for contributing to this repository
  • I made sure to follow the project's coding style
  • I've documented or updated the documentation of every function and struct this PR changes. If not so I've explained why.
  • I've added tests that prove my fix is effective or that my feature works (if possible)
  • I've updated the rizin book with the relevant information (if needed)

Detailed description

This is a complete rewrite of the legacy code which is too complicated to import into new-shell.

The goal is to refactor rz_search and implement the search command properly using pre-existing code like search of strings via rz_utils and more.

closes #1909

RZ_API void rz_search_collection_free(RZ_NULLABLE RzSearchCollection *sc);
RZ_API void rz_search_hit_free(RZ_NULLABLE RzSearchHit *hit);

RZ_API RZ_OWN RzList /*<RzSearchHit *>*/ *rz_search_run(RZ_NONNULL RzSearchOpt *opt, RZ_NONNULL RzSearchCollection *col, RZ_NONNULL RzIO *io, RZ_NONNULL RzList /*<RzIOMap *>*/ *search_in);
Copy link
Member

Choose a reason for hiding this comment

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

Maybe changing the search_in parameter to void * and infer the type based on some flag in opt. This way we can use this function later to search other things then IO.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not so sure about this, but maybe.

librz/search/collection.c Outdated Show resolved Hide resolved
Copy link
Member

@XVilka XVilka left a comment

Choose a reason for hiding this comment

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

This is great work!

librz/core/cmd/cmd_print.c Show resolved Hide resolved
librz/core/cmd/cmd_search.c Outdated Show resolved Hide resolved
librz/core/cmd/cmd_search.c Outdated Show resolved Hide resolved
librz/core/cmd_descs/cmd_search.yaml Outdated Show resolved Hide resolved
librz/main/rz-find.c Outdated Show resolved Hide resolved
// SPDX-FileCopyrightText: 2008 J. Alex Halderman
// SPDX-License-Identifier: BSD-3-Clause

// Originally from RSAKeyFinder 1.0 (2008-07-18) By Nadia Heninger and J. Alex Halderman
Copy link
Member

Choose a reason for hiding this comment

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

Same, please convert into \file

{ 0x02, 0x01, 0x00, 0x30 },
};

/*Baby BER parser, just good enough for private keys.
Copy link
Member

Choose a reason for hiding this comment

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

Since there is comment already for this function , maybe convert to Doxygen?

Copy link
Member Author

Choose a reason for hiding this comment

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

this comment is actually wrong. the code is looking for DER encoding, but i will fix this once it will be "ready"

return start + 2 + lensize;
}

/* Check if `start` points to an ensemble of BER fields
Copy link
Member

Choose a reason for hiding this comment

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

Same

return true;
}

// Finds and return index of a private key based on the asn1 bytes
Copy link
Member

Choose a reason for hiding this comment

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

Same


#include <rz_search.h>
#include <rz_util.h>

Copy link
Member

Choose a reason for hiding this comment

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

Please add \file to note that it searches not only ANSI/ASCII but also Unicode and some other encodings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants