desaster / kippo

Kippo - SSH Honeypot
1.62k stars 277 forks source link

Docker Image for running Kippo #241

Closed aristofanischionis closed 1 year ago

aristofanischionis commented 1 year ago

I was trying to run Kippo locally for a University project and I found it very difficult, so I decided to create a Dockerfile and pushed the Docker image in Docker Hub for anyone who wants to easily run the latest version of Kippo on their local machine. Can I open a PR with the Dockerfile to be included in the official repository? Is anyone interested in this? The link to the Docker Image I created is here: https://hub.docker.com/r/aristofanischionis/kippo

The Dockerfile has these contents:

# Use an official Python runtime as a parent image
FROM python:2.7-slim

# Create a non-root user and switch to it
RUN adduser --disabled-password --gecos '' app
USER app

# Set the working directory in the container to /app
WORKDIR /app

# Copy the current directory contents into the container at /app
COPY . /app

# Switch back to root to install dependencies
USER root

# Install necessary packages and clean up
RUN apt-get update && apt-get install -y \
    python-dev=2.7.* \
    build-essential=* && \
    rm -rf /var/lib/apt/lists/*

# Create the data and log directory and set their permissions
RUN mkdir -p /app/data /app/log && \
    chown -R app:app /app/data /app/log

# Install Python packages
RUN pip install --no-cache-dir zope.interface==5.5.2 Twisted==9.0.0 pycrypto==2.6.1 pyasn1==0.5.0

# Modify the start.sh script to include the "-n" option so that it doesn't start in deamon mode and so stay in the foreground, otherwise the container will exit immediately.
RUN sed -i 's/twistd -y kippo.tac -l log\/kippo.log --pidfile kippo.pid/twistd -n -y kippo.tac -l log\/kippo.log --pidfile kippo.pid/' start.sh

# Switch back to the non-root user
USER app

# Make port 2222 available to the world outside this container
EXPOSE 2222

# Run start.sh when the container launches
CMD ["./start.sh"]
desaster commented 1 year ago

I haven't maintained kippo, or accepted any pull requests for a long time. Perhaps adding a Dockerfile would be a good last thing to add before archiving the repository, since it makes it easier to run it with the older dependencies that it needs.

The Dockerfile looks good in general, but there's a couple things that probably should be changed:

aristofanischionis commented 1 year ago

Hi @desaster, thanks for replying so quickly! I tried to implement your comments.

Here is the updated Dockerfile code:

# Use an official Python runtime as a parent image
FROM python:2.7-slim

# Create a non-root user and switch to it
RUN adduser --disabled-password --gecos '' app
USER app

# Set the working directory in the container to /app
WORKDIR /app

# Copy the current directory contents into the container at /app
COPY . /app

# Switch back to root to install dependencies
USER root

# Install necessary packages and clean up
RUN apt-get update && apt-get install -y \
    python-dev=2.7.* \
    build-essential=* \
    mariadb-client=* \
    libmariadbclient-dev=* && \
    rm -rf /var/lib/apt/lists/*

# Create the data and log directory and set their permissions
RUN mkdir -p /app/data /app/log /app/log/tty && \
    chown -R 777 /app/log/tty && \
    chown -R app:app /app/data /app/log

# Install Python packages
RUN pip install --no-cache-dir zope.interface==5.5.2 Twisted==15.1.0 pycrypto==2.6.1 pyasn1==0.5.0

# Switch back to the non-root user
USER app

# Make port 2222 available to the world outside thiscontainer
EXPOSE 2222

# Run twistd command when the container launches
CMD ["twistd", "-n", "-y", "kippo.tac", "-l", "log/kippo.log", "--pidfile", "kippo.pid"]
desaster commented 1 year ago

I changed the base image to alpine, and added docker-compoyse.yml. PR #242