BananeMan

Untitled

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