Advertisement
Guest User

gg

a guest
Jun 8th, 2016
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.69 KB | None | 0 0
  1. local function readN(len, replaceChar)
  2. len = len or 12
  3. local input=""
  4. local key = 0
  5. term.setCursorBlink(true)
  6. repeat
  7. local e,p1 = os.pullEvent()
  8. if e=="char" then
  9. if #input < len then
  10. input = input .. p1
  11. term.write(replaceChar or p1)
  12. end
  13. elseif e=="key" and p1==keys.backspace and #input > 0 then
  14. input = input:sub(1,#input-1)
  15. local x,y = term.getCursorPos()
  16. term.setCursorPos(x-1,y)
  17. term.write(" ")
  18. term.setCursorPos(x-1,y)
  19. end
  20. until p1==keys.enter
  21. term.setCursorBlink(false)
  22. return input
  23. end
  24.  
  25. sid = 0
  26. lockdown = 0
  27. actc = ""
  28. actpw = ""
  29. actpc = ""
  30. userlog = ""
  31. userpas = ""
  32. puselog = ""
  33. prog = 0
  34.  
  35. function clear()
  36. term.clear()
  37. term.setCursorPos(1,1)
  38. end
  39.  
  40. function menu(id, text)
  41. if sid == id then
  42. write">> "
  43. else
  44. write" "
  45. end
  46. print(text)
  47. end
  48.  
  49. clear()
  50. while prog == 0 do
  51. os.pullEvent = os.pullEventRaw
  52. rep1 = 0
  53. rep2 = 0
  54. rep3 = 0
  55. rep4 = 0
  56. rep5 = 0
  57. rep6 = 0
  58. ioerror = 0
  59. term.setCursorPos(1, 12)
  60. term.clearLine()
  61. term.setCursorPos(1, 13)
  62. term.clearLine()
  63. term.setCursorPos(1, 14)
  64. term.clearLine()
  65. term.setCursorPos(1, 15)
  66. term.clearLine()
  67. term.setCursorPos(1, 16)
  68. term.clearLine()
  69. term.setCursorPos(1, 17)
  70. term.clearLine()
  71. term.setCursorPos(1,1)
  72. print("|################################################|")
  73. print("| BOUTECH SYSTEM LOGIN |")
  74. print("| OS Version : 1.3 |")
  75. print("|################################################|")
  76. term.setCursorPos(13,7)
  77. print("|------------------------|")
  78. term.setCursorPos(13,8)
  79. print("| |")
  80. term.setCursorPos(13,9)
  81. print("| |")
  82. term.setCursorPos(13,10)
  83. print("| |")
  84. term.setCursorPos(13,11)
  85. print("|------------------------|")
  86. term.setCursorPos(16,8)
  87. menu(0, "Login")
  88. term.setCursorPos(16,9)
  89. menu(1, "Create Account")
  90. term.setCursorPos(16,10)
  91. menu(2, "Shutdown")
  92. event, key = os.pullEvent("key")
  93.  
  94. if key == 200 then
  95. if sid == 0 then
  96. sid = sid+2
  97. elseif sid == 1 then
  98. sid = sid-1
  99. elseif sid == 2 then
  100. sid = sid-1
  101. end
  102. elseif key == 208 then
  103. if sid == 2 then
  104. sid = sid-2
  105. elseif sid == 1 then
  106. sid = sid+1
  107. elseif sid == 0 then
  108. sid = sid+1
  109. end
  110. elseif key == 28 then
  111. if sid == 0 then
  112. term.setCursorPos(13, 12)
  113. print("| Enter Credentials. |")
  114. term.setCursorPos(13, 13)
  115. print("| |")
  116. term.setCursorPos(13, 14)
  117. print("| |")
  118. term.setCursorPos(13, 15)
  119. print("| |")
  120. term.setCursorPos(13, 16)
  121. print("| |")
  122. term.setCursorPos(13, 17)
  123. print("|------------------------|")
  124.  
  125. while rep5 == 0 do
  126. term.setCursorPos(1, 14)
  127. term.clearLine()
  128. term.setCursorPos(1, 16)
  129. term.clearLine()
  130. term.setCursorPos(13, 16)
  131. print("| |")
  132. term.setCursorPos(13, 14)
  133. print("| |")
  134. term.setCursorPos(15, 14)
  135. write("Username: ")
  136. userlog = readN()
  137. if userlog == "adminovrride" then
  138. rnd = math.random(100, 500)
  139. term.setCursorPos(1, 18)
  140. term.clearLine()
  141. term.setCursorPos (17, 18)
  142. print("Override Code: ".. rnd)
  143. apass = tostring((rnd + 11) * 83)
  144. term.setCursorPos(1, 16)
  145. term.clearLine()
  146. term.setCursorPos(13, 16)
  147. print("| |")
  148. term.setCursorPos(15, 16)
  149. write("Password: ")
  150. ovrpass = readN(12, "*")
  151. if ovrpass == apass then
  152. term.setCursorPos(1, 18)
  153. term.clearLine()
  154. term.setCursorPos(15, 18)
  155. print("Override Successful...")
  156. sleep(3)
  157. term.clear()
  158. term.setCursorPos(1, 1)
  159. rep5 = rep5+1
  160. rep6 = rep6+1
  161. prog = prog+1
  162. else
  163. term.setCursorPos(1, 18)
  164. term.clearLine()
  165. term.setCursorPos(15, 18)
  166. print(" Override Failed...")
  167. sleep(1)
  168. rep5 = rep5+1
  169. rep6 = rep6+1
  170. sid = 0
  171. end
  172. else
  173. if userlog == "" then
  174. term.setCursorPos(1, 18)
  175. term.clearLine()
  176. term.setCursorPos(18, 18)
  177. print("Invalid Username")
  178. sleep(1)
  179. ioerror = ioerror+1
  180. if ioerror == 3 then
  181. rep5 = rep5+1
  182. rep6 = rep6+1
  183. sid = 0
  184. else
  185. end
  186. else
  187. ioerror = 0
  188. ulog = fs.exists("users/".. userlog)
  189. if ulog == true then
  190. term.setCursorPos(1, 16)
  191. term.clearLine()
  192. term.setCursorPos(13, 16)
  193. print("| |")
  194. term.setCursorPos(15, 16)
  195. write("Password: ")
  196. userpas = readN(12, "*")
  197. if userpas == "" then
  198. term.setCursorPos(1, 18)
  199. term.clearLine()
  200. term.setCursorPos(15, 18)
  201. print("Invalid Password Entry")
  202. sleep(1)
  203. ioerror = ioerror+1
  204. term.setCursorPos(1, 18)
  205. term.clearLine()
  206. if ioerror == 3 then
  207. rep5 = rep5+1
  208. sid = 0
  209. else
  210. end
  211. else
  212. ulog = io.open("users/".. userlog, "r") or nil
  213. pass = ulog and ulog:read()
  214. ulog:close()
  215. if (pass and pass==userpas) then
  216. term.setCursorPos(1, 18)
  217. term.clearLine()
  218. term.setCursorPos(16, 18)
  219. print(" Login Success...")
  220. rep5 = rep5+1
  221. rep6 = rep6+1
  222. sid = 0
  223. sleep(2)
  224. --Put your shell.run([PROGRAM]) here to move into the system you had locked by this program.
  225. else
  226. if lockdown < 2 then
  227. term.setCursorPos(1, 18)
  228. term.clearLine()
  229. term.setCursorPos(16, 18)
  230. print(" Wrong Password")
  231. sleep(1)
  232. if userlog == puselog then
  233. lockdown = lockdown+1
  234. else
  235. lockdown = 0
  236. puselog = userlog
  237. lockdown = lockdown+1
  238. end
  239. else
  240. while rep6 == 0 do
  241. term.setCursorPos(15, 18)
  242. rnd = tostring(math.random(101, 999))
  243. if not fs.exists("pending/".. rnd) then
  244. fs.move("users/".. userlog, "pending/".. rnd)
  245. term.setCursorPos(1, 18)
  246. term.clearLine()
  247. term.setCursorPos(15, 18)
  248. print(" Lockdown Ref #: "..rnd)
  249. sleep(1)
  250. ulog = fs.open("pending/".. rnd, "a")
  251. ulog.writeLine("Username: ".. userlog)
  252. ulog.close()
  253. rep6 = rep6+1
  254. rep5 = rep5+1
  255. sid = 0
  256. else
  257. end
  258. end
  259. end
  260. end
  261. end
  262. else
  263. term.setCursorPos(14, 18)
  264. print(" Bad/Unknown Username")
  265. sleep(1)
  266. end
  267. end
  268. end
  269. end
  270. elseif sid == 1 then
  271. term.setCursorPos(13, 12)
  272. print("| Submit Account Info. |")
  273. term.setCursorPos(13, 13)
  274. print("| |")
  275. term.setCursorPos(13, 14)
  276. print("| |")
  277. term.setCursorPos(13, 15)
  278. print("| |")
  279. term.setCursorPos(13, 16)
  280. print("| |")
  281. term.setCursorPos(13, 17)
  282. print("|------------------------|")
  283.  
  284. while rep1 == 0 do
  285. term.setCursorPos(1, 14)
  286. term.clearLine()
  287. term.setCursorPos(13, 14)
  288. print("| |")
  289. term.setCursorPos(15, 14)
  290. write("Username: ")
  291. input = readN()
  292. actc = input
  293. actex = fs.exists("users/".. actc)
  294. if input == "adminovrride" then
  295. term.setCursorPos(1, 18)
  296. term.clearLine()
  297. term.setCursorPos(18, 18)
  298. print("Invalid Username")
  299. sleep(1)
  300. ioerror = ioerror+1
  301. if ioerror == 3 then
  302. rep1 = 1
  303. rep2 = 1
  304. rep3 = 1
  305. sid = 0
  306. else
  307. end
  308. else
  309. if input == "" then
  310. term.setCursorPos(1, 18)
  311. term.clearLine()
  312. term.setCursorPos(18, 18)
  313. print("Invalid Username")
  314. sleep(1)
  315. ioerror = ioerror+1
  316. if ioerror == 3 then
  317. rep1 = 1
  318. rep2 = 1
  319. rep3 = 1
  320. sid = 0
  321. else
  322. end
  323. elseif actex == true then
  324. term.setCursorPos(1, 18)
  325. term.clearLine()
  326. term.setCursorPos(15, 18)
  327. print (" Username Unavailable")
  328. sleep(1)
  329. else
  330. ioerror = 0
  331. rep1 = 1
  332. end
  333. end
  334. end
  335.  
  336. while rep2 == 0 do
  337. while rep3 == 0 do
  338. term.setCursorPos(15, 15)
  339. write("Password: ")
  340. input = readN(12, "*")
  341. if input == "" then
  342. term.setCursorPos(1, 18)
  343. term.clearLine()
  344. term.setCursorPos(15, 18)
  345. print("Invalid Password Entry")
  346. sleep(1)
  347. ioerror = ioerror+1
  348. if ioerror == 3 then
  349. rep1 = 1
  350. rep2 = 1
  351. rep3 = 1
  352. else
  353. end
  354. else
  355. ioerror = 0
  356. actpw = input
  357. rep3 = 1
  358. rep2 = 1
  359. end
  360. end
  361.  
  362. term.setCursorPos(13, 16)
  363. print("| |")
  364. term.setCursorPos(15, 16)
  365. write("Confirm : ")
  366. input = readN(12, "*")
  367. actpc = input
  368. if (actpc) == (actpw) then
  369. while rep4 == 0 do
  370. rnd = tostring(math.random(1011, 9999))
  371. if not fs.exists("pending/".. rnd) then
  372. file = fs.open("pending/".. rnd, "w")
  373. file.writeLine(actc)
  374. file.writeLine(actpw)
  375. file.close()
  376. rep4 = rep4+1
  377. else
  378. end
  379. end
  380. term.setCursorPos(1, 18)
  381. term.clearLine()
  382. term.setCursorPos(13, 18)
  383. print(" Pending... Ref #: ", rnd)
  384. sleep(1)
  385. ioerror = 0
  386. rep2 = 1
  387. sid = 0
  388. else
  389. term.setCursorPos(1, 18)
  390. term.clearLine()
  391. term.setCursorPos(15, 18)
  392. print("Password Doesn't Match")
  393. sleep(1)
  394. rep2 = 0
  395. ioerror = ioerror+1
  396. if ioerror == 3 then
  397. rep1 = 1
  398. rep2 = 1
  399. rep3 = 1
  400. else
  401. end
  402. end
  403. end
  404.  
  405. elseif sid == 2 then
  406. term.setCursorPos(13,14)
  407. print("|########################|")
  408. term.setCursorPos(13,15)
  409. print("# SYSTEM SHUTTING DOWN!! #")
  410. term.setCursorPos(13,16)
  411. print("|########################|")
  412. sleep(3)
  413. os.shutdown()
  414. end
  415. end
  416. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement