pepeknamornik

stahni utility

Mar 17th, 2020 (edited)
592
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.62 KB | None | 0 0
  1. verze = "21.0617.R1"
  2. local tArgs = { ... }
  3. local PastebinMode = false
  4. local DevbinMode = false
  5.  
  6. if #tArgs < 2 then
  7.     return
  8. end
  9.  
  10.     if fs.exists("/C/system/RAM/online") then
  11.     term.setBackgroundColor(colors.black)
  12.         local data = fs.open("/C/system/RAM/online", "r")
  13.         local Conser = data.readLine()
  14.         if (Conser == "pastebin.com") then PastebinMode = true  DevbinMode = false
  15.         elseif (Conser == "devbin.dev") then DevbinMode = true PastebinMode = false
  16.         else DevbinMode = false PastebinMode = false end
  17.         data.close()
  18.     else DevbinMode = false PastebinMode = false end
  19.    
  20. if not http then
  21.     return
  22. end
  23.  
  24. local function extractId(paste)
  25.     local patterns = {
  26.         "^([%a%d]+)$",
  27.         "^https?://pastebin.com/([%a%d]+)$",
  28.         "^pastebin.com/([%a%d]+)$",
  29.         "^https?://pastebin.com/raw/([%a%d]+)$",
  30.         "^pastebin.com/raw/([%a%d]+)$",
  31.     }
  32.  
  33.     for i = 1, #patterns do
  34.         local code = paste:match(patterns[i])
  35.         if code then return code end
  36.     end
  37.  
  38.     return nil
  39. end
  40.  
  41. local function get(url)
  42.     local paste = extractId(url)
  43.     if not paste then
  44.         io.stderr:write("Invalid pastebin code.\n")
  45.         io.write("The code is the ID at the end of the pastebin.com URL.\n")
  46.         return
  47.     end
  48.  
  49.     local cacheBuster = ("%x"):format(math.random(0, 2 ^ 30))
  50.     local response, err = http.get(
  51.         "https://pastebin.com/raw/" .. textutils.urlEncode(paste) .. "?cb=" .. cacheBuster
  52.     )
  53.  
  54.     if response then
  55.         -- If spam protection is activated, we get redirected to /paste with Content-Type: text/html
  56.         local headers = response.getResponseHeaders()
  57.         if not headers["Content-Type"] or not headers["Content-Type"]:find("^text/plain") then
  58.             io.stderr:write("Failed.\n")
  59.             return
  60.         end
  61.  
  62.         local sResponse = response.readAll()
  63.         response.close()
  64.         return sResponse
  65.     else
  66.         io.stderr:write("Failed.\n")
  67.     end
  68. end
  69.  
  70. local function getdevbin( pasteid, filepath ) --#more descriptive variable names
  71.   local handle = http.get( "https://devbin.dev/raw/" .. pasteid ) --#sometimes CC has problems with https
  72.   if handle then --#if the request succeeded
  73.     local file = fs.open( filepath, "w" )
  74.     file.write( handle.readAll() )
  75.     file.close()
  76.     handle.close() --#always close web handles!
  77.     return true --#we succeeded, return true
  78.   end
  79.   return false --#it didn't work, return false
  80. end
  81.  
  82. if PastebinMode or DevbinMode then
  83.     local cesta = tArgs[3]
  84.  
  85.     if (cesta == "/C/system/api/device.api") then
  86.         if PastebinMode then tArgs[1] = "get" tArgs[2] = "34aaDf4t"
  87.         elseif DevbinMode then tArgs[1] = "getDev"  tArgs[2] = "mjcr9z3b"
  88.         end
  89.     elseif (cesta == "/C/Programs/PepekSoft/smanager.lua") then
  90.         if PastebinMode then tArgs[1] = "get" tArgs[2] = "z02yAN3M"
  91.         elseif DevbinMode then tArgs[1] = "getDev"  tArgs[2] = "cn90fdux"
  92.         end
  93.     elseif (cesta == "/C/setting.lua") then
  94.         if PastebinMode then tArgs[1] = "get" tArgs[2] = "vxJjQzem"
  95.         elseif DevbinMode then tArgs[1] = "getDev"  tArgs[2] = "nhbaj5fb"
  96.         end
  97.     elseif (cesta == "/C/system/api/bluescreen.lua") then
  98.         if PastebinMode then tArgs[1] = "get" tArgs[2] = "DSNcZuMZ"
  99.         elseif DevbinMode then tArgs[1] = "getDev"  tArgs[2] = "ofep5qq2"
  100.         end
  101.     elseif (cesta == "/C/system/api/sound.api") then
  102.         if PastebinMode then tArgs[1] = "get" tArgs[2] = "Td7gSZZq"
  103.         elseif DevbinMode then tArgs[1] = "getDev"  tArgs[2] = "6mfywzvq"
  104.         end
  105.     elseif (cesta == "/C/system/api/print.api") then
  106.         if PastebinMode then tArgs[1] = "get" tArgs[2] = "VEfwuEHM"
  107.         elseif DevbinMode then tArgs[1] = "getDev"  tArgs[2] = "4sx3qe7f"
  108.         end
  109.     elseif (cesta == "/C/system/api/smbc.lua") then
  110.         if PastebinMode then tArgs[1] = "get" tArgs[2] = "gQVYieMJ"
  111.         elseif DevbinMode then tArgs[1] = "getDev"  tArgs[2] = "op7md1yp"
  112.         end
  113.     elseif (cesta == "/C/system/api/stahni.api") then
  114.         if PastebinMode then tArgs[1] = "get" tArgs[2] = "GssKCexp"
  115.         elseif DevbinMode then tArgs[1] = "getDev"  tArgs[2] = "can5mlrd"
  116.         end
  117.     elseif (cesta == "/C/system/api/commands.lua") then
  118.         if PastebinMode then tArgs[1] = "get" tArgs[2] = "r18V4xrG"
  119.         elseif DevbinMode then tArgs[1] = "getDev"  tArgs[2] = "kvbpbizu"
  120.         end
  121.     elseif (cesta == "/C/system/api/commander.lua") then
  122.         if PastebinMode then tArgs[1] = "get" tArgs[2] = "LY8cUArW"
  123.         elseif DevbinMode then tArgs[1] = "getDev"  tArgs[2] = "mjcr9z3b"
  124.         end
  125.     elseif (cesta == "/startup.lua") then
  126.         if PastebinMode then tArgs[1] = "get" tArgs[2] = "0xh6jEx1"
  127.         elseif DevbinMode then tArgs[1] = "getDev"  tArgs[2] = "nJ6DXtfN"
  128.         end
  129.     elseif (cesta == "/C/system/.core/desktop.lua") then
  130.         if PastebinMode then tArgs[1] = "get" tArgs[2] = "HyhMtGvd"
  131.         elseif DevbinMode then tArgs[1] = "getDev"  tArgs[2] = "dyxq5e3a"
  132.         end
  133.     elseif (cesta == "/C/system/api/APIS.lua") then
  134.         if PastebinMode then tArgs[1] = "get" tArgs[2] = "rt2e0GLX"
  135.         elseif DevbinMode then tArgs[1] = "getDev"  tArgs[2] = "yezxwowf"
  136.         end
  137.     end
  138. end
  139.  
  140. local sCommand = tArgs[1]
  141. if sCommand == "getDev" then
  142.     getdevbin( tArgs[2], tArgs[3])
  143. elseif sCommand == "get" then
  144.  
  145.     local sCode = tArgs[2]
  146.     local sFile = tArgs[3]
  147.     local sPath = shell.resolve(sFile)
  148.     if fs.exists(sPath) then
  149.         return
  150.     end
  151.  
  152.     local res = get(sCode)
  153.     if res then
  154.         local file = fs.open(sPath, "w")
  155.         file.write(res)
  156.         file.close()
  157.     end
  158. elseif sCommand == "run" then
  159.     local sCode = tArgs[2]
  160.  
  161.     local res = get(sCode)
  162.     if res then
  163.         local func, err = load(res, sCode, "t", _ENV)
  164.         if not func then
  165.             return
  166.         end
  167.         local success, msg = pcall(func, select(3, ...))
  168.     end
  169. else
  170.     return
  171. end
Add Comment
Please, Sign In to add comment