Improved Recent Scan Viev

This commit is contained in:
Ajin Abraham
2020-03-05 20:04:32 -05:00
parent 5f5f226fbe
commit 8da16694f9
11 changed files with 40 additions and 36 deletions
+2 -2
View File
@@ -215,7 +215,7 @@ def not_found(request):
def recent_scans(request):
"""Show Recent Scans Route."""
entries = []
db_obj = RecentScansDB.objects.all().order_by('-TS').values()
db_obj = RecentScansDB.objects.all().order_by('-TIMESTAMP').values()
android = StaticAnalyzerAndroid.objects.all()
package_mapping = {}
for item in android:
@@ -328,7 +328,7 @@ class RecentScans(object):
def recent_scans(self):
page = self.request.GET.get('page', 1)
page_size = self.request.GET.get('page_size', 10)
result = RecentScansDB.objects.all().values().order_by('-TS')
result = RecentScansDB.objects.all().values().order_by('-TIMESTAMP')
try:
paginator = Paginator(result, page_size)
content = paginator.page(page)
+1 -1
View File
@@ -17,7 +17,7 @@ def add_to_recent_scan(name, md5, url):
db_obj = RecentScansDB.objects.filter(MD5=md5)
if not db_obj.exists():
new_db_obj = RecentScansDB(
NAME=name, MD5=md5, URL=url, TS=timezone.now())
FILE_NAME=name, MD5=md5, URL=url, TIMESTAMP=timezone.now())
new_db_obj.save()
except Exception:
logger.exception('Adding Scan URL to Database')
+3 -2
View File
@@ -3,10 +3,11 @@ from django.db import models
class RecentScansDB(models.Model):
NAME = models.CharField(max_length=260)
FILE_NAME = models.CharField(max_length=260)
MD5 = models.CharField(max_length=32)
URL = models.URLField()
TS = models.DateTimeField()
TIMESTAMP = models.DateTimeField()
APP_NAME = models.CharField(max_length=260)
PACKAGE_NAME = models.CharField(max_length=260)
VERSION_NAME = models.CharField(max_length=50)
@@ -191,7 +191,7 @@ def save_or_update(update_type,
logger.exception('Updating DB')
try:
values = {
'MD5': app_dic['md5'],
'APP_NAME': app_dic['real_name'],
'PACKAGE_NAME': man_data_dic['packagename'],
'VERSION_NAME': man_data_dic['androvername'],
}
+1 -1
View File
@@ -159,7 +159,7 @@ def save_or_update(update_type,
logger.exception('Updating DB')
try:
values = {
'MD5': app_dict['md5_hash'],
'APP_NAME': info_dict['bin_name'],
'PACKAGE_NAME': info_dict['id'],
'VERSION_NAME': info_dict['bundle_version_name'],
}
+1 -1
View File
@@ -593,7 +593,7 @@ def score(findings):
def update_scan_timestamp(scan_hash):
# Update the last scan time.
tms = timezone.now()
RecentScansDB.objects.filter(MD5=scan_hash).update(TS=tms)
RecentScansDB.objects.filter(MD5=scan_hash).update(TIMESTAMP=tms)
def open_firebase(url):
@@ -118,8 +118,8 @@ def save_or_update(update_type,
logger.exception('Updating DB')
try:
values = {
'MD5': app_dic['md5'],
'PACKAGE_NAME': bin_an_dic['bin_name'],
'APP_NAME': bin_an_dic['bin_name'],
'PACKAGE_NAME': xml_dic['pub_name'],
'VERSION_NAME': xml_dic['version'],
}
RecentScansDB.objects.filter(
File diff suppressed because one or more lines are too long
@@ -297,7 +297,7 @@ div.loading{
<tr>
<td align="center">
<img id="app_icon" src="{% if e.ICON_FOUND %}/download/{{ e.MD5 }}-icon.png{% else %}{% static 'img/no_icon.png' %}{% endif %}"/>
<br/><strong>{{ e.APP_NAME }}</strong>
<br/><strong>{{ e.APP_NAME }} - {{ e.VERSION_NAME }}</strong>
</td>
<td>
{{ e.FILE_NAME }}
+2 -2
View File
@@ -504,10 +504,10 @@ pre {
"content": [
{
"id": 1,
"NAME": "xxxxx.ipa",
"FILE_NAME": "xxxxx.ipa",
"MD5": "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
"URL": "StaticAnalyzer_iOS/?name=xxxxx.ipa&type=ipa&checksum=xxxxxxxxxxxxxxx",
"TS": "2019-03-09T08:08:51.813Z"
"TIMESTAMP": "2019-03-09T08:08:51.813Z"
}
],
"count": 1,
+25 -22
View File
@@ -6,6 +6,7 @@
{% endblock %}
{% block extra_css %}
<link href="{% static "adminlte/plugins/sweetalert2/sweetalert2.min.css" %}" rel="stylesheet">
<style>
#app_icon{
width: 64px;
@@ -41,45 +42,47 @@
<table class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th>App</th>
<th>File</th>
<th>Type</th>
<th>Package-Name</th>
<th>Version</th>
<th>Hash</th>
<th>Date</th>
<th>View</th>
<th>Delete</th>
<th>APP</th>
<th>FILE</th>
<th>TYPE</th>
<th>HASH</th>
<th>SCAN DATE</th>
<th>ACTIONS</th>
</tr>
</thead>
<tbody>
{% for e in entries %}
<tr>
<td>
<td align="center">
<img id="app_icon" src="/download/{{ e.MD5 }}-icon.png" onerror="this.src='{% static 'img/no_icon.png' %}'">
{% if e.PACKAGE_NAME %}
<br/><strong>{{ e.APP_NAME }} - {{ e.VERSION_NAME }}</strong>
</br>{{ e.PACKAGE_NAME }}
{% else %}
</br><span class="badge bg-warning">scan not completed</span>
{% endif %}
</td>
<td>{{ e.NAME }}</td>
<td>
{% if '.apk' == e.NAME|slice:"-4:"%}<i class="fab fa-android fa-3x"></i>
{% elif '.ipa' == e.NAME|slice:"-4:"%}<i class="fab fa-apple fa-3x"></i>
{% elif '.zip' == e.NAME|slice:"-4:"%}<i class="fas fa-file-archive fa-3x"></i>
{% elif '.appx' == e.NAME|slice:"-5:"%}<i class="fab fa-windows fa-3x"></i>
<td>{{ e.FILE_NAME }}
</td>
<td align="center">
{% if '.apk' == e.FILE_NAME|slice:"-4:"%}<i class="fab fa-android fa-3x"></i>
{% elif '.ipa' == e.FILE_NAME|slice:"-4:"%}<i class="fab fa-apple fa-3x"></i>
{% elif '.zip' == e.FILE_NAME|slice:"-4:"%}<i class="fas fa-file-archive fa-3x"></i>
{% elif '.appx' == e.FILE_NAME|slice:"-5:"%}<i class="fab fa-windows fa-3x"></i>
{% endif %}
</td>
<td>{{ e.PACKAGE_NAME }}</td>
<td>{{ e.VERSION_NAME }}</td>
<td>{{ e.MD5 }}</td>
<td>{{ e.TS }}</td>
<td>{{ e.TIMESTAMP }}</td>
<td><p><a class="btn btn-primary" href="../{{ e.URL }}"><i class="fas fa-eye"></i> Static Report</a>
<a class="btn btn-primary" href="../PDF/?md5={{ e.MD5 }}"><i class="fas fa-file-pdf"></i></a>
</p>
{% if '.apk' == e.NAME|slice:"-4:"%}
{% if '.apk' == e.FILE_NAME|slice:"-4:"%}
<p><a class="btn btn-success" href="../dynamic_report/?hash={{ e.MD5 }}&amp;package={{e.PACKAGE}}"><i class="fa fa-mobile"></i> Dynamic Report</a>
</p><p><a class="diffButton btn btn-warning" id="{{ e.MD5 }}_{{ e.NAME }}"><i class="fas fa-not-equal"></i> Diff or Compare</a>
</p><p><a class="diffButton btn btn-warning" id="{{ e.MD5 }}_{{ e.FILE_NAME }}"><i class="fas fa-not-equal"></i> Diff or Compare</a>
</p>
<p> <a class="btn btn-danger" id="{{ e.MD5 }}" onclick="delete_scan(this)" href="#"><i class="fa fa-trash"></i> Delete Scan</a> </p>
{% endif %}
</td>
<td> <a class="btn btn-danger" id="{{ e.MD5 }}" onclick="delete_scan(this)" href="#"><i class="fa fa-trash"></i> Delete</a></td>
</tr>
{% endfor %}
</tbody>