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

Added support for callables; added base64 and hex string prototypes #34

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

insomniacslk
Copy link

Encodings are another interesting type of data to match. While these could be matched with a regex, a more robust approach is to attempt the actual decoding. This could be slower than regex'es in certain cases.

I've added a callable argument, and made the regex optional, but at least one is required.

Examples:

$ ./hashid.py $(echo hashid | base64)
Analyzing 'aGFzaGlkCg=='
[+] Base64

$ ./hashid.py 414243 # the string 'ABC' as hex string
Analyzing '414243'
[+] CRC-24
[+] Hex string

@bburky
Copy link
Collaborator

bburky commented Apr 4, 2017

Base64 and hex maybe sound ok, but I really think we could still implement these with a regex?

Hex can be matched with ^[a-fA-F0-9]+$ (or ^([a-fA-F0-9]{2})+$ to match only even length strings for actual bytes).

I think ^([a-zA-Z0-9+/]{4})*([a-zA-Z0-9+/]{4}|[a-zA-Z0-9+/]{2}==|[a-zA-Z0-9+/]{3}=)$ is a valid regex for base64. It checks the alphabet, that the length is a multiple of four, and that the last block is valid.

Including encodings may be something of a slippery slope. Should we include URL encoding too?

@insomniacslk
Copy link
Author

These can totally be implemented with a regex, but I was suggesting at the same time an alternative method. Maybe in a separate commit? I think it's nice to have the option to use both, e.g. with a command line switch (--prefer-regex and --prefer-callable maybe?).

On the encodings - I'd say to start humble with these two, and add the others as soon as they're needed, in separate commits.

@bburky
Copy link
Collaborator

bburky commented Apr 4, 2017

There's really no reason to use a callable though for these encodings. The regex is equivalent.

@insomniacslk
Copy link
Author

I'll take it as a no. Code reverted to only use regexes

@psypanda
Copy link
Owner

psypanda commented Apr 6, 2017

Hey! Since I have almost no spare time at the moment I have added @bburky as a collaborator with push access to the repository.

@insomniacslk
Copy link
Author

any joy here?

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.

3 participants