|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2015 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog to show the VirusTotal domain report. |
|
8 """ |
|
9 |
|
10 from __future__ import unicode_literals |
|
11 |
|
12 from PyQt5.QtCore import pyqtSlot, Qt |
|
13 from PyQt5.QtWidgets import QDialog, QTreeWidgetItem |
|
14 |
|
15 from .Ui_VirusTotalDomainReportDialog import Ui_VirusTotalDomainReportDialog |
|
16 |
|
17 import UI.PixmapCache |
|
18 |
|
19 |
|
20 class VirusTotalDomainReportDialog(QDialog, Ui_VirusTotalDomainReportDialog): |
|
21 """ |
|
22 Class implementing a dialog to show the VirusTotal domain report. |
|
23 """ |
|
24 def __init__(self, domain, resolutions, urls, subdomains, |
|
25 bdCategory, tmCategory, wtsCategory, whois, parent=None): |
|
26 """ |
|
27 Constructor |
|
28 |
|
29 @param domain domain name |
|
30 @type str |
|
31 @param resolutions list of resolved host names |
|
32 @type list of dict |
|
33 @param urls list of detected URLs |
|
34 @type list of dict |
|
35 @param subdomains list of subdomains |
|
36 @type list of str |
|
37 @param bdCategory BitDefender categorization |
|
38 @type str |
|
39 @param tmCategory TrendMicro categorization |
|
40 @type str |
|
41 @param wtsCategory Websense ThreatSeeker categorization |
|
42 @type str |
|
43 @param whois whois information |
|
44 @type str |
|
45 @param parent reference to the parent widget |
|
46 @type QWidget |
|
47 """ |
|
48 super(VirusTotalDomainReportDialog, self).__init__(parent) |
|
49 self.setupUi(self) |
|
50 self.setWindowFlags(Qt.Window) |
|
51 |
|
52 self.headerLabel.setText( |
|
53 self.tr("<b>Report for domain {0}</b>").format(domain)) |
|
54 self.headerPixmap.setPixmap( |
|
55 UI.PixmapCache.getPixmap("virustotal.png")) |
|
56 |
|
57 for resolution in resolutions: |
|
58 QTreeWidgetItem( |
|
59 self.resolutionsList, |
|
60 [resolution["ip_address"], |
|
61 resolution["last_resolved"].split()[0]] |
|
62 ) |
|
63 self.resolutionsList.resizeColumnToContents(0) |
|
64 self.resolutionsList.resizeColumnToContents(1) |
|
65 self.resolutionsList.sortByColumn(0, Qt.AscendingOrder) |
|
66 |
|
67 if not urls: |
|
68 self.detectedUrlsGroup.setVisible(False) |
|
69 for url in urls: |
|
70 QTreeWidgetItem( |
|
71 self.urlsList, |
|
72 [url["url"], |
|
73 self.tr("{0}/{1}", "positives / total").format( |
|
74 url["positives"], url["total"]), |
|
75 url["scan_date"].split()[0]] |
|
76 ) |
|
77 self.urlsList.resizeColumnToContents(0) |
|
78 self.urlsList.resizeColumnToContents(1) |
|
79 self.urlsList.resizeColumnToContents(2) |
|
80 self.urlsList.sortByColumn(0, Qt.AscendingOrder) |
|
81 |
|
82 if not subdomains: |
|
83 self.subdomainsGroup.setVisible(False) |
|
84 else: |
|
85 self.subdomainsList.addItems(subdomains) |
|
86 self.subdomainsList.sortItems() |
|
87 |
|
88 self.bdLabel.setText(bdCategory) |
|
89 self.tmLabel.setText(tmCategory) |
|
90 self.wtsLabel.setText(wtsCategory) |
|
91 |
|
92 self.__whois = whois |
|
93 self.__whoisDomain = domain |
|
94 self.whoisButton.setEnabled(bool(whois)) |
|
95 |
|
96 @pyqtSlot() |
|
97 def on_whoisButton_clicked(self): |
|
98 """ |
|
99 Private slot to show the whois information. |
|
100 """ |
|
101 from .VirusTotalWhoisDialog import VirusTotalWhoisDialog |
|
102 dlg = VirusTotalWhoisDialog(self.__whoisDomain, self.__whois) |
|
103 dlg.exec_() |