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: Make it easy to embed and auto fill in input #903

Closed
awick opened this issue Nov 20, 2019 · 3 comments
Closed

Feature request: Make it easy to embed and auto fill in input #903

awick opened this issue Nov 20, 2019 · 3 comments
Labels

Comments

@awick
Copy link

awick commented Nov 20, 2019

First off CyberChef is awesome!

Is your feature request related to a problem? Please describe.
We've had a simple action from Moloch (https://molo.ch) for a while that will auto launch CyberChef and fill in the input box with data from Moloch. It was always kind of a hack, didn't work great with certain browsers, and works even worse lately.

Currently we generate a page, try setting 'input-text' after a timeout, and cross our fingers.
(https://github.com/aol/moloch/blob/master/viewer/views/cyberchef.pug)

Sometimes the timeout isn't long enough and the user has to hit the Bake button again. Some browsers just don't work

Describe the solution you'd like
Really we are looking for suggestions on how to do it right.

Maybe add a url param that uses the browser fetch api to get the input box, or make it easy for us to inject a function that we could then write in the page to fetch the data?

Sorry if we are missing some obvious way to already do this. :)

@awick awick added the feature label Nov 20, 2019
@n1474335
Copy link
Member

You can populate the input field using the input URL param. The value should be encoded in Base64. e.g. https://gchq.github.io/CyberChef/#input=SGVsbG8sIFdvcmxkIQ

@awick
Copy link
Author

awick commented Nov 21, 2019

Oh sorry, I left out that we want to populate more then what can be in a url parameter usually. 50k or more.

@n1474335
Copy link
Member

Ah fair enough, that makes sense.

There is a globally defined variable called app that gives you access to the main CyberChef web app and lets you control almost everything.

You can call

app.setInput("some string")

to cleanly add a new input string.

If you want to upload a file it's a little less obvious but still fairly simple:

const myFile = new File([1,2,3,4,5], "my_file.dat")
app.manager.input.loadUIFiles([myFile])

You can load multiple files by passing them into the array argument. They will get passed off to a separate thread to be loaded as efficiently as possible.

You should be able to call these functions fairly quickly after loading CyberChef. If you want to be certain they will work, you can listen for the custom apploaded event which fires once everything is set up and ready to rock and roll.

window.addEventListener("apploaded", () => {
    const myFile = new File([1, 2, 3, 4, 5], "my_file.dat");
    app.manager.input.loadUIFiles([myFile]);
});

Does that answer the question?

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

No branches or pull requests

2 participants