Example #1
0
	def lancement(self, type):		
		config = {
				"host": "192.168.1.1",
			    "deb_port": 0, 
				"end_port": 90, 
				"timeout": 0.01,
				"type":type
				}

		if self.scan!=None and self.scan.isRunning():
			self.scan.terminate()

		if self.scan==None or not self.scan.isRunning():
			self.output.setText("")
			self.scan = Scan(config)
			self.scan.info.connect(self.discover)
			self.scan.fini.connect(self.finished)
			self.scan.down.connect(self.down)
			self.scan.output.connect(self.write_output)
			self.scan.start()
Example #2
0
class Main(QWidget):
	def __init__(self, parent=None):
		super(Main,self).__init__(parent)
		# Fenêtre principale 
		self.windows = QMainWindow()
		self.windows.setWindowIcon(QIcon('src/ana.ico'))
		self.windows.setWindowTitle("PortSC v0.1")
		# Zone centrale et layout principal
		self.zoneCentrale = QWidget()
		self.windowsLayout = QGridLayout()
		# Groubox et layout
		self.groupWidget = QGroupBox("Configuration")		
		# Form 
		self.formLayout = QFormLayout()
		self.inputHost = QLineEdit()
		self.inputDEBplage = QSpinBox()
		self.inputENDplage = QSpinBox()
		self.inputDEBplage.setRange(0, 65535)
		self.inputENDplage.setRange(0, 65535)
		self.inputTimeOut = QDoubleSpinBox()
		self.inputTimeOut.setRange(0.01, 3600.00)
		self.inputTimeOut.setSingleStep(0.01)
		self.formLayout.addRow("Host", self.inputHost)
		self.formLayout.addRow("Début plage", self.inputDEBplage)
		self.formLayout.addRow("Fin plage", self.inputENDplage)
		self.formLayout.addRow("Timeout", self.inputTimeOut)
		# Ajout du layout au group
		self.groupWidget.setLayout(self.formLayout)
		# Ajout du widget au layout principal
		self.windowsLayout.addWidget(self.groupWidget, 0, 0, 1, 2)
		# Création et ajout du boutton scanner	
		self.buttonSubmitSYN = QPushButton("SYN scanner")
		self.buttonSubmitDis = QPushButton("SYN random scanner")
		self.windowsLayout.addWidget(self.buttonSubmitSYN, 1, 0)
		self.windowsLayout.addWidget(self.buttonSubmitDis, 1, 1)
		# Création de la zone d'output
		self.output = QTextEdit()
		self.output.setReadOnly(True)
		# Ajout de la zone dans le layout principal
		self.windowsLayout.addWidget(self.output, 2, 0, 1, 2)
		# Ajout des layout à la zone centrale
		self.zoneCentrale.setLayout(self.windowsLayout)
		# Ajout de la zone centrale à la fenêtre
		self.windows.setCentralWidget(self.zoneCentrale)
		self.windows.show()
		# Fonction	
		self.scan = None
		self.buttonSubmitSYN.clicked.connect(lambda: self.lancement("syn"))
		self.buttonSubmitDis.clicked.connect(lambda: self.lancement("random_syn"))

	def lancement(self, type):		
		config = {
				"host": "192.168.1.1",
			    "deb_port": 0, 
				"end_port": 90, 
				"timeout": 0.01,
				"type":type
				}

		if self.scan!=None and self.scan.isRunning():
			self.scan.terminate()

		if self.scan==None or not self.scan.isRunning():
			self.output.setText("")
			self.scan = Scan(config)
			self.scan.info.connect(self.discover)
			self.scan.fini.connect(self.finished)
			self.scan.down.connect(self.down)
			self.scan.output.connect(self.write_output)
			self.scan.start()

	def write_output(self, data):
			self.output.append(data)

	def discover(self, i):
		"""lancé à chaque réception d'info émis par le thread"""
		
		self.output.append(str(i) + " open")
		QCoreApplication.processEvents() 

	def finished(self, time, opened):
		self.output.append("Finish in "+ str(time) + " seconds. " + str(int(self.inputENDplage.text()) - int(self.inputDEBplage.text())) + " ports scanned")

	def down(self):
		self.output.append("Host appear to be down, please check host input")