CCHacker132

Minra_Client

Dec 4th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if not term.isColor() then
  2.   error('This program works on advanced computers only')
  3. end
  4.  
  5. --Made by MinerMan132 C:
  6.  
  7. --Released on December 5th 2019
  8.  
  9. --Do not modify this code
  10.  
  11. if not fs.exists('tempdat/') then
  12.     fs.makeDir('tempdat/')
  13. end
  14.  
  15. local safe = true
  16. function draw()
  17. term.setBackgroundColor(colors.cyan)
  18. term.clear()
  19. term.setTextColor(colors.gray)
  20. term.setCursorPos(2,17)
  21. write('Made by MinerMan132')
  22. term.setCursorPos(2,18)
  23. write('Released on December 5th, 2019')
  24. term.setCursorPos(2,19)
  25. term.setTextColor(colors.red)
  26. write('Do not modify this program')
  27. term.setTextColor(colors.black)
  28. term.setCursorPos(15,7)
  29. write('Website URL')
  30. term.setCursorPos(2,7)
  31. write('Safe Mode')
  32. term.setCursorPos(5,4)
  33. term.setTextColor(colors.gray)
  34. write("Entering the URL 'help' will redirect")
  35. term.setCursorPos(5,5)
  36. write("you to the help page.")
  37. term.setCursorPos(3,8)
  38. term.setTextColor(colors.black)
  39. if safe then
  40. term.setBackgroundColor(colors.lime)
  41. write('O')
  42. else
  43. term.setBackgroundColor(colors.red)
  44. write('|')
  45. end
  46. paintutils.drawLine(15,8,50,8,colors.lightGray)
  47. end
  48.  
  49. local function webget(ad)
  50. local check = true
  51. if http.request(ad) then
  52.   check = true
  53. else
  54.   check = false
  55. end
  56. if check then
  57. local site = http.get(ad)
  58. local web = {}
  59. local cweb = {}
  60. repeat
  61.   local line = site.readLine()
  62.   if line ~= nil then
  63.     table.insert(web,line)
  64.   end
  65. until line == nil
  66. local hts
  67. local hte
  68. for i,v in ipairs(web) do
  69.   if string.find(v,'</cc>') and hte == nil then
  70.       hte = i
  71.   elseif string.find(v,'<cc>') and hts == nil then
  72.     hts = i
  73.   end
  74. end
  75. if not hts or not hte then
  76.   return false
  77. end
  78. for pos = hts+1,hte-1 do
  79.   table.insert(cweb,web[pos])
  80. end
  81. return cweb
  82. else
  83. return false
  84. end
  85. end
  86.  
  87. function evcheck()
  88.   while true do
  89.     local ev = {os.pullEvent('mouse_click')}
  90.     if ev[3] == 3 and ev[4] == 8 then
  91.       local x,y = term.getCursorPos()
  92.       local color1 = term.getTextColor()
  93.       local color2 = term.getBackgroundColor()
  94.       term.setCursorPos(3,8)
  95.       term.setTextColor(colors.black)
  96.       if safe then
  97.         safe = false
  98.         term.setBackgroundColor(colors.red)
  99.         write('|')
  100.       else
  101.         safe = true
  102.         term.setBackgroundColor(colors.lime)
  103.         write('O')
  104.       end
  105.       term.setCursorPos(x,y)
  106.       term.setTextColor(color1)
  107.       term.setBackgroundColor(color2)
  108.     end
  109.   end
  110. end
  111.  
  112. local webcon
  113. local webname
  114.  
  115. function readcheck()
  116.   local report
  117.   local input
  118.   repeat
  119.     paintutils.drawLine(15,8,50,8,colors.lightGray)
  120.     term.setCursorPos(15,8)
  121.     term.setBackgroundColor(colors.lightGray)
  122.     term.setTextColor(colors.gray)
  123.     input = read()
  124.     if input == 'help' then
  125.       input = 'https://minraclient.github.io/Minra/'
  126.     end
  127.     report = webget(input)
  128.     if report == false then
  129.       term.setBackgroundColor(colors.cyan)
  130.       term.setCursorPos(10,9)
  131.       term.setTextColor(colors.red)
  132.       write('Website not found/website incompatable')
  133.       sleep(2)
  134.       term.setCursorPos(10,9)
  135.       term.clearLine()
  136.     end
  137.   until report ~= false
  138.   webcon = report
  139.   webname = input
  140. end
  141.  
  142. local sweblist = {}
  143.  
  144. if not http.request('https://minraclient.github.io/trusted_sources/') then
  145.   error('Verified website list offline or unreachable, contact creator.')
  146. end
  147.  
  148. local sweb = http.get('https://minraclient.github.io/trusted_sources/')
  149.  
  150. repeat
  151.   local line = sweb.readLine()
  152.   if line ~= nil then
  153.     table.insert(sweblist,line)
  154.   end
  155. until line == nil
  156.  
  157. table.remove(sweblist,1)
  158. table.remove(sweblist,1)
  159. table.remove(sweblist,#sweblist-1)
  160. table.remove(sweblist,#sweblist)
  161.  
  162. while true do
  163.   local skip = false
  164.   draw()
  165.   webcon = {}
  166.   parallel.waitForAny(readcheck,evcheck)
  167.   if webname and safe then
  168.     local check = false
  169.     for i,v in pairs(sweblist) do
  170.       if webname == v then
  171.         check = true
  172.       end
  173.     end
  174.     if not check then
  175.       term.setTextColor(colors.red)
  176.       term.setBackgroundColor(colors.cyan)
  177.       term.setCursorPos(6,9)
  178.       write('This website is not on the pre-approved list.')
  179.       term.setCursorPos(6,10)
  180.       write('Please disable safe mode to visit unlisted')
  181.       term.setCursorPos(6,11)
  182.       write('websites.')
  183.       sleep(6)
  184.       skip = true
  185.       for y = 9,11 do
  186.         term.setCursorPos(1,y)
  187.         term.clearLine()
  188.       end
  189.     end
  190.   end
  191.   if not skip then
  192.   local name = 'tempdat/temp'..tostring(math.random(1,2^10))
  193.   if fs.exists(name) then
  194.     fs.delete(name)
  195.   end
  196.   local tempfile = fs.open(name,'w')
  197.   for i,v in ipairs(webcon) do
  198.     tempfile.writeLine(v)
  199.   end
  200.   tempfile.close()
  201.   shell.run(name)
  202.   fs.delete(name)
  203.   end
  204. end
Add Comment
Please, Sign In to add comment