def currentNH(self,ip): ifc = IPv4Interface(self.myIp("mask")) Tools().MsgSystem("IP Scan Ongoing","...") nm = nmap.PortScanner() nm.scan(hosts=ip+'/24', arguments='-n -sP -PE -PA21,23,80,3389') hosts_list = nm.all_hosts() for lettre in hosts_list : if lettre == self.myIp("ip"): Database("knownIps","id","hostname","address","NULL",f"{currentPc}",f"{lettre}").insertInDatabase() else : print("L'adresse ip : "+lettre+" a été identifié sur votre réseau actuel") answer=input("Connaissez vous cette adresse ip ? [yes/no] \n> ") if answer == "yes": name=input("Nommez là \n> ") Database("knownIps","id","hostname","address","NULL",f"{name}",f"{lettre}").insertInDatabase() Database("reseau","id","Network","Programme","Nature","Information","NULL",f"Network : {ifc.network}","NBook","Online",f"{lettre}").insertInDatabase() elif answer == "no" : Database("unknownIps","id","address","NULL",f"{lettre}").insertInDatabase() else : print("Wrong answer") hosts_list = str(hosts_list) hosts_list = hosts_list.strip("[]") hosts_list = hosts_list.replace("',","") hosts_list = hosts_list.replace("'","") Database("reseau","id","Network","Programme","Nature","Information","NULL",f"Network : {ifc.network}","NBook","currentNetworkHosts",f"{hosts_list}").insertInDatabase() Tools().MsgSystem("Current host list recovered","+")
def networkSpace(self): previousIp=Database("reseau","Information","Nature","previousIp").getFromDatabase() if self.monIp != previousIp[0] : Tools().Notification(f"Vous avez changé d'espace Réseau\nPrevious IP : {previousIp[0]} \n Current IP : {self.monIp}") Tools().Rapport("Changement Espace Réseau") Tools().Rapport(f"Previous IP {previousIp[0]}") Tools().Rapport(f"Current IP {self.monIp}") Database('reseau',"Information",self.monIp,"Nature","currentIp").updateValue() Database('reseau',"Information",self.monIp,"Nature","previousIp").updateValue() Network().networkScan(self.monIp)
def Scanip(self): toDisplay = [] if self.lineEdit.text() == "" : Database("rapportExecution","id","Programme","Information","NULL","Tobias","{ Tobias Network's Client Message } : [-] Aucune adresse ip saisie").insertInDatabase() else : Tools().Notification("IP Scan ongoing") Database("rapportExecution","id","Programme","Information","NULL","Tobias","IP Scan ongoing").insertInDatabase() nm = nmap.PortScanner() nm.scan(self.lineEdit.text(), '1-1024') for host in nm.all_hosts(): #HÔTES SUR LE RESEAU #Trying something toDisplay.append('%s' % (host)) toDisplay.append('%s' % (nm[host].hostname())) ################################### #Trying something toDisplay.append('%s' % nm[host].state()) ################################### for proto in nm[host].all_protocols(): #Trying something toDisplay.append('%s' % proto) ################################### lport = nm[host][proto].keys() for port in lport: #Trying something toDisplay.append('port : %s' % (port)) toDisplay.append('%s' % (nm[host][proto][port]['state'])) ################################### Tools().Notification("IP Scan is Done") Database("rapportExecution","id","Programme","Information","NULL","Tobias","IP Scan is Done").insertInDatabase() for i in range(0,len(toDisplay)): self.listWidget.insertItem(i,toDisplay[i])
def saveAddresses(self): mydb = mysql.connector.connect( host="localhost", user="******", passwd=self.MagicWord, ) if self.getAddresses() == " ": Command = mydb.cursor() Command.execute("USE tobiasdb") Ins = "INSERT INTO backbone (id,statut,ipAddress) VALUES (NULL,'Allowed','{}')".format( self.lineEdit.text()) Command.execute(Ins) mydb.commit() elif self.getAddresses() != " ": Database("backbone", "ipAddress", self.lineEdit.text(), "statut", "Allowed").updateValue() else: Command = mydb.cursor() Command.execute("USE tobiasdb") Ins = "INSERT INTO backbone (id,statut,ipAddress) VALUES (NULL,'Allowed',{})".format( self.lineEdit.text()) Command.execute(Ins) mydb.commit()
def getItems(self): Commande = [] indexObjets = [] nObjets = self.listWidget.count() if nObjets > 0: for i in range(0, nObjets): items = self.listWidget.item(i).text() indexObjets.append(items) for item in indexObjets: Command = self.mydb.cursor() Command.execute("USE tobiasdb") Command.execute( f"SELECT command FROM creator WHERE name='{item}'") for x in Command: for lettre in x: Commande.append(lettre) result = Database("creator", "command", "name", f"{item}").getFromDatabase() #L'item n'a pas de commande , il sera donc executé comme un argument étrangé if result is None: Commande.append(str(item)) print("L'item : " + item + " A été rajouté en temps qu'argument") list_of_strings = [str(s) for s in Commande] joined_string = " ".join(list_of_strings)
def Comparaison(self): p=self.ipActuelles() m=self.Liste_Autorisée() correct = 0 trueList=[] for i in range(0,len(p)): for k in range(0,len(self.Liste_Autorisée())): if p[i] == m[k]: correct=correct+1 if correct >= 1 : trueList.append(p[i]) else : pass else : pass badssh=list(set(p) - set(trueList)) for h in range(0,len(badssh)): pts=subprocess.getoutput("who | egrep '"+badssh[h]+"' | sort -u | uniq | awk '{print $2}' ") os.system("ps -aux | egrep 'sshd:' | egrep 'joel@'"+str(pts)+"|awk '{print $2}' | xargs kill ") Database("backbone","id","statut","ipAddress","NULL","Unallowed",f"{badssh[h]}").insertInDatabase() Tools().Notification(" Tentative de connexion non approuvé en cours") print("Denied Access")
def Hebergeur(self): self.label1.setText("Etat serveur : On") self.update() if self.lineEdit_6.text() != "" : host,port = (self.lineEdit_6.text(),5567) if self.lineEdit_4.text() != "" : host,port = (self.lineEdit_6.text(),self.lineEdit_4.text()) else : pass else : host,port = ('',5567) if self.lineEdit_4.text() != "" : host,port = ('',int(self.lineEdit_4.text())) else : pass prise = socket.socket(socket.AF_INET,socket.SOCK_STREAM) prise.bind((host,port)) #Associer à Adresse IP Database("rapportExecution","id","Programme","Information","NULL","Tobias","Le serveur est initialisé").insertInDatabase() while True : prise.listen(10) #Lier à port défini dans le tuple plus haut connexion, address = prise.accept() data = connexion.recv(2048) #Recevoir une donnée data = data.decode("utf8") Database("rapportExecution","id","Programme","Information","NULL","Hebergeur",f"{data}").insertInDatabase() self.update() connexion.close() prise.close() self.label1.setText("Etat serveur : Off")
def openPacketWindow(self): Utilisateur = os.environ["USER"] sys.path.insert(1, f"/home/{Utilisateur}/Archetype/Tobi") from Library.DBook import Database path = Database().getPaths('packets', 'Executables') print("Please write your password in the terminal") os.system(f"{path}")
def getAddresses(self): a = Database("backbone", "ipAddress", "statut", "Allowed").getFromDatabase() list_of_strings = [str(s) for s in a] joined_string = " ".join(list_of_strings) return joined_string
def getModuleData(self,searchingFor,fieldName='user'): self.confs = Database().getPaths('path','ConfigurationJson') with open(self.confs,"r") as config : content = json.load(config) for parameters in content['Configurations'] : for keys,values in parameters[fieldName].items() : if searchingFor == keys : return values
def Connecteur(self): if self.lineEdit_2.text() != "" : host,port = (self.lineEdit_2.text(),5567) if self.lineEdit_17.text() != "" : host,port = (self.lineEdit_2.text(),int(self.lineEdit_17.text())) else : pass else : host,port = ('',5567) if self.lineEdit_17.text() != "" : host,port = ('',int(self.lineEdit_17.text())) else : pass try : socket_Nedih = socket.socket(socket.AF_INET,socket.SOCK_STREAM)#Indispensable socket_Nedih.connect((host,port)) Database("rapportExecution","id","Programme","Information","NULL","Tobias","{ Tobias Socket's Client Message } : [+] Connecté").insertInDatabase() if self.lineEdit_16.text() != "" : data=self.lineEdit_16.text() else : data="Hey je suis connecté" data=data.encode("utf8") socket_Nedih.sendall(data) except : Database("rapportExecution","id","Programme","Information","NULL","Tobias","{ Tobias Socket's Client Message } : [-] Failed").insertInDatabase() finally : socket_Nedih.close()
def ipScan(self,ip): ifc = IPv4Interface(self.myIp("mask")) Tools().MsgSystem("IP Scan Ongoing","...") nm = nmap.PortScanner() nm.scan(ip, '1-1024') for host in nm.all_hosts(): #HÔTES SUR LE RESEAU Database("reseau","id","Network","Programme","Nature","Information","NULL",f"Network : {ifc.network}","NBook","ipScan","---------------------").insertInDatabase() Database("reseau","id","Network","Programme","Nature","Information","NULL",f"Network : {ifc.network}","NBook","ipScan",f"{host} : {nm[host].hostname()}").insertInDatabase() Database("reseau","id","Network","Programme","Nature","Information","NULL",f"Network : {ifc.network}","NBook","ipScan",f"State : {nm[host].state()}").insertInDatabase() for proto in nm[host].all_protocols(): Database("reseau","id","Network","Programme","Nature","Information","NULL",f"Network : {ifc.network}","NBook","ipScan",f"Protocol : {proto}").insertInDatabase() lport = nm[host][proto].keys() for port in lport: Database("reseau","id","Network","Programme","Nature","Information","NULL",f"Network : {ifc.network}","NBook","ipScan",f"Port | State : {port} {nm[host][proto][port]['state']}").insertInDatabase() Tools().MsgSystem("IP Scan Done","+")
def connexion(self): a = subprocess.getoutput("ss | egrep -i ssh | wc -l ") b = Database("reseau", "Information", "Nature", "Liaison SSH Etablie").getFromDatabase() if int(b[0]) == int(a): pass elif int(b[0]) < int(a): Database("reseau", "Information", str(a), "Nature", "Liaison SSH Etablie").updateValue() Tools().Notification("Liaison SSH Etablie") print("SSh Connection Established") #SMS("0694232624","Quelqu'un est là ") else: Database("reseau", "Information", str(a), "Nature", "Liaison SSH Etablie").updateValue() Tools().Notification("Liaison SSH Arrêtée") print("SSh Connection Unestablished")
def createBloc(self): Database("creator", "id", "name", "type", "command", "category", "pattern", "NULL", f"{self.lineEdit.text()}", "Bloc", f"{self.lineEdit_6.text()}", f"{self.comboBox.currentText()}", f"{self.spinBox.value()}").insertInDatabase() Tools().Notification("Block Successfully Created") self.lineEdit_6.clear() self.lineEdit.clear() self.spinBox.setValue(0) self.fill()
def globalScan(self) : toDisplay = [] Tools().Notification("Network IP Scan ongoing") Database("rapportExecution","id","Programme","Information","NULL","Tobias","Network IP Scan ongoing").insertInDatabase() nm = nmap.PortScanner() nm.scan(hosts=Network().myIp("mask"), arguments='-n -sP -PE -PA21,23,80,3389') hosts_list = [(x, nm[x]['status']['state']) for x in nm.all_hosts()] for host, status in hosts_list: toDisplay.append(host+" : "+status) nm.scan(host, '1-1024') toDisplay.append('Host : %s (%s)' % (host, nm[host].hostname())) for proto in nm[host].all_protocols(): toDisplay.append('Protocol : %s' % proto) lport = nm[host][proto].keys() for port in lport: toDisplay.append(('port : %s\tstate : %s' % (port, nm[host][proto][port]['state']))) Tools().Notification("The Network IP Scan is Done") Database("rapportExecution","id","Programme","Information","NULL","Tobias","The Network IP Scan is Done").insertInDatabase() for i in range(0,len(toDisplay)): self.listWidget.insertItem(i,toDisplay[i])
def __init__(self): from Library.DBook import Database self.confs = Database().getPaths('path', 'ConfigurationJson') self.networkB = Database().getPaths('network', 'sysCommandsDirectory') from PyQt5 import QtCore, QtGui, QtWidgets self.user = os.environ["USER"] #User's name #Launching Sequence if len(sys.argv) > 1: if sys.argv[1] == "Start": self.firstStartSequence() #Working elif sys.argv[1] == "Terminal": # self.terminalMode() pass else: self.threadLoop() app = QtWidgets.QApplication(sys.argv) MainWindow = QtWidgets.QMainWindow() ui = ByPass() ui.setupUi(MainWindow) MainWindow.show() sys.exit(app.exec_())
def getMyPorts(self): #---------------DECL-------------------------- currentPc=subprocess.getoutput("hostname") #---------------END DECL-------------------------- nm = nmap.PortScanner() nm.scan(self.monIp, '1-1024') for host in nm.all_hosts(): for proto in nm[host].all_protocols(): lport = nm[host][proto].keys() for port in lport: self.portList.append(port) #---------------CUSTOM METHODS-------------------------- Database(f"{currentPc}","id","name","field","data","NULL","openPorts","Hardware",f"{self.portList}").insertInDatabase()
def setupUi(self, MainWindow): sys.path.insert(1, f"/home/{Utilisateur}/Archetype/Tobi") from Library.DBook import Database image = Database().getPaths('icon', 'Images') self.MainWindow = MainWindow from PyQt5 import QtCore, QtGui, QtWidgets MainWindow.setObjectName("MainWindow") MainWindow.resize(556, 237) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.lineEdit_2 = QtWidgets.QLineEdit(self.centralwidget) self.lineEdit_2.setGeometry(QtCore.QRect(30, 40, 221, 32)) self.lineEdit_2.setObjectName("lineEdit_2") self.lineEdit = QtWidgets.QLineEdit(self.centralwidget) self.lineEdit.setGeometry(QtCore.QRect(30, 90, 221, 32)) self.lineEdit.setObjectName("lineEdit") self.lineEdit.setEchoMode(QtWidgets.QLineEdit.Password) self.pushButton = QtWidgets.QPushButton(self.centralwidget) self.pushButton.setGeometry(QtCore.QRect(30, 150, 88, 34)) self.pushButton.setObjectName("pushButton") self.lineEdit.returnPressed.connect(self.login) self.pushButton.clicked.connect(self.login) self.label = QtWidgets.QLabel(self.centralwidget) self.label.setGeometry(QtCore.QRect(320, 20, 161, 191)) self.label.setText("") self.label.setPixmap(QtGui.QPixmap(image)) self.label.setObjectName("label") self.radioButton = QtWidgets.QRadioButton(self.centralwidget) self.radioButton.setGeometry(QtCore.QRect(150, 160, 105, 22)) self.radioButton.setObjectName("radioButton") self.label.raise_() self.lineEdit.raise_() self.lineEdit_2.raise_() self.radioButton.raise_() MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtWidgets.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 556, 30)) self.menubar.setObjectName("menubar") MainWindow.setMenuBar(self.menubar) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow)
def networkScan(self,ip): ifc = IPv4Interface(self.myIp("mask")) Tools().MsgSystem("Network IP Scan Ongoing","...") nm = nmap.PortScanner() nm.scan(hosts=ip+'/24', arguments='-n -sP -PE -PA21,23,80,3389') hosts_list = [(x, nm[x]['status']['state']) for x in nm.all_hosts()] for host, status in hosts_list: Database("reseau","id","Network","Programme","Nature","Information","NULL",f"Network : {ifc.network}","NBook","NetworkIpScan",f"{host} : {status}").insertInDatabase() nm.scan(host, '1-1024') Database("reseau","id","Network","Programme","Nature","Information","NULL",f"Network : {ifc.network}","NBook","NetworkIpScan","-----------------------------").insertInDatabase() Database("reseau","id","Network","Programme","Nature","Information","NULL",f"Network : {ifc.network}","NBook","NetworkIpScan",f"{host} : {nm[host].hostname()}").insertInDatabase() for proto in nm[host].all_protocols(): Database("reseau","id","Network","Programme","Nature","Information","NULL",f"Network : {ifc.network}","NBook","NetworkIpScan","-----------------------------").insertInDatabase() Database("reseau","id","Network","Programme","Nature","Information","NULL",f"Network : {ifc.network}","NBook","NetworkIpScan",f"Port : {proto}").insertInDatabase() lport = nm[host][proto].keys() for port in lport: Database("reseau","id","Network","Programme","Nature","Information","NULL",f"Network : {ifc.network}","NBook","NetworkIpScan",f"Port | State {port} | {nm[host][proto][port]['state']}").insertInDatabase() Tools().MsgSystem("The Network IP Scan is Done","+")
def __init__(self): self.confs = Database().getPaths('path','ConfigurationJson')
def storeData(self): import hashlib import sys sys.path.insert(1,"/home/joel/Archetype/Tobi") from Library.DBook import Database self.confs = Database().getPaths('path','ConfigurationJson') self.networkCSV = Database().getPaths('path','NetworkCSV') import json #Hash Mot_de_passe_Entre=(self.lineEdit_2.text()) Mot_de_passe_Entre=Mot_de_passe_Entre.encode() Mot_de_passe_chiffre = hashlib.sha1(Mot_de_passe_Entre).hexdigest() Database("passwords","id","Information","NULL","{}".format(Mot_de_passe_chiffre)).insertInDatabase() #Conserver en fichier json newConfig = { "Configurations": [ { "Backbone": { "ipScan" : "False", "networkSpace" : "False" , "allow/Deny access" : "False" }, "Riot": { "authorized_keys" : "False", "crontabCheck" : "False", "connexions" : "False", "processus" : "False" }, "General" : { "AllyComputer" : "False" , "Internet Protocol" : "False" , "Langue" : "FR" }, "user": { "name": self.lineEdit.text(), "prenom": self.lineEdit_3.text(), "phone number" : self.lineEdit_4.text(), "adresse mail" : self.lineEdit_5.text() }, "Tobias" : { "name": "MainTobias", "local dbpassword" : self.lineEdit_2.text(), "MainServer": self.lineEdit_6.text() } } ] } with open(self.confs,"w") as config : json.dump(newConfig,config,indent=2) with open(self.networkCSV,"w") as variable : variable.write("address,state,action") variable.write("\n0.0.0.0,CONNECTED,TELL")
def firstStartSequence(self): databasePassword = getpass.getpass("Mot de passe de base de donnée : ") os.environ['MDP'] = databasePassword newConfig = { "Configurations": [{ "Backbone": { "ipScan": "False", "networkSpace": "False", "allow/Deny access": "False" }, "Riot": { "authorized_keys": "False", "crontabCheck": "False", "connexions": "False", "processus": "False" }, "General": { "AllyComputer": "False", "Internet Protocol": "False", "Langue": "FR" }, "user": { "name": "Toula", "prenom": "Joel", "phone number": "0694232624", "adresse mail": "*****@*****.**" }, "Tobias": { "name": "MainTobias", "local dbpassword": databasePassword } }] } with open(f"{self.confs}", "w") as config: json.dump(newConfig, config, indent=2) from launcher import firstPart from launcher import PromptWindow firstPart().fromZeroToHero() #Work in Progress from Library.NBook import Network from Library.DBook import Database from Backbone import Backbone from PyQt5 import QtCore, QtGui, QtWidgets print("Launching startSequence") """ Execute the Start Sequence everytime Tobias is summoned Make sure the packages are here and configure what needs to be for the first start """ #Install packages #Creates and deploy databases firstPart().createDatabases() #Works os.system(f"{self.networkB}") #First Start interface and input password Database("backbone", "id", "statut", "ipAddress", "NULL", "Allowed", f"{Network().myIp('ip')}").insertInDatabase() #Creates rsa'keys firstPart().rsaKeys() #Port Scan Backbone().getMyPorts() #Get the athorized_keys file copy # Security.initialisationAutorizedKeys() #Get the Crontab file copy # Security.initialisationCrontab() #Get Network Informations , initialize values in the database #Get the diffrent ips on my network Network().currentNH(Network().myIp("ip")) #Do an in-depth check on the ips Network().networkScan(Network().myIp("ip")) PromptWindow()
def setupUi(self, MainWindow): from PyQt5 import QtCore, QtGui, QtWidgets sys.path.insert(1, f"/home/{Utilisateur}/Archetype/Tobi") from Library.DBook import Database image = Database().getPaths('icon', 'Images') MainWindow.setObjectName("MainWindow") MainWindow.resize(553, 177) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.label = QtWidgets.QLabel(self.centralwidget) self.label.setGeometry(QtCore.QRect(20, 20, 251, 81)) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(image), QtGui.QIcon.Normal, QtGui.QIcon.Off) MainWindow.setWindowIcon(icon) font = QtGui.QFont() font.setFamily("Bitstream Vera Sans Mono") font.setPointSize(20) font.setBold(True) font.setItalic(True) font.setWeight(75) self.label.setFont(font) self.label.setObjectName("label") self.listWidget = QtWidgets.QListWidget(self.centralwidget) self.listWidget.setGeometry(QtCore.QRect(280, 10, 261, 111)) self.listWidget.setObjectName("listWidget") self.listWidget.itemDoubleClicked.connect(self.start) for i in range(0, len(self.featureContent)): self.listWidget.insertItem(i, self.featureContent[i]) MainWindow.setCentralWidget(self.centralwidget) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.menuBar = QtWidgets.QMenuBar(MainWindow) self.menuBar.setGeometry(QtCore.QRect(0, 0, 1049, 30)) self.menuBar.setObjectName("menuBar") self.menuOutils = QtWidgets.QMenu(self.menuBar) self.menuOutils.setObjectName("menuOutils") self.menuR_seau = QtWidgets.QMenu(self.menuBar) self.menuR_seau.setObjectName("menuR_seau") self.menuInternet = QtWidgets.QMenu(self.menuBar) self.menuInternet.setObjectName("menuInternet") self.menuStockage = QtWidgets.QMenu(self.menuBar) self.menuStockage.setObjectName("menuStockage") self.menuServeur = QtWidgets.QMenu(self.menuBar) self.menuServeur.setObjectName("menuServeur") self.menuConfiguration = QtWidgets.QMenu(self.menuBar) self.menuConfiguration.setObjectName("menuConfiguration") self.menuCreator = QtWidgets.QMenu(self.menuBar) self.menuCreator.setObjectName("menuCreator") MainWindow.setMenuBar(self.menuBar) self.actionBloc_Note = QtWidgets.QAction(MainWindow) self.actionBloc_Note.setObjectName("actionBloc_Note") self.actionBloc_Note.triggered.connect(self.openNotesWindow) self.actionArchiver = QtWidgets.QAction(MainWindow) self.actionArchiver.setObjectName("actionArchiver") self.actionArchiver.triggered.connect(self.openArchive) self.actionMail = QtWidgets.QAction(MainWindow) self.actionMail.setObjectName("actionMail") self.actionMail.triggered.connect(self.openMail) self.actionRecherche = QtWidgets.QAction(MainWindow) self.actionRecherche.setObjectName("actionRecherche") self.actionCoffre_Fort = QtWidgets.QAction(MainWindow) self.actionCoffre_Fort.setObjectName("actionCoffre_Fort") self.actionCoffre_Fort.triggered.connect( self.openPageStockageMainWindow) self.actionArchiver_2 = QtWidgets.QAction(MainWindow) self.actionArchiver_2.setObjectName("actionArchiver_2") # self.actionArchiver_2.triggered.connect() self.actionLobby = QtWidgets.QAction(MainWindow) self.actionLobby.setObjectName("actionLobby") self.actionLobby.triggered.connect(self.openServerWindow) self.actionLobby_2 = QtWidgets.QAction(MainWindow) self.actionLobby_2.setObjectName("actionLobby_2") self.actionLobby_2.triggered.connect(self.openWindows) self.actionPaquets = QtWidgets.QAction(MainWindow) self.actionPaquets.setObjectName("actionPaquets") self.actionPaquets.triggered.connect(self.openPacketWindow) self.actionHandler = QtWidgets.QAction(MainWindow) self.actionHandler.setObjectName("actionHandler") self.actionHandler.triggered.connect(self.openHandlerMainWindow) self.actionRaw = QtWidgets.QAction(MainWindow) self.actionRaw.setObjectName("actionRAw") self.actionRaw.triggered.connect(self.openRawMainWindow) self.actionH_berger = QtWidgets.QAction(MainWindow) self.actionH_berger.setObjectName("actionH_berger") self.actionModifier_le_fichier_de_configuration = QtWidgets.QAction( MainWindow) self.actionModifier_le_fichier_de_configuration.setObjectName( "actionModifier_le_fichier_de_configuration") self.actionModifier_le_fichier_de_configuration.triggered.connect( self.openConfigWindow) self.actionPage_Createur = QtWidgets.QAction(MainWindow) self.actionPage_Createur.setObjectName("actionPage_Createur") self.actionPage_Createur.triggered.connect(self.opencreatorWindow) self.actionVoice_Feedback = QtWidgets.QAction(MainWindow) self.actionVoice_Feedback.setObjectName("actionVoice_Feedback") self.actionVoice_Feedback.triggered.connect(self.openRapportWindow) self.actionPage_Internet = QtWidgets.QAction(MainWindow) self.actionPage_Internet.setObjectName("actionPage_Internet") self.menuOutils.addAction(self.actionBloc_Note) self.menuOutils.addAction(self.actionHandler) self.menuOutils.addAction(self.actionRaw) self.menuR_seau.addAction(self.actionLobby_2) self.menuR_seau.addAction(self.actionPaquets) self.actionModifier_une_base_de_donn_e = QtWidgets.QAction(MainWindow) self.actionModifier_une_base_de_donn_e.setObjectName( "actionModifier_une_base_de_donn_e") self.menuInternet.addAction(self.actionMail) self.menuInternet.addAction(self.actionRecherche) self.menuInternet.addAction(self.actionPage_Internet) self.menuStockage.addAction(self.actionCoffre_Fort) self.menuStockage.addAction(self.actionArchiver_2) self.menuStockage.addAction(self.actionArchiver) self.menuServeur.addAction(self.actionLobby) self.menuServeur.addAction(self.actionH_berger) self.menuConfiguration.addAction( self.actionModifier_le_fichier_de_configuration) self.menuConfiguration.addAction(self.actionVoice_Feedback) self.menuConfiguration.addAction( self.actionModifier_une_base_de_donn_e) self.menuCreator.addAction(self.actionPage_Createur) self.menuBar.addAction(self.menuOutils.menuAction()) self.menuBar.addAction(self.menuR_seau.menuAction()) self.menuBar.addAction(self.menuInternet.menuAction()) self.menuBar.addAction(self.menuStockage.menuAction()) self.menuBar.addAction(self.menuServeur.menuAction()) self.menuBar.addAction(self.menuConfiguration.menuAction()) self.menuBar.addAction(self.menuCreator.menuAction()) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow)
def __init__(self): self.nCsv = Database().getPaths('path','NetworkCSV')
def __init__(self): self.MagicWord = Tools().getModuleData("local dbpassword", "Tobias") self.networkCSV = Database().getPaths('path', 'NetworkCSV')
def send(self): echantillon = [] #Trouver les IPS for i in range(0, len(display)): items = self.listWidget_3.findItems(display[i], QtCore.Qt.MatchExactly) if len(items) > 0: Command = mydb.cursor() Command.execute("USE tobiasdb") for item in items: ipStage1 = item.text() ipStage2 = ipStage1.find(" ") ipStage3 = ipStage1[:ipStage2] echantillon.append(ipStage3) passwordTextBox = self.lineEdit.text() passwordList = passwordTextBox.split(",") usernameTextBox = self.lineEdit_3.text() usernameList = usernameTextBox.split(",") #Si la combo box dit sauvegarder alors : sinon : Command = mydb.cursor() Command.execute("USE tobiasdb") for i in range(0, len(echantillon)): Command.execute( "INSERT INTO server (id , ipAddress , Password ) VALUES ( NULL , '{}' , '{}')" .format(echantillon[i], passwordList[i])) mydb.commit() commande = self.lineEdit_2.text() if self.lineEdit_2.text() != "": Command = mydb.cursor() Command.execute("USE tobiasdb") Command.execute( "INSERT INTO servCommands (id, Information) VALUES (NULL , '{}')" .format(commande)) mydb.commit() commandeList = commande.split(",") else: commandeList = self.CommandeClique() #Liste des IPS : echantillon[i] #Liste des mot de passe : passwordList[i] #Liste des commandes : commandeList[i] #Executer : for i in range(0, len(echantillon)): ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(echantillon[i], port=22, username=usernameList[i], password=passwordList[i]) for i in range(0, len(commandeList)): stdin, stdout, stderr = ssh.exec_command(commandeList[i]) output = stdout.readlines() print("\n".join(output)) Database("rapportExecution", "id", "Programme", "Information", "NULL", "Tobias", f"{output}").insertInDatabase()
def Main(self): List = [] #DECL currentNetworkHosts = self.findCurrentHosts() registredNetworkHosts = self.getCurrentNetworkHostsFromDB() #MAIN if len(str(currentNetworkHosts)) > len( registredNetworkHosts): #CONNEXIONS registredNetworkHosts = registredNetworkHosts.strip("[]") registredNetworkHosts = registredNetworkHosts.strip("\'") registredNetworkHosts = registredNetworkHosts.split("', '") a = set(currentNetworkHosts) - set(registredNetworkHosts) for _ in a: List.append(_.strip("'")) for i in range(0, len(List)): if self.getKnownNames(List[i]) is None: Database( "rapportExecution", "id", "Programme", "Information", "NULL", "Tobias", f"{List[i]} est inconnue est actuellement connectée" ).insertInDatabase() Database("unknownIps", "id", "address", "NULL", f"{List[i]}").insertInDatabase() recieved = self.rule("CONNECTED") for x in range(0, len(recieved)): if List[i] == recieved[x]: action = recieved[x + 1] if action == "NOTIFY": Tools().Notification( "{} viens de se connecter".format( recieved[x])) if action == "TELL": print("{} viens de se connecter".format( recieved[x])) if action == "TALK": Tools().talktoMe("{} just connected".format( recieved[x])) if Database("reseau", "Nature", "Information", List[i]).getFromDatabase() == "": Database("reseau", "id", "Network", "Programme", "Nature", "Information", "NULL", Network().myIp("ip"), "RawNetwork", "Online", List[i]).insertInDatabase() else: mydb = mysql.connector.connect( host="localhost", user="******", passwd=self.MagicWord, ) Command = mydb.cursor() Command.execute("USE tobiasdb") Ins = f"UPDATE reseau SET Nature='Online' WHERE Information='{List[i]}' AND Nature!='currentIp' AND Nature!='previousIp'" Command.execute(Ins) mydb.commit() if Database("unknownIps", "address", "address", List[i]).getFromDatabase() is None: Database("unknownIps", "id", "address", "NULL", List[i]).insertInDatabase() else: pass else: recieved = self.rule("CONNECTED") for x in range(0, len(recieved)): if List[i] == recieved[x]: action = recieved[x + 1] if action == "NOTIFY": Tools().Notification( f"{self.getKnownNames(List[i])} viens de se connecter" ) if action == "TELL": print( f"{self.getKnownNames(List[i])} viens de se connecter" ) if action == "TALK": Tools().talktoMe( f"{self.getKnownNames(List[i])} just connected" ) Database("rapportExecution", "id", "Programme", "Information", "NULL", "Tobias", f"{List[i]} est connectée").insertInDatabase() if Database("reseau", "Nature", "Information", List[i]).getFromDatabase() == "": Database("reseau", "id", "Network", "Programme", "Nature", "Information", "NULL", Network().myIp("ip"), "RawNetwork", "Online", List[i]).insertInDatabase() else: mydb = mysql.connector.connect( host="localhost", user="******", passwd=self.MagicWord, ) Command = mydb.cursor() Command.execute("USE tobiasdb") Ins = f"UPDATE reseau SET Nature='Online' WHERE Information='{List[i]}' AND Nature!='currentIp' AND Nature!='previousIp'" Command.execute(Ins) mydb.commit() if Database("unknownIps", "address", "address", List[i]).getFromDatabase() is None: Database("id", "address", "NULL", List[i]).insertInDatabase() else: pass if len(a) > 1: Database("rapportExecution", "id", "Programme", "Information", "NULL", "Tobias", f"'{len(List)}' computers connected from last sweap" ).insertInDatabase() elif len(a) == 0: pass else: Database("rapportExecution", "id", "Programme", "Information", "NULL", "Tobias", f"{len(List)} computers connected from last sweap" ).insertInDatabase() mydb = mysql.connector.connect( host="localhost", user="******", passwd=self.MagicWord, ) Command = mydb.cursor() Command.execute("USE tobiasdb") Ins = "UPDATE reseau SET Information=\"{}\" WHERE Nature='currentNetworkHosts'".format( str(currentNetworkHosts)) Command.execute(Ins) mydb.commit() elif len(str(currentNetworkHosts)) == len(registredNetworkHosts): pass else: #DECONNEXIONS registredNetworkHosts = registredNetworkHosts.strip("[]") registredNetworkHosts = registredNetworkHosts.strip("\'") registredNetworkHosts = registredNetworkHosts.split("', '") a = set(registredNetworkHosts) - set(currentNetworkHosts) for _ in a: List.append(_.strip("'")) for i in range(0, len(List)): if self.getKnownNames(List[i]) is None: Database( "rapportExecution", "id", "Programme", "Information", "NULL", "Tobias", f"{List[i]} est inconnue est actuellement disconnected" ).insertInDatabase() Database("unknownIps", "id", "address", "NULL", f"{List[i]}").insertInDatabase() recieved = self.rule("DISCONNECTED") for x in range(0, len(recieved)): if List[i] == recieved[x]: action = recieved[x + 1] if action == "NOTIFY": Tools().Notification( "{} viens de se déconnecter".format( recieved[x])) if action == "TALK": Tools().talktoMe( "{} viens de se déconnecter".format( recieved[x])) if action == "TELL": print("{} viens de se déconnecter".format( recieved[x])) if Database("reseau", "Nature", "Information", List[i]).getFromDatabase() == "": Database("reseau", "id", "Network", "Programme", "Nature", "Information", "NULL", Network().myIp("ip"), "RawNetwork", "Offline", List[i]).insertInDatabase() else: mydb = mysql.connector.connect( host="localhost", user="******", passwd=self.MagicWord, ) Command = mydb.cursor() Command.execute("USE tobiasdb") Ins = f"UPDATE reseau SET Nature='Offline' WHERE Information='{List[i]}' AND Nature!='currentIp' AND Nature!='previousIp'" Command.execute(Ins) mydb.commit() else: recieved = self.rule("DISCONNECTED") for x in range(0, len(recieved)): if List[i] == recieved[x]: action = recieved[x + 1] if action == "NOTIFY": Tools().Notification( f"{self.getKnownNames(List[i])} viens de se déconnecter" ) if action == "TELL": print( f"{self.getKnownNames(List[i])} viens de se déconnecter" ) if action == "TALK": Tools().talktoMe( f"{self.getKnownNames(List[i])} viens de se déconnecter" ) Database("rapportExecution", "id", "Programme", "Information", "NULL", "Tobias", f"{List[i]} est actuellement disconnected" ).insertInDatabase() if Database("reseau", "Nature", "Information", List[i]).getFromDatabase() == "": Database("reseau", "id", "Network", "Programme", "Nature", "Information", "NULL", Network().myIp("ip"), "RawNetwork", "Offline", List[i]).insertInDatabase() else: mydb = mysql.connector.connect( host="localhost", user="******", passwd=self.MagicWord, ) Command = mydb.cursor() Command.execute("USE tobiasdb") Ins = f"UPDATE reseau SET Nature='Offline' WHERE Information='{List[i]}' AND Nature!='currentIp' AND Nature!='previousIp'" Command.execute(Ins) mydb.commit() if len(a) > 1: print("{} computers disconnected from last sweap".format( len(List))) elif len(a) == 0: pass else: Database( "rapportExecution", "id", "Programme", "Information", "NULL", "Tobias", f"{len(List)} computers disconnected from last sweap" ).insertInDatabase() Tools().Rapport(f'currentNetworkHosts') mydb = mysql.connector.connect( host="localhost", user="******", passwd=self.MagicWord, ) Command = mydb.cursor() Command.execute("USE tobiasdb") Ins = "UPDATE reseau SET Information=\"{}\" WHERE Nature='currentNetworkHosts'".format( str(currentNetworkHosts)) Command.execute(Ins) mydb.commit()
def Main(self): a = self.customRecup() b = self.currentSsh() toStock = set(b) - set(a) list_of_strings = [str(s) for s in toStock] joined_string = " ".join(list_of_strings) if joined_string == "": pass else: Database(f"{currentPc}", "id", "name", "field", "data", "NULL", "RawNetworkA", "Ally_Computer", joined_string).insertInDatabase() if self.customRecup() == "": pass else: try: #checker() mydb = mysql.connector.connect( host="localhost", user="******", passwd=self.MagicWord, ) Command = mydb.cursor() Command.execute("USE tobiasdb") Command.execute( f"SELECT data FROM {currentPc} WHERE field='Ally_Computer' AND data !='127.0.0.1'" ) for x in Command: for lettre in x: ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy( paramiko.AutoAddPolicy()) ssh.connect(lettre, port=22, username='******', password=self.MagicWord) Tools().Notification("La machine avec l'IP " + lettre + " est allumé") time.sleep(1) except paramiko.ssh_exception.NoValidConnectionsError: print("[-] Connexion Impossible : \n" + Database(f"{currentPc}", "data", "field", "Ally_Computer").getFromDatabase() + " est hors d'atteinte") print("Pas de connexion Internet") except paramiko.ssh_exception.AuthenticationException: print("Mot de passe incorrect") print("\n") except OSError: print("[-] Connexion Impossible : \n" + Database(f"{currentPc}", "data", "field", "Ally_Computer").getFromDatabase() + " est hors d'atteinte") except paramiko.ssh_exception.SSHException: print("Erreur") time.sleep(1)
def __init__(self): self.right = " True" self.wrong = " False" self.confs = Database().getPaths('path', 'ConfigurationJson')
def __init__(self): self.notesPath = Database().getPaths('noteFile', 'Notes')