This repository was archived by the owner on Feb 24, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrun.sh
206 lines (160 loc) · 4.71 KB
/
run.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#!/bin/bash
FLASK_PID=""
EVILGINX_PID=""
CHROME_PID=""
FRONTEND_PID=""
NEW_VENV_CREATED=false
install_virtualenv() {
NEW_VENV_CREATED=false
if [ -d "venv" ]; then
echo "Virtual environment found."
source venv/bin/activate
elif [ -d ".venv" ]; then
echo "Virtual environment found."
source .venv/bin/activate
else
echo "No virtual environment found."
echo "Creating venv..."
python3 -m venv venv
source venv/bin/activate
NEW_VENV_CREATED=true
fi
echo "Virtual environment activated."
}
install_backend() {
cd backend || exit
install_virtualenv
if [ "$NEW_VENV_CREATED" = true ]; then
echo "New virtual environment created. Installing requirements..."
pip install -r requirements.txt
else
echo "Using existing virtual environment. Skipping requirement installation."
fi
deactivate
cd ..
}
install_evilginx() {
cd evilginx || exit
if [ ! -f "evilginx" ]; then
echo "Downloading Evilginx..."
wget https://github.com/kgretzky/evilginx2/releases/download/v3.3.0/evilginx-v3.3.0-linux-64bit.zip -O evilginx.zip
echo "Extracting Evilginx..."
unzip evilginx.zip
rm evilginx.zip
chmod +x evilginx
sudo setcap CAP_NET_BIND_SERVICE=+eip ./evilginx
else
echo "Evilginx is already installed."
fi
cd ..
}
install_extension() {
cd extension || exit
if [ ! -d "node_modules" ]; then
echo "Installing dependencies for extension..."
npm install
else
echo "Extension dependencies already installed."
fi
if [ ! -d "build" ]; then
echo "Building extension..."
npm run build
else
echo "Extension build already exists."
fi
cd ..
}
install_frontend() {
cd frontend || exit
if [ ! -d "node_modules" ]; then
echo "Installing dependencies for frontend..."
npm install
else
echo "Frontend dependencies already installed."
fi
cd ..
}
download_and_extract_chrome_data() {
url="https://firebasestorage.googleapis.com/v0/b/itsyourap-misc.appspot.com/o/hack4bengal%2Fchrome-data.zip?alt=media&token=958db72d-36d5-422b-901e-f2427fefefc8"
zip_file="chrome-data.zip"
destination="chrome-data"
if [[ ! -f "$zip_file" && ! -d "$destination" ]]; then
echo "Downloading Chrome data..."
if curl -o "$zip_file" -L "$url"; then
echo "Extracting Chrome data..."
if unzip -o "$zip_file" -d .; then
echo "Chrome data extraction completed."
rm -f "$zip_file"
else
echo "Failed to extract Chrome data."
return 1
fi
else
echo "Failed to download Chrome data."
return 1
fi
else
if [[ -d "$destination" ]]; then
echo "Chrome data or its extracted folder already exists. Skipping download and extraction."
else
echo "Extracting Chrome data..."
if unzip -o "$zip_file" -d .; then
echo "Chrome data extraction completed."
rm -f "$zip_file"
else
echo "Failed to extract Chrome data."
return 1
fi
fi
fi
}
start_backend() {
cd backend || exit
install_virtualenv
echo "Starting Flask app..."
export FLASK_APP="main.py"
export FLASK_ENV="development"
export FLASK_DEBUG="0"
python3 -m flask run --host=0.0.0.0 &
FLASK_PID=$!
deactivate
cd ..
return $FLASK_PID
}
start_evilginx() {
cd evilginx || exit
echo "Starting Evilginx..."
./evilginx -developer -c . &
EVILGINX_PID=$!
cd ..
return $EVILGINX_PID
}
start_extension() {
cd extension || exit
EXTENSION_PATH=$(realpath build)
DATA_PATH=$(realpath ../chrome-data)
echo "Launching Chrome with extension..."
google-chrome --new-window --user-data-dir="$DATA_PATH" --ignore-certificate-errors --host-resolver-rules="MAP *.localhost 127.0.0.1" --load-extension="$EXTENSION_PATH" &
CHROME_PID=$!
cd ..
return $CHROME_PID
}
start_frontend() {
cd frontend || exit
echo "Starting frontend..."
npm run dev &
FRONTEND_PID=$!
cd ..
}
trap 'echo "Stopping processes..."; [ -n "$FLASK_PID" ] && kill "$FLASK_PID"; [ -n "$EVILGINX_PID" ] && kill "$EVILGINX_PID"; [ -n "$CHROME_PID" ] && kill "$CHROME_PID"; [ -n "$FRONTEND_PID" ] && kill "$FRONTEND_PID"; exit' INT
install_backend
install_frontend
install_evilginx
download_and_extract_chrome_data
install_extension
start_backend
start_frontend
start_evilginx
start_extension
echo "Press CTRL+C to exit..."
while true; do sleep 1; done