Skip to content

Commit

Permalink
Address test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
sscottgvit committed Feb 5, 2020
1 parent 05c5e73 commit c1f3cb2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 20 deletions.
2 changes: 1 addition & 1 deletion app/ApplicationInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
4 changes: 2 additions & 2 deletions tests/app/tools/nmap/test_DefaultNmapExporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
42 changes: 25 additions & 17 deletions ui/dialogs.py
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
'''
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 <http://www.gnu.org/licenses/>.
"""
import os
from PyQt5.QtGui import * # for filters dialog
from PyQt5.QtWidgets import *
Expand Down Expand Up @@ -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 = ''
Expand Down Expand Up @@ -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('/')

Expand Down Expand Up @@ -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 }')
Expand Down Expand Up @@ -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"')
###
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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))
Expand All @@ -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)
Expand Down Expand Up @@ -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]:
Expand Down

0 comments on commit c1f3cb2

Please sign in to comment.