40 from .AdBlock.AdBlockManager import AdBlockManager |
40 from .AdBlock.AdBlockManager import AdBlockManager |
41 from .OfflineStorage.OfflineStorageConfigDialog import OfflineStorageConfigDialog |
41 from .OfflineStorage.OfflineStorageConfigDialog import OfflineStorageConfigDialog |
42 from .UserAgent.UserAgentMenu import UserAgentMenu |
42 from .UserAgent.UserAgentMenu import UserAgentMenu |
43 from .HelpTabWidget import HelpTabWidget |
43 from .HelpTabWidget import HelpTabWidget |
44 from .Download.DownloadManager import DownloadManager |
44 from .Download.DownloadManager import DownloadManager |
|
45 from .VirusTotalApi import VirusTotalAPI |
45 |
46 |
46 from E5Gui.E5Action import E5Action |
47 from E5Gui.E5Action import E5Action |
47 from E5Gui import E5MessageBox, E5FileDialog |
48 from E5Gui import E5MessageBox, E5FileDialog |
48 |
49 |
49 from E5Network.E5NetworkMonitor import E5NetworkMonitor |
50 from E5Network.E5NetworkMonitor import E5NetworkMonitor |
1370 self.bookmarksToolBar.openUrl.connect(self.openUrl) |
1371 self.bookmarksToolBar.openUrl.connect(self.openUrl) |
1371 self.bookmarksToolBar.newUrl.connect(self.openUrlNewTab) |
1372 self.bookmarksToolBar.newUrl.connect(self.openUrlNewTab) |
1372 self.addToolBarBreak() |
1373 self.addToolBarBreak() |
1373 self.addToolBar(self.bookmarksToolBar) |
1374 self.addToolBar(self.bookmarksToolBar) |
1374 |
1375 |
|
1376 self.addToolBarBreak() |
|
1377 vttb = self.addToolBar(self.trUtf8("VirusTotal")) |
|
1378 vttb.setObjectName("VirusTotalToolBar") |
|
1379 vttb.setIconSize(UI.Config.ToolBarIconSize) |
|
1380 vttb.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) |
|
1381 self.virustotalSearchEdit = QLineEdit() |
|
1382 self.virustotalSearchEdit.setMaximumWidth(250) |
|
1383 self.virustotalSearchEdit.setWhatsThis(self.trUtf8( |
|
1384 """<h2>File search</h2>""" |
|
1385 """<p>In order to search for the last VirusTotal report on a given file""" |
|
1386 """ just enter its hash. Currently the allowed hashes are MD5, SHA1 and""" |
|
1387 """ SHA256. You can also search for a particular file report by typing""" |
|
1388 """ in its permalink id.</p>""" |
|
1389 """<h2>URL search</h2>""" |
|
1390 """<p>URL searches are simple, just type in the given URL, the application""" |
|
1391 """ will normalize it and compare it with the entries in VirusTotal's""" |
|
1392 """ database. Alternatively you may enter the MD5 hash of an URL preceded""" |
|
1393 """ by "url:", e.g. url:7f911bbcf618f052ac6b9928600d2820.</p>""" |
|
1394 """<h2>User search</h2>""" |
|
1395 """<p>Do you want to know whether a friend has a VT Community account?""" |
|
1396 """ Simply type in his nick preceded by the symbol "@", e.g.""" |
|
1397 """ @EmilianoMartinez.</p>""" |
|
1398 """<h2>Search through comments</h2>""" |
|
1399 """<p>The comments in VT Community may often help in disinfecting your PC""" |
|
1400 """ or may proof themselves useful when analysing a particular malware""" |
|
1401 """ sample, comment tags enable users to search through the VT Community""" |
|
1402 """ reviews. The standard file tags are: {0} The standard URL tags are: {1}""" |
|
1403 """User generated tags are preceded by the symbol "#", e.g.""" |
|
1404 """ #disinfect.</p>""" |
|
1405 ).format( |
|
1406 """<ul>""" |
|
1407 """<li>goodware</li>""" |
|
1408 """<li>malware</li>""" |
|
1409 """<li>spamattachmentorlink</li>""" |
|
1410 """<li>p2pdownload</li>""" |
|
1411 """<li>impropagating</li>""" |
|
1412 """<li>networkworm</li>""" |
|
1413 """<li>drivebydownload</li>""" |
|
1414 """</ul>""", |
|
1415 """<ul>""" |
|
1416 """<li>malicious</li>""" |
|
1417 """<li>benign</li>""" |
|
1418 """<li>malewaredownload</li>""" |
|
1419 """<li>phishingsite</li>""" |
|
1420 """<li>browserexploit</li>""" |
|
1421 """<li>spamlink</li>""" |
|
1422 """</ul>""", |
|
1423 )) |
|
1424 self.virustotalSearchEdit.textChanged.connect(self.__virusTotalSearchChanged) |
|
1425 self.virustotalSearchEdit.returnPressed.connect(self.__virusTotalSearch) |
|
1426 vttb.addWidget(self.virustotalSearchEdit) |
|
1427 self.virustotalSearchAct = vttb.addAction( |
|
1428 UI.PixmapCache.getIcon("virustotal.png"), |
|
1429 self.trUtf8("Search VirusTotal"), |
|
1430 self.__virusTotalSearch) |
|
1431 self.virustotalSearchAct.setEnabled(False) |
|
1432 vttb.addSeparator() |
|
1433 self.virustotalScanCurrentAct = vttb.addAction( |
|
1434 UI.PixmapCache.getIcon("virustotal.png"), |
|
1435 self.trUtf8("Scan current site"), |
|
1436 self.__virusTotalScanCurrentSite) |
|
1437 if not Preferences.getHelp("VirusTotalEnabled") or \ |
|
1438 Preferences.getHelp("VirusTotalServiceKey") == "": |
|
1439 self.virustotalSearchEdit.setEnabled(False) |
|
1440 self.virustotalScanCurrentAct.setEnabled(False) |
|
1441 |
1375 def __nextTab(self): |
1442 def __nextTab(self): |
1376 """ |
1443 """ |
1377 Private slot used to show the next tab. |
1444 Private slot used to show the next tab. |
1378 """ |
1445 """ |
1379 fwidget = QApplication.focusWidget() |
1446 fwidget = QApplication.focusWidget() |
1431 @param title new title (string) |
1498 @param title new title (string) |
1432 """ |
1499 """ |
1433 self.historyManager().updateHistoryEntry( |
1500 self.historyManager().updateHistoryEntry( |
1434 self.currentBrowser().url().toString(), title) |
1501 self.currentBrowser().url().toString(), title) |
1435 |
1502 |
1436 def newTab(self, link=None): |
1503 def newTab(self, link=None, requestData=None): |
1437 """ |
1504 """ |
1438 Public slot called to open a new help window tab. |
1505 Public slot called to open a new help window tab. |
1439 |
1506 |
1440 @param link file to be displayed in the new window (string or QUrl) |
1507 @param link file to be displayed in the new window (string or QUrl) |
1441 """ |
1508 @param requestData tuple containing the request data (QNetworkRequest, |
1442 self.tabWidget.newBrowser(link) |
1509 QNetworkAccessManager.Operation, QByteArray) |
|
1510 """ |
|
1511 self.tabWidget.newBrowser(link, requestData) |
1443 |
1512 |
1444 def newWindow(self, link=None): |
1513 def newWindow(self, link=None): |
1445 """ |
1514 """ |
1446 Public slot called to open a new help browser dialog. |
1515 Public slot called to open a new help browser dialog. |
1447 |
1516 |
1863 self.historyManager().preferencesChanged() |
1932 self.historyManager().preferencesChanged() |
1864 |
1933 |
1865 self.tabWidget.preferencesChanged() |
1934 self.tabWidget.preferencesChanged() |
1866 |
1935 |
1867 self.searchEdit.preferencesChanged() |
1936 self.searchEdit.preferencesChanged() |
|
1937 |
|
1938 if not Preferences.getHelp("VirusTotalEnabled") or \ |
|
1939 Preferences.getHelp("VirusTotalServiceKey") == "": |
|
1940 self.virustotalSearchEdit.setEnabled(False) |
|
1941 self.virustotalScanCurrentAct.setEnabled(False) |
|
1942 else: |
|
1943 self.virustotalSearchEdit.setEnabled(True) |
|
1944 self.virustotalScanCurrentAct.setEnabled(True) |
|
1945 self.__virusTotalSearchChanged(self.virustotalSearchEdit.text()) |
1868 |
1946 |
1869 def __showAcceptedLanguages(self): |
1947 def __showAcceptedLanguages(self): |
1870 """ |
1948 """ |
1871 Private slot to configure the accepted languages for web pages. |
1949 Private slot to configure the accepted languages for web pages. |
1872 """ |
1950 """ |
2573 Public method to record keyboard modifiers. |
2651 Public method to record keyboard modifiers. |
2574 |
2652 |
2575 @param modifiers keyboard modifiers to record (Qt.KeyboardModifiers) |
2653 @param modifiers keyboard modifiers to record (Qt.KeyboardModifiers) |
2576 """ |
2654 """ |
2577 self.__eventKeyboardModifiers = modifiers |
2655 self.__eventKeyboardModifiers = modifiers |
|
2656 |
|
2657 ########################################################################### |
|
2658 ## Interface to VirusTotal below ## |
|
2659 ########################################################################### |
|
2660 |
|
2661 def __virusTotalSearchChanged(self, txt): |
|
2662 """ |
|
2663 Private slot to react upon changes of the VirusTotal search text. |
|
2664 |
|
2665 @param txt contents of the search (string) |
|
2666 """ |
|
2667 self.virustotalSearchAct.setEnabled(txt != "" and \ |
|
2668 Preferences.getHelp("VirusTotalEnabled") and \ |
|
2669 Preferences.getHelp("VirusTotalServiceKey") != "") |
|
2670 |
|
2671 def __virusTotalSearch(self): |
|
2672 """ |
|
2673 Private slot to search VirusTotal for a given entry. |
|
2674 """ |
|
2675 search = self.virustotalSearchEdit.text() |
|
2676 if search: |
|
2677 requestData = VirusTotalAPI.getSearchRequestData(search) |
|
2678 self.newTab(requestData=requestData) |
|
2679 |
|
2680 def __virusTotalScanCurrentSite(self): |
|
2681 """ |
|
2682 Private slot to ask VirusTotal for a scan of the URL of the current browser. |
|
2683 """ |
|
2684 cb = self.currentBrowser() |
|
2685 if cb is not None: |
|
2686 url = cb.url() |
|
2687 if url.scheme() in ["http", "https", "ftp"]: |
|
2688 self.requestVirusTotalScan(url) |
|
2689 |
|
2690 def requestVirusTotalScan(self, url): |
|
2691 """ |
|
2692 Public method to submit a request to scan an URL by VirusTotal. |
|
2693 """ |
|
2694 vt = VirusTotalAPI(self) |
|
2695 ok, res = vt.submitUrl(url) |
|
2696 if ok: |
|
2697 self.newTab(vt.getUrlScanReportUrl(res)) |
|
2698 fileScanPageUrl = vt.getFileScanReportUrl(res) |
|
2699 if fileScanPageUrl: |
|
2700 self.newTab(fileScanPageUrl) |
|
2701 else: |
|
2702 E5MessageBox.critical(self, |
|
2703 self.trUtf8("VirusTotal Scan"), |
|
2704 self.trUtf8("""<p>The VirusTotal scan could not be""" |
|
2705 """ scheduled.<p>\n<p>Reason: {0}</p>""").format(res)) |