Added date in Duplicate for better distinguish duplicate. Also, added a timeout for the dataTable in duplicate inside the modal.

This commit is contained in:
Mokaddem 2016-11-24 15:05:29 +01:00
parent df8d978088
commit 5d269ea1ee
4 changed files with 22 additions and 6 deletions

View file

@ -131,8 +131,10 @@ if __name__ == "__main__":
# index of paste # index of paste
index_current = r_serv_dico.get(dico_hash) index_current = r_serv_dico.get(dico_hash)
paste_path = r_serv_dico.get(index_current) paste_path = r_serv_dico.get(index_current)
paste_date = r_serv_dico.get(index_current+'_date')
paste_date = paste_date if paste_date != None else "No date available"
if paste_path != None: if paste_path != None:
hash_dico[dico_hash] = (hash_type, paste_path, percent) hash_dico[dico_hash] = (hash_type, paste_path, percent, paste_date)
print '['+hash_type+'] '+'comparing: ' + str(PST.p_path[44:]) + ' and ' + str(paste_path[44:]) + ' percentage: ' + str(percent) print '['+hash_type+'] '+'comparing: ' + str(PST.p_path[44:]) + ' and ' + str(paste_path[44:]) + ' percentage: ' + str(percent)
except Exception,e: except Exception,e:
@ -142,6 +144,7 @@ if __name__ == "__main__":
# Add paste in DB after checking to prevent its analysis twice # Add paste in DB after checking to prevent its analysis twice
# hash_type_i -> index_i AND index_i -> PST.PATH # hash_type_i -> index_i AND index_i -> PST.PATH
r_serv1.set(index, PST.p_path) r_serv1.set(index, PST.p_path)
r_serv1.set(index+'_date', PST._get_p_date())
r_serv1.sadd("INDEX", index) r_serv1.sadd("INDEX", index)
# Adding hashes in Redis # Adding hashes in Redis
for hash_type, paste_hash in paste_hashes.iteritems(): for hash_type, paste_hash in paste_hashes.iteritems():
@ -152,7 +155,7 @@ if __name__ == "__main__":
# if there is data in this dictionnary # if there is data in this dictionnary
if len(hash_dico) != 0: if len(hash_dico) != 0:
# paste_tuple = (paste_path, percent) # paste_tuple = (hash_type, date, paste_path, percent)
for dico_hash, paste_tuple in hash_dico.items(): for dico_hash, paste_tuple in hash_dico.items():
dupl.append(paste_tuple) dupl.append(paste_tuple)

View file

@ -143,6 +143,7 @@ def showpaste(content_range):
p_duplicate_full_list = json.loads(paste._get_p_duplicate()) p_duplicate_full_list = json.loads(paste._get_p_duplicate())
p_duplicate_list = [] p_duplicate_list = []
p_simil_list = [] p_simil_list = []
p_date_list = []
p_hashtype_list = [] p_hashtype_list = []
@ -170,20 +171,29 @@ def showpaste(content_range):
hash_types = str(hash_types).replace("[","").replace("]","") if len(hash_types)==1 else str(hash_types) hash_types = str(hash_types).replace("[","").replace("]","") if len(hash_types)==1 else str(hash_types)
comp_vals = str(comp_vals).replace("[","").replace("]","") if len(comp_vals)==1 else str(comp_vals) comp_vals = str(comp_vals).replace("[","").replace("]","") if len(comp_vals)==1 else str(comp_vals)
new_dup_list.append([hash_types.replace("'", ""), p_duplicate_full_list[dup_list_index][1], comp_vals]) if len(p_duplicate_full_list[dup_list_index]) > 3:
try:
date_paste = str(int(p_duplicate_full_list[dup_list_index][3]))
date_paste = date_paste[0:4]+"-"+date_paste[4:6]+"-"+date_paste[6:8]
except ValueError:
date_paste = str(p_duplicate_full_list[dup_list_index][3])
else:
date_paste = "No date available"
new_dup_list.append([hash_types.replace("'", ""), p_duplicate_full_list[dup_list_index][1], comp_vals, date_paste])
# Create the list to pass to the webpage # Create the list to pass to the webpage
for dup_list in new_dup_list: for dup_list in new_dup_list:
hash_type, path, simil_percent = dup_list hash_type, path, simil_percent, date_paste = dup_list
p_duplicate_list.append(path) p_duplicate_list.append(path)
p_simil_list.append(simil_percent) p_simil_list.append(simil_percent)
p_hashtype_list.append(hash_type) p_hashtype_list.append(hash_type)
p_date_list.append(date_paste)
if content_range != 0: if content_range != 0:
p_content = p_content[0:content_range] p_content = p_content[0:content_range]
return render_template("show_saved_paste.html", date=p_date, source=p_source, encoding=p_encoding, language=p_language, size=p_size, mime=p_mime, lineinfo=p_lineinfo, content=p_content, initsize=len(p_content), duplicate_list = p_duplicate_list, simil_list = p_simil_list, hashtype_list = p_hashtype_list) return render_template("show_saved_paste.html", date=p_date, source=p_source, encoding=p_encoding, language=p_language, size=p_size, mime=p_mime, lineinfo=p_lineinfo, content=p_content, initsize=len(p_content), duplicate_list = p_duplicate_list, simil_list = p_simil_list, hashtype_list = p_hashtype_list, date_list=p_date_list)
def getPastebyType(server, module_name): def getPastebyType(server, module_name):
all_path = [] all_path = []

View file

@ -115,7 +115,7 @@
</table> </table>
<div id="div_stil_data"> <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> <button id="load_more_json_button1" type="button" class="btn btn-default" onclick="add_entries();" style="display: none">Load 50 entries</button>
<strong> Totalling {{ num_res }} items </strong> <strong> Totalling {{ num_res }} results related to paste content </strong>
</div> </div>
</div> </div>
<!-- /.panel-body --> <!-- /.panel-body -->
@ -266,6 +266,7 @@
// clear data by removing html, body, head tags. prevent dark modal background stack bug. // clear data by removing html, body, head tags. prevent dark modal background stack bug.
var cleared_data = data.split("<body>")[1].split("</body>")[0]; var cleared_data = data.split("<body>")[1].split("</body>")[0];
$("#mymodalbody").html(cleared_data); $("#mymodalbody").html(cleared_data);
setTimeout(function() { $('#tableDup').DataTable(); }, 150);
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>'); 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(); button.tooltip();

View file

@ -61,6 +61,7 @@
<tr> <tr>
<th>Hash type</th> <th>Hash type</th>
<th>Paste info</th> <th>Paste info</th>
<th>Date</th>
<th>Path</th> <th>Path</th>
</tr> </tr>
</thead> </thead>
@ -69,6 +70,7 @@
<tr> <tr>
<td>{{ hashtype_list[i] }}</td> <td>{{ hashtype_list[i] }}</td>
<td>Similarity: {{ simil_list[i] }}%</td> <td>Similarity: {{ simil_list[i] }}%</td>
<td>{{ date_list[i] }}</td>
<td><a target="_blank" href="{{ url_for('showsavedpaste') }}?paste={{ dup_path }}" id='dup_path'>{{ dup_path }}</a></td> <td><a target="_blank" href="{{ url_for('showsavedpaste') }}?paste={{ dup_path }}" id='dup_path'>{{ dup_path }}</a></td>
</tr> </tr>
{% set i = i + 1 %} {% set i = i + 1 %}