UMDLARS / dtanm

A framework to teach adversarial thinking to software developers without requiring any special security knowledge
3 stars 2 forks source link

Add docker container input other than arguments #35

Open ChandlerSwift opened 5 years ago

ChandlerSwift commented 5 years ago

Right now, none of these are working.

ChandlerSwift commented 5 years ago

Standard input is looking tough.

It looks like there's no official support in the Docker python library for it, though not for lack of trying: https://github.com/docker/docker-py/issues/73 https://github.com/docker/docker-py/pull/239 Somewhat related: https://github.com/docker/docker-py/issues/390 https://github.com/docker/docker-py/pull/946 Simply trying the fixes listed there don't seem to close standard input when completed, though I could be missing something (taken from https://github.com/docker/docker-py/pull/239#issuecomment-106958176):

container = client.api.create_container(
    image="debian",
    command="cat",
    stdin_open=True)
client.api.start(container)
s = client.api.attach_socket(container, params={'stdin': 1, 'stream': 1})
s._sock.send("Hello, world! This is on stdin!")
s.close()

This does provide input to standard input, but s.close() (and s._sock.close(), which seems to do the same thing?) don't send whatever EOF is necessary to close standard input, and cat hangs waiting for more input.

ChandlerSwift commented 5 years ago

More info/potential solutions: https://stackoverflow.com/questions/26843625/how-to-send-to-stdin-of-a-docker-py-container