From e3e5338523ed06fc6a64e83f2f85920870133e3c Mon Sep 17 00:00:00 2001 From: Kleo Bercero Date: Sat, 2 May 2020 15:54:30 +0800 Subject: [PATCH 01/12] Docker support --- Dockerfile | 2 ++ docker-compose.yml | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1dc295c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,2 @@ +FROM php:7.2.30-apache-buster +RUN docker-php-ext-install mysqli \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..80ab8c9 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,32 @@ +version: "3.3" +services: + www: + build: . + ports: + - "80:80" + volumes: + - ./web:/var/www/html + links: + - db + networks: + - default + + db: + image: mysql:8.0 + ports: + - "3306:3306" + command: --default-authentication-plugin=mysql_native_password + environment: + MYSQL_DATABASE: wpa + MYSQL_USER: wpa + MYSQL_PASSWORD: wpapass + MYSQL_ROOT_PASSWORD: wpapass + volumes: + - ./db:/docker-entrypoint-initdb.d + - ./conf:/etc/mysql/conf.d + - dwpa:/var/lib/mysql + networks: + - default + +volumes: + dwpa: \ No newline at end of file From 6b88cc5b2fb2eed64d9fd777c5e308eb0b28826f Mon Sep 17 00:00:00 2001 From: Kleo Bercero Date: Sat, 2 May 2020 15:55:09 +0800 Subject: [PATCH 02/12] Apply DB config --- web/conf.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web/conf.php b/web/conf.php index 80ac1cb..5bcf05e 100644 --- a/web/conf.php +++ b/web/conf.php @@ -1,9 +1,9 @@ Date: Sat, 2 May 2020 15:55:34 +0800 Subject: [PATCH 03/12] Combine wpa.sql and wpa-data.sql --- db/wpa-data.sql | 28 ---------------------------- db/wpa.sql | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 28 deletions(-) delete mode 100644 db/wpa-data.sql diff --git a/db/wpa-data.sql b/db/wpa-data.sql deleted file mode 100644 index 71592aa..0000000 --- a/db/wpa-data.sql +++ /dev/null @@ -1,28 +0,0 @@ -SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; - --- --- Database: `wpa` --- - --- --- Dumping data for table `stats` --- - -INSERT INTO `stats` (`pname`, `pvalue`) VALUES -('nets', '0'), -('nets_unc', '0'), -('cracked', '0'), -('cracked_unc', '0'), -('cracked_rkg', '0'), -('cracked_rkg_unc', '0'), -('cracked_pmkid', '0'), -('cracked_pmkid_unc', '0'), -('pmkid', '0'), -('pmkid_unc', '0'), -('24getwork', '0'), -('24psk', '0'), -('24sub', '0'), -('24founds', '0'), -('words', '0'), -('triedwords', '0'), -('wigle_found', '0'); diff --git a/db/wpa.sql b/db/wpa.sql index dbdf553..95c9544 100644 --- a/db/wpa.sql +++ b/db/wpa.sql @@ -306,3 +306,31 @@ UPDATE stats SET pvalue=(SELECT count(1) FROM bssids WHERE lat IS NOT NULL) WHER END$$ CREATE EVENT `e_cleanup_n2d` ON SCHEDULE EVERY 1 HOUR ON COMPLETION NOT PRESERVE ENABLE DO DELETE FROM n2d WHERE hkey IS NOT NULL AND TIMESTAMPDIFF(DAY, ts, CURRENT_TIMESTAMP) > 0$$ +SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; + +-- +-- Database: `wpa` +-- + +-- +-- Dumping data for table `stats` +-- + +INSERT INTO `stats` (`pname`, `pvalue`) VALUES +('nets', '0'), +('nets_unc', '0'), +('cracked', '0'), +('cracked_unc', '0'), +('cracked_rkg', '0'), +('cracked_rkg_unc', '0'), +('cracked_pmkid', '0'), +('cracked_pmkid_unc', '0'), +('pmkid', '0'), +('pmkid_unc', '0'), +('24getwork', '0'), +('24psk', '0'), +('24sub', '0'), +('24founds', '0'), +('words', '0'), +('triedwords', '0'), +('wigle_found', '0'); From dd1f51b7f2d9b72a7c80021ab0bbedf2b438c678 Mon Sep 17 00:00:00 2001 From: Kleo Bercero Date: Sat, 2 May 2020 15:55:53 +0800 Subject: [PATCH 04/12] Add mysqld conf --- conf/mysqld_events.cnf | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 conf/mysqld_events.cnf diff --git a/conf/mysqld_events.cnf b/conf/mysqld_events.cnf new file mode 100644 index 0000000..777f542 --- /dev/null +++ b/conf/mysqld_events.cnf @@ -0,0 +1,2 @@ +[mysqld] +event_scheduler=ON \ No newline at end of file From ea4b197471c76cc9639baae7e56ca338a4ad41b5 Mon Sep 17 00:00:00 2001 From: Kleo Bercero Date: Sat, 2 May 2020 21:36:11 +0800 Subject: [PATCH 05/12] Build tools --- Dockerfile | 24 +++++++++++++++++++++++- web/conf.php | 4 ++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1dc295c..38a598e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,2 +1,24 @@ FROM php:7.2.30-apache-buster -RUN docker-php-ext-install mysqli \ No newline at end of file +RUN docker-php-ext-install mysqli + +RUN apt-get update +RUN apt-get install -y build-essential git qt5-default libssl-dev zlib1g-dev libcurl4-openssl-dev + +WORKDIR /tools +RUN mkdir /tools/bin + +RUN git clone https://github.com/routerkeygen/routerkeygenPC +WORKDIR /tools/routerkeygenPC/cli +RUN qmake +RUN make +RUN cp -v /tools/routerkeygenPC/cli/routerkeygen-cli /tools/bin + +WORKDIR /tools +RUN git clone https://github.com/ZerBea/hcxtools +WORKDIR /tools/hcxtools +RUN make +RUN cp -v /tools/hcxtools/hcxpcaptool /tools/bin +WORKDIR /tools/bin + +RUN rm -rf /tools/routerkeygenPC +RUN rm -rf /tools/hcxtools diff --git a/web/conf.php b/web/conf.php index 5bcf05e..dcf2789 100644 --- a/web/conf.php +++ b/web/conf.php @@ -19,8 +19,8 @@ $wigleapikey = ''; // App specific defines -define('HCXPCAPTOOL', '/var/www/wpa-sec/cap/hcxpcaptool'); -define('RKG', '/var/www/wpa-sec/cap/routerkeygen-cli'); +define('HCXPCAPTOOL', '/tools/bin/hcxpcaptool'); +define('RKG', '/tools/bin/routerkeygen-cli'); define('CAP', '/var/www/wpa-sec/cap/'); define('CRACKED', '/var/www/wpa-sec/dict/cracked.txt.gz'); From 425d808f0ce18175707bcfd046c1a305dcc8ea92 Mon Sep 17 00:00:00 2001 From: Kleo Bercero Date: Sun, 3 May 2020 14:36:38 +0800 Subject: [PATCH 06/12] Change port --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 80ab8c9..7fbe166 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,7 @@ services: www: build: . ports: - - "80:80" + - "8000:80" volumes: - ./web:/var/www/html links: From aefbe28e186d7c2ac1b5813b4d76db532fe2be82 Mon Sep 17 00:00:00 2001 From: Kleo Bercero Date: Sun, 3 May 2020 14:37:00 +0800 Subject: [PATCH 07/12] rkg cron --- Dockerfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 38a598e..d114a8e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,11 @@ FROM php:7.2.30-apache-buster RUN docker-php-ext-install mysqli RUN apt-get update -RUN apt-get install -y build-essential git qt5-default libssl-dev zlib1g-dev libcurl4-openssl-dev +RUN apt-get install -y build-essential cron git qt5-default libssl-dev zlib1g-dev libcurl4-openssl-dev + +COPY misc/rkg.cron /etc/cron.d/rkg.cron +RUN chmod 0644 /etc/cron.d/rkg.cron +RUN crontab /etc/cron.d/rkg.cron WORKDIR /tools RUN mkdir /tools/bin From b20dac1cb4cb68afb8cb34bcd6bb034283bc8ae8 Mon Sep 17 00:00:00 2001 From: Kleo Bercero Date: Sun, 3 May 2020 14:38:05 +0800 Subject: [PATCH 08/12] Change directory --- web/conf.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/conf.php b/web/conf.php index dcf2789..ce8c93d 100644 --- a/web/conf.php +++ b/web/conf.php @@ -22,8 +22,8 @@ define('HCXPCAPTOOL', '/tools/bin/hcxpcaptool'); define('RKG', '/tools/bin/routerkeygen-cli'); -define('CAP', '/var/www/wpa-sec/cap/'); -define('CRACKED', '/var/www/wpa-sec/dict/cracked.txt.gz'); +define('CAP', '/var/www/html/cap/'); +define('CRACKED', '/var/www/html/dict/cracked.txt.gz'); if (is_dir('/run/shm')) define('SHM', '/run/shm/'); elseif (is_dir('/dev/shm')) From a686f283042c45486586560aba386bfc0fef3bce Mon Sep 17 00:00:00 2001 From: Kleo Bercero Date: Sun, 3 May 2020 17:39:57 +0800 Subject: [PATCH 09/12] Fix permissions --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index d114a8e..f3e523a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,8 @@ COPY misc/rkg.cron /etc/cron.d/rkg.cron RUN chmod 0644 /etc/cron.d/rkg.cron RUN crontab /etc/cron.d/rkg.cron +RUN usermod -u 1000 www-data + WORKDIR /tools RUN mkdir /tools/bin From 52d33139bfe5d89bff3c9f72bdd823128f5ab704 Mon Sep 17 00:00:00 2001 From: Kleo Bercero Date: Wed, 6 May 2020 20:46:01 +0800 Subject: [PATCH 10/12] Setup cron and supervisor --- Dockerfile | 11 +++++++---- misc/rkg.cron | 3 +-- misc/services.conf | 9 +++++++++ 3 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 misc/services.conf diff --git a/Dockerfile b/Dockerfile index f3e523a..58511fd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,11 +2,12 @@ FROM php:7.2.30-apache-buster RUN docker-php-ext-install mysqli RUN apt-get update -RUN apt-get install -y build-essential cron git qt5-default libssl-dev zlib1g-dev libcurl4-openssl-dev +RUN apt-get install -y build-essential cron git qt5-default libssl-dev zlib1g-dev libcurl4-openssl-dev supervisor -COPY misc/rkg.cron /etc/cron.d/rkg.cron -RUN chmod 0644 /etc/cron.d/rkg.cron -RUN crontab /etc/cron.d/rkg.cron +COPY misc/services.conf /etc/supervisor/conf.d + +ADD --chown=1000:crontab misc/rkg.cron /var/spool/cron/crontabs/www-data +RUN /bin/bash -c 'chmod 0600 /var/spool/cron/crontabs/www-data' RUN usermod -u 1000 www-data @@ -28,3 +29,5 @@ WORKDIR /tools/bin RUN rm -rf /tools/routerkeygenPC RUN rm -rf /tools/hcxtools + +CMD ["/usr/bin/supervisord"] \ No newline at end of file diff --git a/misc/rkg.cron b/misc/rkg.cron index 88dd29d..c59463e 100644 --- a/misc/rkg.cron +++ b/misc/rkg.cron @@ -1,3 +1,2 @@ # This is cron entry every 5 minutes for rkg.php. You have to adjust your path. -*/5 * * * * www-data cd /var/www/wpa-sec && /usr/bin/flock -n /tmp/rkg.php.lock /usr/bin/php rkg.php - +* * * * * cd /var/www/html && /usr/bin/flock -n /tmp/rkg.php.lock /usr/local/bin/php rkg.php diff --git a/misc/services.conf b/misc/services.conf new file mode 100644 index 0000000..e915afc --- /dev/null +++ b/misc/services.conf @@ -0,0 +1,9 @@ +[supervisord] +nodaemon=true +user=root + +[program:apache] +command=/usr/local/bin/apache2-foreground + +[program:cron] +command=/usr/sbin/cron -f \ No newline at end of file From 84c238bff41ef668bcc34f768ea39f007a9e3df2 Mon Sep 17 00:00:00 2001 From: Kleo Bercero Date: Thu, 7 May 2020 00:27:04 +0800 Subject: [PATCH 11/12] Setup guide --- DOCKER.md | 44 ++++++++++++++++++++++++++++++++++++++++++++ README.md | 2 ++ 2 files changed, 46 insertions(+) create mode 100644 DOCKER.md diff --git a/DOCKER.md b/DOCKER.md new file mode 100644 index 0000000..59c527f --- /dev/null +++ b/DOCKER.md @@ -0,0 +1,44 @@ +# Docker + +Setup requirements: + +1. Configured web server proxypass to port 8000 +2. Domain pointing to your web server +3. Let's Encrypt configured to your domain + +Note: For testing you can still run the container and access dwpa at port 8000 + +Clone repository + +``` +git clone https://github.com/kbeflo/dwpa +``` + +Download and generate wordlists at `dwpa/misc` + +``` +wget rockyou.txt +./create_gz.sh +set url https://example.com/dict/ +``` + +Move `*.txt.gz` to `dwpa/web/dict` + +Change `help_crack.py` `base_url` + +Move `CHANGELOG`, `help_crack.py` and `help_crack.py.version` to `web/hc` + +Configure `reCAPTCHA`, `bosskey`, `3wifi` and `wigle` keys at `dwpa/web/conf.php` + +Build image and start container + +``` +docker-compose build +docker-compose up +``` + +Import `dict.sql` generated by `./create_gz.sh` at `dwpa/misc` + +``` +docker exec -i dwpa_db_1 mysql -uwpa -pwpapass wpa -v < dict.sql +``` diff --git a/README.md b/README.md index c9304a2..a5ad713 100644 --- a/README.md +++ b/README.md @@ -10,3 +10,5 @@ Live installation: https://wpa-sec.stanev.org To install dwpa on your server, please refer to [INSTALL.md](INSTALL.md) + +Quickstart with [Docker](DOCKER.md) From 5446112096736db1426c3ba38d8151a46afe6c5d Mon Sep 17 00:00:00 2001 From: Kleo Bercero Date: Thu, 7 May 2020 00:27:46 +0800 Subject: [PATCH 12/12] Minor changes --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 58511fd..10d5c5d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ RUN apt-get install -y build-essential cron git qt5-default libssl-dev zlib1g-de COPY misc/services.conf /etc/supervisor/conf.d -ADD --chown=1000:crontab misc/rkg.cron /var/spool/cron/crontabs/www-data +COPY --chown=1000:crontab misc/rkg.cron /var/spool/cron/crontabs/www-data RUN /bin/bash -c 'chmod 0600 /var/spool/cron/crontabs/www-data' RUN usermod -u 1000 www-data