Advertisement
VlaD00m

SecuCODEX Color (HDD)

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