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

base62 decoding not working #4

Closed
beuguissime opened this issue Sep 13, 2020 · 4 comments · Fixed by #6
Closed

base62 decoding not working #4

beuguissime opened this issue Sep 13, 2020 · 4 comments · Fixed by #6

Comments

@beuguissime
Copy link

Hi,

I think there is a bug in the base62 decoding attempt.

Should not the line

base62_decode = base62.encode(int(encoded_base)).decode('utf-8', 'replace')

read something like

base62_decode = str(base62.decode(encoded_base))

?

For instance, with base-62 from pypi I get

In [3]: base62.encode(999)
Out[3]: 'g7'

With the original basecrack.py:

$ python3 basecrack.py -b 'g7
[-] Encoded Base: g7

[>] Decoding as Base91: 

[>] Decoding as Base92: Â

With my suggested modification:

$ python3 basecrack.py -b 'g7
[-] Encoded Base: g7

[>] Decoding as Base62: 999

[>] Decoding as Base91: 

[>] Decoding as Base92: Â

[-] The Encoding Scheme Is Base62

Moreover, I find disagreeing results when I encode a integer with base-62 and with pybase62 (both taken from pypi).

@mufeedvh
Copy link
Owner

mufeedvh commented Nov 2, 2020

Hey @beuguissime, first of all, I am really sorry for the late response, this issue was buried in my notifications. :(

Nice Catch, my implementation was indeed wrong. Thank You so much for making a PR and writing a very detailed Issue, I really appreciate it! ❤️👏

Moreover, I find disagreeing results when I encode a integer with base-62 and with pybase62 (both taken from pypi).

Seems like an issue with the same root cause. I started working on the next release and I will maybe consider making a custom library code for base62 just like I did for base92.

Again, thank you for bringing this to my attention and also fixing it with a great PR! ❤️🙌

@beuguissime
Copy link
Author

Hi @mufeedvh

No problem at all, we all have a busy life, especially during the pandemic.
Thanks for addressing my issue and for your very nice reply.

Regarding my comment about base-62 vs pybase62, I later understood that the disagreement is a matter of convention: whether you adopt '1234567890ABCD...abcd...' or '1234567890abcd...ABCD...' as a charset.
I understand that both choices are valid so I suggest basecrack should test both and report if the decoding was successful with the direct or the inverted charset.

@mufeedvh
Copy link
Owner

mufeedvh commented Dec 7, 2020

Hey @beuguissime,

Yeah that seems like a really good plan, I will implement it when I get some time off work! 👍

Again, thank you so much for your contribution to this project. ❤️🙌

@r4gn4r0x
Copy link

Consider using codext, it supports many base encodings, whose 45, 58, 62 and many others...

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 a pull request may close this issue.

3 participants