-
Notifications
You must be signed in to change notification settings - Fork 0
/
InstanDVWA.sh
94 lines (63 loc) · 1.89 KB
/
InstanDVWA.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
#DVWA-insta Generate multiple installation of DVWA
#Need root to execute
#number start instan to deploy
START=1
#Total instan to deploy
TOTAL=30
#name insta
UNAMEBASE="insta"
#Directory Web
DIRECTORYWEB="/var/www/html/"
#php.ini file
PHPINI="/etc/php/7.0/apache2/php.ini"
BTICK='`'
SQL=''
#Check if root
if (( $EUID != 0 )); then
echo "Please run as root"
exit
fi
#Update an upgrade system
sudo apt-get update
sudo apt-get upgrade
#Install apache, php, mysql, unzip
sudo apt-get install apache2 libapache2-mod-php7.0 php7.0 mysql-server php7.0-mysql phpmyadmin unzip
#Download DVWA
wget https://github.com/ethicalhack3r/DVWA/archive/master.zip
#Unzip DVWA
unzip master.zip
echo "Generating instances..."
for ((i=$START;i<$TOTAL;i++))
do
UNAME="$UNAMEBASE$i"
#Generate N Instances of DVWA
cp -R DVWA-master/ "$UNAME"
#change user database
sed -i "s/root/$UNAME/g" "$UNAME/config/config.inc.php.dist"
#Change name database
sed -i "s/dvwa/$UNAME/g" "$UNAME/config/config.inc.php.dist"
#change password database
sed -i "s/p@ssw0rd/$UNAME/g" "$UNAME/config/config.inc.php.dist"
#change name config
mv "$UNAME/config/config.inc.php.dist" "$UNAME/config/config.inc.php"
#move instan to website
mv $UNAME $DIRECTORYWEB
#change permisions
chmod 775 "$DIRECTORYWEB$UNAME/hackable/uploads/"
#change user execute DVWA
chown -R www-data:www-data "$DIRECTORYWEB$UNAME"
Q1="CREATE DATABASE IF NOT EXISTS $UNAME;"
Q2="GRANT ALL ON ${BTICK}$UNAME${BTICK}.* TO '$UNAME'@'localhost' IDENTIFIED BY '$UNAME';"
SQL="$SQL${Q1}${Q2}"
done
SQL="$SQL FLUSH PRIVILEGES;"
echo "Generating database..."
mysql -u root -p -e "$SQL"
echo "Delete default index.html"
rm "$DIRECTORYWEBindex.html"
echo "Enabled url include"
sed -i "s/allow_url_include = Off/allow_url_include = On/g" "$PHPINI"
echo "Reload apache"
service apache2 reload
echo "Now can use DVWA Happy Hacking"