Skip to content

Commit 45746ab

Browse files
committed
Added dockerfile
1 parent cc08865 commit 45746ab

File tree

5 files changed

+99
-2
lines changed

5 files changed

+99
-2
lines changed

Diff for: .dockerignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Dockerfile
2+
.env
3+
.vscode

Diff for: Dockerfile

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
FROM python:3
2+
3+
RUN apt-get update \
4+
&& apt-get install -y \
5+
git \
6+
wget \
7+
sqlite3 \
8+
supervisor \
9+
unzip \
10+
&& apt-get clean \
11+
&& rm -rf /var/lib/apt/lists/*
12+
13+
# Download and install Gophish
14+
WORKDIR /usr/src/gophish
15+
RUN wget -O gophish.zip https://getgophish.com/releases/latest/linux/64
16+
RUN unzip gophish.zip
17+
RUN rm gophish.zip
18+
RUN chmod +x gophish
19+
20+
# Expose the admin port to the host
21+
RUN sed -i 's/127.0.0.1/0.0.0.0/g' config.json
22+
23+
WORKDIR /usr/src/gophish-demo/
24+
COPY . .
25+
RUN mv docker/* .
26+
RUN chmod +x run_demo.sh
27+
28+
# Install depenedencies
29+
RUN pip install --no-cache-dir -r requirements.txt
30+
31+
# Setup the supervisor
32+
RUN mv supervisord.conf /etc/supervisor/conf.d/supervisord.conf
33+
34+
CMD ["/usr/bin/supervisord"]

Diff for: create_demo.py

+20-2
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ def open_email(campaign, result, user_agent=DEFAULT_USER_AGENT):
198198
create the event
199199
"""
200200
print('Opening email for {}'.format(result.email))
201+
sys.stdout.flush()
201202
return requests.get(
202203
'{}/track'.format(campaign.url),
203204
params={'rid': result.id},
@@ -221,6 +222,7 @@ def click_link(campaign, result, user_agent=DEFAULT_USER_AGENT):
221222
create the event
222223
"""
223224
print('Clicking link for {}'.format(result.email))
225+
sys.stdout.flush()
224226
return requests.get(
225227
campaign.url,
226228
params={'rid': result.id},
@@ -244,6 +246,7 @@ def submit_data(campaign, result, user_agent=DEFAULT_USER_AGENT):
244246
create the event
245247
"""
246248
print('Submitting data for {}'.format(result.email))
249+
sys.stdout.flush()
247250
return requests.post(
248251
campaign.url,
249252
params={'rid': result.id},
@@ -271,6 +274,7 @@ def report_email(campaign, result, user_agent=DEFAULT_USER_AGENT):
271274
create the event
272275
"""
273276
print('Reporting email for {}'.format(result.email))
277+
sys.stdout.flush()
274278
return requests.get(
275279
'{}/report'.format(campaign.url),
276280
params={'rid': result.id},
@@ -331,22 +335,27 @@ def main():
331335
api = Gophish(api_key=args.api_key, host=args.api_url, verify=False)
332336

333337
# Generate our groups
334-
print('Generating groups...')
338+
print('Generating Groups...')
339+
sys.stdout.flush()
335340
group_names = generate_groups(
336341
api, num_groups=args.num_groups, num_members=args.num_members)
337342
groups = [Group(name=group) for group in group_names]
338343

339344
print('Generating SMTP')
345+
sys.stdout.flush()
340346
smtp = generate_sending_profile(api, '{}:{}'.format(
341347
smtp.hostname, smtp.port))
342348

343349
print('Generating Template')
350+
sys.stdout.flush()
344351
template = generate_template(api)
345352

346353
print('Generating Landing Page')
354+
sys.stdout.flush()
347355
landing_page = generate_landing_page(api)
348356

349357
print('Generating Campaigns')
358+
sys.stdout.flush()
350359
campaign = Campaign(
351360
name='Demo Campaign',
352361
groups=groups,
@@ -366,7 +375,10 @@ def main():
366375
)
367376
print('Exiting...')
368377
sys.exit(1)
369-
print('Waiting for emails to finish sending...')
378+
print(
379+
'Waiting for mock emails to finish sending (this takes a few seconds)...'
380+
)
381+
sys.stdout.flush()
370382
time.sleep(1)
371383
continue
372384
break
@@ -379,6 +391,12 @@ def main():
379391
percent_submitted=args.percent_submitted,
380392
percent_reported=args.percent_reported)
381393

394+
print(
395+
'\n\nAll set! You can now browse to {} to view the Gophish dashboard'.
396+
format(args.api_url))
397+
print('The credentials are admin:gophish')
398+
print('Enjoy!')
399+
382400

383401
if __name__ == '__main__':
384402
main()

Diff for: docker/run_demo.sh

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/sh
2+
3+
DATABASE=/usr/src/gophish/gophish.db
4+
5+
# Wait for the gophish.db file to exist
6+
until [ -f $DATABASE ]; do
7+
>&2 echo "Waiting for database"
8+
sleep 1
9+
done
10+
11+
# Wait for the table to be populated
12+
until sqlite3 $DATABASE 'select api_key from users limit 1'; do
13+
>&2 echo "Waiting for database"
14+
sleep 1
15+
done
16+
17+
# Get the API key
18+
export API_KEY=$(sqlite3 $DATABASE 'select api_key from users limit 1');
19+
20+
# Launch the demo
21+
python create_demo.py --api-key=$API_KEY --num-members 30

Diff for: docker/supervisord.conf

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[supervisord]
2+
nodaemon=true
3+
4+
[include]
5+
files = /etc/supervisor/conf.d/*.conf
6+
7+
[program:gophish]
8+
command=/usr/src/gophish/gophish
9+
directory=/usr/src/gophish/
10+
autostart=true
11+
autorestart=true
12+
13+
[program:demo]
14+
command=/usr/src/gophish-demo/run_demo.sh
15+
directory=/usr/src/gophish-demo/
16+
autostart=true
17+
autorestart=false
18+
stdout_logfile=/dev/stdout
19+
stdout_logfile_maxbytes=0
20+
stderr_logfile=/dev/stderr
21+
stderr_logfile_maxbytes=0

0 commit comments

Comments
 (0)