Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
sscottgvit committed Nov 21, 2023
1 parent 83a253f commit 15b6bd2
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 7 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
LEGION 0.4.3

* Revise NMAP import process
* Fix import progress calculations
* Doubleckick to copy hostname (Linux only)
* Script to generate huge bogus NMAP XML imports for testing.

LEGION 0.4.2

* Tweak the screenshooter to use eyewitness as suggested by daniruiz
Expand Down
4 changes: 2 additions & 2 deletions app/ApplicationInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

applicationInfo = {
"name": "LEGION",
"version": "0.4.2",
"build": '1700525714',
"version": "0.4.3",
"build": '1700529501',
"author": "Gotham Security",
"copyright": "2023",
"links": ["http://github.com/GoVanguard/legion/issues", "https://gotham-security.com/legion"],
Expand Down
37 changes: 33 additions & 4 deletions buildHugeNmapTest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import xml.etree.ElementTree as ET
from random import randint, choice, sample
from random import randint, choice, choices, sample
import datetime

def generate_nmap_xml(num_hosts=1000, base_subnet="172.16"):
Expand Down Expand Up @@ -62,20 +62,49 @@ def generate_nmap_xml(num_hosts=1000, base_subnet="172.16"):
"afp": {"product": "Netatalk AFP", "version": "3.1.12"}
}

# Expanded lists for generating hostnames
colors = ["Red", "Blue", "Green", "Yellow", "Purple", "Orange", "Cyan", "Magenta", "Lime", "Pink"]
foods = ["Apple", "Burger", "Cake", "Dumpling", "Eclair", "Pizza", "Sushi", "Taco", "Waffle", "Bagel"]
cities = ["Tokyo", "Paris", "London", "NewYork", "Sydney", "Berlin", "Rome", "Madrid", "Moscow", "Beijing"]
verbs = ["Jumping", "Running", "Flying", "Swimming", "Dancing", "Singing", "Playing", "Walking", "Reading", "Writing"]

# Unique hostname tracker
generated_hostnames = set()

# Function to create unique random hostnames
def generate_hostname():
while True:
parts = [choice(colors), choice(foods), choice(cities), choice(verbs)]
hostname = '.'.join(parts)
# Ensure uniqueness by appending a number if needed
if hostname not in generated_hostnames:
generated_hostnames.add(hostname)
return hostname
else:
hostname += str(randint(0, 9999))
if hostname not in generated_hostnames:
generated_hostnames.add(hostname)
return hostname

# Function to create a random IP address within the extended subnet range
def random_ip(base_subnet, host_number):
subnet_third_octet = host_number // 254
host_fourth_octet = host_number % 254 + 1
return f"{base_subnet}.{subnet_third_octet}.{host_fourth_octet}"

# Generating hosts with updated IP address method
# Generating hosts with updated IP address and hostname method
for i in range(num_hosts):
host_os = choice(list(os_services.keys()))

host = ET.Element("host")
ET.SubElement(host, "status", {"state": "up", "reason": "arp-response", "reason_ttl": "0"})
ET.SubElement(host, "address", {"addr": random_ip(base_subnet, i), "addrtype": "ipv4"})
ET.SubElement(host, "hostnames")

# Hostnames
hostnames = ET.SubElement(host, "hostnames")
num_hostnames = randint(1, 3) # Random number of hostnames per host
for _ in range(num_hostnames):
ET.SubElement(hostnames, "hostname", {"name": generate_hostname(), "type": "user"})

# Ports
ports = ET.SubElement(host, "ports")
Expand Down Expand Up @@ -135,7 +164,7 @@ def random_ip(base_subnet, host_number):
xml_str = xml_header + '\n' + ET.tostring(nmaprun, encoding='unicode', method='xml')
return xml_str

def save_nmap_xml(filename, num_hosts=1000, base_subnet="172.16"):
def save_nmap_xml(filename, num_hosts=200, base_subnet="172.16"):
# Generate the XML content
xml_content = generate_nmap_xml(num_hosts, base_subnet)

Expand Down
3 changes: 3 additions & 0 deletions controller/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ def closeProject(self):
self.view.updateProcessesTableView() # clear process table
self.logic.projectManager.closeProject(self.logic.activeProject)

def copyToClipboard(self, data):
clipboard = QtWidgets.QApplication.clipboard()
clipboard.setText(data) # Assuming item.text() contains the IP or hostname

@timing
def addHosts(self, targetHosts, runHostDiscovery, runStagedNmap, nmapSpeed, scanMode, nmapOptions = []):
Expand Down
9 changes: 9 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,12 @@ legion (0.4.2-0) UNRELEASED; urgency=medium
* Fix typo in startLegion.sh

-- Shane Scott <sscot@gotham-security.com> Mon, 20 Nov 2023 12:50:55 -0600

legion (0.4.3-0) UNRELEASED; urgency=medium

* Revise NMAP import process
* Fix import progress calculations
* Doubleckick to copy hostname (Linux only)
* Script to generate huge bogus NMAP XML imports for testing.

-- Shane Scott <sscott@gotham-security.com> Mon, 20 Nov 2023 19:17:00 -0600
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Priority: optional
Maintainer: GoVanguard <hello@gotham-security.com>
Uploaders: Shane Scott <sscott@gotham-security.com>
Build-Depends: debhelper, python3, python3-requests
Standards-Version: 0.4.2
Standards-Version: 0.4.3
Homepage: https://github.com/GoVanguard/Legion

Package: legion
Expand Down
10 changes: 10 additions & 0 deletions ui/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ def initTables(self): # this function prepares the default settings for each ta
self.HostsTableModel.sort(3, Qt.SortOrder.DescendingOrder)
# Connect the clicked signal of the HostsTableView to the hostTableClick() method
self.ui.HostsTableView.clicked.connect(self.hostTableClick)
self.ui.HostsTableView.doubleClicked.connect(self.hostTableDoubleClick)

##

Expand Down Expand Up @@ -580,6 +581,15 @@ def hostTableClick(self):

def connectServiceNamesTableClick(self):
self.ui.ServiceNamesTableView.clicked.connect(self.serviceNamesTableClick)

def hostTableDoubleClick(self, index):
# Get the item from the model using the index
model = self.ui.HostsTableView.model()
row = index.row()
new_index = model.index(row, 3)
data = model.data(new_index, QtCore.Qt.ItemDataRole.DisplayRole)
if data:
self.controller.copyToClipboard(data)

def serviceNamesTableClick(self):
if self.ui.ServiceNamesTableView.selectionModel().selectedRows():
Expand Down

0 comments on commit 15b6bd2

Please sign in to comment.