var opts={lines:15,length:18,width:9,radius:61,scale:2,corners:1,color:"#000",opacity:0.2,rotate:13,direction:1,speed:0.5,trail:50,fps:20,zIndex:2000000000,className:"spinner",top:"50%",left:"50%",shadow:false,hwaccel:false,position:"absolute"};var sel_tgts=[];$(function(){var a=document.getElementById("loading");var b=new Spinner(opts).spin(a);$(".close, .backdrop").click(function(){close_box()});$(".notes").click(function(){$(this).siblings("span").show()});$(".toggler").click(collapse_expand);$(".target-notes").click(get_target_notes);$("#save-tgt-notes").click(save_target_notes)});function update_tgt_chk(a){if($(a).is(":checked")){sel_tgts.push($(a).val())}else{sel_tgts.splice($.inArray($(a).val(),sel_tgts),1)}}function open_move_to(){if($("#ste").val()<1){alert("Please select an ST&E");return}if($(":checkbox:checked").length<1){alert("Please select a device to move");return}$("#move_to").animate({opacity:"1.00"},300,"linear");$("#move_to").css("display","block");view_box()}function edit_cat(e){if($("#ste").val()<1){alert("Please select an ST&E");return}for(var a in $("#scan_sources option")){$("#scan_sources option").eq(a).attr("selected",false)}var b=$("#cat_name_"+e).text();var d=b.match(/\s+\(([\d]+)\)\s+\(([^\d][ \w]+)\)|\s+\(([\d]+)\)/i);b=b.replace(/\s+\(([\d]+)\)\s+\(([^\d][ \w]+)\)|\s+\(([\d]+)\)/i,"");b=b.replace(/\s{2,}/g,"");$("#new_cat_name").val(b);$("#selected_cat").val(e);if(d&&typeof d[2]!=="undefined"){$("#analyst").val(d[2])}else{$("#analyst").val("")}var c=JSON.parse($("#cat_sources_"+e).val());for(var a in c){$("#src_"+c[a]).attr("selected",true)}$("#edit_cat").animate({opacity:"1.00"},300,"linear");$("#edit_cat").css("display","block");view_box()}function merge_target(){$("#merge_target").animate({opacity:"1.00"},300,"linear");$("#merge_target").css("display","block");view_box()}function delete_cat(a){if($("#ste").val()<1){alert("Please select an ST&E");return}if(!confirm("Are you sure you want to delete this category? Currently assigned targets will be set to the 'Unassigned' category.")){return}$.ajax("/ajax.php",{data:{action:"delete-cat",ste_id:$("#ste").val(),cat_id:a},success:function(b){if(b.error){alert(b.error)}else{location.reload()}},error:function(d,b,c){console.error(c)},dataType:"json",method:"post",timeout:3000})}function del_target(){if(!confirm("Are you sure you want to delete the target? This will also delete all findings and interfaces for the selected targets and is irreversible")){return}}function add_cat(){if($("#ste").val()<1){alert("Please select an ST&E");return}$("#add_ste").val($("#ste").val());$("#add_cat").animate({opacity:"1.00"},300,"linear");$("#add_cat").css("display","block");view_box()}function get_category(a){$.ajax("/ajax.php",{data:{action:"get_category_details",cat_id:a},success:function(c){$("#new_cat_name").val(c.name);for(var b in c.sources){$("#src_"+c.sources[b].id).attr("selected",true)}},datatype:"json",method:"post"})}function close_box(){$(".backdrop, .box").animate({opacity:"0"},300,"linear",function(){$(".backdrop, .box").css("display","none")})}function view_box(){$(".backdrop").animate({opacity:".5"},300,"linear");$(".backdrop").css("display","block")}function update_Status(a){if($(a).val()<1){return false}if($(":checkbox:checked").length<1){alert("Please select a device to update");return false}return true}function collapse_expand(){var a=$(this).data("id");if(!$(".cat_"+a).length){get_hosts(a)}$(this).toggleClass("fa-minus-square fa-plus-square");$(".cat_"+a).toggle(300)}function select(a){$(".cat_"+a+" input[type=checkbox]").each(function(){this.checked=!this.checked;update_tgt_chk(this)})}function assign(b){var a=prompt('Who do you want to assign this category to?\n\nEnter "none" to clear out assignment');if(a){$("#analyst_"+b).val(a);$("#assign_"+b).submit()}}function upload_host_list(){if($("#ste").val()<1){alert("Please select an ST&E");return}$("#import_host_list").animate({opacity:"1.00"},300,"linear");$("#import_host_list").css("display","block");view_box()}function get_hosts(a){$.ajax("/ajax.php",{data:{action:"get_hosts",cat_id:a},beforeSend:function(){$("#loading,#waiting").show();$("#waiting").animate({opacity:"0.5"},300,"linear")},success:function(b){if($("#ops-page").val()=="main"){display_ops_hosts(b)}else{if($("#ops-page").val()=="stats"){display_stats_hosts(b)}else{if($("#ops-page").val()=="task"){display_task_hosts(b)}}}},error:function(d,b,c){console.error(c)},complete:function(){$("#loading,#waiting").hide();$("#waiting").animate({opacity:"0"},300,"linear")},dataType:"json",method:"post"})}function display_ops_hosts(c){if(c.error){console.error(c.error)}else{var e=c.cat_id;var b=$("#cat_"+e);var d=true;for(var a in c.targets){$(b).after("
"+c.targets[a].name+""+c.targets[a].ip+""+c.targets[a].os+""+(c.targets[a].location?c.targets[a].location:" ")+""+c.targets[a].auto+""+c.targets[a].man+""+c.targets[a].data+""+c.targets[a].fp+""+(c.targets[a].scans?c.targets[a].scans:" ")+""+(c.targets[a].chk?c.targets[a].chk:" ")+""+(c.targets[a].notes?c.targets[a].notes:" ")+"
");d=!d}$("#cat_"+e+"_dl").val(1);$(".target-notes").click(get_target_notes);$(".fa-ellipsis-h").tooltip({classes:{"ui-tooltip":"highlight"}})}}function display_stats_hosts(c){if(c.error){console.error(c.error)}else{var e=c.cat_id;var b=$("#cat_"+e);var d=true;for(var a in c.targets){$(b).after("
"+c.targets[a].name+""+c.targets[a].ip+""+c.targets[a].os+""+c.targets[a].cat_1+""+c.targets[a].cat_2+""+c.targets[a].cat_3+""+c.targets[a].nf+""+c.targets[a].na+""+c.targets[a].nr+""+(c.targets[a].comp.toFixed(2)*100)+"%"+(c.targets[a].assessed.toFixed(2)*100)+"%"+(c.targets[a].scans?c.targets[a].scans:" ")+""+(c.targets[a].chk?c.targets[a].chk:" ")+""+c.targets[a].notes+"
");d=!d}$("#cat_"+e+"_dl").val(1);$(".target-notes").click(get_target_notes);$(".fa-ellipsis-h").tooltip({classes:{"ui-tooltip":"highlight"}})}}function display_task_hosts(a){}function get_target_notes(){var a=$(this).data("id");$("#tgt-id").val(a);$.ajax("/ajax.php",{data:{action:"get-target-notes","tgt-id":a},success:function(b){if(b.error){alert(b.error)}else{$("#notes").val(b.notes);view_box()}$("#tgt-notes").animate({opacity:"1.00"},300,"linear");$("#tgt-notes").css("display","block")},error:function(d,b,c){console.error(c)},dataType:"json",method:"post"})}function save_target_notes(){$.ajax("/ajax.php",{data:{action:"save-target-notes","tgt-id":$("#tgt-id").val(),notes:$("#notes").val()},success:function(a){if(a.error){alert(a.error)}else{$("#note_"+$("#tgt-id").val()).html($("#notes").val()+" ");$(".target-notes").click(get_target_notes);$(".fa-ellipsis-h").tooltip({classes:{"ui-tooltip":"highlight"}});close_box()}},error:function(c,a,b){console.error(b)},dataType:"json",method:"post"})}function auto_cat(){$.ajax("/ajax.php",{data:{ste:$("#ste").val(),action:"auto-categorize"},beforeSend:function(){$("#loading,#waiting").show();$("#waiting").animate({opacity:"0.5"},300,"linear")},success:function(a){location.reload()},error:function(c,a,b){console.error(b)},complete:function(){$("#loading,#waiting").hide();$("#waiting").animate({opacity:"0"},300,"linear")},dataType:"json",timeout:5000,method:"post"})}function export_ckl(b,a){if(!b){$.ajax("/ajax.php",{data:{ste:$("#ste").val(),tgt:a,action:"export-ckl"},complete:function(c){alert("Exporting target CKL files to document_root/tmp/ckl")},method:"post"})}else{$.ajax("/ajax.php",{data:{ste:$("#ste").val(),cat:b,action:"export-ckl"},complete:function(c){alert("Exporting CKL files to document_root/tmp/ckl")},method:"post"})}}var percentColors=[{pct:0,color:{r:255,g:0,b:0}},{pct:0.5,color:{r:255,g:255,b:0}},{pct:1,color:{r:0,g:255,b:0}}];var getColorForPercentage=function(g){for(var b=1;b