DeadPackets / pwnbox-cli

The CLI tool that lets you easily deploy, customize and manage PwnBox.
MIT License
3 stars 1 forks source link

empty ports binding if network mode is set to host #3

Closed shizonic closed 3 years ago

shizonic commented 3 years ago

With network_mode='host' I get the following exception:

Traceback (most recent call last):
  File "/home/tm/.local/bin/pwnbox", line 33, in <module>
    sys.exit(load_entry_point('pwnbox==1.5.1', 'console_scripts', 'pwnbox')())
  File "/home/tm/.local/lib/python3.9/site-packages/pwnbox-1.5.1-py3.9.egg/pwnbox/__main__.py", line 223, in main
    container_id = client.containers.run(
  File "/home/tm/.local/lib/python3.9/site-packages/docker-5.0.0-py3.9.egg/docker/models/containers.py", line 811, in run
    container = self.create(image=image, command=command,
  File "/home/tm/.local/lib/python3.9/site-packages/docker-5.0.0-py3.9.egg/docker/models/containers.py", line 869, in create
    create_kwargs = _create_container_args(kwargs)
  File "/home/tm/.local/lib/python3.9/site-packages/docker-5.0.0-py3.9.egg/docker/models/containers.py", line 1087, in _create_container_args
    create_kwargs['host_config'] = HostConfig(**host_config_kwargs)
  File "/home/tm/.local/lib/python3.9/site-packages/docker-5.0.0-py3.9.egg/docker/types/containers.py", line 338, in __init__
    raise host_config_incompatible_error(
docker.errors.InvalidArgument: "host" network_mode is incompatible with port_bindings

To solve it I empty ports parameter if network_mode='host'. network_mode='host' isn't support in combination with ports or network. Have a look at https://docker-py.readthedocs.io/en/stable/containers.html:

network_mode (str) – One of:

bridge Create a new network stack for the container on on the bridge network. none No networking for this container. container:<name|id> Reuse another container’s network stack. host Use the host network stack. This mode is incompatible with ports. Incompatible with network.

DeadPackets commented 3 years ago

Thanks for catching that. Only tested pwnbox on MacOS, so thanks for the fix

DeadPackets commented 3 years ago

I'll push a new release today in ~2 hours with all your contributions and a permanent spot in the README!

Big thanks for everything

shizonic commented 3 years ago

Thank you! :+1: I'll going on with bugfixes and new features because I really like pwnbox + pwnbox-cli... Thank you very much for your work!