Advertisement
VlaD00m

SecuCODEX Mono (HDD)

Oct 4th, 2020 (edited)
1,341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 12.12 KB | None | 0 0
  1. --[[ SecuCODEX Code Door System.
  2.      Mono Edition
  3. Program-system for password and "fingerprint" based monochrome access computer system
  4. ONLY FOR TIER 1 VIDEO CARD
  5. Author: Bs()Dd
  6.  
  7. Idea and base interface concept borrowed from ECS's CodeDoor
  8.  
  9. Program-system working without OpenOS, because "hackers" can't kill it by CTRL+ALT+C
  10.  
  11. Requirements to computer system:
  12.  - Tier 1 Computer
  13.  - Tier 1 Video Card
  14.  - Tier 2 Monitor (Tier 1 don't have touchscreen)
  15.  - Tier 1 Processor
  16.  - Tier 1 Hard Drive or Floppy Disk
  17.  - 1x Tier 1 Memory
  18.  - Tier 1 Redstone Card or Redstone I/O block
  19.  
  20. Installing:
  21.  1. Download this file as init.lua to hard drive or floppy disk in access computer system (pastebin get ahbjHpvV init.lua)
  22.  2. Boot from drive by Lua BIOS
  23.  3. Make first Setup
  24.  4. Enjoy))
  25.  
  26. To enter in Setup menu, click on 'c' in "(c)" in copyright line and enter access password
  27.  
  28. After entering correct password, player's "fingerprint" adds to DB
  29. Player may be deleted from DB by removing his nickname from /configs/fingers.cfg
  30. ]]
  31.  
  32. function totable(inputstr)
  33.   local t={}
  34.    for str in string.gmatch(inputstr, "([^\n]+)") do
  35.      table.insert(t, str)
  36.    end
  37.    return t
  38. end
  39.  
  40. function untable(table)
  41.   res= ''
  42.   for _,x in pairs(table) do
  43.     res= res..x..'\n'
  44.   end
  45.   return res
  46. end
  47.  
  48. function toucheve()
  49.   while true do
  50.     eve,w,tx,ty,z,who = computer.pullSignal()
  51.     if eve == 'touch' then break end
  52.   end
  53.   return eve,w,tx,ty,z,who
  54. end
  55.  
  56. function sleep(timeout)
  57.   checkArg(1, timeout, "number", "nil")
  58.   local deadline = computer.uptime() + (timeout or 0)
  59.   repeat
  60.     computer.pullSignal(deadline - computer.uptime())
  61.   until computer.uptime() >= deadline
  62. end
  63.  
  64. function drawplate(preset)
  65.   vid.setBackground(1)
  66.   vid.fill(1,1,60,5, " ")
  67.   vid.setForeground(0)
  68.   vid.set(8,1,'SecuCODEX Code Door System')
  69.   if preset == 'gr' then
  70.     npos = (40-10-#who)/2
  71.     if (40-10-#who)%2 ~= 0 then npos = npos + 1 end
  72.     vid.set(math.floor(npos)+1,3,'Welcome, '..who..'!')
  73.   elseif preset == 'rd' then
  74.     vid.set(14,3,'ACCESS DENIED!')
  75.   end
  76. end
  77.  
  78. function drawkeys()
  79.   vid.setBackground(0)
  80.   vid.setForeground(1)
  81.   vid.set(3,7 , '╔═════╗  ╔═════╗  ╔═════╗')
  82.   vid.set(3,8 , '║  1  ║  ║  2  ║  ║  3  ║')
  83.   vid.set(3,9 , '╚═════╝  ╚═════╝  ╚═════╝')
  84.   vid.set(3,10, '╔═════╗  ╔═════╗  ╔═════╗')
  85.   vid.set(3,11, '║  4  ║  ║  5  ║  ║  6  ║')
  86.   vid.set(3,12, '╚═════╝  ╚═════╝  ╚═════╝')
  87.   vid.set(3,13, '╔═════╗  ╔═════╗  ╔═════╗')
  88.   vid.set(3,14, '║  7  ║  ║  8  ║  ║  9  ║')
  89.   vid.set(3,15, '╚═════╝  ╚═════╝  ╚═════╝')
  90.   vid.set(3,16, '╔═════╗  ╔═════╗  ╔═════╗')
  91.   vid.set(3,17, '║  C  ║  ║  0  ║  ║  E  ║')
  92.   vid.set(3,18, '╚═════╝  ╚═════╝  ╚═════╝')
  93. end
  94.  
  95. function drawfinger()
  96.   vid.setBackground(0)
  97.   vid.setForeground(1)
  98.   vid.set(30,9 , '╔═════════╗')
  99.   vid.set(30,10, '║Finger   ║')
  100.   vid.set(30,11, '║   print ║')
  101.   vid.set(30,12, '║ Scanner ║')
  102.   vid.set(30,13, '║Compys   ║')
  103.   vid.set(30,14, '║ OCFPS-35║')
  104.   vid.set(30,15, '╚═════════╝')
  105.   vid.setBackground(0)
  106.   vid.setForeground(1)
  107. end
  108.  
  109. function drawpushed(x,y,n)
  110.   vid.setBackground(1)
  111.   vid.setForeground(0)
  112.   vid.set(x,y  , '╔═════╗')
  113.   vid.set(x,y+1, '║  '..n..'  ║')
  114.   vid.set(x,y+2, '╚═════╝')
  115. end
  116.  
  117. function know(setmode)
  118.   if 2 < tpoint[1] and tpoint[1] < 10 and 6 < tpoint[2] and tpoint[2] < 10 then return 3,7,1
  119.   elseif 11 < tpoint[1] and tpoint[1] < 19 and 6 < tpoint[2] and tpoint[2] < 10 then return 12,7,2
  120.   elseif 20 < tpoint[1] and tpoint[1] < 28 and 6 < tpoint[2] and tpoint[2] < 10 then return 21,7,3
  121.   elseif 2 < tpoint[1] and tpoint[1] < 10 and 9 < tpoint[2] and tpoint[2] < 13 then return 3,10,4
  122.   elseif 11 < tpoint[1] and tpoint[1] < 19 and 9 < tpoint[2] and tpoint[2] < 13 then return 12,10,5
  123.   elseif 20 < tpoint[1] and tpoint[1] < 28 and 9 < tpoint[2] and tpoint[2] < 13 then return 21,10,6
  124.   elseif 2 < tpoint[1] and tpoint[1] < 10 and 12 < tpoint[2] and tpoint[2] < 16 then return 3,13,7
  125.   elseif 11 < tpoint[1] and tpoint[1] < 19 and 12 < tpoint[2] and tpoint[2] < 16 then return 12,13,8
  126.   elseif 20 < tpoint[1] and tpoint[1] < 28 and 12 < tpoint[2] and tpoint[2] < 16 then return 21,13,9
  127.   elseif 2 < tpoint[1] and tpoint[1] < 10 and 15 < tpoint[2] and tpoint[2] < 19 then return 3,16,'C'
  128.   elseif 11 < tpoint[1] and tpoint[1] < 19 and 15 < tpoint[2] and tpoint[2] < 19 then return 12,16,0
  129.   elseif 20 < tpoint[1] and tpoint[1] < 28 and 15 < tpoint[2] and tpoint[2] < 19 then return 21,16,'E'
  130.   elseif tpoint[1] == 10 and tpoint[2] == 20 and setmode == false then setup()
  131.   elseif setmode == false then
  132.       if 29 < tpoint[1] and tpoint[1] < 41 and 8 < tpoint[2] and tpoint[2] < 16 then
  133.         finger()
  134.         for _,name in pairs(allowed) do
  135.           if who == name then inpassw = passw fg= nil return 500,500,'E' end
  136.         end
  137.         inpassw='' return 500,500,'E'
  138.       end
  139.   end
  140. end  
  141.  
  142. function setup()
  143.   vid.setBackground(0)
  144.   vid.setForeground(1)
  145.   vid.fill(1,1,60,5, " ")
  146.   vid.set(1,1,'SecuCODEX Mono Edition v1.09 Setup')
  147.   vid.set(1,2,'Old Password: ')
  148.   apassw = ''
  149.   drawkeys()
  150.   pos = 1
  151.   while true do
  152.     _,_,tx,ty,_,who = toucheve()
  153.     tpoint = {tx,ty}
  154.     x,y,n = know(true)
  155.     if n ~= nil then
  156.       drawpushed(x,y,n)
  157.       if n== 'C' then apassw='' vid.fill(14, 2, 60, 1, " ") pos =1 sleep(0.1) drawkeys()
  158.       elseif n== 'E' then sleep(0.1) drawkeys() break
  159.       else
  160.         pos = pos+1
  161.         apassw = apassw..n
  162.         vid.set(pos+13,2, "*")
  163.         sleep(0.1)
  164.         drawkeys()
  165.       end
  166.     end
  167.   end
  168.   if apassw == passw then intap(true) else drawplate('wh') end
  169. end
  170.  
  171. function intap(setp)
  172.   f=hdd.open('/configs/sets.cfg',"w")
  173.   vid.setBackground(0)
  174.   vid.setForeground(1)
  175.   vid.fill(1,1,60,5, " ")
  176.   vid.set(1,1,'SecuCODEX Mono Edition v1.09 Setup')
  177.   vid.set(1,2,'New Password: ')
  178.   passw = ''
  179.   drawkeys()
  180.   pos = 1
  181.   while true do
  182.     _,_,tx,ty,_,who = toucheve()
  183.     tpoint = {tx,ty}
  184.     x,y,n = know(true)
  185.     if n ~= nil then
  186.       drawpushed(x,y,n)
  187.       if n== 'C' then passw='' vid.fill(14, 2, 60, 1, " ") pos =1 sleep(0.1) drawkeys()
  188.       elseif n== 'E' then sleep(0.1) drawkeys() break
  189.       else
  190.         pos = pos+1
  191.         passw = passw..n
  192.         vid.set(pos+13,2, "*")
  193.         sleep(0.1)
  194.         drawkeys()
  195.       end
  196.     end
  197.   end
  198.   vid.fill(1,2,60,5, " ")
  199.   vid.set(1,2,'Side for correct code (0-5): ')
  200.   corr = ''
  201.   pos = 1
  202.   while true do
  203.     _,_,tx,ty,_,who = toucheve()
  204.     tpoint = {tx,ty}
  205.     x,y,n = know(true)
  206.     if n ~= nil then
  207.       drawpushed(x,y,n)
  208.       if n== 'C' then corr='' vid.fill(29, 2, 60, 1, " ") pos =1 sleep(0.1) drawkeys()
  209.       elseif n== 'E' then sleep(0.1) drawkeys() break
  210.       else
  211.         pos = pos+1
  212.         corr = corr..n
  213.         vid.set(pos+28,2, tostring(n))
  214.         sleep(0.1)
  215.         drawkeys()
  216.       end
  217.     end
  218.   end
  219.   vid.fill(1,2,60,5, " ")
  220.   vid.set(1,2,'Side for incorrect code (0-5): ')
  221.   incorr = ''
  222.   pos = 1
  223.   while true do
  224.     _,_,tx,ty,_,who = toucheve()
  225.     tpoint = {tx,ty}
  226.     x,y,n = know(true)
  227.     if n ~= nil then
  228.       drawpushed(x,y,n)
  229.       if n== 'C' then incorr='' vid.fill(31, 2, 60, 1, " ") pos =1 sleep(0.1) drawkeys()
  230.       elseif n== 'E' then sleep(0.1) drawkeys() break
  231.       else
  232.         pos = pos+1
  233.         incorr = incorr..n
  234.         vid.set(pos+30,2, tostring(n))
  235.         sleep(0.1)
  236.         drawkeys()
  237.       end
  238.     end
  239.   end
  240.   vid.fill(1,2,60,5, " ")
  241.   vid.set(1,2,'Show password? [E/C]: ')
  242.   while true do
  243.     _,_,tx,ty,_,who = toucheve()
  244.     tpoint = {tx,ty}
  245.     x,y,n = know(true)
  246.     if n ~= nil then
  247.       drawpushed(x,y,n)
  248.       if n== 'C' then stars = 'false' sleep(0.1) drawkeys() break
  249.       elseif n== 'E' then stars = 'true' sleep(0.1) drawkeys() break
  250.       end
  251.     end
  252.   end
  253.   vid.fill(1,2,60,5, " ")
  254.   vid.set(1,2,'Show key push? [E/C]: ')
  255.   while true do
  256.     _,_,tx,ty,_,who = toucheve()
  257.     tpoint = {tx,ty}
  258.     x,y,n = know()
  259.     if n ~= nil then
  260.       drawpushed(x,y,n)
  261.       if n== 'C' then kpush = 'false'  sleep(0.1) drawkeys() break
  262.       elseif n== 'E' then kpush = 'true' sleep(0.1) drawkeys() break
  263.       end
  264.     end
  265.   end
  266.   if setp then
  267.     vid.fill(1,2,60,8, " ")
  268.     vid.set(1,2,'Clear fingerprints database? [E/C]: ')
  269.     while true do
  270.       _,_,tx,ty,_,who = toucheve()
  271.       tpoint = {tx,ty}
  272.       x,y,n = know()
  273.       if n ~= nil then
  274.         drawpushed(x,y,n)
  275.         if n== 'C' then sleep(0.1) drawkeys() break
  276.         elseif n== 'E' then m=hdd.open('/configs/fingers.cfg', "w") hdd.close(m) sleep(0.1) drawkeys() break
  277.         end
  278.       end
  279.     end
  280.   end
  281.   hdd.write(f,passw..'\n'..stars..'\n'..kpush..'\n'..corr..'\n'..incorr)
  282.   hdd.close(f)
  283.   computer.shutdown(true)
  284. end
  285.  
  286. function finger()
  287.   vid.setBackground(0)
  288.   vid.setForeground(1)
  289.   rr=14
  290.   while rr ~=10 do
  291.     vid.set(31,rr, '─────────')
  292.     sleep(0.05)
  293.     vid.set(31,rr, '         ')
  294.     rr=rr-1
  295.   end
  296.   while rr ~=14 do
  297.     vid.set(31,rr, '─────────')
  298.     sleep(0.05)
  299.     vid.set(31,rr, '         ')
  300.     rr=rr+1
  301.   end
  302.   sleep(0.05)
  303.   vid.set(31,10, '█████████')
  304.   vid.set(31,11, '█  ████ █')
  305.   vid.set(31,12, '█ █ █ █ █')
  306.   vid.set(31,13, '█ █ █ █ █')
  307.   vid.set(31,14, '█████████')
  308. end
  309.  
  310. if component.list("gpu")() == nil then error('Ow, where is Video Card?') end
  311. vid=component.proxy(component.list("gpu")())
  312. if vid.maxDepth() > 1 then error("It's version for Tier 1 Video Card only!") end
  313. if component.list("redstone")() == nil then error('Redstone device not found in system!') end
  314. red=component.proxy(component.list("redstone")())
  315. mx, my = vid.getResolution()
  316. vid.fill(1, 1, mx, my, " ")
  317. vid.setResolution(40,20)
  318. mx, my = vid.getResolution()
  319. for hda in pairs(component.list("filesystem")) do
  320.   hdd=component.proxy(hda)
  321.   if hdd.getLabel() ~= 'tmpfs' then break end
  322. end
  323. if hdd.exists('/configs/sets.cfg') then
  324.   f=hdd.open('/configs/sets.cfg',"r")
  325.   rd=hdd.read(f,512)
  326.   if rd == nil then intap() end
  327.   rd = totable(rd)
  328.   if #rd ~= 5 then intap() end
  329.   passw= rd[1]
  330.   stars= rd[2]
  331.   kpush= rd[3]
  332.   corr= rd[4]
  333.   incorr= rd[5]
  334.   hdd.close(f)
  335.   f=hdd.open('/configs/fingers.cfg',"r")
  336.   allowed = hdd.read(f,2048)
  337.   if allowed == nil then allowed = {} else allowed = totable(allowed) end
  338.   hdd.close(f)
  339. else
  340.   hdd.makeDirectory('/configs/')
  341.   hdd.open('/configs/fingers.cfg',"w")
  342.   intap()
  343. end
  344. drawplate('wh')
  345. drawkeys()
  346. vid.setForeground(0x00FF00)
  347. vid.set(4,20,'2020 (c) Compys Security Software')
  348. while true do
  349.   inpassw=''
  350.   see=''
  351.   drawkeys()
  352.   drawfinger()
  353.   pos = 1
  354.   prept = 21
  355.   while true do
  356.     _,_,tx,ty,_,who = toucheve()
  357.     tpoint = {tx,ty}
  358.     x,y,n = know(false)
  359.     if n ~= nil then
  360.       if kpush =='true' then drawpushed(x,y,n) end
  361.       if n== 'C' then inpassw='' see='' vid.fill(1, 3, 60, 1, " ") pos =1 prept = 21 sleep(0.1) drawkeys()
  362.       elseif n== 'E' then sleep(0.1) drawkeys() break
  363.       else
  364.         pos = pos+1
  365.         if pos % 2 == 0 then prept= prept-1 end
  366.         inpassw = inpassw..n
  367.         if stars == 'false' then
  368.           see= see..'*'
  369.         else
  370.           see= see..n
  371.         end
  372.         vid.set(prept,3,see)
  373.         sleep(0.1)
  374.         drawkeys()
  375.       end
  376.     end
  377.   end
  378.   if inpassw == passw then
  379.     drawplate('gr')
  380.     red.setOutput(tonumber(corr), 15)
  381.     for _,name in pairs(allowed) do
  382.       if who == name then exis=true break end
  383.     end
  384.     if exis~=true then table.insert(allowed, who) f=hdd.open('/configs/fingers.cfg',"w") hdd.write(f,untable(allowed)) hdd.close(f) end
  385.     exis= nil
  386.   else
  387.     drawplate('rd')
  388.     red.setOutput(tonumber(incorr), 15)
  389.   end
  390.   sleep(1.5)
  391.   drawplate('wh')
  392.   red.setOutput(tonumber(corr), 0)
  393.   red.setOutput(tonumber(incorr), 0)
  394. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement