From c1f3cb2f54180e7613587ef77882efe4972d9f84 Mon Sep 17 00:00:00 2001 From: sscottgvit Date: Wed, 5 Feb 2020 05:41:32 -0600 Subject: [PATCH] Address test failures --- app/ApplicationInfo.py | 2 +- .../tools/nmap/test_DefaultNmapExporter.py | 4 +- ui/dialogs.py | 42 +++++++++++-------- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/app/ApplicationInfo.py b/app/ApplicationInfo.py index b263b9d..bd60fe7 100644 --- a/app/ApplicationInfo.py +++ b/app/ApplicationInfo.py @@ -19,7 +19,7 @@ applicationInfo = { "name": "LEGION", "version": "0.3.6", - "build": '1580901813', + "build": '1580902879', "author": "GoVanguard", "copyright": "2020", "links": ["http://github.com/GoVanguard/legion/issues", "https://GoVanguard.com/legion"], diff --git a/tests/app/tools/nmap/test_DefaultNmapExporter.py b/tests/app/tools/nmap/test_DefaultNmapExporter.py index 7c39b75..5dcf9bb 100644 --- a/tests/app/tools/nmap/test_DefaultNmapExporter.py +++ b/tests/app/tools/nmap/test_DefaultNmapExporter.py @@ -29,14 +29,14 @@ def setUp(self, legionLog) -> None: @patch("subprocess.Popen") def test_exportOutputToHtml_WhenProvidedFileNameAndOutputFolder_ExportsOutputSuccessfully(self, processOpen): - exportCommand = f"xsltproc -o some-file.html some-file.xml" + exportCommand = f"xsltproc -o some-file.html nmap.xsl some-file.xml" self.nmapExporter.exportOutputToHtml("some-file", "some-folder/") processOpen.assert_called_once_with(exportCommand, shell=True) self.mockShell.move.assert_called_once_with("some-file.html", "some-folder/") @patch("subprocess.Popen") def test_exportOutputToHtml_WhenExportFailsDueToProcessError_DoesNotMoveAnyFilesToOutputFolder(self, processOpen): - exportCommand = f"xsltproc -o some-bad-file.html some-bad-file.xml" + exportCommand = f"xsltproc -o some-bad-file.html nmap.xsl some-bad-file.xml" processOpen.side_effect = Exception("something went wrong") self.nmapExporter.exportOutputToHtml("some-bad-file", "some-folder/") processOpen.assert_called_once_with(exportCommand, shell=True) diff --git a/ui/dialogs.py b/ui/dialogs.py index 2bac8bb..e569801 100644 --- a/ui/dialogs.py +++ b/ui/dialogs.py @@ -1,16 +1,19 @@ #!/usr/bin/env python - -''' +""" LEGION (https://govanguard.com) Copyright (c) 2020 GoVanguard - This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public + License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later + version. - You should have received a copy of the GNU General Public License along with this program. If not, see . -''' + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + details. + You should have received a copy of the GNU General Public License along with this program. + If not, see . +""" import os from PyQt5.QtGui import * # for filters dialog from PyQt5.QtWidgets import * @@ -47,7 +50,8 @@ def __init__(self, ip, port, service, settings, parent=None): self.checkAddMoreOptions.stateChanged.connect(self.showMoreOptions) def setupLayoutHlayout(self): - hydraServiceConversion = {'login':'rlogin', 'ms-sql-s':'mssql', 'ms-wbt-server':'rdp', 'netbios-ssn':'smb', 'netbios-ns':'smb', 'microsoft-ds':'smb', 'postgresql':'postgres', 'vmware-auth':'vmauthd"'} + hydraServiceConversion = {'login':'rlogin', 'ms-sql-s':'mssql', 'ms-wbt-server':'rdp', 'netbios-ssn':'smb', \ + 'netbios-ns':'smb', 'microsoft-ds':'smb', 'postgresql':'postgres', 'vmware-auth':'vmauthd"'} # sometimes nmap service name is different from hydra service name if self.service is None: self.service = '' @@ -85,7 +89,7 @@ def setupLayoutHlayout(self): self.serviceComboBox.setCurrentIndex(i) break -# self.labelPath = QtWidgets.QLineEdit() # this is the extra input field to insert the path to brute force +# self.labelPath = QtWidgets.QLineEdit() # this is the extra input field to insert the path to brute force # self.labelPath.setFixedWidth(800) # self.labelPath.setText('/') @@ -144,7 +148,9 @@ def setupLayoutHlayout2(self): self.foundUsersRadio.toggle() self.warningLabel = QtWidgets.QLabel() - self.warningLabel.setText('*Note: when using form-based services from the Service menu, select the "Additional Options" checkbox and add the proper arguments for the webpage form. See Hydra documentation for extra help when targeting HTTP/HTTPS forms.') + self.warningLabel.setText('*Note: when using form-based services from the Service menu, select the \ + "Additional Options" checkbox and add the proper arguments for the webpage form. See Hydra \ + documentation for extra help when targeting HTTP/HTTPS forms.') self.warningLabel.setWordWrap(True) self.warningLabel.setAlignment(Qt.AlignRight) self.warningLabel.setStyleSheet('QLabel { color: red }') @@ -271,7 +277,7 @@ def setupLayoutHlayout4(self): def setupLayout(self): ### - self.labelPath = QtWidgets.QLineEdit() # this is the extra input field to insert the path to brute force + self.labelPath = QtWidgets.QLineEdit() # this is the extra input field to insert the path to brute force self.labelPath.setFixedWidth(800) self.labelPath.setText('-m "/login/login.html:username=^USER^&password=^PASS^&Login=Login:failed"') ### @@ -332,7 +338,8 @@ def buildHydraCommand(self, runningfolder, userlistPath, passlistPath): self.port = self.portTextinput.text() self.service = str(self.serviceComboBox.currentText()) self.command = "hydra " + str(self.ip) + " -s " + self.port + " -o " - self.outputfile = runningfolder + "/hydra/" + getTimestamp() + "-" + str(self.ip) + "-" + self.port + "-" + self.service + ".txt" + self.outputfile = runningfolder + "/hydra/" + getTimestamp() + "-" + str(self.ip) + "-" + self.port + "-" + \ + self.service + ".txt" self.command += "\"" + self.outputfile + "\"" if 'form' not in str(self.service): @@ -377,9 +384,9 @@ def buildHydraCommand(self, runningfolder, userlistPath, passlistPath): self.command += " " + self.service -# if self.labelPath.isVisible(): # append the additional field's content, if it was visible +# if self.labelPath.isVisible(): # append the additional field's content, if it was visible if self.checkAddMoreOptions.isChecked(): - self.command += " "+str(self.labelPath.text()) # TODO: sanitise this? + self.command += " "+str(self.labelPath.text()) # TODO: sanitise this? #command = "echo "+escaped_password+" > /tmp/hydra-sub.txt" #os.system(unicode(command)) @@ -394,7 +401,7 @@ def toggleRunButton(self): else: self.runButton.setText('Run') - def resetDisplay(self): # used to be able to display the tool output in both the Brute tab and the tool display panel + def resetDisplay(self): self.display.setParent(None) self.display = QtWidgets.QPlainTextEdit() self.display.setReadOnly(True) @@ -470,8 +477,9 @@ def setupLayout(self): self.setLayout(layout) def getFilters(self): - #return [self.hostsUp.isChecked(), self.hostsDown.isChecked(), self.hostsChecked.isChecked(), self.portsOpen.isChecked(), self.portsFiltered.isChecked(), self.portsClosed.isChecked(), self.portsTcp.isChecked(), self.portsUdp.isChecked(), str(self.hostKeywordText.text()).split()] - return [self.hostsUp.isChecked(), self.hostsDown.isChecked(), self.hostsChecked.isChecked(), self.portsOpen.isChecked(), self.portsFiltered.isChecked(), self.portsClosed.isChecked(), self.portsTcp.isChecked(), self.portsUdp.isChecked(), unicode(self.hostKeywordText.text()).split()] + return [self.hostsUp.isChecked(), self.hostsDown.isChecked(), self.hostsChecked.isChecked(), \ + self.portsOpen.isChecked(), self.portsFiltered.isChecked(), self.portsClosed.isChecked(), \ + self.portsTcp.isChecked(), self.portsUdp.isChecked(), unicode(self.hostKeywordText.text()).split()] def setCurrentFilters(self, filters): if not self.hostsUp.isChecked() == filters[0]: