Skip to content

Commit

Permalink
Added extra parameter functions
Browse files Browse the repository at this point in the history
  • Loading branch information
haraldaarz committed Aug 8, 2023
1 parent 2cbd084 commit 9c36870
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 23 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@ Once you have the application running, you can use it to perform scans. Follow t
- **Efficient Keyboard Interaction:** Initiate scans using the Return key for quicker navigation.
- **Code Optimization:** Remove unnecessary star (*) imports to ensure a cleaner codebase.
- **Fix Freeze Bug:** Fix the bug that causes the application to freeze when a large scan is performed.
- Thread for Nmap scan

35 changes: 12 additions & 23 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import sys
import subprocess
import os
import threading
from threading import Thread
# import ipaddress
# import socket
from datetime import datetime
from PyQt6.QtCore import QTimer
from PyQt6.QtWidgets import *

class Window(QMainWindow):
Expand All @@ -28,11 +31,14 @@ def __init__(self):
self.ip_address_input = QLineEdit()
self.ports_input = QLineEdit()
self.rate_input = QLineEdit()
self.extra_input = QLineEdit()
formLayout = QFormLayout()
formLayout.addRow("IP address:", self.ip_address_input)
formLayout.addRow("Ports:", self.ports_input)
formLayout.addRow("Rate:", self.rate_input)
formLayout.addRow("Extra arguments:", self.extra_input)
self.rate_input.setPlaceholderText("Optional")
self.extra_input.setPlaceholderText("Optional")
self.dialogLayout.addLayout(formLayout)

# Create checkboxes for either a TCP or UDP scan. Only one can be selected at a time, and the default is TCP. Make the boxes right next to each other.
Expand All @@ -55,9 +61,6 @@ def __init__(self):
self.dialogLayout.addLayout(checkbox_layout)





buttons = QDialogButtonBox()
buttons.setStandardButtons(
QDialogButtonBox.StandardButton.Cancel
Expand All @@ -74,33 +77,28 @@ def __init__(self):
# Create a QLabel for the status bar
self.status_label = QLabel("Status: Idle")
self.statusBar().addWidget(self.status_label)

self.status_bar = self.statusBar() # Store the status bar instance

self._createMenu()
#self._createToolBar()
self._createStatusBar()


def buttonOK_clicked(self):
ip_address = self.ip_address_input.text()
ports = self.ports_input.text()
rate = self.rate_input.text()
protocol = "TCP" if self.tcp_checkbox.isChecked() else "UDP"
vuln_scan = self.vuln_checkbox.isChecked()

extra = self.extra_input.text()

# Validate input (you may want to add further validation logic)
if not ip_address or not ports:
QMessageBox.warning(self, "Input Error", "Please fill in IP and ports.")
return


try:
# Construct the nmap command

now = datetime.now()
dt_string = now.strftime("%d-%m-%Y-%H-%M-%S")
filename = "scan_output-" + dt_string + ".txt"

nmap_cmd = ["nmap", "-sV", "-p", ports, "--stats-every", "1s", "-oG", filename]

if rate:
Expand All @@ -114,15 +112,16 @@ def buttonOK_clicked(self):
else:
nmap_cmd.extend(["-sU", ip_address])

if extra:
nmap_cmd.extend(extra.split())

result = subprocess.run(nmap_cmd, capture_output=True, text=True)

# Open a new tab with the contents of the output file
with open(filename, "r") as file:
output_data = file.read()
self.create_output_tab(output_data, ip_address)

#QMessageBox.information(self, "Scan complete", "The scan is complete.")


except subprocess.CalledProcessError as e:
QMessageBox.warning(self, "Error", f"An error occurred: {e}")
Expand All @@ -131,7 +130,6 @@ def buttonOK_clicked(self):
QMessageBox.warning(self, "Error", f"An unexpected error occurred: {e}")



def create_output_tab(self, content, ip_address):
# Create a new tab and add a text area to display the content
results_tab = QWidget()
Expand All @@ -150,8 +148,6 @@ def buttonCancel_clicked(self):
pass




def closeEvent(self, event):
if self.tab_widget.count() > 0:
message = QMessageBox()
Expand Down Expand Up @@ -193,7 +189,6 @@ def _createMenu(self):
menu.addAction("&Load config", self.close)
menu.addAction("&Save config", self.close)


edit_menu = self.menuBar().addMenu("&Edit")
edit_menu.addAction("&Undo")
edit_menu.addAction("&Redo")
Expand All @@ -203,12 +198,6 @@ def _createMenu(self):
settings_menu.addAction("&About")


# def _createToolBar(self):
# tools = QToolBar()
# tools.addAction("Exit", self.close)

# self.addToolBar(tools)

def _createStatusBar(self):
status = QStatusBar()
status.showMessage("Status progess: Running?")
Expand Down

0 comments on commit 9c36870

Please sign in to comment.