Skip to content

Feature/naked docker #9

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

Merged
merged 14 commits into from
Aug 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM debian:6.0.10

# Updating base system
RUN apt-get update
RUN apt-get upgrade -y

# Installing Apache, PHP, git and generic PHP modules
RUN apt-get install -y apache2 libapache2-mod-php5 git php5-dev php5-gd php-pear \
php5-mysql php5-pgsql php5-sqlite php5-interbase php5-sybase \
php5-odbc unzip make libaio1 bc screen htop git \
subversion sqlite sqlite3 mysql-client libmysqlclient-dev \
netcat

# Configuring Apache and PHP
RUN rm /var/www/index.html
RUN mkdir /var/www/test
RUN chmod 777 /var/www/test
RUN a2enmod auth_basic auth_digest
RUN sed -i 's/AllowOverride None/AllowOverride AuthConfig/' /etc/apache2/sites-enabled/*
RUN sed -i 's/magic_quotes_gpc = On/magic_quotes_gpc = Off/g' /etc/php5/*/php.ini
RUN sed -i 's/extension=suhosin.so/;extension=suhosin.so/g' /etc/php5/conf.d/suhosin.ini

# Copy sqlmap test environment to /var/www
COPY . /var/www/sqlmap/
WORKDIR /var/www/sqlmap

# Now point the scripts to connect to mysql
RUN sed -i 's/"localhost"/"mydb"/' /var/www/sqlmap/libs/mysql.inc.php
RUN sed -i 's/"localhost"/"mydb"/' /var/www/sqlmap/libs/mysql_user.inc.php

# Listen on port 80
EXPOSE 80

CMD ["/var/www/sqlmap/docker/run.sh"]
16 changes: 16 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
mydb:
image: mysql
environment:
- MYSQL_ROOT_PASSWORD=testpass

testenv:
image: andresriancho/testenv:latest
ports:
- "8998:80"
links:
- mydb
environment:
- APACHE_RUN_USER=www-data
- APACHE_RUN_GROUP=www-data
- APACHE_LOG_DIR=/var/log/apache2/

28 changes: 28 additions & 0 deletions docker/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

# Wait for database to get available
MYSQL_LOOPS="20"
MYSQL_HOST="mydb"
MYSQL_PORT="3306"

# Wait for mysql
i=0
while ! nc ${MYSQL_HOST} ${MYSQL_PORT} >/dev/null 2>&1 < /dev/null; do
i=`expr $i + 1`
if [ ${i} -ge ${MYSQL_LOOPS} ]; then
echo "$(date) - ${MYSQL_HOST}:${MYSQL_PORT} still not reachable, giving up"
exit 1
fi
echo "$(date) - waiting for ${MYSQL_HOST}:${MYSQL_PORT}..."
sleep 1
done


echo "Create the database"
mysql -u root -ptestpass -h ${MYSQL_HOST} mysql < /var/www/sqlmap/schema/mysql.sql


echo "Start apache"
# Apache gets grumpy about PID files pre-existing
rm -f /var/run/apache2/apache2.pid
exec apache2 -DFOREGROUND
2 changes: 1 addition & 1 deletion schema/mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ CREATE USER 'testuser'@'%' identified by 'testpass';

USE mysql;

UPDATE USER SET host='%' WHERE user='root' AND host='localhost';
UPDATE user SET host='%' WHERE user='root' AND host='localhost';
GRANT SELECT ON testdb.* TO 'testuser'@'%';