BananeMan

Untitled

Sep 23rd, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. --*****************************--
  2. --********BANQUE SERVEUR*******--
  3. --*****************************--
  4.  
  5. --Décalaration de variable
  6.  
  7. local checkstartup = false
  8. local checkfiles = false
  9. local checkshell2 = false
  10. local filesnumb = 0
  11. fileserror = 0
  12. local id = os.getComputerID()
  13. local st = ""
  14. local ver = "0.0.1"
  15. local string = ""
  16.  
  17. local usersf = "/files/users/"
  18. local adminsf = "/files/admins.txt"
  19. local atmsf = "/files/atms.txt"
  20. --local ronda = "/libs/rednet"
  21. local crypt = "/disk/crypto"
  22.  
  23. local privekey = ""
  24. local publickey = ""
  25. local allkey = ""
  26.  
  27. local coter = "left"
  28. --Fin de décalaration de variable
  29.  
  30. function startup()
  31. print("Démarage du serveur")
  32. print("Id de l'ordinateur:", id)
  33. print("Version: "..ver)
  34. print("Vérification des fichiers utilisateur")
  35. verif(usersf)
  36. verif(adminsf)
  37. verif(crypt)
  38. verif(atmsf)
  39. --verif(ronda)
  40. if fileserror == 0 then
  41. print(filesnumb, "fichiers on été vérifier")
  42. else
  43. print(fileserror, "fichiers on n'on pas été vérifier !")
  44. sleep(2)
  45. os.shutdown()
  46. end
  47.  
  48. print("\n\n\n")
  49. print("Load des apis")
  50. os.loadAPI(crypt)
  51. --os.loadAPI(ronda)
  52. print("Création des clées de cryptage")
  53. allkey = crypto.generate()
  54. publickey = allkey.public
  55. privkey = allkey.private
  56. print("Ouverture de rednet")
  57. rednet.open(coter)
  58. print("Fin du startup")
  59. parallel.waitForAll(redne, idre)
  60. end
  61.  
  62. function verif(var)
  63. if fs.exists(var) then
  64. print(var.." existant")
  65. filesnumb = filesnumb + 1
  66. else
  67. print(var.." n'existe pas !")
  68. fileserror = fileserror + 1
  69. sleep(10)
  70. os.shutdown()
  71. end
  72. end
  73.  
  74. function files(string)
  75. local response
  76.  
  77. return(response)
  78. end
  79.  
  80. function redne()
  81. print("Ecoute activée !")
  82. while true do
  83. local senderid, mess, proto = rednet.receive("superproto")
  84. print("[BANQUE]", "[SenderID]:",senderid)
  85. if mess == "keyretrive" then
  86. messagedc = crypto.decrypt(mess, privekey)
  87. local table = textutils.unserialize(messagedc)
  88. if table.action == "login" then
  89. local user = table.User
  90. local pass = table.Pass
  91. if fs.exists("/files/users/"..user) then
  92. local file = fs.open("/files/users/"..user, "r")
  93.  
  94. local id = file.readLine()
  95. local pseudo = file.readLine()
  96. local mot = file.readLine()
  97. local argent = file.readLine()
  98. local historique = file.readLine()
  99. local entreprise = file.readLine()
  100. file.close()
  101. if user == pseudo and mot == pass then
  102. local table = {action = "login", user = pseudo, response = "yes"}
  103. tablesy = textutils.serialize(table)
  104. rednet.send(senderid, tablesy)
  105. else
  106. local table = {action = "login", user = pseudo, response = "no"}
  107. tablesn = textutils.serialize(table)
  108. rednet.send(senderid, tablesn)
  109. end
  110. else
  111. print("Utilisateur non existant")
  112. local table = {action = "login", user = user, response = "no"}
  113. tablesn = textutils.serialize(table)
  114. rednet.send(senderid, tablesn)
  115. end
  116. else
  117. print("Pas implementer", tablea.action)
  118. end
  119. else
  120. rednet.send(senderid, publickey)
  121. print("Clée public envoyée a",senderid)
  122. end
  123. rednet.close()
  124. end
  125. end
  126.  
  127. function shell2()
  128. shell.openTab("shell")
  129. end
  130.  
  131. function acces()
  132. end
  133.  
  134. function token(pseudo)
  135.  
  136. end
  137.  
  138. function idre()
  139. rednet.open(coter)
  140. rednet.host("2banque", "server")
  141. end
  142.  
  143. parallel.waitForAll(startup, shell2)
  144.  
  145. ---260 + 2478
Add Comment
Please, Sign In to add comment