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

Can't enable Builder plugin: Error enabling plugin=builder, request() got an unexpected keyword argument 'chunked' #2793

Closed
heyquentin opened this issue Jul 25, 2023 · 4 comments · May be fixed by mitre/builder#23

Comments

@heyquentin
Copy link

I wanted to try out Caldera's dynamically compiled payloads so I read the docs and set up my abilities but nothing was happening. Eventually I clued in to the plugin not being actually enabled but when I tried to enable it I got the following error when starting up the server:
2023-07-24 17:39:18 - ERROR (c_plugin.py:70 enable) Error enabling plugin=builder, request() got an unexpected keyword argument 'chunked'

So I started putting debug strings in the plugin's hook.py, build_svc.py and c_plugin.py and eventually I figured out it had something to do with Docker. I did some digging and found this: docker/docker-py#3113

I do not have docker-py installed but once I set requests to 2.29.0 (pip install requests==2.29.0) the docker images started downloading. When you make an ability then check out the yml file, the format is a little different than the example format on the builder plugin's github page. This is what worked for me:
vmware_aeep0UETSO

And this version, which should compile HelloWorld.cs, failed for some reason.
vmware_1ybN9nAQTo

It looks like it created the exe but didn't xfer it to the target system? Idk, will play with it and see if I can get it working.

@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

@b1tst0rm
Copy link
Contributor

Hey @heyquentin did you ever get this figured out? I opened PR mitre/builder#23 that resolves the chunked issues with Docker-Py. However, I cannot seem to get a payload generating dynamically with the builder plugin based on the example here (https://caldera.readthedocs.io/en/latest/Dynamically-Compiled-Payloads.html#basic-example) or yours. Any further luck debugging this?

@heyquentin
Copy link
Author

Do you have this specific version of the requests module: (pip install requests==2.29.0). I'm running Caldera in a virtual environment which I think is nice for stuff like this. This is what I have in my notes for setup. I've used these notes to setup Caldera on a few machines and I think they should be good to go. See if there's any differences between your env:

Install unzip, Go, pip3, venv
$ sudo apt update
Go: https://go.dev/doc/install
$ sudo apt install unzip p7zip-full7za python3.8-venv python3-pip

Create a new venv
$ unzip caldera.zip
$ cd caldera/plugins/builder, run ./install.sh to install Docker for the Builder plugin
$ cd ../../
$ rm -rf calderaEnv
$ python3 -m venv calderaENV
$ source calderaENV/bin/activate

Install requirements
$ pip3 install -r requirements.txt
$ pip3 install requests==2.29.0
$ pip3 install pyminizip

Run the server.
$ python3 server.py -E config --log DEBUG

I also made notes specifically on this problem (I take notes on everything that takes me more than 30 seconds to fix lol) See if these help you:

DO NOT install docker-py

I was trying to use dynamically compiled executables but the builder plugin wouldn't start. I tracked down the problem to the requests module: #2793

To fix this just install requests 2.29 in your python env
$ pip install requests==2.29.0

If you get this error:
2023-07-26 10:52:40 - ERROR (c_plugin.py:70 enable) Error enabling plugin=builder, module 'docker' has no attribute 'from_env'
Install Docker from the requirements.txt. You probably nave a newer docker installed

This FileNotFoundError error:
2023-08-23 23:31:41 - ERROR (c_plugin.py:70 enable) Error enabling plugin=builder, ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))
Go into plugins/builder and run ./install.sh

@b1tst0rm
Copy link
Contributor

Thanks for the quick reply! Interesting you mention using requests here. I was able to resolve the issue of builder not starting by upgrading docker-py and did not have to touch requests. But I think both are "fixes" to the problem. Ultimately we are running into a dependency issue that will need to get resolved. Either the urllib/requests needs to be sorted out or docker-py needs to be bumped to accommodate the issue.

Anyway, getting the builder plugin enabled was not my issue. My issue was trying to figure out why the payload was not generating. I realized after following the code that the actual payload generation is not triggered unless and until the ability is linked in an actual operation under the planning service (

await executor.HOOKS[executor.language](ability, executor)
). I was attempting to run my ability using the access plugin and therefore the executor.HOOK to generate the payload and command was never actually being triggered. So for those scratching their head at this, make sure you are running your abilities in an actual operation and not in a one-off setting such as access plugin!

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

Successfully merging a pull request may close this issue.

3 participants