fix: [UI showDomain] fix down domain history

pull/453/head
Terrtia 2019-12-16 15:55:50 +01:00
parent fffb4464c6
commit b4f49f9e81
No known key found for this signature in database
GPG Key ID: 1E1B1F50D84613D0
4 changed files with 69 additions and 64 deletions

View File

@ -283,15 +283,16 @@ def get_domain_items_crawled(domain, domain_type, port, epoch=None, items_link=F
item_crawled['epoch'] = item_root['epoch'] item_crawled['epoch'] = item_root['epoch']
item_crawled['date'] = time.strftime('%Y/%m/%d - %H:%M.%S', time.gmtime(item_root['epoch'])) item_crawled['date'] = time.strftime('%Y/%m/%d - %H:%M.%S', time.gmtime(item_root['epoch']))
item_crawled['items'] = [] item_crawled['items'] = []
for item in get_domain_items(domain, item_root['root_item']): if item_root['root_item'] != str(item_root['epoch']):
dict_item = {"id": item} for item in get_domain_items(domain, item_root['root_item']):
if items_link: dict_item = {"id": item}
dict_item['link'] = Item.get_item_link(item) if items_link:
if item_screenshot: dict_item['link'] = Item.get_item_link(item)
dict_item['screenshot'] = Item.get_item_screenshot(item) if item_screenshot:
if item_tag: dict_item['screenshot'] = Item.get_item_screenshot(item)
dict_item['tags'] = Tag.get_item_tags_minimal(item) if item_tag:
item_crawled['items'].append(dict_item) dict_item['tags'] = Tag.get_item_tags_minimal(item)
item_crawled['items'].append(dict_item)
return item_crawled return item_crawled
def get_link_tree(): def get_link_tree():
@ -540,7 +541,7 @@ class Domain(object):
def __init__(self, domain, port=None): def __init__(self, domain, port=None):
self.domain = str(domain) self.domain = str(domain)
self.type = get_domain_type(domain) self.type = get_domain_type(domain)
if self.is_domain_up(): if self.domain_was_up():
self.current_port = sanathyse_port(port, self.domain, self.type) self.current_port = sanathyse_port(port, self.domain, self.type)
def get_domain_name(self): def get_domain_name(self):

View File

@ -61,7 +61,7 @@ def showDomain():
dict_domain = domain.get_domain_metadata() dict_domain = domain.get_domain_metadata()
dict_domain['domain'] = domain_name dict_domain['domain'] = domain_name
if domain.is_domain_up(): if domain.domain_was_up():
dict_domain = {**dict_domain, **domain.get_domain_correlation()} dict_domain = {**dict_domain, **domain.get_domain_correlation()}
dict_domain['correlation_nb'] = Domain.get_domain_total_nb_correlation(dict_domain) dict_domain['correlation_nb'] = Domain.get_domain_total_nb_correlation(dict_domain)
dict_domain['origin_item'] = domain.get_domain_last_origin() dict_domain['origin_item'] = domain.get_domain_last_origin()
@ -69,7 +69,8 @@ def showDomain():
dict_domain['tags_safe'] = Tag.is_tags_safe(dict_domain['tags']) dict_domain['tags_safe'] = Tag.is_tags_safe(dict_domain['tags'])
dict_domain['history'] = domain.get_domain_history_with_status() dict_domain['history'] = domain.get_domain_history_with_status()
dict_domain['crawler_history'] = domain.get_domain_items_crawled(items_link=True, epoch=epoch, item_screenshot=True, item_tag=True) # # TODO: handle multiple port dict_domain['crawler_history'] = domain.get_domain_items_crawled(items_link=True, epoch=epoch, item_screenshot=True, item_tag=True) # # TODO: handle multiple port
dict_domain['crawler_history']['random_item'] = random.choice(dict_domain['crawler_history']['items']) if dict_domain['crawler_history']['items']:
dict_domain['crawler_history']['random_item'] = random.choice(dict_domain['crawler_history']['items'])
return render_template("showDomain.html", dict_domain=dict_domain, bootstrap_label=bootstrap_label, return render_template("showDomain.html", dict_domain=dict_domain, bootstrap_label=bootstrap_label,
modal_add_tags=Tag.get_modal_add_tags(dict_domain['domain'], tag_type="domain")) modal_add_tags=Tag.get_modal_add_tags(dict_domain['domain'], tag_type="domain"))

View File

@ -449,7 +449,7 @@ if (d.popover) {
} else { } else {
desc = desc + "Red" desc = desc + "Red"
} }
desc = desc + ";\"><i class=\"fas" desc = desc + ";\"><i class=\"fas "
if (data["status"]) { if (data["status"]) {
desc = desc + "fa-check-circle" desc = desc + "fa-check-circle"
} else { } else {

View File

@ -287,52 +287,54 @@
{{dict_domain["crawler_history"]["port"]}} {{dict_domain["crawler_history"]["port"]}}
</span> </span>
</div> </div>
<h5>Crawled Items</h5> <h5>Crawled Items {% if not dict_domain["crawler_history"]["items"] %}: DOWN{% endif %}</h5>
</div> </div>
</div> </div>
<table class="table table-striped table-bordered table-hover" id="myTable_1"> {% if dict_domain["crawler_history"]["items"] %}
<thead class="thead-dark"> <table class="table table-striped table-bordered table-hover" id="myTable_1">
<tr> <thead class="thead-dark">
<th>Crawled Pastes</th> <tr>
<th class="text-center"><i class="fas fa-images"></i></th> <th>Crawled Pastes</th>
</tr> <th class="text-center"><i class="fas fa-images"></i></th>
</thead> </tr>
<tbody> </thead>
{% for item in dict_domain["crawler_history"]["items"] %} <tbody>
<tr> {% for item in dict_domain["crawler_history"]["items"] %}
<td> <tr>
<a target="_blank" href="{{ url_for('showsavedpastes.showsavedpaste') }}?paste={{item["id"]}}" class="text-secondary"> <td>
<div style="line-height:0.9;">{{ item["link"] }}</div> <a target="_blank" href="{{ url_for('showsavedpastes.showsavedpaste') }}?paste={{item["id"]}}" class="text-secondary">
</a> <div style="line-height:0.9;">{{ item["link"] }}</div>
<div> </a>
{% for tag in item["tags"] %} <div>
<a href="{{ url_for('Tags.Tags_page') }}?ltags={{ tag["tag"] }}"> {% for tag in item["tags"] %}
<span class="badge badge-{{ bootstrap_label[loop.index0 % 5] }} pull-left">{{ tag["min_tag"] }}</span> <a href="{{ url_for('Tags.Tags_page') }}?ltags={{ tag["tag"] }}">
</a> <span class="badge badge-{{ bootstrap_label[loop.index0 % 5] }} pull-left">{{ tag["min_tag"] }}</span>
{% endfor %} </a>
</div> {% endfor %}
</td> </div>
<td class="text-center"> </td>
{%if item["screenshot"]%} <td class="text-center">
<span class="icon_img" onclick="reload_image('{{ item["screenshot"] }}', '{{ item["link"] }}', '{{ item["id"] }}');" id="{{ item["screenshot"].replace('/', '') }}"> {%if item["screenshot"]%}
<i class="far fa-image"></i> <span class="icon_img" onclick="reload_image('{{ item["screenshot"] }}', '{{ item["link"] }}', '{{ item["id"] }}');" id="{{ item["screenshot"].replace('/', '') }}">
<i class="far fa-image"></i>
</button>
{%endif%}
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="text-center mb-4">
<a href="{{ url_for('hiddenServices.download_domain') }}?domain={{domain}}&port={{port}}{% if epoch %}&epoch={{epoch}}{% endif %}" target="blank" style="font-size: 15px">
<button class="btn btn-info"><i class="fas fa-download"></i> Download Domain Content
</button> </button>
{%endif%} </a>
</td> </div>
</tr> {%endif%}
{% endfor %}
</tbody>
</table>
<div class="text-center mb-4">
<a href="{{ url_for('hiddenServices.download_domain') }}?domain={{domain}}&port={{port}}{% if epoch %}&epoch={{epoch}}{% endif %}" target="blank" style="font-size: 15px">
<button class="btn btn-info"><i class="fas fa-download"></i> Download Domain Content
</button>
</a>
</div>
{%endif%} {%endif%}
{% if dict_domain["history"] %} {% if dict_domain["history"] %}
@ -456,17 +458,18 @@ img.addEventListener("error", img_error);
var draw_img = false; var draw_img = false;
{%if "crawler_history" in dict_domain%} {%if "crawler_history" in dict_domain%}
{%if dict_domain['crawler_history']['random_item']['screenshot']%} {%if "random_item" in dict_domain['crawler_history']%}
var screenshot = "{{dict_domain['crawler_history']['random_item']['screenshot']}}"; {%if dict_domain['crawler_history']['random_item']['screenshot']%}
var selected_icon = $("#"+screenshot.replace(/\//g, "")); var screenshot = "{{dict_domain['crawler_history']['random_item']['screenshot']}}";
selected_icon.addClass("icon_selected"); var selected_icon = $("#"+screenshot.replace(/\//g, ""));
selected_icon.removeClass("icon_img"); selected_icon.addClass("icon_selected");
selected_icon.removeClass("icon_img");
$("#screenshot_link").attr("href", screenshot_href + "{{dict_domain['crawler_history']['random_item']['id']}}");
$("#screenshot_link").attr("href", screenshot_href + "{{dict_domain['crawler_history']['random_item']['id']}}"); $("#screenshot_link").text("{{dict_domain['crawler_history']['random_item']['link']}}");
$("#screenshot_link").text("{{dict_domain['crawler_history']['random_item']['link']}}"); {%else%}
{%else%} var screenshot = "";
var screenshot = ""; {%endif%}
{%endif%} {%endif%}
{%else%} {%else%}
var screenshot = ""; var screenshot = "";