Skip to content

Commit 22891a5

Browse files
committed
Merge pull request #9 from andresriancho/feature/naked-docker
Feature/naked docker
2 parents 7b4f8b0 + 2a42484 commit 22891a5

File tree

4 files changed

+79
-1
lines changed

4 files changed

+79
-1
lines changed

Dockerfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
FROM debian:6.0.10
2+
3+
# Updating base system
4+
RUN apt-get update
5+
RUN apt-get upgrade -y
6+
7+
# Installing Apache, PHP, git and generic PHP modules
8+
RUN apt-get install -y apache2 libapache2-mod-php5 git php5-dev php5-gd php-pear \
9+
php5-mysql php5-pgsql php5-sqlite php5-interbase php5-sybase \
10+
php5-odbc unzip make libaio1 bc screen htop git \
11+
subversion sqlite sqlite3 mysql-client libmysqlclient-dev \
12+
netcat
13+
14+
# Configuring Apache and PHP
15+
RUN rm /var/www/index.html
16+
RUN mkdir /var/www/test
17+
RUN chmod 777 /var/www/test
18+
RUN a2enmod auth_basic auth_digest
19+
RUN sed -i 's/AllowOverride None/AllowOverride AuthConfig/' /etc/apache2/sites-enabled/*
20+
RUN sed -i 's/magic_quotes_gpc = On/magic_quotes_gpc = Off/g' /etc/php5/*/php.ini
21+
RUN sed -i 's/extension=suhosin.so/;extension=suhosin.so/g' /etc/php5/conf.d/suhosin.ini
22+
23+
# Copy sqlmap test environment to /var/www
24+
COPY . /var/www/sqlmap/
25+
WORKDIR /var/www/sqlmap
26+
27+
# Now point the scripts to connect to mysql
28+
RUN sed -i 's/"localhost"/"mydb"/' /var/www/sqlmap/libs/mysql.inc.php
29+
RUN sed -i 's/"localhost"/"mydb"/' /var/www/sqlmap/libs/mysql_user.inc.php
30+
31+
# Listen on port 80
32+
EXPOSE 80
33+
34+
CMD ["/var/www/sqlmap/docker/run.sh"]

docker/docker-compose.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
mydb:
2+
image: mysql
3+
environment:
4+
- MYSQL_ROOT_PASSWORD=testpass
5+
6+
testenv:
7+
image: andresriancho/testenv:latest
8+
ports:
9+
- "8998:80"
10+
links:
11+
- mydb
12+
environment:
13+
- APACHE_RUN_USER=www-data
14+
- APACHE_RUN_GROUP=www-data
15+
- APACHE_LOG_DIR=/var/log/apache2/
16+

docker/run.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
3+
# Wait for database to get available
4+
MYSQL_LOOPS="20"
5+
MYSQL_HOST="mydb"
6+
MYSQL_PORT="3306"
7+
8+
# Wait for mysql
9+
i=0
10+
while ! nc ${MYSQL_HOST} ${MYSQL_PORT} >/dev/null 2>&1 < /dev/null; do
11+
i=`expr $i + 1`
12+
if [ ${i} -ge ${MYSQL_LOOPS} ]; then
13+
echo "$(date) - ${MYSQL_HOST}:${MYSQL_PORT} still not reachable, giving up"
14+
exit 1
15+
fi
16+
echo "$(date) - waiting for ${MYSQL_HOST}:${MYSQL_PORT}..."
17+
sleep 1
18+
done
19+
20+
21+
echo "Create the database"
22+
mysql -u root -ptestpass -h ${MYSQL_HOST} mysql < /var/www/sqlmap/schema/mysql.sql
23+
24+
25+
echo "Start apache"
26+
# Apache gets grumpy about PID files pre-existing
27+
rm -f /var/run/apache2/apache2.pid
28+
exec apache2 -DFOREGROUND

schema/mysql.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ CREATE USER 'testuser'@'%' identified by 'testpass';
4242

4343
USE mysql;
4444

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

0 commit comments

Comments
 (0)