BananeMan

Untitled

Sep 23rd, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 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. rednet.send(senderid, publickey)
  87. print("Clée public envoyée a",senderid)
  88. else
  89. messagedc = crypto.decrypt(mess, privekey)
  90. local table = textutils.unserialize(messagedc)
  91. if table.action == "login" then
  92. local user = table.User
  93. local pass = table.Pass
  94. if fs.exists("/files/users/"..user) then
  95. local file = fs.open("/files/users/"..user, "r")
  96.  
  97. local id = file.readLine()
  98. local pseudo = file.readLine()
  99. local mot = file.readLine()
  100. local argent = file.readLine()
  101. local historique = file.readLine()
  102. local entreprise = file.readLine()
  103. file.close()
  104. if user == pseudo and mot == pass then
  105. local table = {action = "login", user = pseudo, response = "yes"}
  106. tablesy = textutils.serialize(table)
  107. rednet.send(senderid, tablesy)
  108. else
  109. local table = {action = "login", user = pseudo, response = "no"}
  110. tablesn = textutils.serialize(table)
  111. rednet.send(senderid, tablesn)
  112. end
  113. else
  114. print("Utilisateur non existant")
  115. local table = {action = "login", user = user, response = "no"}
  116. tablesn = textutils.serialize(table)
  117. rednet.send(senderid, tablesn)
  118. end
  119. end
  120. end
  121.  
  122. end
  123. rednet.close()
  124. end
  125.  
  126. function shell2()
  127. shell.openTab("shell")
  128. end
  129.  
  130. function acces()
  131. end
  132.  
  133. function token(pseudo)
  134.  
  135. end
  136.  
  137. function idre()
  138. rednet.open(coter)
  139. rednet.host("2banque", "server")
  140. end
  141.  
  142. parallel.waitForAll(startup, shell2)
  143.  
  144. ---260 + 2478
Add Comment
Please, Sign In to add comment