gophish/static/js/dist/app/campaign_results.min.js

2 lines
12 KiB
JavaScript
Raw Normal View History

2017-02-10 16:52:05 +00:00
function dismiss(){$("#modal\\.flashes").empty(),$("#modal").modal("hide"),$("#resultsTable").dataTable().DataTable().clear().draw()}function deleteCampaign(){swal({title:"Are you sure?",text:"This will delete the campaign. This can't be undone!",type:"warning",animation:!1,showCancelButton:!0,confirmButtonText:"Delete Campaign",confirmButtonColor:"#428bca",reverseButtons:!0,allowOutsideClick:!1,preConfirm:function(){return new Promise(function(a,b){api.campaignId.delete(campaign.id).success(function(b){a()}).error(function(a){b(a.responseJSON.message)})})}}).then(function(){swal("Campaign Deleted!","This campaign has been deleted!","success"),$('button:contains("OK")').on("click",function(){location.href="/campaigns"})})}function completeCampaign(){swal({title:"Are you sure?",text:"Gophish will stop processing events for this campaign",type:"warning",animation:!1,showCancelButton:!0,confirmButtonText:"Complete Campaign",confirmButtonColor:"#428bca",reverseButtons:!0,allowOutsideClick:!1,preConfirm:function(){return new Promise(function(a,b){api.campaignId.complete(campaign.id).success(function(b){a()}).error(function(a){b(a.responseJSON.message)})})}}).then(function(){swal("Campaign Completed!","This campaign has been completed!","success"),$("#complete_button")[0].disabled=!0,$("#complete_button").text("Completed!"),doPoll=!1})}function exportAsCSV(a){exportHTML=$("#exportButton").html();var b=null;switch(a){case"results":b=campaign.results;break;case"events":b=campaign.timeline}if(b){$("#exportButton").html('<i class="fa fa-spinner fa-spin"></i>');var c=Papa.unparse(b,{}),d=new Blob([c],{type:"text/csv;charset=utf-8;"});if(navigator.msSaveBlob)navigator.msSaveBlob(d,a+".csv");else{var e=window.URL.createObjectURL(d),f=document.createElement("a");f.href=e,f.setAttribute("download",a+".csv"),document.body.appendChild(f),f.click(),document.body.removeChild(f)}$("#exportButton").html(exportHTML)}}function replay(a){function b(){form.attr({action:url}),form.appendTo("body").submit().remove()}request=campaign.timeline[a],details=JSON.parse(request.details),url=null,form=$("<form>").attr({method:"POST",target:"_blank"}),$.each(Object.keys(details.payload),function(a,b){return"rid"==b||("__original_url"==b?(url=details.payload[b],!0):void $("<input>").attr({name:b}).val(details.payload[b]).appendTo(form))}),swal({title:"Where do you want the credentials submitted to?",input:"text",showCancelButton:!0,inputPlaceholder:"http://example.com/login",inputValue:url||"",inputValidator:function(a){return new Promise(function(b,c){a?b():c("Invalid URL.")})}}).then(function(a){url=a,b()})}function renderTimeline(a){return record={first_name:a[2],last_name:a[3],email:a[4],position:a[5]},results='<div class="timeline col-sm-12 well well-lg"><h6>Timeline for '+escapeHtml(record.first_name)+" "+escapeHtml(record.last_name)+'</h6><span class="subtitle">Email: '+escapeHtml(record.email)+'</span><div class="timeline-graph col-sm-6">',$.each(campaign.timeline,function(a,b){b.email&&b.email!=record.email||(results+='<div class="timeline-entry"> <div class="timeline-bar"></div>',results+=' <div class="timeline-icon '+statuses[b.message].label+'"> <i class="fa '+statuses[b.message].icon+'"></i></div> <div class="timeline-message">'+escapeHtml(b.message)+' <span class="timeline-date">'+moment(b.time).format("MMMM Do YYYY h:mm a")+"</span>",b.details&&("Submitted Data"==b.message&&(results+='<div class="timeline-replay-button"><button onclick="replay('+a+')" class="btn btn-success">',results+='<i class="fa fa-refresh"></i> Replay Credentials</button></div>',results+='<div class="timeline-event-details"><i class="fa fa-caret-right"></i> View Details</div>'),details=JSON.parse(b.details),details.payload&&(results+='<div class="timeline-event-results">',results+=' <table class="table table-condensed table-bordered table-striped">',results+=" <thead><tr><th>Parameter</th><th>Value(s)</tr></thead><tbody>",$.each(Object.keys(details.payload),function(a,b){return"rid"==b||(results+=" <tr>",results+=" <td>"+escapeHtml(b)+