eric6/WebBrowser/VirusTotal/VirusTotalDomainReportDialog.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 domain 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
4336
473bf2a8676f Finished implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4335
diff changeset
10 from PyQt5.QtCore import pyqtSlot, Qt
4335
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_VirusTotalDomainReportDialog import Ui_VirusTotalDomainReportDialog
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 VirusTotalDomainReportDialog(QDialog, Ui_VirusTotalDomainReportDialog):
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 domain 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, domain, resolutions, urls, subdomains,
4336
473bf2a8676f Finished implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4335
diff changeset
23 bdCategory, tmCategory, wtsCategory, whois, parent=None):
4335
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 """
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 Constructor
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 @param domain domain name
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 @type str
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 @param resolutions list of resolved host names
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 @type list of dict
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 @param urls list of detected URLs
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 @type list of dict
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 @param subdomains list of subdomains
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 @type list of str
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 @param bdCategory BitDefender categorization
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 @type str
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 @param tmCategory TrendMicro categorization
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 @type str
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 @param wtsCategory Websense ThreatSeeker categorization
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 @type str
4336
473bf2a8676f Finished implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4335
diff changeset
41 @param whois whois information
473bf2a8676f Finished implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4335
diff changeset
42 @type str
4335
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 @param parent reference to the parent widget
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 @type QWidget
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 """
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 super(VirusTotalDomainReportDialog, self).__init__(parent)
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 self.setupUi(self)
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 self.setWindowFlags(Qt.Window)
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 self.headerLabel.setText(
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 self.tr("<b>Report for domain {0}</b>").format(domain))
4336
473bf2a8676f Finished implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4335
diff changeset
52 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
53 UI.PixmapCache.getPixmap("virustotal"))
4335
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 for resolution in resolutions:
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 QTreeWidgetItem(
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 self.resolutionsList,
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 [resolution["ip_address"],
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 resolution["last_resolved"].split()[0]]
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 )
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 self.resolutionsList.resizeColumnToContents(0)
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 self.resolutionsList.resizeColumnToContents(1)
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 self.resolutionsList.sortByColumn(0, Qt.AscendingOrder)
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 if not urls:
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 self.detectedUrlsGroup.setVisible(False)
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 for url in urls:
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 QTreeWidgetItem(
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 self.urlsList,
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 [url["url"],
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 self.tr("{0}/{1}", "positives / total").format(
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 url["positives"], url["total"]),
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 url["scan_date"].split()[0]]
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 )
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 self.urlsList.resizeColumnToContents(0)
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 self.urlsList.resizeColumnToContents(1)
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 self.urlsList.resizeColumnToContents(2)
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 self.urlsList.sortByColumn(0, Qt.AscendingOrder)
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 if not subdomains:
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 self.subdomainsGroup.setVisible(False)
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 else:
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 self.subdomainsList.addItems(subdomains)
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 self.subdomainsList.sortItems()
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 self.bdLabel.setText(bdCategory)
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 self.tmLabel.setText(tmCategory)
a25c157625c4 Started implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 self.wtsLabel.setText(wtsCategory)
4336
473bf2a8676f Finished implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4335
diff changeset
89
473bf2a8676f Finished implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4335
diff changeset
90 self.__whois = whois
473bf2a8676f Finished implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4335
diff changeset
91 self.__whoisDomain = domain
473bf2a8676f Finished implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4335
diff changeset
92 self.whoisButton.setEnabled(bool(whois))
473bf2a8676f Finished implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4335
diff changeset
93
473bf2a8676f Finished implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4335
diff changeset
94 @pyqtSlot()
473bf2a8676f Finished implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4335
diff changeset
95 def on_whoisButton_clicked(self):
473bf2a8676f Finished implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4335
diff changeset
96 """
473bf2a8676f Finished implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4335
diff changeset
97 Private slot to show the whois information.
473bf2a8676f Finished implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4335
diff changeset
98 """
473bf2a8676f Finished implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4335
diff changeset
99 from .VirusTotalWhoisDialog import VirusTotalWhoisDialog
473bf2a8676f Finished implementing the VirusTotal APIv2 interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4335
diff changeset
100 dlg = VirusTotalWhoisDialog(self.__whoisDomain, self.__whois)
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
101 dlg.exec()

eric ide

mercurial