2014-12-24 14:42:20 +00:00
<!DOCTYPE html>
< html >
< head >
< meta charset = "utf-8" >
< meta name = "viewport" content = "width=device-width, initial-scale=1.0" >
< title > Analysis Information Leak framework Dashboard< / title >
<!-- 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" / >
2016-07-12 08:02:01 +00:00
< link href = "{{ url_for('static', filename='css/dataTables.bootstrap.css') }}" rel = "stylesheet" type = "text/css" / >
2014-12-24 14:42:20 +00:00
<!-- 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 >
2016-07-12 08:02:01 +00:00
< script src = "{{ url_for('static', filename='js/jquery.dataTables.min.js') }}" > < / script >
< script src = "{{ url_for('static', filename='js/dataTables.bootstrap.js') }}" > < / script >
<!-- Custom style -->
2016-07-19 16:07:29 +00:00
< style >
2016-07-05 14:53:03 +00:00
.tooltip-inner {
text-align: left;
height: 200%;
max-width: 500px;
max-height: 500px;
font-size: 13px;
}
2016-08-23 09:20:48 +00:00
pre {
2016-07-12 08:02:01 +00:00
white-space:pre-wrap;
word-wrap:break-word;
}
2016-11-10 13:56:25 +00:00
2016-07-05 14:53:03 +00:00
< / style >
2014-12-24 14:42:20 +00:00
< / head >
< body >
2017-04-19 13:14:20 +00:00
{% include 'navbar.html' %}
2016-07-05 14:53:03 +00:00
<!-- Modal -->
< div id = "mymodal" class = "modal fade" role = "dialog" >
< div class = "modal-dialog modal-lg" >
<!-- Modal content -->
< div id = "mymodalcontent" class = "modal-content" >
2016-07-12 08:02:01 +00:00
< div id = "mymodalbody" class = "modal-body" max-width = "850px" >
< 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;" >
2016-07-05 14:53:03 +00:00
< / div >
< div class = "modal-footer" >
2016-07-12 08:02:01 +00:00
< a id = "button_show_path" target = "_blank" href = "" > < button type = "button" class = "btn btn-info" > Show saved paste< / button > < / a >
2016-11-10 13:56:25 +00:00
< button type = "button" class = "btn btn-default" data-dismiss = "modal" > Close< / button >
2016-07-05 14:53:03 +00:00
< / div >
< / div >
< / div >
< / div >
2014-12-24 14:42:20 +00:00
< div id = "page-wrapper" >
<!-- /.row -->
< div class = "row" > < / div >
< div class = "row" >
< div class = "col-lg-12" >
2016-07-12 08:02:01 +00:00
< / br >
2014-12-24 14:42:20 +00:00
< div class = "panel panel-default" >
< div class = "panel-heading" >
2018-06-15 15:25:43 +00:00
< i class = "glyphicon glyphicon-search" > < / i > < b id = "numberOfRes" > {{ r|length }}< / b > Results for "< strong > {{ query }}< / strong > "
2014-12-24 14:42:20 +00:00
< div class = "pull-right" >
2016-07-19 16:07:29 +00:00
2014-12-24 14:42:20 +00:00
< / div >
< / div >
<!-- /.panel - heading -->
< div class = "panel-body" >
2017-03-15 08:39:48 +00:00
< div class = "row" >
< div class = "col-md-12" >
2018-05-17 09:00:05 +00:00
< strong style = "" > Index: < / strong >
2017-03-15 10:51:35 +00:00
< select class = "form-control" id = "index_name" style = "display: inline-block; margin-bottom: 5px; width: 30%" >
2017-03-15 08:39:48 +00:00
{% for indexElem in index_list %}
< option { % if indexElem [ 2 ] % } selected = "selected" { % endif % } value = "{{ indexElem[0] }}" > {{ indexElem[1] }}< / option >
{% endfor %}
< / select >
< / div >
< / div >
2016-07-12 08:02:01 +00:00
< table class = "table table-striped table-bordered table-hover" id = "myTable" >
2016-07-05 14:53:03 +00:00
< thead >
< tr >
< th > #< / th >
2016-07-12 08:02:01 +00:00
< th style = "max-width: 800px;" > Path< / th >
< th > Date< / th >
< th > Size (Kb)< / th >
2016-07-05 14:53:03 +00:00
< th > Action< / th >
< / tr >
< / thead >
2016-10-28 07:28:42 +00:00
< tbody id = "table_body" >
2016-07-05 14:53:03 +00:00
{% for path in r %}
< tr >
2018-05-17 09:00:05 +00:00
< td > {{ loop.index0 }}< / td >
< td > < a target = "_blank" href = "{{ url_for('showsavedpastes.showsavedpaste') }}?paste={{path}}" > {{ path }}< / a >
< div >
{% for tag in paste_tags[loop.index0] %}
2018-05-23 14:58:56 +00:00
< a href = "{{ url_for('Tags.get_tagged_paste') }}?ltags={{ tag[1] }}" >
2018-05-29 15:17:02 +00:00
< span class = "label label-{{ bootstrap_label[loop.index0 % 5] }} pull-left" > {{ tag[0] }}< / span >
2018-05-23 14:58:56 +00:00
< / a >
2018-05-17 09:00:05 +00:00
{% endfor %}
< / div >
< / td >
< td > {{ paste_date[loop.index0] }}< / td >
< td > {{ paste_size[loop.index0] }}< / td >
< td > < p > < span class = "glyphicon glyphicon-info-sign" data-toggle = "tooltip" data-placement = "left" title = "{{ c[loop.index0] }} " > < / span > < button type = "button" class = "btn-link" data-num = "{{ loop.index0 + 1 }}" data-toggle = "modal" data-target = "#mymodal" data-url = "{{ url_for('showsavedpastes.showsavedpaste') }}?paste={{ path }}" data-path = "{{ path }}" > < span class = "fa fa-search-plus" > < / span > < / button > < / p > < / td >
2016-07-05 14:53:03 +00:00
< / tr >
2014-12-24 14:42:20 +00:00
{% endfor %}
2016-07-05 14:53:03 +00:00
< / tbody >
2014-12-24 14:42:20 +00:00
< / table >
2016-11-24 12:31:31 +00:00
< div id = "div_stil_data" >
< button id = "load_more_json_button1" type = "button" class = "btn btn-default" onclick = "add_entries();" style = "display: none" > Load 50 entries< / button >
2016-11-24 14:05:29 +00:00
< strong > Totalling {{ num_res }} results related to paste content < / strong >
2014-12-24 14:42:20 +00:00
< / div >
2016-11-24 12:31:31 +00:00
< / div >
2014-12-24 14:42:20 +00:00
<!-- /.panel - body -->
< / div >
< / div >
<!-- /.row -->
< / div >
<!-- /#page - wrapper -->
< / div >
< script src = "{{ url_for('static', filename='js/bootstrap.min.js') }}" > < / script >
2016-11-24 12:31:31 +00:00
< / br >
2014-12-24 14:42:20 +00:00
< / body >
2016-07-12 08:02:01 +00:00
<!-- enable tooltip and dataTable -->
2016-07-05 14:53:03 +00:00
< script >
2016-11-10 13:56:25 +00:00
var search_table;
2016-11-10 14:39:45 +00:00
var last_clicked_paste;
var can_change_modal_content = true;
2016-11-24 12:31:31 +00:00
var page_offset;
var offset;
var all_loaded;
var init_num_of_elements_in_table;
var query;
var pagelen = 50;
2016-11-10 13:56:25 +00:00
2016-07-12 08:02:01 +00:00
$(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip();
2016-10-28 12:21:08 +00:00
2016-07-12 08:02:01 +00:00
$("#button_show_path").hide();
2016-11-24 12:31:31 +00:00
search_table = $('#myTable').DataTable();
query = "{{ query }}";
offset = 0;
page_offset = 2; //page 1 already loaded
all_loaded = false;
init_num_of_elements_in_table = parseInt("{{ r|length }}"); // Comes from the file search
2016-10-28 07:28:42 +00:00
2016-11-24 12:31:31 +00:00
if (init_num_of_elements_in_table == pagelen) {
$("#load_more_json_button1").show();
}
2017-03-15 08:39:48 +00:00
2017-03-15 09:07:46 +00:00
$('#index_name').on('change', function() {
2017-03-15 08:39:48 +00:00
var form = document.createElement('form');
form.setAttribute("method", 'post');
2017-04-19 09:02:03 +00:00
form.setAttribute("action", "{{ url_for('searches.search') }}");
2017-03-15 08:39:48 +00:00
var input1 = document.createElement('input');
input1.setAttribute("type", "hidden");
2017-03-15 09:07:46 +00:00
input1.setAttribute("name", "index_name");
2017-03-15 08:39:48 +00:00
input1.setAttribute("value", this.value);
form.appendChild(input1);
2018-05-17 09:00:05 +00:00
2017-03-15 08:39:48 +00:00
var input2 = document.createElement('input');
input2.setAttribute("type", "hidden");
input2.setAttribute("name", "query");
input2.setAttribute("value", "{{ query }}");
form.appendChild(input2);
document.body.appendChild(form);
form.submit();
})
2016-07-12 08:02:01 +00:00
});
2016-10-28 07:28:42 +00:00
< / script >
< script >
// Loop to recover all the data from get_more_search_results
// And add it dynamically top the dataTable
2016-11-24 12:31:31 +00:00
function add_entries() { //Used to disable the button before going to the big loop
$("#load_more_json_button1").attr('disabled','disabled');
setTimeout(function() { load_search_50_data();}, 50);
}
2016-10-28 07:28:42 +00:00
2016-11-24 12:31:31 +00:00
function load_search_50_data() {
2017-03-15 09:07:46 +00:00
var options = { query: query, page_offset: page_offset, index_name: $("#index_name").val() };
2017-04-19 09:02:03 +00:00
$.post( "{{ url_for('searches.get_more_search_result') }}", options).done(function( data ) {
2016-10-28 07:28:42 +00:00
for(i=0; i< data.path_array.length ; i + + ) {
2016-10-28 12:21:08 +00:00
var curr_preview = data.preview_array[i].replace(/\"/g, "\'");
2018-05-17 09:00:05 +00:00
var tag = ""
for(j=0; j< data.list_tags [ i ] . length ; j + + ) {
2018-05-29 15:17:02 +00:00
tag = tag + "< span class = \"label label- " + data . bootstrap_label [ j % 5 ] + " pull-left \ " > " + data.list_tags[j] + "< / span > "
2018-05-17 09:00:05 +00:00
}
2016-10-28 07:28:42 +00:00
search_table.row.add( [
2016-11-24 12:31:31 +00:00
init_num_of_elements_in_table+((offset))+i+1,
2018-05-17 09:00:05 +00:00
"< a target = \"_blank\" href = \"{{ url_for ( ' showsavedpastes . showsavedpaste ' ) } } ? paste = "+data.path_array[i]+" & num = "+i+" \ " > "+ data.path_array[i] +"< / a > "
+ "< div > " + tag + "< / div > ",
2016-10-28 07:28:42 +00:00
data.date_array[i],
data.size_array[i],
2017-04-19 09:02:03 +00:00
"< p > < span class = \"glyphicon glyphicon-info-sign \ " data-toggle = \"tooltip\" data-placement = \"left\" title = \""+curr_preview+"\" > < / span > < button type = \"button\" class = \"btn-link\" data-num = \""+i+"\" data-toggle = \"modal\" data-target = \"#mymodal\" data-url = \"{{ url_for ( ' showsavedpastes . showsavedpaste ' ) } } ? paste = "+data.path_array[i]+" & num = "+i+" \ " data-path = \""+data.path_array[i]+"\" > < span class = \"fa fa-search-plus \ " > < / span > < / button > < / p > "
2016-10-28 07:28:42 +00:00
] ).draw( false );
}
2016-11-24 12:31:31 +00:00
offset = offset + data.path_array.length;
page_offset = page_offset+1;
2016-10-28 12:21:08 +00:00
$("#numberOfRes").text(parseInt($("#numberOfRes").text()) + data.path_array.length);
2016-11-24 12:31:31 +00:00
if (data.moreData == true) {
//continue
} else {
all_loaded = true;
$("#load_more_json_button1").hide();
2016-10-28 12:21:08 +00:00
}
2016-11-24 12:31:31 +00:00
$("#load_more_json_button1").removeAttr('disabled');
return data.path_array.length;
2016-10-28 07:28:42 +00:00
});
}
2016-07-05 14:53:03 +00:00
< / script >
<!-- Dynamically update the modal -->
< script type = "text/javascript" >
2016-07-12 08:02:01 +00:00
// static data
var alert_message = '< div class = "alert alert-info alert-dismissable" > < button type = "button" class = "close" data-dismiss = "alert" aria-hidden = "true" > × < / button > < strong > No more data.< / strong > Full paste displayed.< / div > ';
var complete_paste = null;
var char_to_display = {{ char_to_display }};
var start_index = 0;
// When the modal goes out, refresh it to normal content
$("#mymodal").on('hidden.bs.modal', function () {
2016-11-10 14:39:45 +00:00
can_change_modal_content = true;
2016-07-12 08:02:01 +00:00
$("#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
$("#button_show_path").attr('href', '');
$("#button_show_path").hide();
complete_paste = null;
start_index = 0;
});
2016-07-19 16:07:29 +00:00
2016-07-12 08:02:01 +00:00
// Update the paste preview in the modal
function update_preview() {
if (start_index + char_to_display > complete_paste.length-1){ // end of paste reached
var final_index = complete_paste.length-1;
var flag_stop = true;
} else {
var final_index = start_index + char_to_display;
}
if (final_index != start_index){ // still have data to display
2016-08-23 07:08:17 +00:00
// Append the new content using text() and not append (XSS)
2018-05-17 09:00:05 +00:00
$("#mymodalbody").find("#paste-holder").text($("#mymodalbody").find("#paste-holder").text() + complete_paste.substring(start_index+1, final_index+1));
2016-07-19 16:07:29 +00:00
start_index = final_index;
2016-07-12 08:02:01 +00:00
if (flag_stop)
nothing_to_display();
} else {
2016-07-19 16:07:29 +00:00
nothing_to_display();
2016-07-12 08:02:01 +00:00
}
2016-07-19 16:07:29 +00:00
}
2016-07-12 08:02:01 +00:00
// Update the modal when there is no more data
function nothing_to_display() {
var new_content = $(alert_message).hide();
$("#mymodalbody").find("#panel-body").append(new_content);
new_content.show('fast');
$("#load-more-button").hide();
}
2016-11-10 13:56:25 +00:00
$('#myTable').on( 'draw.dt', function () {
// Bind tooltip each time we draw a new page
$('[data-toggle="tooltip"]').tooltip();
// On click, get html content from url and update the corresponding modal
$("[data-toggle='modal']").off('click.openmodal').on("click.openmodal", function (event) {
var modal=$(this);
2017-04-19 09:02:03 +00:00
var url = " {{ url_for('showsavedpastes.showpreviewpaste') }}?paste=" + $(this).attr('data-path') + "& num=" + $(this).attr('data-num');
2016-11-10 14:39:45 +00:00
last_clicked_paste = $(this).attr('data-num');
2016-11-10 13:56:25 +00:00
$.get(url, function (data) {
2016-11-10 14:39:45 +00:00
2018-05-17 09:00:05 +00:00
// verify that the reveived data is really the current clicked paste. Otherwise, ignore it.
2016-11-10 14:39:45 +00:00
var received_num = parseInt(data.split("|num|")[1]);
if (received_num == last_clicked_paste & & can_change_modal_content) {
can_change_modal_content = false;
// clear data by removing html, body, head tags. prevent dark modal background stack bug.
var cleared_data = data.split("< body > ")[1].split("< / body > ")[0];
$("#mymodalbody").html(cleared_data);
2016-11-24 14:05:29 +00:00
setTimeout(function() { $('#tableDup').DataTable(); }, 150);
2016-11-10 14:39:45 +00:00
var button = $('< button type = "button" id = "load-more-button" class = "btn btn-info btn-xs center-block" data-url = "' + $(modal).attr('data-path') +'" data-toggle = "tooltip" data-placement = "bottom" title = "Load more content" > < span class = "glyphicon glyphicon-download" > < / span > < / button > ');
button.tooltip();
$("#mymodalbody").children(".panel-default").append(button);
2018-05-17 09:00:05 +00:00
2016-11-10 14:39:45 +00:00
$("#button_show_path").attr('href', $(modal).attr('data-url'));
$("#button_show_path").show('fast');
$("#loading-gif-modal").css("visibility", "hidden"); // Hide the loading GIF
if ($("[data-initsize]").attr('data-initsize') < char_to_display ) { / / All the content is displayed
nothing_to_display();
2016-11-10 13:56:25 +00:00
}
2016-11-10 14:39:45 +00:00
// On click, donwload all paste's content
$("#load-more-button").off('click.download').on("click.download", function (event) {
if (complete_paste == null) { //Donwload only once
2017-04-19 09:02:03 +00:00
$.get("{{ url_for('showsavedpastes.getmoredata') }}"+"?paste="+$(modal).attr('data-path'), function(data, status){
2016-11-10 14:39:45 +00:00
complete_paste = data;
update_preview();
});
} else {
update_preview();
}
});
} else if (can_change_modal_content) {
$("#mymodalbody").html("Ignoring previous not finished query of paste #" + received_num);
}
2016-11-10 13:56:25 +00:00
});
});
} );
2016-07-05 14:53:03 +00:00
< / script >
2014-12-24 14:42:20 +00:00
< / html >