2017-07-17 17:26:19 +02:00
<!DOCTYPE html>
< html >
2017-07-19 11:52:06 +02:00
< head >
< meta charset = "utf-8" >
< meta name = "viewport" content = "width=device-width, initial-scale=1.0" >
2018-08-02 10:44:47 +02:00
< title > Credentials Tracker - AIL< / title >
< link rel = "icon" href = "{{ url_for('static', filename='image/ail-icon.png') }}" >
2017-07-19 11:52:06 +02:00
<!-- Core CSS -->
< link href = "{{ url_for('static', filename='css/bootstrap.min.css') }}" rel = "stylesheet" >
< link href = "{{ url_for('static', filename='font-awesome/css/font-awesome.css') }}" rel = "stylesheet" >
< link href = "{{ url_for('static', filename='css/sb-admin-2.css') }}" rel = "stylesheet" >
< link href = "{{ url_for('static', filename='css/dygraph_gallery.css') }}" rel = "stylesheet" type = "text/css" / >
<!-- JS -->
< script type = "text/javascript" src = "{{ url_for('static', filename='js/dygraph-combined.js') }}" > < / script >
< script language = "javascript" src = "{{ url_for('static', filename='js/jquery.js')}}" > < / script >
< script src = "{{ url_for('static', filename='js/jquery.flot.js') }}" > < / script >
< script src = "{{ url_for('static', filename='js/jquery.flot.pie.js') }}" > < / script >
< script src = "{{ url_for('static', filename='js/jquery.flot.time.js') }}" > < / script >
< script src = "{{ url_for('static', filename='js/bootstrap.min.js') }}" > < / script >
< script src = "{{ url_for('static', filename='js/jquery.dataTables.min.js') }}" > < / script >
< script src = "{{ url_for('static', filename='js/dataTables.bootstrap.js') }}" > < / script >
< script src = "{{ url_for('static', filename='js/jquery.flot.js') }}" > < / script >
< script src = "{{ url_for('static', filename='js/jquery.flot.time.js') }}" > < / script >
< script src = "{{ url_for('static', filename='js/jquery.flot.stack.js') }}" > < / script >
2018-08-02 10:44:47 +02:00
2017-07-19 11:52:06 +02:00
< style >
.btn-link {
color: #000000
}
< / style >
2018-08-02 10:44:47 +02:00
2017-07-19 11:52:06 +02:00
< / head >
< body >
<!-- Modal -->
< div id = "mymodal" class = "modal fade" role = "dialog" >
< div class = "modal-dialog modal-lg" >
2018-08-02 10:44:47 +02:00
2017-07-19 11:52:06 +02:00
<!-- Modal content -->
< div id = "mymodalcontent" class = "modal-content" >
< div id = "mymodalbody" class = "modal-body" max-width = "8500px" >
< p > Loading paste information...< / p >
< img id = "loading-gif-modal" src = "{{url_for('static', filename='image/loading.gif') }}" height = "26" width = "26" style = "margin: 4px;" >
< / div >
< div class = "modal-footer" >
< a id = "button_show_plot" target = "_blank" href = "" > < button type = "button" class = "btn btn-info" > Plot term< / button > < / a >
< button type = "button" class = "btn btn-default" data-dismiss = "modal" > Close< / button >
< / div >
< / div >
< / div >
< / div >
{% include 'navbar.html' %}
2018-08-02 10:44:47 +02:00
2017-07-19 11:52:06 +02:00
< div id = "page-wrapper" >
< div class = "row" >
< div class = "col-lg-12" >
< h1 class = "page-header" data-page = "page-termsfrequency" > Credential seeker< / h1 >
< / div >
2017-07-17 17:26:19 +02:00
<!-- /.col - lg - 12 -->
<!-- Panel OPTIONS -->
< div class = "row" >
< div class = "col-lg-12" >
< div class = "row" >
< div class = "col-lg-12" >
< div id = "panel-today" class = "panel panel-success" >
< div class = "panel-heading" >
2017-07-18 16:57:15 +02:00
< strong > Credential seeker< / strong >
2017-07-17 17:26:19 +02:00
< / div >
< div class = "panel-body" >
2017-07-20 10:04:30 +02:00
< label > < input type = "checkbox" id = "extensive" style = "margin-bottom: 10px;" > < strong > Extensive search (takes time)< / strong > < / input > < / label >
2017-07-17 17:26:19 +02:00
< div class = "form-group input-group" style = "margin-bottom: 30px;" >
2017-07-19 11:52:06 +02:00
< span class = "input-group-addon" > < span class = "glyphicon glyphicon-screenshot" > < / span > < / span >
2017-07-18 16:57:15 +02:00
< input id = "seekInput" class = "form-control" placeholder = "Credential to seek." type = "text" style = "max-width: 400px;" >
< button id = "followTermBtn" class = "btn btn-success btn-interaction" style = "margin-left: 10px;" data-section = "seek" data-action = "seek" > Seek< / button >
2017-07-19 11:52:06 +02:00
< span id = "nodata" class = "alert alert-info" style = "margin-left: 10px; display: none; padding: 6px;" > No data< / span >
2017-07-17 17:26:19 +02:00
< / div >
< table class = "table table-striped table-bordered table-hover" id = "myTable" >
< thead >
< tr >
2017-07-19 11:52:06 +02:00
< th style = "max-width: 800px;" > Username< / th >
< th > Similarity< / th >
< th > # concerned paste(s)< / th >
2017-07-17 17:26:19 +02:00
< th > Action< / th >
< / tr >
< / thead >
< tbody >
< / tbody >
< / table >
<!-- /.panel - body -->
< / div >
< / div >
<!-- /.panel -->
< / div >
<!-- /.panel -->
< / div >
< / div >
2017-07-19 11:52:06 +02:00
< / div >
<!-- /.row -->
< / div >
2017-07-17 17:26:19 +02:00
<!-- /#page - wrapper -->
< script >
$(document).ready(function(){
activePage = $('h1.page-header').attr('data-page');
$("#"+activePage).addClass("active");
$('[data-toggle="tooltip"]').tooltip();
2017-07-19 11:52:06 +02:00
table_track = $('#myTable').DataTable({ "order": [[ 1, "dec" ]] });
2018-08-02 10:44:47 +02:00
2017-07-17 17:26:19 +02:00
table_track.on( 'draw.dt', function () {
perform_binding();
});
2017-07-19 11:52:06 +02:00
$("#seekInput").keyup(function(event){
2017-07-17 17:26:19 +02:00
if(event.keyCode == 13){
$("#followTermBtn").click();
2017-07-19 11:52:06 +02:00
$("#seekInput").val("");
2017-07-17 17:26:19 +02:00
}
});
perform_binding();
2017-07-20 10:04:30 +02:00
$("#mymodal").on('hidden.bs.modal', function () {
$("#mymodalbody").html("< p > Loading paste information...< / p > ");
var loading_gif = "< img id = 'loading-gif-modal' class = 'img-center' src = \"{{url_for('static', filename = 'image/loading.gif' ) } } \ " height = '26' width = '26' style = 'margin: 4px;' > ";
$("#mymodalbody").append(loading_gif); // Show the loading GIF
});
});
< / script >
< script >
function perform_binding() {
$(".btn-interaction").unbind("click.interaction");
$(".btn-interaction").bind("click.interaction", perform_operation);
}
function perform_modal_binding() {
2017-07-17 17:26:19 +02:00
// On click, get html content from url and update the corresponding modal
$("[data-toggle='modal']").on("click.openmodal", function (event) {
event.preventDefault();
var the_modal=$(this);
var url = "{{ url_for('terms.credentials_management_query_paste') }}?cred=" + encodeURIComponent($(this).attr('data-term'));
2017-07-20 10:04:30 +02:00
$.ajax({
type: 'POST',
2018-08-02 10:44:47 +02:00
url: url,
2017-07-20 10:04:30 +02:00
dataType: "json",
data: JSON.stringify({ 'allPath': JSON.parse($(this).attr('data-path')) }),
contentType : "application/json"
}).done(function (data) {
2017-07-17 17:26:19 +02:00
if (data.length != 0) {
var html_to_add = "";
html_to_add += "< table id = \"modal-table\" class = \"table table-striped \ " > ";
html_to_add += "< thead > ";
html_to_add += "< tr > ";
html_to_add += "< th > Source< / th > ";
html_to_add += "< th > Date< / th > ";
html_to_add += "< th > Encoding< / th > ";
html_to_add += "< th > Size (Kb)< / th > ";
html_to_add += "< th > # lines< / th > ";
html_to_add += "< th > Max length< / th > ";
html_to_add += "< th > Preview< / th > ";
html_to_add += "< / tr > ";
html_to_add += "< / thead > ";
html_to_add += "< tbody > ";
for (i=0; i< data.length ; i + + ) {
curr_data = data[i];
html_to_add += "< tr > ";
html_to_add += "< td > "+curr_data.source+"< / td > ";
html_to_add += "< td > "+curr_data.date+"< / td > ";
html_to_add += "< td > "+curr_data.encoding+"< / td > ";
html_to_add += "< td > "+curr_data.size+"< / td > ";
html_to_add += "< td > "+curr_data.lineinfo[0]+"< / td > ";
html_to_add += "< td > "+curr_data.lineinfo[1]+"< / td > ";
html_to_add += "< td > < div class = \"row\" > < button class = \"btn btn-xs btn-default \ " data-toggle = \"popover\" data-placement = \"left\" data-content = \""+curr_data.content.replace(/\"/g, " \ ' " ) + " \ " > Preview content< / button > < a target = \"_blank\" href = \"{{ url_for ( ' showsavedpastes . showsavedpaste ' ) } } ? paste = "+curr_data.path+" & num = 0\" > < button type = \"button\" class = \"btn btn-xs btn-info \ " > Show Paste< / button > < / a > < / div > < / td > ";
html_to_add += "< / tr > ";
}
html_to_add += "< / tbody > ";
html_to_add += "< / table > ";
$("#mymodalbody").html(html_to_add);
$("[data-toggle=popover]").popover();
$('#modal-table').DataTable();
} else {
$("#mymodalbody").html("No paste containing this term has been received yet.");
}
2017-07-20 10:04:30 +02:00
}
)});
2017-07-17 17:26:19 +02:00
}
2018-08-02 10:44:47 +02:00
2017-07-17 17:26:19 +02:00
function perform_operation(){
var curr_section = $(this).attr('data-section');
2018-08-02 10:44:47 +02:00
var curr_action = $(this).attr('data-action');
2017-07-17 17:26:19 +02:00
if (curr_action == "add") {
var curr_term = $('#'+curr_section+'Input').val();
2017-07-18 16:57:15 +02:00
} else if (curr_action == "seek") {
var curr_term = $('#'+curr_section+'Input').val();
2017-07-17 17:26:19 +02:00
} else {
var curr_term = $(this).attr('data-content');
}
2017-07-20 10:04:30 +02:00
var data_to_send = { section: curr_section, action:curr_action, term: curr_term, extensive: $("#extensive").is(":checked")};
2018-08-02 10:44:47 +02:00
2017-07-17 17:26:19 +02:00
if (curr_term != "") {
2017-07-18 16:57:15 +02:00
//console.log(data_to_send);
2017-07-17 17:26:19 +02:00
$.get("{{ url_for('terms.cred_management_action') }}", data_to_send, function(data, status){
if(status == "success") {
var json = data;
2018-08-02 10:44:47 +02:00
2017-07-18 16:57:15 +02:00
if(json.action == "add") {
2017-07-20 10:04:30 +02:00
//not used for the moment
2017-07-18 16:57:15 +02:00
} else if (json.action == "seek") {
2017-07-19 11:52:06 +02:00
table_track.clear().draw();
var rep = json.data;
2017-07-20 10:04:30 +02:00
//var action_button = "< button class = \"btn-link btn-interaction \ " data-toggle = \"tooltip\" data-placement = \"left\" title = \"Track this term \ " data-content = \"" + json . term + " \ " data-section = \"followTerm\" data-action = \"add\" > ";
var action_button = "";
2017-07-18 16:57:15 +02:00
if (rep.usr.length == 0) {
2017-07-19 11:52:06 +02:00
$( "#nodata" ).removeClass('alert-info').addClass('alert-danger');
$( "#nodata" ).text("No data");
2017-07-18 16:57:15 +02:00
$( "#nodata" ).fadeIn( "fast", function() {
setTimeout(function() {
$( "#nodata" ).fadeOut("fast");
}, 2000);
2017-07-17 17:26:19 +02:00
});
2017-07-18 16:57:15 +02:00
} else {
2017-07-19 11:52:06 +02:00
for(i=0; i < rep.usr.length ; i + + ) {
$( "#nodata" ).removeClass('alert-danger').addClass('alert-info');
$( "#nodata" ).text(curr_term);
$( "#nodata" ).fadeIn( "fast");
2017-07-20 10:04:30 +02:00
toAdd = "< / button > < span data-toggle = \"modal\" data-target = \"#mymodal\" data-term = \""+rep.usr[i]+"\" data-path = \"["+rep.path[i]+"]\" > < button class = \"btn-link\" data-toggle = \"tooltip\" data-placement = \"right\" title = \"Show concerned paste ( s ) \ " > < span class = \"glyphicon glyphicon-info-sign \ " > < / span > < / button > < / span > ";
2018-08-02 10:44:47 +02:00
table_track.row.add( [
rep.usr[i],
rep.simil[i],
rep.numPaste[i],
2017-07-19 11:52:06 +02:00
toAdd+action_button ] ).draw( false );
2017-07-18 16:57:15 +02:00
}
2017-07-19 11:52:06 +02:00
perform_binding();
2017-07-20 10:04:30 +02:00
perform_modal_binding();
2017-07-17 17:26:19 +02:00
}
2018-08-02 10:44:47 +02:00
}
2017-07-17 17:26:19 +02:00
}
});
}
}
< / script >
< / body >
< / html >