Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions natlas-server/app/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ def ctime(s, human=False):
return parser.parse(s).strftime("%Y-%m-%d %H:%M")


@bp.app_template_filter("hashpath")
def hashpath(inhash):
return f"{inhash[0:2]}/{inhash[2:4]}/{inhash}.png"
@bp.app_template_filter("get_screenshot_path")
def get_screenshot_path(inhash: str, service: str = "HTTP"):
ext_map = {"HTTP": ".png", "HTTPS": ".png", "VNC": ".jpg"}

return f"{inhash[0:2]}/{inhash[2:4]}/{inhash}{ext_map[service]}"
Comment on lines +15 to +18
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand this is a short-term fix since you mentioned you were going to add a better strategy, but we shouldn't make assumptions like this in the rendering logic just in case we change formats.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, this just brings the rendering logic in line with the logic in screenshot processing:

for item in screenshots:
if item["service"] == "VNC":
file_ext = ".jpg"
else: # Handles http, https files from aquatone/chromium-headless
file_ext = ".png"

With the agent rearchitecture we'll probably lose backwards compatibility and it's the perfect time to make big changes to the data model too for a 0.7.0 release.

Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ <h5 class="mt-2">Tags</h5>
<div class="image-browser-service p-2">{{ screenshot.service }}</div>
<div class="image-browser-port p-2">{{ screenshot.host }}:{{ screenshot.port }}</div>
</div>
<img class="img-responsive img-thumbnail" data-path='/media/original/{{screenshot.hash|hashpath}}' data-ip='{{host.ip}}' data-scan_id='{{host.scan_id}}' src='/media/thumbs/{{screenshot.thumb_hash|hashpath}}' alt="{{ screenshot.host }} - {{ screenshot.port }}{%if screenshot.host != host.ip %} ({{host.ip}}){%endif%}">
<img class="img-responsive img-thumbnail" data-path='/media/original/{{screenshot.hash|get_screenshot_path(screenshot.service)}}' data-ip='{{host.ip}}' data-scan_id='{{host.scan_id}}' src='/media/thumbs/{{screenshot.thumb_hash|get_screenshot_path(screenshot.service)}}' alt="{{ screenshot.host }} - {{ screenshot.port }}{%if screenshot.host != host.ip %} ({{host.ip}}){%endif%}">
</div>
{% endif %}
{% endfor %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h5 class="border-bottom">
<div class="image-browser-service p-2">{{ screenshot.service }}</div>
<div class="image-browser-port p-2">{{ screenshot.host }}:{{ screenshot.port }}</div>
</div>
<img class="img-responsive img-thumbnail" data-path='/media/original/{{screenshot.hash|hashpath}}' data-ip='{{ip}}' data-scan_id='{{entry.scan_id}}' src='/media/thumbs/{{screenshot.thumb_hash|hashpath}}' alt="{{ screenshot.host }} - {{ screenshot.port }}{%if screenshot.host != ip %} ({{ip}}){%endif%}">
<img class="img-responsive img-thumbnail" data-path='/media/original/{{screenshot.hash|get_screenshot_path(screenshot.service)}}' data-ip='{{ip}}' data-scan_id='{{entry.scan_id}}' src='/media/thumbs/{{screenshot.thumb_hash|get_screenshot_path(screenshot.service)}}' alt="{{ screenshot.host }} - {{ screenshot.port }}{%if screenshot.host != ip %} ({{ip}}){%endif%}">
</div>
</div>
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h5 class="mt-2">Tags</h5>
{% for screenshot in host.screenshots %}
{% if screenshot.hash %}
<h5 class="mt-2">{{ screenshot.service }}</h5>
<div class="expand-img"><img class="img-responsive img-thumbnail" data-path='/media/original/{{screenshot.hash|hashpath}}' src='/media/thumbs/{{screenshot.thumb_hash|hashpath}}' alt="{{ host.ip }} - {{ screenshot.service }} Screenshot"></div>
<div class="expand-img"><img class="img-responsive img-thumbnail" data-path='/media/original/{{screenshot.hash|get_screenshot_path(screenshot.service)}}' src='/media/thumbs/{{screenshot.thumb_hash|get_screenshot_path(screenshot.service)}}' alt="{{ host.ip }} - {{ screenshot.service }} Screenshot"></div>
{% endif %}
{% endfor %}
</div><!--meta column-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h5 class="border-bottom">
{% if screenshot.hash %}
<div class="col-xs-12 col-sm-3">
<strong class="mt-2">{{ screenshot.service }}</strong>
<div class="expand-img"><img class="img-responsive img-thumbnail" data-path='/media/original/{{screenshot.hash|hashpath}}' src='/media/thumbs/{{screenshot.thumb_hash|hashpath}}' alt="{{ entry.ctime|ctime }} - {{ screenshot.service }}"></div>
<div class="expand-img"><img class="img-responsive img-thumbnail" data-path='/media/original/{{screenshot.hash|get_screenshot_path(screenshot.service)}}' src='/media/thumbs/{{screenshot.thumb_hash|get_screenshot_path(screenshot.service)}}' alt="{{ entry.ctime|ctime }} - {{ screenshot.service }}"></div>
</div>
{% endif %}
{% if screenshot.path %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ <h5 class="mt-2">Tags</h5>
{% if screenshot.hash %}
<h5 class="mt-2">Port {{ screenshot.port }}</h5>
<small>{{screenshot.host}}</small>
<div class="expand-img"><img class="img-responsive img-thumbnail" data-path='/media/original/{{screenshot.hash|hashpath}}' src='/media/thumbs/{{screenshot.thumb_hash|hashpath}}' alt="{{ host.ip }} - {{ screenshot.service }} Screenshot"></div>
<div class="expand-img"><img class="img-responsive img-thumbnail" data-path='/media/original/{{screenshot.hash|get_screenshot_path(screenshot.service)}}' src='/media/thumbs/{{screenshot.thumb_hash|get_screenshot_path(screenshot.service)}}' alt="{{ host.ip }} - {{ screenshot.service }} Screenshot"></div>
{% endif %}
{% endfor %}
</div><!--meta column-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h5 class="border-bottom">
{% if screenshot.hash %}
<div class="col-xs-12 col-sm-3">
<strong class="mt-2">{{ screenshot.service }}</strong>
<div class="expand-img"><img class="img-responsive img-thumbnail" data-path='/media/original/{{screenshot.hash|hashpath}}' src='/media/thumbs/{{screenshot.thumb_hash|hashpath}}' alt="{{ entry.ctime|ctime }} - {{ screenshot.service }}"></div>
<div class="expand-img"><img class="img-responsive img-thumbnail" data-path='/media/original/{{screenshot.hash|get_screenshot_path(screenshot.service)}}' src='/media/thumbs/{{screenshot.thumb_hash|get_screenshot_path(screenshot.service)}}' alt="{{ entry.ctime|ctime }} - {{ screenshot.service }}"></div>
</div>
{% endif %}
{% if screenshot.path %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ <h5 class="mt-2">Tags</h5>
<div class="image-browser-service p-2">{{ screenshot.service }}</div>
<div class="image-browser-port p-2">{{ screenshot.host }}:{{ screenshot.port }}</div>
</div>
<img class="img-responsive img-thumbnail" data-path='/media/original/{{screenshot.hash|hashpath}}' data-ip='{{host.ip}}' data-scan_id='{{host.scan_id}}' src='/media/thumbs/{{screenshot.thumb_hash|hashpath}}' alt="{{ screenshot.host }} - {{ screenshot.port }}{%if screenshot.host != host.ip %} ({{host.ip}}){%endif%}">
<img class="img-responsive img-thumbnail" data-path='/media/original/{{screenshot.hash|get_screenshot_path(screenshot.service)}}' data-ip='{{host.ip}}' data-scan_id='{{host.scan_id}}' src='/media/thumbs/{{screenshot.thumb_hash|get_screenshot_path(screenshot.service)}}' alt="{{ screenshot.host }} - {{ screenshot.port }}{%if screenshot.host != host.ip %} ({{host.ip}}){%endif%}">
</div>
{% endif %}
{% endfor %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h5 class="border-bottom">
<div class="image-browser-service p-2">{{ screenshot.service }}</div>
<div class="image-browser-port p-2">{{ screenshot.host }}:{{ screenshot.port }}</div>
</div>
<img class="img-responsive img-thumbnail" data-path='/media/original/{{screenshot.hash|hashpath}}' data-ip='{{ip}}' data-scan_id='{{entry.scan_id}}' src='/media/thumbs/{{screenshot.thumb_hash|hashpath}}' alt="{{ screenshot.host }} - {{ screenshot.port }}{%if screenshot.host != ip %} ({{ip}}){%endif%}">
<img class="img-responsive img-thumbnail" data-path='/media/original/{{screenshot.hash|get_screenshot_path(screenshot.service)}}' data-ip='{{ip}}' data-scan_id='{{entry.scan_id}}' src='/media/thumbs/{{screenshot.thumb_hash|get_screenshot_path(screenshot.service)}}' alt="{{ screenshot.host }} - {{ screenshot.port }}{%if screenshot.host != ip %} ({{ip}}){%endif%}">
</div>
</div>
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion natlas-server/app/templates/main/screenshots.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h2 class="sub-header">{{total_screenshots}} screenshots across {{total_hosts}}
<div class="image-browser-service p-2">{{ screenshot.service }}</div>
<div class="image-browser-port p-2">{{ screenshot.host }}:{{ screenshot.port }}</div>
</div>
<img class="img-responsive img-thumbnail" data-path='/media/original/{{screenshot.hash|hashpath}}' data-ip='{{host.ip}}' data-scan_id='{{host.scan_id}}' src='/media/thumbs/{{screenshot.thumb_hash|hashpath}}' alt="{{ screenshot.host }} - {{ screenshot.port }}{%if screenshot.host != host.ip %} ({{host.ip}}){%endif%}">
<img class="img-responsive img-thumbnail" data-path='/media/original/{{screenshot.hash|get_screenshot_path(screenshot.service)}}' data-ip='{{host.ip}}' data-scan_id='{{host.scan_id}}' src='/media/thumbs/{{screenshot.thumb_hash|get_screenshot_path(screenshot.service)}}' alt="{{ screenshot.host }} - {{ screenshot.port }}{%if screenshot.host != host.ip %} ({{host.ip}}){%endif%}">
</div>
</div>
{% endif %}
Expand Down