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

Feature request: Simple arithmetic is not possible in CyberChef #1129

Open
executionByFork opened this issue Nov 23, 2020 · 6 comments · May be fixed by #1258
Open

Feature request: Simple arithmetic is not possible in CyberChef #1129

executionByFork opened this issue Nov 23, 2020 · 6 comments · May be fixed by #1258
Labels

Comments

@executionByFork
Copy link

As of right now, as far as I can tell, there is not an easy way to use CyberChef to do mathematical conversions or operations on various numbers. For example, I can use the ToBase operation to turn 97 into its equivalent hexadecimal 61, OR input 16 to get 10. However, I cannot input "97 16" to get an output of "61 10" (example here). There is no easy way to do an operation on an array of numbers. The majority of modules assume that the input is ASCII.

Additionally, modules like multiply and divide take all inputs from the data itself, which is also being mangled. There is not an easy way to multiply the result of some conversion by 2 without altering the input, and if your input is being altered by several modules it can be very cumbersome to figure out a way to get the mathematical operation to work without destroying your input, not to mention this is infeasible on large inputs. There needs to be mathematical operation modules like the following.
image
These would also allow the intake of an input like "2 4 6" and when run through the MultiplyByX module with a setting of 2, could output "4 8 12"

Also, as a side point, many of the module names can be misleading. For example, the ToHex module assumes that input is text, so when inputting a number, that number is converted to the hexadecimal value for that character in the ASCII table. The example here takes 2 and outputs 32 instead of 2. This is correct if the input is text but incorrect if the input is meant to be a number. I suggest changing the names of the modules to something like ToAsciiHex, or leave the name and add a dropdown to the module allowing you to define the input/output as numerical. There have been many others confused about this in the past (962, 609, 1029...). A name like FromHex or ToHex is too ambiguous when the module itself does a very specific thing.

TL;DR
As it stands right now, you cannot properly work with numerics in CyberChef.

@sganson-tss
Copy link

sganson-tss commented Nov 23, 2020 via email

@executionByFork
Copy link
Author

executionByFork commented Nov 25, 2020

Fork seems to solve the problem of working with arrays, thank you. However, this still leaves the issue that you cannot properly run mathematical operations on the forked numbers because the arithmetic modules are lacking. I cannot multiply, divide, add, or subtract by an arbitrary number. This in turn means I cannot run shifts on ASCII to simulate things like Caesar cipher rotational encoding, or really anything involving math in general.
EDIT: There is a ROT13 module that allows for Caesar cipher encode/decode, so that was a bad example, but my point is that doing mathematical operations on the input with arbitrary numbers should be a feature as it would allow for a range of possibilities that CyberChef currently doesnt offer.

The only mathematical operations I can run are between numbers already in the input. I could potentially alter the input to work around the current state of the mathematics modules, but this isn't feasible for large inputs. It also isn't intuitive or simple like CyberChef is meant to be. It should be as easy as adding a multiply module and setting it to multiply the current input by X, like the example image I have in the original post.

(I still do think modules like FromHex should be renamed to FromAsciiHex, but this is less important.)

@sganson-tss
Copy link

sganson-tss commented Nov 25, 2020 via email

@executionByFork
Copy link
Author

I edited my message after posting, which doesn't do much for email notifications, but yes I do realize there is a ROT13 module. A Caesar cipher shift was just the first example I pulled out of my head. My point is that if CyberChef allowed for arbitrary math to be done on inputs, it would allow for a lot more than what you can reasonably do now. Yes, there probably is a workaround available to get CyberChef to do what I want, but it's not intuitive and it's not apparent to me what that is. Why can the multiply/divide/add/subtract modules not be supplied a number? I'd think most people would imagine it should. It doesn't make much sense to force these modules to only be capable of running arithmetic between numbers already in the input. If someone wants to divide a potential cipher key by 3 before XORing that number in binary form with a ciphertext, the first thing they are going to search for is divide. That person is going to be disappointed when they quickly realize that something as simple as a division is not possible in CyberChef.

If I can find time to fork and modify the code base to submit a PR I will, but I am quite busy with my own projects right now. So in the meantime if one of the maintainers are able to include this feature as an update I think it would be very beneficial to CyberChef users.

PS: I've changed the issue title to better match the actual problem in this discussion, as working with number arrays is possible but arithmetic is not

@executionByFork executionByFork changed the title Feature request: Allow for working with arrays of numbers Feature request: Simple arithmetic is not possible in CyberChef Nov 25, 2020
@BigYellowHammer BigYellowHammer linked a pull request Oct 5, 2021 that will close this issue
@agnesoshiro
Copy link

TL;DR As it stands right now, you cannot properly work with numerics in CyberChef.

Thank you for this! I was looking at a much more trivial example of the number 42 being converted to 00110100 00110010 via "To Binary": https://gchq.github.io/CyberChef/#recipe=To_Binary('Space',8)&input=NDI

The workaround is to add an extra "From Decimal" step (which, by itself, only produces the output "*") before the "To Binary" step: https://gchq.github.io/CyberChef/#recipe=From_Decimal('Space',false)To_Binary('Space',8)&input=NDI

@xjzh123
Copy link

xjzh123 commented Jul 18, 2024

TL;DR As it stands right now, you cannot properly work with numerics in CyberChef.

Thank you for this! I was looking at a much more trivial example of the number 42 being converted to 00110100 00110010 via "To Binary": https://gchq.github.io/CyberChef/#recipe=To_Binary('Space',8)&input=NDI

The workaround is to add an extra "From Decimal" step (which, by itself, only produces the output "*") before the "To Binary" step: https://gchq.github.io/CyberChef/#recipe=From_Decimal('Space',false)To_Binary('Space',8)&input=NDI

This isn't always viable. If you want to convert 12345 to hex, from_decimal can't convert it to a byte, and fails.

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

Successfully merging a pull request may close this issue.

4 participants