eric6/WebBrowser/VirusTotal/VirusTotalIpReportDialog.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 7923
91e843545d9a
child 8143
2c730d5fd177
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

4335
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
3 # Copyright (c) 2015 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
4335
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to show the VirusTotal IP address report.
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 from PyQt5.QtCore import Qt
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 from PyQt5.QtWidgets import QDialog, QTreeWidgetItem
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 from .Ui_VirusTotalIpReportDialog import Ui_VirusTotalIpReportDialog
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
4336
473bf2a8676f Finished implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4335
diff changeset
15 import UI.PixmapCache
473bf2a8676f Finished implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4335
diff changeset
16
4335
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 class VirusTotalIpReportDialog(QDialog, Ui_VirusTotalIpReportDialog):
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 """
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 Class implementing a dialog to show the VirusTotal IP address report.
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 """
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 def __init__(self, ip, owner, resolutions, urls, parent=None):
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 """
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 Constructor
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 @param ip IP address
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 @type str
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 @param owner owner of the IP address
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 @type str
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 @param resolutions list of resolved host names
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 @type list of dict
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 @param urls list of detected URLs
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 @type list of dict
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 @param parent reference to the parent widget
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 @type QWidget
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 """
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 super(VirusTotalIpReportDialog, self).__init__(parent)
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 self.setupUi(self)
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 self.setWindowFlags(Qt.Window)
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 self.headerLabel.setText(
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 self.tr("<b>Report for IP {0}</b>").format(ip))
4336
473bf2a8676f Finished implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4335
diff changeset
43 self.headerPixmap.setPixmap(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
44 UI.PixmapCache.getPixmap("virustotal"))
4335
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 self.ownerLabel.setText(owner)
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 for resolution in resolutions:
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 QTreeWidgetItem(
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 self.resolutionsList,
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 [resolution["hostname"],
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 resolution["last_resolved"].split()[0]]
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 )
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 self.resolutionsList.resizeColumnToContents(0)
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 self.resolutionsList.resizeColumnToContents(1)
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 self.resolutionsList.sortByColumn(0, Qt.AscendingOrder)
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 if not urls:
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 self.detectedUrlsGroup.setVisible(False)
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 for url in urls:
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 QTreeWidgetItem(
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 self.urlsList,
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 [url["url"],
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 self.tr("{0}/{1}", "positives / total").format(
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 url["positives"], url["total"]),
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 url["scan_date"].split()[0]]
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 )
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 self.urlsList.resizeColumnToContents(0)
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 self.urlsList.resizeColumnToContents(1)
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 self.urlsList.resizeColumnToContents(2)
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 self.urlsList.sortByColumn(0, Qt.AscendingOrder)

eric ide

mercurial