var map = null var doPoll = true; // statuses is a helper map to point result statuses to ui classes var statuses = { "Email Sent": { slice: "ct-slice-donut-sent", legend: "ct-legend-sent", label: "label-success", icon: "fa-envelope", point: "ct-point-sent" }, "Email Opened": { slice: "ct-slice-donut-opened", legend: "ct-legend-opened", label: "label-warning", icon: "fa-envelope", point: "ct-point-opened" }, "Clicked Link": { slice: "ct-slice-donut-clicked", legend: "ct-legend-clicked", label: "label-clicked", icon: "fa-mouse-pointer", point: "ct-point-clicked" }, "Success": { slice: "ct-slice-donut-success", legend: "ct-legend-success", label: "label-danger", icon: "fa-exclamation", point: "ct-point-clicked" }, "Error": { slice: "ct-slice-donut-error", legend: "ct-legend-error", label: "label-default", icon: "fa-times", point: "ct-point-error" }, "Error Sending Email": { slice: "ct-slice-donut-error", legend: "ct-legend-error", label: "label-default", icon: "fa-times", point: "ct-point-error" }, "Submitted Data": { slice: "ct-slice-donut-success", legend: "ct-legend-success", label: "label-danger", icon: "fa-exclamation", point: "ct-point-clicked" }, "Unknown": { slice: "ct-slice-donut-error", legend: "ct-legend-error", label: "label-default", icon: "fa-question", point: "ct-point-error" }, "Sending": { slice: "ct-slice-donut-sending", legend: "ct-legend-sending", label: "label-primary", icon: "fa-spinner", point: "ct-point-sending" }, "Campaign Created": { label: "label-success", icon: "fa-rocket" } } var campaign = {} var bubbles = [] function dismiss() { $("#modal\\.flashes").empty() $("#modal").modal('hide') $("#resultsTable").dataTable().DataTable().clear().draw() } // Deletes a campaign after prompting the user function deleteCampaign() { swal({ title: "Are you sure?", text: "This will delete the campaign. This can't be undone!", type: "warning", animation: false, showCancelButton: true, confirmButtonText: "Delete Campaign", confirmButtonColor: "#428bca", reverseButtons: true, allowOutsideClick: false, preConfirm: function() { return new Promise(function(resolve, reject) { api.campaignId.delete(campaign.id) .success(function(msg) { resolve() }) .error(function(data) { reject(data.responseJSON.message) }) }) } }).then(function() { swal( 'Campaign Deleted!', 'This campaign has been deleted!', 'success' ); $('button:contains("OK")').on('click', function() { location.href = '/campaigns' }) }) } // Completes a campaign after prompting the user function completeCampaign() { swal({ title: "Are you sure?", text: "Gophish will stop processing events for this campaign", type: "warning", animation: false, showCancelButton: true, confirmButtonText: "Complete Campaign", confirmButtonColor: "#428bca", reverseButtons: true, allowOutsideClick: false, preConfirm: function() { return new Promise(function(resolve, reject) { api.campaignId.complete(campaign.id) .success(function(msg) { resolve() }) .error(function(data) { reject(data.responseJSON.message) }) }) } }).then(function() { swal( 'Campaign Completed!', 'This campaign has been completed!', 'success' ); $('#complete_button')[0].disabled = true; $('#complete_button').text('Completed!') doPoll = false; }) } // Exports campaign results as a CSV file function exportAsCSV(scope) { exportHTML = $("#exportButton").html() var csvScope = null switch (scope) { case "results": csvScope = campaign.results break; case "events": csvScope = campaign.timeline break; } if (!csvScope) { return } $("#exportButton").html('') var csvString = Papa.unparse(csvScope, {}) var csvData = new Blob([csvString], { type: 'text/csv;charset=utf-8;' }); if (navigator.msSaveBlob) { navigator.msSaveBlob(csvData, scope + '.csv'); } else { var csvURL = window.URL.createObjectURL(csvData); var dlLink = document.createElement('a'); dlLink.href = csvURL; dlLink.setAttribute('download', scope + '.csv'); document.body.appendChild(dlLink) dlLink.click(); document.body.removeChild(dlLink) } $("#exportButton").html(exportHTML) } function replay(event_idx) { request = campaign.timeline[event_idx] details = JSON.parse(request.details) url = null form = $('