Updated new campaigns modal, send test email modal, and js to use sending profile

pull/169/head
William Woodson 2016-02-21 11:13:28 -06:00
parent 3d8126e981
commit b2eafd07c3
2 changed files with 50 additions and 38 deletions

View File

@ -31,11 +31,7 @@ function launch() {
name: $("#page").val()
},
smtp: {
from_address: $("input[name=from]").val(),
host: $("input[name=host]").val(),
username: $("input[name=username]").val(),
password: $("input[name=password]").val(),
ignore_cert_errors: $("#ignore_cert_errors").prop("checked")
name: $("#profile").val()
},
groups: groups
}
@ -70,11 +66,7 @@ function sendTestEmail() {
name: $("#page").val()
},
smtp: {
from_address: $("input[name=from]").val(),
host: $("input[name=host]").val(),
username: $("input[name=username]").val(),
password: $("input[name=password]").val(),
ignore_cert_errors: $("#ignore_cert_errors").prop("checked")
name: $("#profile").val()
}
}
btnHtml = $("#sendTestModalSubmit").html()
@ -114,6 +106,7 @@ function edit(campaign) {
group_bh.clear();
template_bh.clear();
page_bh.clear();
profile_bh.clear();
if (campaign == "new") {
api.groups.get()
.success(function(groups) {
@ -142,6 +135,15 @@ function edit(campaign) {
page_bh.add(pages)
}
})
api.SMTP.get()
.success(function(profiles) {
if (profiles.length == 0){
modalError("No profiles found!")
return false
} else {
profile_bh.add(profiles)
}
})
}
}
@ -330,4 +332,35 @@ $(document).ready(function() {
.bind('typeahead:autocomplete', function(ev, page) {
$("#page").typeahead('val', page.name)
});
// Create the sending profile typeahead objects
profile_bh = new Bloodhound({
datumTokenizer: function(s) {
return Bloodhound.tokenizers.whitespace(s.name)
},
queryTokenizer: Bloodhound.tokenizers.whitespace,
local: []
})
profile_bh.initialize()
$("#profile.typeahead.form-control").typeahead({
hint: true,
highlight: true,
minLength: 1
}, {
name: "profiles",
source: profile_bh,
templates: {
empty: function(data) {
return '<div class="tt-suggestion">No profiles matched that query</div>'
},
suggestion: function(data) {
return '<div>' + data.name + '</div>'
}
}
})
.bind('typeahead:select', function(ev, profile) {
$("#profile").typeahead('val', profile.name)
})
.bind('typeahead:autocomplete', function(ev, profile) {
$("#profile").typeahead('val', profile.name)
});
})

View File

@ -81,34 +81,13 @@
<br>
<label class="control-label" for="url">URL: <i class="fa fa-question-circle" data-toggle="tooltip" data-placement="right" title="Location of gophish listener (must be reachable by targets!)"></i></label>
<input type="text" class="form-control" placeholder="http://192.168.1.1" id="url"/>
<br/>
<div class="panel panel-default">
<div class="panel-heading" role="tab">
<a role="button" class="collapsed" data-toggle="collapse" href="#smtpPanel" aria-expanded="false" aria-controls="#smtpPanel">
SMTP Options <i class="pull-right glyphicon"></i>
</a>
</div>
<div class="panel-collapse collapse" id="smtpPanel" role="tabpanel">
<div class="panel-body">
<label class="control-label" for="from">From:</label>
<input type="text" class="form-control" placeholder="First Last <test@example.com>" value="" name="from">
<br />
<label class="control-label" for="smtp_server">Host:</label>
<input type="text" class="form-control" placeholder="smtp.example.com:25" value="" name="host">
<br />
<label class="control-label" for="smtp_server">Username:</label>
<input type="text" class="form-control" placeholder="Username" value="" name="username">
<br />
<label class="control-label" for="smtp_server">Password:</label>
<input type="password" class="form-control" placeholder="Password" value="" name="password">
<div class="checkbox checkbox-primary">
<input id="ignore_cert_errors" type="checkbox" checked>
<label for="ignore_cert_errors">Ignore Certificate Errors <i class="fa fa-question-circle" data-toggle="tooltip" data-placement="right" title="Ignore common certificate errors such as self-signed certs (exposes you to MiTM attacks - use carefully!)"></i></label>
</div>
<button type="button" data-toggle="modal" data-target="#sendTestEmailModal" class="btn btn-primary"><i class="fa fa-envelope"></i> Send Test Email</button>
</div>
</div>
</div>
<label class="control-label" for="profile">Sending Profile:</label>
<div class="input-group">
<input type="text" class="typeahead form-control" placeholder="Sending Profile" id="profile"/>
<span class="input-group-btn">
<button type="button" data-toggle="modal" data-target="#sendTestEmailModal" class="btn btn-primary typeahead-button"><i class="fa fa-envelope"></i> Send Test Email</button>
</span>
</div>
<label class="control-label" for="users">Groups:</label>
<form id="groupForm">
<div class="input-group">