-
Notifications
You must be signed in to change notification settings - Fork 0
/
day0.py
executable file
·65 lines (53 loc) · 2.46 KB
/
day0.py
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
from gophishUtility import *
from gophish.models import *
import csv
from math import ceil
import os
# This client has all methods attached to it necessary to create, read, and run our campaigns.
gophishClient = GophishUtility.createGophishClient()
# Sets up new groups and moves all persons who clicked the link into our control group for training.
# Then it deletes all the groups and then recreates them with their new audience.
def setUpNewGroupsByCSV(csvFilename):
students = [] # lists of users
with open(csvFilename) as studentInfo:
infoReader = csv.DictReader(studentInfo)
for student in infoReader:
newUser = User(first_name = student['firstName'], last_name = student['lastName'], email = student['email'])
students.append(newUser)
print("Students have been loaded into User objects")
# Split the students into 20 groups of equal length. Each group will be adjusted later after seeing results.
groups = []
for i in range(GophishUtility.numGroups):
targets = [students[j] for j in range(len(students)) if j % GophishUtility.numGroups == i]
newGroup = Group(name = GophishUtility.groupNames[i], targets=targets)
groups.append(newGroup)
print(newGroup.name)
print("Users have been loaded into Group objects")
for group in gophishClient.groups.get():
if group.name in GophishUtility.groupNames:
gophishClient.groups.delete(group.id)
# Load groups into Gophish
for group in groups:
response = gophishClient.groups.post(group)
print(response.name, "has been created on the server")
return groups
# Starts the new campaigns based on the groups that are passed to it.
def startNewCampaigns(groups):
for group in groups:
emailSet = group.name.split('-')[0].strip()
pageSet = group.name.split('-')[1].strip()
campaign = Campaign(
name=group.name,
groups=[group],
url="http://acu-edu.info",
smtp=GophishUtility.getSMTPProfile(),
template=GophishUtility.getEmailTemplateForDay(0, emailSet),
page=GophishUtility.chooseLandingPage(pageSet)
)
response = gophishClient.campaigns.post(campaign)
print(response.name, "Campaign has been started")
campaigns = GophishUtility.getOurCampaigns()
GophishUtility.markListCampaignsComplete(campaigns)
csvFilename = 'studentList.csv'
groups = setUpNewGroupsByCSV(csvFilename)
startNewCampaigns(groups)