CyberChef icon indicating copy to clipboard operation
CyberChef copied to clipboard

Feature request: Command-line interface for CyberChef

Open Boolean263 opened this issue 4 years ago • 2 comments

It would be very helpful to have a command line interface for performing CyberChef operations on local files without the need for a GUI web app.

@d98762625 suggested I create this ticket to be a better venue than PR #1043 for the design discussion of what CyberChef's official CLI could look like.

Design considerations

An ideal CLI would have a fairly simple interface. The only inputs needed are:

  • A recipe, being a list of operations to perform
  • A list of files upon which to perform the operations
  • A directory or file into which to place the output

In keeping with a common paradigm in unix-like operating systems, if no input files are given, then input should come from stdin; likewise, if no output destination is specified, then output should go to stdout. This is to accommodate the very common practice of chaining several single-purpose commands together to address specific needs.

A CLI would not replace the web app, and should not be designed with feature-parity to the web app in mind. The thrust of this ticket is to get command-line access to the operations which CyberChef provides, for use on data which shouldn't or can't easily be loaded into the web app.

A CLI would not replace the Node API, and should not be designed to expose every last detail of that API. Using the CLI should be easier for the general case than writing a program.

Specifying recipes

There are many ways one could specify a recipe to the CLI, and this is probably where most of the complexity will come from. The CLI could possibly support multiple ways of receiving the recipe. Some possibilities:

  • String of JSON from a file
    • eg. from CyberChef's "Save Recipe → Clean JSON" or "→ Compact JSON" dialog
  • List of "Chef Format" operations in a file
    • eg. from CyberChef's "Save Recipe → Chef Format" dialog
  • List of operations specified on the command line
    • Strict "Chef Format": To_Base64('A-Za-z0-9+/=') To_Hex('None')
    • Simplified semantic format leveraging the flexibility of chef.bake(): 'tobase64:A-Za-z0-9+/=' to-hex:none

I ordered these roughly from least to most end-user friendly, but they aren't mutually exclusive. Some use cases are easier when loading a pre-composed recipe from a file, while others are easier by specifying operations on the command line.

Boolean263 avatar Jun 01 '20 15:06 Boolean263

Not sure if you are aware of this: https://chepy.readthedocs.io/en/latest/

Might provide some ways to do things, albeit in Python.

I'd love to be able to run using a native cyberchef instance! At the moment I'm converting between CyberChef and Chepy

It would be great to be able to manage recipes from the cli, giving them friendly names for use with the cli

geekscrapy avatar Jul 05 '21 07:07 geekscrapy

I was not aware of chepy, why do reinvent the wheel instead of providing cyberchef api over node or something?

Kreijstal avatar Jul 26 '22 13:07 Kreijstal

A Cyberchef offline API would be great

meiraxx avatar Nov 13 '22 19:11 meiraxx