-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Flow Control
Split the input data up based on the specified delimiter and run all subsequent operations on each branch separately.For example, to decode multiple Base64 strings, enter them all on separate lines then add the 'Fork' and 'From Base64' operations to the recipe. Each string will be decoded separately.
The operation splits the input on '\n'(split delimiter), it then runs fromBase64 on [dGhl, cXVpY2s=, YnJvd24=, Zm94, anVtcGVk, b3Zlcg==, dGhl, c2xvdw==, ZG9n] each separately. Any operation you place after fromBase64 will run on [the, quick, brown, fox, jumped, over, the, slow, dog] separately also. The operation joins the output on ' '(merge delimiter).
Consolidate all branches back into a single trunk. The opposite of Fork.
When you apply a fork, it splits the input and all subsequent operations run separately on each split part. Merge reverts the fork, so every operation after a merge operates on the whole input.
Select a part of the input data using a regular expression (regex), and run all subsequent operations on each match separately. You can use up to one capture group, where the recipe will only be run on the data in the capture group. If there's more than one capture group, only the first one will be operated on.
In this case, the subsection regex(\d+) forces the subsequent operations to operate on the decimal numbers (similar to fork). Also similar to fork, to operate on the whole input again you will have to include a merge.
Extract data from the input and store it in registers which can then be passed into subsequent operations as arguments. Regular expression capture groups are used to select the data to extract.
To use registers in arguments, refer to them using the notation $Rn
where n is the register number, starting at 0.
For example:
Input: Test
Extractor: (.*)
Argument: $R0
becomes Test
Registers can be escaped in arguments using a backslash. e.g. \$R0
would become $R0
rather than Test
.
In this case, the extractor regex(\d+) matches on the number 1234. It then saves 1234 into register 0(R0) and you can then use that register in future operations as an argument.
Provides a location for conditional and fixed jumps to redirect execution to.
The label provides a labelled location for the jump instructions to jump to.
Jump forwards or backwards to the specified Label.
The jump instruction jumps backwards until its maximum jump limit is reached (in this case it is 9). The result is 10 because it adds 1 and then does the comparison. This is equivalent to just chaining ten ADD 1 operations in the recipe.
Conditionally jump forwards or backwards to the specified Label based on whether the data matches the specified regular expression.
The conditional jump operation jumps to the specified label based on whether the current output matches the specified regex. You can also invert this regex so that the conditional jump will jump to the label if the current output does not match the regex. In this example, it adds 1 to 0 until it does not match [0-8] hence it stops at 9.
End execution of operations at this point in the recipe.
This example isn't as immediately clear as the others, I will transform this into some abstract assembly to show it is working.
main:
mov output, 0
jmp start
exit:
ret
start:
add output, 1
match output, [0-8]
jnm exit
jmp start
jnm means jump not match(jumps if the regex does not match). In this case ret = return, I am not using ret in the conventional sense but it is there to terminate the recipe when it is executed. The Return operation inside CyberChef stops the execution of all operations currently running.
Provides a place to write comments within the flow of the recipe. This operation has no computational effect.
This serves the same purpose as comments in programming, it is an aid to help yourself and others understand how your logic works.