Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --*****************************--
- --********BANQUE SERVEUR*******--
- --*****************************--
- --Décalaration de variable
- local checkstartup = false
- local checkfiles = false
- local checkshell2 = false
- local filesnumb = 0
- fileserror = 0
- local id = os.getComputerID()
- local st = ""
- local ver = "0.0.1"
- local string = ""
- local usersf = "/files/users/"
- local adminsf = "/files/admins.txt"
- local atmsf = "/files/atms.txt"
- --local ronda = "/libs/rednet"
- local crypt = "/disk/crypto"
- local privekey = ""
- local publickey = ""
- local allkey = ""
- local coter = "left"
- --Fin de décalaration de variable
- function startup()
- print("Démarage du serveur")
- print("Id de l'ordinateur:", id)
- print("Version: "..ver)
- print("Vérification des fichiers utilisateur")
- verif(usersf)
- verif(adminsf)
- verif(crypt)
- verif(atmsf)
- --verif(ronda)
- if fileserror == 0 then
- print(filesnumb, "fichiers on été vérifier")
- else
- print(fileserror, "fichiers on n'on pas été vérifier !")
- sleep(2)
- os.shutdown()
- end
- print("\n\n\n")
- print("Load des apis")
- os.loadAPI(crypt)
- --os.loadAPI(ronda)
- print("Création des clées de cryptage")
- allkey = crypto.generate()
- publickey = allkey.public
- privkey = allkey.private
- print("Ouverture de rednet")
- rednet.open(coter)
- print("Fin du startup")
- parallel.waitForAll(redne, idre)
- end
- function verif(var)
- if fs.exists(var) then
- print(var.." existant")
- filesnumb = filesnumb + 1
- else
- print(var.." n'existe pas !")
- fileserror = fileserror + 1
- sleep(10)
- os.shutdown()
- end
- end
- function files(string)
- local response
- return(response)
- end
- function redne()
- print("Ecoute activée !")
- while true do
- local senderid, mess, proto = rednet.receive("superproto")
- print("[BANQUE]", "[SenderID]:",senderid)
- if mess == "keyretrive" then
- messagedc = crypto.decrypt(mess, privekey)
- local table = textutils.unserialize(messagedc)
- if table.action == "login" then
- local user = table.User
- local pass = table.Pass
- if fs.exists("/files/users/"..user) then
- local file = fs.open("/files/users/"..user, "r")
- local id = file.readLine()
- local pseudo = file.readLine()
- local mot = file.readLine()
- local argent = file.readLine()
- local historique = file.readLine()
- local entreprise = file.readLine()
- file.close()
- if user == pseudo and mot == pass then
- local table = {action = "login", user = pseudo, response = "yes"}
- tablesy = textutils.serialize(table)
- rednet.send(senderid, tablesy)
- else
- local table = {action = "login", user = pseudo, response = "no"}
- tablesn = textutils.serialize(table)
- rednet.send(senderid, tablesn)
- end
- else
- print("Utilisateur non existant")
- local table = {action = "login", user = user, response = "no"}
- tablesn = textutils.serialize(table)
- rednet.send(senderid, tablesn)
- end
- else
- print("Pas implementer", tablea.action)
- end
- else
- rednet.send(senderid, publickey)
- print("Clée public envoyée a",senderid)
- end
- rednet.close()
- end
- end
- function shell2()
- shell.openTab("shell")
- end
- function acces()
- end
- function token(pseudo)
- end
- function idre()
- rednet.open(coter)
- rednet.host("2banque", "server")
- end
- parallel.waitForAll(startup, shell2)
- ---260 + 2478
Add Comment
Please, Sign In to add comment