mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-23 06:37:15 +00:00
chg: [UI item tags search] refractor: search item tag by object, use new functions
This commit is contained in:
parent
6bf9bc3ef7
commit
2b735e3b97
17 changed files with 404 additions and 215 deletions
|
@ -126,6 +126,8 @@ def validate_str_date(str_date, separator=''):
|
|||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
except TypeError:
|
||||
return False
|
||||
|
||||
def sanitise_date_range(date_from, date_to, separator=''):
|
||||
'''
|
||||
|
|
|
@ -446,7 +446,7 @@ def delete_obj_tags(object_id, object_type, tags=[]):
|
|||
return res
|
||||
|
||||
def sanitise_tags_date_range(l_tags, date_from=None, date_to=None):
|
||||
if date_from and date_to is None:
|
||||
if date_from or date_to is None:
|
||||
date_from = get_tags_min_last_seen(l_tags, r_int=False)
|
||||
date_to = date_from
|
||||
return Date.sanitise_date_range(date_from, date_to)
|
||||
|
@ -473,7 +473,7 @@ def get_obj_by_tags(object_type, l_tags, date_from=None, date_to=None, nb_obj=50
|
|||
if object_type=='item':
|
||||
#sanityze date
|
||||
date_range = sanitise_tags_date_range(l_tags, date_from=date_from, date_to=date_to)
|
||||
l_dates = Date.substract_date(date_from, date_to)
|
||||
l_dates = Date.substract_date(date_range['date_from'], date_range['date_to'])
|
||||
|
||||
for date_day in l_dates:
|
||||
l_set_keys = get_obj_keys_by_tags(object_type, l_tags, date_day)
|
||||
|
@ -499,12 +499,21 @@ def get_obj_by_tags(object_type, l_tags, date_from=None, date_to=None, nb_obj=50
|
|||
if page > nb_pages:
|
||||
page = nb_pages
|
||||
|
||||
# select index
|
||||
start = nb_obj*(page -1)
|
||||
stop = (nb_obj*page) -1
|
||||
l_tagged_obj = l_tagged_obj[start:stop]
|
||||
if nb_pages > 1:
|
||||
stop = (nb_obj*page)
|
||||
l_tagged_obj = l_tagged_obj[start:stop]
|
||||
# only one page
|
||||
else:
|
||||
stop = nb_all_elem
|
||||
l_tagged_obj = l_tagged_obj[start:]
|
||||
|
||||
return {"tagged_obj":l_tagged_obj, "page":page, "nb_pages":nb_pages, "nb_first_elem":start+1, "nb_last_elem":stop+1, "nb_all_elem":nb_all_elem}
|
||||
if stop > nb_all_elem:
|
||||
stop = nb_all_elem
|
||||
stop = stop -1
|
||||
|
||||
return {"tagged_obj":l_tagged_obj, "date" : date_range,
|
||||
"page":page, "nb_pages":nb_pages, "nb_first_elem":start+1, "nb_last_elem":stop+1, "nb_all_elem":nb_all_elem}
|
||||
|
||||
# without daterange
|
||||
else:
|
||||
|
|
|
@ -94,6 +94,15 @@ def get_all_obj_tags():
|
|||
return jsonify(res)
|
||||
return jsonify(Tag.get_all_obj_tags(object_type))
|
||||
|
||||
@tags_ui.route('/tag/search/item')
|
||||
@login_required
|
||||
@login_read_only
|
||||
def tags_search_items():
|
||||
object_type = 'item'
|
||||
dict_tagged = {"object_type":object_type, "object_name":object_type.title() + "s"}
|
||||
dict_tagged['date'] = Date.sanitise_date_range('', '', separator='-')
|
||||
return render_template("tags/search_obj_by_tags.html", bootstrap_label=bootstrap_label, dict_tagged=dict_tagged)
|
||||
|
||||
@tags_ui.route('/tag/search/domain')
|
||||
@login_required
|
||||
@login_read_only
|
||||
|
@ -119,8 +128,14 @@ def get_obj_by_tags():
|
|||
object_type = request.args.get('object_type')
|
||||
ltags = request.args.get('ltags')
|
||||
page = request.args.get('page')
|
||||
date_from = request.args.get('ltags')
|
||||
date_to = request.args.get('ltags')
|
||||
date_from = request.args.get('date_from')
|
||||
date_to = request.args.get('date_to')
|
||||
|
||||
# remove date separator
|
||||
if date_from:
|
||||
date_from = date_from.replace('-', '')
|
||||
if date_to:
|
||||
date_to = date_to.replace('-', '')
|
||||
|
||||
# unpack tags
|
||||
list_tags = ltags.split(',')
|
||||
|
@ -139,12 +154,13 @@ def get_obj_by_tags():
|
|||
except:
|
||||
page = 1
|
||||
|
||||
dict_obj = Tag.get_obj_by_tags(object_type, list_tag, page=page)
|
||||
dict_obj = Tag.get_obj_by_tags(object_type, list_tag, date_from=date_from, date_to=date_to, page=page)
|
||||
|
||||
if dict_obj['tagged_obj']:
|
||||
dict_tagged = {"object_type":object_type, "object_name":object_type.title() + "s",
|
||||
"tagged_obj":[], "page":dict_obj['page'] ,"nb_pages":dict_obj['nb_pages'],
|
||||
"nb_first_elem":dict_obj['nb_first_elem'], "nb_last_elem":dict_obj['nb_last_elem'], "nb_all_elem":dict_obj['nb_all_elem']}
|
||||
|
||||
for obj_id in dict_obj['tagged_obj']:
|
||||
obj_metadata = Correlate_object.get_object_metadata(object_type, obj_id)
|
||||
obj_metadata['id'] = obj_id
|
||||
|
@ -162,4 +178,7 @@ def get_obj_by_tags():
|
|||
else:
|
||||
dict_tagged = {"object_type":object_type, "object_name":object_type.title() + "s"}
|
||||
|
||||
if 'date' in dict_obj:
|
||||
dict_tagged['date'] = dict_obj['date']
|
||||
|
||||
return render_template("tags/search_obj_by_tags.html", bootstrap_label=bootstrap_label, dict_tagged=dict_tagged)
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<a class="btn btn-light text-secondary" href="{{ url_for('Tags.Tags_page') }}?ltags=infoleak:submission="manual"" target="_blank" id="submit_result" hidden>
|
||||
<a class="btn btn-light text-secondary" href="{{ url_for('tags_ui.get_obj_by_tags') }}?object_type=item<ags=infoleak:submission="manual"" target="_blank" id="submit_result" hidden>
|
||||
<i class="fas fa-paper-plane fa-2x"></i>
|
||||
<span class="label-icon">Submitted Items </span>
|
||||
</a>
|
||||
|
|
|
@ -123,139 +123,139 @@ def get_last_seen_from_tags_list(list_tags):
|
|||
|
||||
# ============= ROUTES ==============
|
||||
|
||||
@Tags.route("/tags/", methods=['GET'])
|
||||
@login_required
|
||||
@login_read_only
|
||||
def Tags_page():
|
||||
date_from = request.args.get('date_from')
|
||||
date_to = request.args.get('date_to')
|
||||
tags = request.args.get('ltags')
|
||||
|
||||
if tags is None:
|
||||
dates = get_all_dates_range(date_from, date_to)
|
||||
return render_template("Tags.html", date_from=dates['date_from'], date_to=dates['date_to'])
|
||||
|
||||
# unpack tags
|
||||
list_tags = tags.split(',')
|
||||
list_tag = []
|
||||
for tag in list_tags:
|
||||
list_tag.append(tag.replace('"','\"'))
|
||||
|
||||
#no search by date, use last_seen for date_from/date_to
|
||||
if date_from is None and date_to is None and tags is not None:
|
||||
date_from = get_last_seen_from_tags_list(list_tags)
|
||||
date_to = date_from
|
||||
|
||||
# TODO verify input
|
||||
|
||||
dates = get_all_dates_range(date_from, date_to)
|
||||
|
||||
if(type(list_tags) is list):
|
||||
# no tag
|
||||
if list_tags is False:
|
||||
print('empty')
|
||||
# 1 tag
|
||||
elif len(list_tags) < 2:
|
||||
tagged_pastes = []
|
||||
for date in dates['date_range']:
|
||||
tagged_pastes.extend(r_serv_tags.smembers('{}:{}'.format(list_tags[0], date)))
|
||||
|
||||
# 2 tags or more
|
||||
else:
|
||||
tagged_pastes = []
|
||||
for date in dates['date_range']:
|
||||
tag_keys = []
|
||||
for tag in list_tags:
|
||||
tag_keys.append('{}:{}'.format(tag, date))
|
||||
|
||||
if len(tag_keys) > 1:
|
||||
daily_items = r_serv_tags.sinter(tag_keys[0], *tag_keys[1:])
|
||||
else:
|
||||
daily_items = r_serv_tags.sinter(tag_keys[0])
|
||||
tagged_pastes.extend(daily_items)
|
||||
|
||||
else :
|
||||
return 'INCORRECT INPUT'
|
||||
|
||||
all_content = []
|
||||
paste_date = []
|
||||
paste_linenum = []
|
||||
all_path = []
|
||||
allPastes = list(tagged_pastes)
|
||||
paste_tags = []
|
||||
|
||||
try:
|
||||
page = int(request.args.get('page'))
|
||||
except:
|
||||
page = 1
|
||||
if page <= 0:
|
||||
page = 1
|
||||
nb_page_max = len(tagged_pastes)/(max_tags_result)
|
||||
if not nb_page_max.is_integer():
|
||||
nb_page_max = int(nb_page_max)+1
|
||||
else:
|
||||
nb_page_max = int(nb_page_max)
|
||||
if page > nb_page_max:
|
||||
page = nb_page_max
|
||||
start = max_tags_result*(page -1)
|
||||
stop = max_tags_result*page
|
||||
|
||||
for path in allPastes[start:stop]:
|
||||
all_path.append(path)
|
||||
paste = Paste.Paste(path)
|
||||
content = paste.get_p_content()
|
||||
content_range = max_preview_char if len(content)>max_preview_char else len(content)-1
|
||||
all_content.append(content[0:content_range].replace("\"", "\'").replace("\r", " ").replace("\n", " "))
|
||||
curr_date = str(paste._get_p_date())
|
||||
curr_date = curr_date[0:4]+'/'+curr_date[4:6]+'/'+curr_date[6:]
|
||||
paste_date.append(curr_date)
|
||||
paste_linenum.append(paste.get_lines_info()[0])
|
||||
p_tags = r_serv_metadata.smembers('tag:'+path)
|
||||
complete_tags = []
|
||||
l_tags = []
|
||||
for tag in p_tags:
|
||||
complete_tag = tag
|
||||
|
||||
tag = tag.split('=')
|
||||
if len(tag) > 1:
|
||||
if tag[1] != '':
|
||||
tag = tag[1][1:-1]
|
||||
# no value
|
||||
else:
|
||||
tag = tag[0][1:-1]
|
||||
# use for custom tags
|
||||
else:
|
||||
tag = tag[0]
|
||||
|
||||
l_tags.append( (tag,complete_tag) )
|
||||
|
||||
paste_tags.append(l_tags)
|
||||
|
||||
if len(allPastes) > 10:
|
||||
finished = False
|
||||
else:
|
||||
finished = True
|
||||
|
||||
if len(list_tag) == 1:
|
||||
tag_nav=tags.replace('"', '').replace('=', '').replace(':', '')
|
||||
else:
|
||||
tag_nav='empty'
|
||||
|
||||
return render_template("Tags.html",
|
||||
all_path=all_path,
|
||||
tags=tags,
|
||||
tag_nav=tag_nav,
|
||||
list_tag = list_tag,
|
||||
date_from=dates['date_from'],
|
||||
date_to=dates['date_to'],
|
||||
page=page, nb_page_max=nb_page_max,
|
||||
paste_tags=paste_tags,
|
||||
bootstrap_label=bootstrap_label,
|
||||
content=all_content,
|
||||
paste_date=paste_date,
|
||||
paste_linenum=paste_linenum,
|
||||
char_to_display=max_preview_modal,
|
||||
finished=finished)
|
||||
# @Tags.route("/tags/", methods=['GET'])
|
||||
# @login_required
|
||||
# @login_read_only
|
||||
# def Tags_page():
|
||||
# date_from = request.args.get('date_from')
|
||||
# date_to = request.args.get('date_to')
|
||||
# tags = request.args.get('ltags')
|
||||
#
|
||||
# if tags is None:
|
||||
# dates = get_all_dates_range(date_from, date_to)
|
||||
# return render_template("Tags.html", date_from=dates['date_from'], date_to=dates['date_to'])
|
||||
#
|
||||
# # unpack tags
|
||||
# list_tags = tags.split(',')
|
||||
# list_tag = []
|
||||
# for tag in list_tags:
|
||||
# list_tag.append(tag.replace('"','\"'))
|
||||
#
|
||||
# #no search by date, use last_seen for date_from/date_to
|
||||
# if date_from is None and date_to is None and tags is not None:
|
||||
# date_from = get_last_seen_from_tags_list(list_tags)
|
||||
# date_to = date_from
|
||||
#
|
||||
# # TODO verify input
|
||||
#
|
||||
# dates = get_all_dates_range(date_from, date_to)
|
||||
#
|
||||
# if(type(list_tags) is list):
|
||||
# # no tag
|
||||
# if list_tags is False:
|
||||
# print('empty')
|
||||
# # 1 tag
|
||||
# elif len(list_tags) < 2:
|
||||
# tagged_pastes = []
|
||||
# for date in dates['date_range']:
|
||||
# tagged_pastes.extend(r_serv_tags.smembers('{}:{}'.format(list_tags[0], date)))
|
||||
#
|
||||
# # 2 tags or more
|
||||
# else:
|
||||
# tagged_pastes = []
|
||||
# for date in dates['date_range']:
|
||||
# tag_keys = []
|
||||
# for tag in list_tags:
|
||||
# tag_keys.append('{}:{}'.format(tag, date))
|
||||
#
|
||||
# if len(tag_keys) > 1:
|
||||
# daily_items = r_serv_tags.sinter(tag_keys[0], *tag_keys[1:])
|
||||
# else:
|
||||
# daily_items = r_serv_tags.sinter(tag_keys[0])
|
||||
# tagged_pastes.extend(daily_items)
|
||||
#
|
||||
# else :
|
||||
# return 'INCORRECT INPUT'
|
||||
#
|
||||
# all_content = []
|
||||
# paste_date = []
|
||||
# paste_linenum = []
|
||||
# all_path = []
|
||||
# allPastes = list(tagged_pastes)
|
||||
# paste_tags = []
|
||||
#
|
||||
# try:
|
||||
# page = int(request.args.get('page'))
|
||||
# except:
|
||||
# page = 1
|
||||
# if page <= 0:
|
||||
# page = 1
|
||||
# nb_page_max = len(tagged_pastes)/(max_tags_result)
|
||||
# if not nb_page_max.is_integer():
|
||||
# nb_page_max = int(nb_page_max)+1
|
||||
# else:
|
||||
# nb_page_max = int(nb_page_max)
|
||||
# if page > nb_page_max:
|
||||
# page = nb_page_max
|
||||
# start = max_tags_result*(page -1)
|
||||
# stop = max_tags_result*page
|
||||
#
|
||||
# for path in allPastes[start:stop]:
|
||||
# all_path.append(path)
|
||||
# paste = Paste.Paste(path)
|
||||
# content = paste.get_p_content()
|
||||
# content_range = max_preview_char if len(content)>max_preview_char else len(content)-1
|
||||
# all_content.append(content[0:content_range].replace("\"", "\'").replace("\r", " ").replace("\n", " "))
|
||||
# curr_date = str(paste._get_p_date())
|
||||
# curr_date = curr_date[0:4]+'/'+curr_date[4:6]+'/'+curr_date[6:]
|
||||
# paste_date.append(curr_date)
|
||||
# paste_linenum.append(paste.get_lines_info()[0])
|
||||
# p_tags = r_serv_metadata.smembers('tag:'+path)
|
||||
# complete_tags = []
|
||||
# l_tags = []
|
||||
# for tag in p_tags:
|
||||
# complete_tag = tag
|
||||
#
|
||||
# tag = tag.split('=')
|
||||
# if len(tag) > 1:
|
||||
# if tag[1] != '':
|
||||
# tag = tag[1][1:-1]
|
||||
# # no value
|
||||
# else:
|
||||
# tag = tag[0][1:-1]
|
||||
# # use for custom tags
|
||||
# else:
|
||||
# tag = tag[0]
|
||||
#
|
||||
# l_tags.append( (tag,complete_tag) )
|
||||
#
|
||||
# paste_tags.append(l_tags)
|
||||
#
|
||||
# if len(allPastes) > 10:
|
||||
# finished = False
|
||||
# else:
|
||||
# finished = True
|
||||
#
|
||||
# if len(list_tag) == 1:
|
||||
# tag_nav=tags.replace('"', '').replace('=', '').replace(':', '')
|
||||
# else:
|
||||
# tag_nav='empty'
|
||||
#
|
||||
# return render_template("Tags.html",
|
||||
# all_path=all_path,
|
||||
# tags=tags,
|
||||
# tag_nav=tag_nav,
|
||||
# list_tag = list_tag,
|
||||
# date_from=dates['date_from'],
|
||||
# date_to=dates['date_to'],
|
||||
# page=page, nb_page_max=nb_page_max,
|
||||
# paste_tags=paste_tags,
|
||||
# bootstrap_label=bootstrap_label,
|
||||
# content=all_content,
|
||||
# paste_date=paste_date,
|
||||
# paste_linenum=paste_linenum,
|
||||
# char_to_display=max_preview_modal,
|
||||
# finished=finished)
|
||||
|
||||
|
||||
@Tags.route("/Tags/get_all_tags")
|
||||
|
|
|
@ -1 +1 @@
|
|||
<li id='page-Tags'><a href="{{ url_for('Tags.Tags_page') }}"><i class="fa fa-tag "></i> Tags </a></li>
|
||||
<li id='page-Tags'><a href="{{ url_for('tags_ui.tags_search_items') }}"><i class="fa fa-tag "></i> Tags </a></li>
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
<a target="_blank" href="{{ url_for('crawler_splash.showDomain') }}?domain={{ domain }}">{{ domain }}</a>
|
||||
<div>
|
||||
{% for tag in domain_metadata[domain]['tags'] %}
|
||||
<a href="{{ url_for('Tags.Tags_page') }}?date_from={{date}}&date_to={{date}}<ags={{ tag }}">
|
||||
<a href="{{ url_for('tags_ui.get_obj_by_tags') }}?object_type=domain<ags={{ tag }}">
|
||||
<span class="badge badge-{{ bootstrap_label[loop.index0 % 5] }} pull-left">{{ tag }} <i>{{ domain_metadata[domain]['tags'][tag] }}</i></span>
|
||||
</a>
|
||||
{% endfor %}
|
||||
|
|
|
@ -92,7 +92,7 @@
|
|||
</td>
|
||||
<td>
|
||||
{% for tag in tracker_metadata['tags'] %}
|
||||
<a href="{{ url_for('Tags.Tags_page') }}?ltags={{ tag }}">
|
||||
<a href="{{ url_for('tags_ui.get_obj_by_tags') }}?object_type=item<ags={{ tag }}">
|
||||
<span class="badge badge-{{ bootstrap_label[loop.index0 % 5] }}">{{ tag }}</span>
|
||||
</a>
|
||||
{% endfor %}
|
||||
|
@ -227,7 +227,7 @@
|
|||
</a>
|
||||
<div class="mb-2">
|
||||
{% for tag in item['tags'] %}
|
||||
<a href="{{ url_for('Tags.Tags_page') }}?ltags={{ tag }}">
|
||||
<a href="{{ url_for('tags_ui.get_obj_by_tags') }}?object_type=item<ags={{ tag }}">
|
||||
<span class="badge badge-{{ bootstrap_label[loop.index0 % 5] }} pull-left">{{ tag }}</span>
|
||||
</a>
|
||||
{% endfor %}
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
<span><a target="_blank" href="{{ url_for('hunter.show_tracker') }}?uuid={{ dict_uuid['uuid'] }}">{{dict_uuid['term']}}</a></span>
|
||||
<div>
|
||||
{% for tag in dict_uuid['tags'] %}
|
||||
<a href="{{ url_for('Tags.Tags_page') }}?ltags={{ tag }}">
|
||||
<a href="{{ url_for('tags_ui.get_obj_by_tags') }}?object_type=item<ags={{ tag }}">
|
||||
<span class="badge badge-{{ bootstrap_label[loop.index0 % 5] }} pull-left">{{ tag }}</span>
|
||||
</a>
|
||||
{% endfor %}
|
||||
|
@ -121,7 +121,7 @@
|
|||
<span><a target="_blank" href="{{ url_for('hunter.show_tracker') }}?uuid={{ dict_uuid['uuid'] }}">{{dict_uuid['term']}}</a></span>
|
||||
<div>
|
||||
{% for tag in dict_uuid['tags'] %}
|
||||
<a href="{{ url_for('Tags.Tags_page') }}?ltags={{ tag }}">
|
||||
<a href="{{ url_for('tags_ui.get_obj_by_tags') }}?object_type=item<ags={{ tag }}">
|
||||
<span class="badge badge-{{ bootstrap_label[loop.index0 % 5] }}">{{ tag }}</span>
|
||||
</a>
|
||||
{% endfor %}
|
||||
|
|
|
@ -101,7 +101,7 @@
|
|||
<td><a target="_blank" href="{{ url_for('showsavedpastes.showsavedpaste') }}?paste={{path}}">{{ path }}</a>
|
||||
<div>
|
||||
{% for tag in paste_tags[loop.index0] %}
|
||||
<a href="{{ url_for('Tags.Tags_page') }}?ltags={{ tag[1] }}">
|
||||
<a href="{{ url_for('tags_ui.get_obj_by_tags') }}?object_type=item<ags={{ tag[1] }}">
|
||||
<span class="label label-{{ bootstrap_label[loop.index0 % 5] }} pull-left">{{ tag[0] }}</span>
|
||||
</a>
|
||||
{% endfor %}
|
||||
|
@ -201,7 +201,7 @@
|
|||
var curr_preview = data.preview_array[i].replace(/\"/g, "\'");
|
||||
var tag = ""
|
||||
for(j=0; j<data.list_tags[i].length; j++) {
|
||||
tag = tag + "<a href=\"{{ url_for('Tags.Tags_page') }}?ltags=" + data.list_tags[i][j][1] + ">"
|
||||
tag = tag + "<a href=\"{{ url_for('tags_ui.get_obj_by_tags') }}?object_type=item<ags=" + data.list_tags[i][j][1] + ">"
|
||||
+ "<span class=\"label label-" + data.bootstrap_label[j % 5] + " pull-left\">" + data.list_tags[i][j][0]
|
||||
+ "</span>" + "</a>"
|
||||
}
|
||||
|
|
|
@ -361,6 +361,7 @@ def show_item_min(requested_path , content_range=0):
|
|||
if 'infoleak:submission="crawler"' in l_tags:
|
||||
crawler_metadata['get_metadata'] = True
|
||||
crawler_metadata['domain'] = r_serv_metadata.hget('paste_metadata:'+relative_path, 'domain')
|
||||
crawler_metadata['domain'] = crawler_metadata['domain'].rsplit(':', 1)[0]
|
||||
crawler_metadata['paste_father'] = r_serv_metadata.hget('paste_metadata:'+relative_path, 'father')
|
||||
crawler_metadata['real_link'] = r_serv_metadata.hget('paste_metadata:'+relative_path,'real_link')
|
||||
crawler_metadata['screenshot'] = get_item_screenshot_path(relative_path)
|
||||
|
|
|
@ -351,7 +351,7 @@
|
|||
</a>
|
||||
<div>
|
||||
{% for tag in item["tags"] %}
|
||||
<a href="{{ url_for('Tags.Tags_page') }}?ltags={{ tag["tag"] }}">
|
||||
<a href="{{ url_for('tags_ui.get_obj_by_tags') }}?object_type=item<ags={{ tag["tag"] }}">
|
||||
<span class="badge badge-{{ bootstrap_label[loop.index0 % 5] }} pull-left">{{ tag["min_tag"] }}</span>
|
||||
</a>
|
||||
{% endfor %}
|
||||
|
|
114
var/www/templates/modals/show_min_item.html
Normal file
114
var/www/templates/modals/show_min_item.html
Normal file
|
@ -0,0 +1,114 @@
|
|||
<div id="modal_show_min_item" class="modal fade" role="dialog">
|
||||
<div class="modal-dialog modal-lg">
|
||||
|
||||
<!-- Modal content-->
|
||||
<div id="modal_show_min_item_content" class="modal-content">
|
||||
<div id="modal_show_min_item_body" class="modal-body" max-width="850px">
|
||||
<p>Loading item 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="modal_show_min_item_button_show_item" target="_blank" href=""><button type="button" class="btn btn-info">Show Item</button></a>
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// static data
|
||||
var can_change_modal_content = true;
|
||||
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_item = null;
|
||||
var char_to_display = {%if char_to_display%}{{ char_to_display }}{%else%}800{%endif%};
|
||||
var start_index = 0;
|
||||
|
||||
// Reset modal content
|
||||
$("#modal_show_min_item").on('hidden.bs.modal', function () {
|
||||
can_change_modal_content = true;
|
||||
$("#modal_show_min_item_body").html("<p>Loading item 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;'>";
|
||||
$("#modal_show_min_item_body").append(loading_gif); // Show the loading GIF
|
||||
$("#modal_show_min_item_button_show_item").attr('href', '');
|
||||
$("#modal_show_min_item_button_show_item").hide();
|
||||
complete_item = null;
|
||||
start_index = 0;
|
||||
});
|
||||
|
||||
// Update the item preview in the modal
|
||||
function update_preview() {
|
||||
if (start_index + char_to_display > complete_item.length-1){ // end of item reached
|
||||
var final_index = complete_item.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
|
||||
// Append the new content using text() and not append (XSS)
|
||||
$("#modal_show_min_item_body").find("#paste-holder")
|
||||
.text($("#modal_show_min_item_body")
|
||||
.find("#paste-holder").text() + complete_item.substring(start_index+1, final_index+1));
|
||||
start_index = final_index;
|
||||
if (flag_stop)
|
||||
nothing_to_display();
|
||||
} else {
|
||||
nothing_to_display();
|
||||
}
|
||||
}
|
||||
|
||||
// Update the modal when there is no more data
|
||||
function nothing_to_display() {
|
||||
var new_content = $(alert_message).hide();
|
||||
$("#modal_show_min_item_body").find("#panel-body").append(new_content);
|
||||
new_content.show('fast');
|
||||
$("#load-more-button").hide();
|
||||
}
|
||||
|
||||
function get_html_and_update_modal(event, truemodal) {
|
||||
event.preventDefault();
|
||||
|
||||
var modal=truemodal;
|
||||
var url = " {{ url_for('showsavedpastes.showpreviewpaste') }}?paste=" + modal.attr('data-path') + "&num=" + modal.attr('data-num');
|
||||
last_clicked_paste = modal.attr('data-num');
|
||||
$.get(url, function (data) {
|
||||
|
||||
// verify that the reveived data is really the current clicked item. Otherwise, ignore it.
|
||||
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];
|
||||
$("#modal_show_min_item_body").html(cleared_data);
|
||||
|
||||
var button = $('<button type="button" id="load-more-button" class="btn btn-outline-primary rounded-circle px-1 py-0" data-url="' + $(modal).attr('data-path') +'" data-toggle="tooltip" data-placement="bottom" title="Load more content"><i class="fas fa-arrow-circle-down mt-1"></i></button>');
|
||||
button.tooltip(button);
|
||||
$("#container-show-more").append(button);
|
||||
|
||||
$("#modal_show_min_item_button_show_item").attr('href', '{{ url_for('showsavedpastes.showsavedpaste') }}?paste=' + $(modal).attr('data-path'));
|
||||
$("#modal_show_min_item_button_show_item").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();
|
||||
}
|
||||
// collapse decoded
|
||||
$('#collapseDecoded').collapse('hide');
|
||||
// On click, donwload all item's content
|
||||
$("#load-more-button").on("click", function (event) {
|
||||
if (complete_item == null) { //Donwload only once
|
||||
$.get("{{ url_for('showsavedpastes.getmoredata') }}"+"?paste="+$(modal).attr('data-path'), function(data, status){
|
||||
complete_item = data;
|
||||
update_preview();
|
||||
});
|
||||
} else {
|
||||
update_preview();
|
||||
}
|
||||
});
|
||||
} else if (can_change_modal_content) {
|
||||
$("#modal_show_min_item_body").html("Ignoring previous not finished query of item #" + received_num);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
|
@ -16,7 +16,7 @@
|
|||
<a class="nav-link" id="page-items-submit" href="{{ url_for('PasteSubmit.PasteSubmit_page') }}" aria-disabled="true"><i class="fas fa-external-link-alt"></i> Submit</a>
|
||||
</li>
|
||||
<li class="nav-item mr-3">
|
||||
<a class="nav-link" id="page-Browse-Items" href="{{ url_for('Tags.Tags_page') }}" aria-disabled="true"><i class="fas fa-tag"></i> Browse Items</a>
|
||||
<a class="nav-link" id="navbar-tags" href="{{ url_for('tags_ui.tags_search_items') }}" aria-disabled="true"><i class="fas fa-tag"></i> Tags</a>
|
||||
</li>
|
||||
<li class="nav-item mr-3">
|
||||
<a class="nav-link" id="page-Tracker" href="{{ url_for('hunter.tracked_menu') }}" aria-disabled="true"><i class="fas fa-crosshairs"></i> Leaks Hunter</a>
|
||||
|
@ -34,7 +34,7 @@
|
|||
<a class="nav-link" id="page-options" href="{{ url_for('settings.settings_page') }}" aria-disabled="true"><i class="fas fa-cog"></i> Server Management</a>
|
||||
</li>
|
||||
<li class="nav-item mr-3">
|
||||
<a class="nav-link" id="page-options" href="{{ url_for('root.logout') }}" aria-disabled="true"><i class="fas fa-sign-out-alt"></i> Log Out</a>
|
||||
<a class="nav-link" id="page-logout" href="{{ url_for('root.logout') }}" aria-disabled="true"><i class="fas fa-sign-out-alt"></i> Log Out</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
|
|
@ -4,20 +4,22 @@
|
|||
</div>
|
||||
<div class="card-body">
|
||||
|
||||
<!-- <div class="row mb-3"> TODO: use condition
|
||||
<div class="col-md-6">
|
||||
<div class="input-group" id="date-range-from">
|
||||
<div class="input-group-prepend"><span class="input-group-text"><i class="far fa-calendar-alt" aria-hidden="true"></i></span></div>
|
||||
<input class="form-control" id="date-range-from-input" placeholder="yyyy-mm-dd" value="{{ date_from }}" name="date_from" autocomplete="off">
|
||||
{%if object_type=='item'%}
|
||||
<div class="row mb-3">
|
||||
<div class="col-md-6">
|
||||
<div class="input-group" id="date-range-from">
|
||||
<div class="input-group-prepend"><span class="input-group-text"><i class="far fa-calendar-alt" aria-hidden="true"></i></span></div>
|
||||
<input class="form-control" id="date-range-from-input" placeholder="yyyy-mm-dd" value="{{ date_from[0:4] }}-{{ date_from[4:6] }}-{{ date_from[6:8] }}" name="date_from" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="input-group" id="date-range-to">
|
||||
<div class="input-group-prepend"><span class="input-group-text"><i class="far fa-calendar-alt" aria-hidden="true"></i></span></div>
|
||||
<input class="form-control" id="date-range-to-input" placeholder="yyyy-mm-dd" value="{{ date_to[0:4] }}-{{ date_to[4:6] }}-{{ date_to[6:8] }}" name="date_to" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="input-group" id="date-range-to">
|
||||
<div class="input-group-prepend"><span class="input-group-text"><i class="far fa-calendar-alt" aria-hidden="true"></i></span></div>
|
||||
<input class="form-control" id="date-range-to-input" placeholder="yyyy-mm-dd" value="{{ date_to }}" name="date_to" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
{%endif%}
|
||||
|
||||
<div class="input-group mb-3">
|
||||
<div class="input-group-prepend">
|
||||
|
@ -53,51 +55,47 @@
|
|||
|
||||
function searchTags() {
|
||||
var data = ltags.getValue();
|
||||
//var date_from = $('#date-range-from-input').val();
|
||||
//var date_to =$('#date-range-to-input').val();
|
||||
//parameter = parameter + "&date_from="+date_from+"&date_to="+date_to
|
||||
var parameter = "?ltags=" + data + "&object_type={{ object_type }}{%if page%}&page={{ page }}{%endif%}";
|
||||
{%if object_type=='item'%}
|
||||
var date_from = $('#date-range-from-input').val();
|
||||
var date_to =$('#date-range-to-input').val();
|
||||
parameter = parameter + "&date_from=" + date_from + "&date_to=" + date_to;
|
||||
{%endif%}
|
||||
window.location.replace("{{ url_for('tags_ui.get_obj_by_tags') }}" + parameter);
|
||||
}
|
||||
function emptyTags() {
|
||||
ltags.clear();
|
||||
}
|
||||
|
||||
// $('#date-range-from').dateRangePicker({
|
||||
// separator : ' to ',
|
||||
// getValue: function(){
|
||||
// if ($('#date-range-from-input').val() && $('#date-range-to-input').val() )
|
||||
// return $('#date-range-from-input').val() + ' to ' + $('#date-range-to-input').val();
|
||||
// else
|
||||
// return '';
|
||||
// },
|
||||
// setValue: function(s,s1,s2){
|
||||
// $('#date-range-from-input').val(s1);
|
||||
// $('#date-range-to-input').val(s2);
|
||||
// }
|
||||
// });
|
||||
// $('#date-range-to').dateRangePicker({
|
||||
// separator : ' to ',
|
||||
// getValue: function(){
|
||||
// if ($('#date-range-from-input').val() && $('#date-range-to-input').val() )
|
||||
// return $('#date-range-from-input').val() + ' to ' + $('#date-range-to-input').val();
|
||||
// else
|
||||
// return '';
|
||||
// },
|
||||
// setValue: function(s,s1,s2){
|
||||
// $('#date-range-from-input').val(s1);
|
||||
// $('#date-range-to-input').val(s2);
|
||||
// }
|
||||
// });
|
||||
|
||||
// tagid + objtype + objid
|
||||
// $('#edit_tags_modal').on('show.bs.modal', function (event) {
|
||||
// var button = $(event.relatedTarget);
|
||||
// var tagid = button.data('tagid')
|
||||
// var objtype = button.data('objtype')
|
||||
// var objid = button.data('objid')
|
||||
// var modal = $(this)
|
||||
// modal.find('#modal_tag_edit_tag_id').text(tagid)
|
||||
// modal.find('#modal_tag_edit_delete_tag').prop("href", "{{ url_for('tags_ui.delete_tag') }}?object_type="+ objtype +"&object_id="+ objid +"&tag="+ tagid)
|
||||
// })
|
||||
{%if object_type=='item'%}
|
||||
$('#date-range-from').dateRangePicker({
|
||||
separator : ' to ',
|
||||
getValue: function(){
|
||||
if ($('#date-range-from-input').val() && $('#date-range-to-input').val() )
|
||||
return $('#date-range-from-input').val() + ' to ' + $('#date-range-to-input').val();
|
||||
else
|
||||
return '';
|
||||
},
|
||||
setValue: function(s,s1,s2){
|
||||
$('#date-range-from-input').val(s1);
|
||||
$('#date-range-to-input').val(s2);
|
||||
}
|
||||
});
|
||||
$('#date-range-to').dateRangePicker({
|
||||
separator : ' to ',
|
||||
getValue: function(){
|
||||
if ($('#date-range-from-input').val() && $('#date-range-to-input').val() )
|
||||
return $('#date-range-from-input').val() + ' to ' + $('#date-range-to-input').val();
|
||||
else
|
||||
return '';
|
||||
},
|
||||
setValue: function(s,s1,s2){
|
||||
$('#date-range-from-input').val(s1);
|
||||
$('#date-range-to-input').val(s2);
|
||||
}
|
||||
});
|
||||
|
||||
{%endif%}
|
||||
|
||||
</script>
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
</h5>
|
||||
<ul class="nav flex-md-column flex-row navbar-nav justify-content-between w-100">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ url_for('Tags.Tags_page') }}" id="nav_tags_search_item">
|
||||
<a class="nav-link" href="{{ url_for('tags_ui.tags_search_items') }}" id="nav_tags_search_item">
|
||||
<i class="far fa-file"></i>
|
||||
Search Items by Tags
|
||||
</a>
|
||||
|
@ -62,49 +62,49 @@
|
|||
</h5>
|
||||
<ul class="nav flex-md-column flex-row navbar-nav justify-content-between w-100">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href='{{url_for('Tags.Tags_page')}}?ltags=infoleak:automatic-detection="credential"' id='nav_tag_infoleakautomatic-detectioncredential'>
|
||||
<a class="nav-link" href='{{url_for('tags_ui.get_obj_by_tags')}}?object_type=item<ags=infoleak:automatic-detection="credential"' id='nav_tag_infoleakautomatic-detectioncredential'>
|
||||
<i class="fas fa-unlock-alt"></i>
|
||||
Credentials
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href='{{url_for('Tags.Tags_page')}}?ltags=infoleak:automatic-detection="credit-card"' id='nav_tag_infoleakautomatic-detectioncredit-card'>
|
||||
<a class="nav-link" href='{{url_for('tags_ui.get_obj_by_tags')}}?object_type=item<ags=infoleak:automatic-detection="credit-card"' id='nav_tag_infoleakautomatic-detectioncredit-card'>
|
||||
<i class="far fa-credit-card"></i>
|
||||
Credit cards
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href='{{url_for('Tags.Tags_page')}}?ltags=infoleak:automatic-detection="mail"' id='nav_tag_infoleakautomatic-detectionmail'>
|
||||
<a class="nav-link" href='{{url_for('tags_ui.get_obj_by_tags')}}?object_type=item<ags=infoleak:automatic-detection="mail"' id='nav_tag_infoleakautomatic-detectionmail'>
|
||||
<i class="fas fa-envelope"></i>
|
||||
Mails
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href='{{url_for('Tags.Tags_page')}}?ltags=infoleak:automatic-detection="cve"' id='nav_tag_infoleakautomatic-detectioncve'>
|
||||
<a class="nav-link" href='{{url_for('tags_ui.get_obj_by_tags')}}?object_type=item<ags=infoleak:automatic-detection="cve"' id='nav_tag_infoleakautomatic-detectioncve'>
|
||||
<i class="fas fa-bug"></i>
|
||||
CVEs
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href='{{url_for('Tags.Tags_page')}}?ltags=infoleak:automatic-detection="onion"' id='nav_tag_infoleakautomatic-detectiononion'>
|
||||
<a class="nav-link" href='{{url_for('tags_ui.get_obj_by_tags')}}?object_type=item<ags=infoleak:automatic-detection="onion"' id='nav_tag_infoleakautomatic-detectiononion'>
|
||||
<i class="fas fa-user-secret"></i>
|
||||
Onions
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href='{{url_for('Tags.Tags_page')}}?ltags=infoleak:automatic-detection="bitcoin-address"' id='nav_tag_infoleakautomatic-detectionbitcoin-address'>
|
||||
<a class="nav-link" href='{{url_for('tags_ui.get_obj_by_tags')}}?object_type=item<ags=infoleak:automatic-detection="bitcoin-address"' id='nav_tag_infoleakautomatic-detectionbitcoin-address'>
|
||||
<i class="fab fa-bitcoin"></i>
|
||||
Bitcoin
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href='{{url_for('Tags.Tags_page')}}?ltags=infoleak:automatic-detection="base64"' id='nav_tag_infoleakautomatic-detectionbase64'>
|
||||
<a class="nav-link" href='{{url_for('tags_ui.get_obj_by_tags')}}?object_type=item<ags=infoleak:automatic-detection="base64"' id='nav_tag_infoleakautomatic-detectionbase64'>
|
||||
<i class="fas fa-lock-open"></i>
|
||||
Base64
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href='{{url_for('Tags.Tags_page')}}?ltags=infoleak:automatic-detection="phone-number"' id='nav_tag_infoleakautomatic-detectionphone-number'>
|
||||
<a class="nav-link" href='{{url_for('tags_ui.get_obj_by_tags')}}?object_type=item<ags=infoleak:automatic-detection="phone-number"' id='nav_tag_infoleakautomatic-detectionphone-number'>
|
||||
<i class="fas fa-phone"></i>
|
||||
Phones
|
||||
</a>
|
||||
|
|
|
@ -32,7 +32,15 @@
|
|||
|
||||
<div class="col-12 col-lg-10" id="core_content">
|
||||
|
||||
{%if dict_tagged["object_type"]=="item"%}
|
||||
{% include 'modals/show_min_item.html' %}
|
||||
{% endif %}
|
||||
|
||||
{% with object_type=dict_tagged['object_type'], current_tags=dict_tagged['current_tags'], object_name=dict_tagged['object_name'] %}
|
||||
{%if 'date' in dict_tagged%}
|
||||
{% set date_from= dict_tagged['date']['date_from'] %}
|
||||
{% set date_to= dict_tagged['date']['date_to'] %}
|
||||
{% endif %}
|
||||
{% include 'tags/block_obj_tags_search.html' %}
|
||||
{% endwith %}
|
||||
|
||||
|
@ -48,6 +56,10 @@
|
|||
<th>status</th>
|
||||
{%elif dict_tagged["object_type"]=="image"%}
|
||||
<th style="max-width: 800px;">Image</th>
|
||||
{%elif dict_tagged["object_type"]=="item"%}
|
||||
<th>Date</th>
|
||||
<th style="max-width: 800px;">Item</th>
|
||||
<th>Action</th>
|
||||
{%endif%}
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -104,6 +116,31 @@
|
|||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
{%elif dict_tagged["object_type"]=="item"%}
|
||||
{% for dict_obj in dict_tagged["tagged_obj"] %}
|
||||
<tr>
|
||||
<td class="pb-0">{{ dict_obj['date'] }}</td>
|
||||
<td class="pb-0">
|
||||
<a target="_blank" href="{{ url_for('showsavedpastes.showsavedpaste') }}?paste={{dict_obj['id']}}" class="text-secondary">
|
||||
<div style="line-height:0.9;">{{ dict_obj['id'] }}</div>
|
||||
</a>
|
||||
<div class="mb-2">
|
||||
{% for tag in dict_obj['tags'] %}
|
||||
<a href="{{ url_for('tags_ui.get_obj_by_tags') }}?object_type={{dict_tagged['object_type']}}<ags={{ tag }}">
|
||||
<span class="badge badge-{{ bootstrap_label[loop.index0 % 5] }}">{{ tag }}</span>
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</td>
|
||||
<td class="pb-0">
|
||||
<button type="button" class="btn btn-light" data-num="{{ loop.index0 + 1 }}" data-toggle="modal" data-target="#modal_show_min_item" data-url="{{ url_for('showsavedpastes.showsaveditem_min') }}?paste={{ dict_obj['id'] }}" data-path="{{ dict_obj['id'] }}">
|
||||
<span class="fas fa-search-plus"></span>
|
||||
</button>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
@ -114,6 +151,9 @@
|
|||
{% with page=dict_tagged['page'], nb_page_max=dict_tagged['nb_pages'], nb_first_elem=dict_tagged['nb_first_elem'], nb_last_elem=dict_tagged['nb_last_elem'], nb_all_elem=dict_tagged['nb_all_elem'] %}
|
||||
{% set object_name= dict_tagged['object_name'] %}
|
||||
{% set target_url=url_for('tags_ui.get_obj_by_tags') + "?object_type=" + dict_tagged['object_type'] + "<ags=" + dict_tagged['current_tags_str'] %}
|
||||
{%if dict_tagged["object_type"]=="item"%}
|
||||
{% set target_url= target_url + "&date_from=" + dict_tagged['date']['date_from'] + "&date_to=" + dict_tagged['date']['date_to'] %}
|
||||
{%endif%}
|
||||
{% include 'pagination.html' %}
|
||||
{% endwith %}
|
||||
{%endif%}
|
||||
|
@ -129,10 +169,16 @@ var ltags;
|
|||
var search_table;
|
||||
|
||||
$(document).ready(function(){
|
||||
$("#navbar-tags").addClass("active");
|
||||
$("#nav_tags_search").removeClass("text-muted");
|
||||
$("#nav_tags_search_{{dict_tagged['object_type']}}").addClass("active");
|
||||
$('#myTable_').DataTable({ "lengthMenu": [ 5, 10, 25, 50, 100 ], "pageLength": 10, "order": [[ 0, "asc" ]] });
|
||||
|
||||
{%if dict_tagged["object_type"]=="item"%}
|
||||
$("[data-toggle='modal']").off('click.openmodal').on("click.openmodal", function (event) {
|
||||
get_html_and_update_modal(event, $(this));
|
||||
});
|
||||
{%endif%}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
Loading…
Reference in a new issue