This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Antelux's profile picture

Sourceclose - Make Your Programs Closed Source!

Started by Antelux, 16 August 2013 - 01:51 PM
Antelux #1
Posted 16 August 2013 - 03:51 PM
Me And MKlegoman357 made a nice program called SourceClose and makes your programs
closed source!

Screenies:

Using It:


Using it to close source firewolf:


Closed Source Firewolf Working:


What closed source firewolf looks like:


Usage:
close <source> <closedSourceDestination>

How to get:
[You can't. -L]
Grim Reaper #2
Posted 16 August 2013 - 04:08 PM
This isn't really the best method for doing this:

Here's your source code:
Spoiler

function load(file)
  file = fs.open(file, "r")
  file2 = file.readAll()
  file.close()
  return file2
end

function write(file,text)
local code = [[local t = ""
for i = 1, #c do
  t = t .. string.char(c[i])
end
local f = assert(loadstring(t, shell.getRunningProgram()))
local env = {shell = shell}
setmetatable(env, {__index = _G})
setfenv(f, env)
f(...)
]]

  file = fs.open(file, "w")
  file.writeLine("local c = " ..text)
  file.writeLine(code)
  file.close()
end

local function ser (t)
  local text = "{"

  for i = 1, #t do
	text = text .. t[i] .. ","
  end

  return text .. "}"
end

function dump(file)
  local tab = {}

  for i = 1, #file do
	table.insert(tab, file:sub(i, i):byte())
  end

  return ser(tab)
end

function close(fileL, fileW)
  fileLoad = load(fileL)
  fileDump = dump(fileLoad)
  write(fileW, fileDump)
end

local fileLoad, fileWrite = ...

if fileLoad == nil or fileWrite == nil then
  print("Usage: " .. shell.getRunningProgram() .. " <sourceFile> <closedSourceFile>")
else
  close(fileLoad, fileWrite)
  print("Done!")
end

Dumping the function with string.dump I think is the approach that most people take when making lua files closed source, but this certainly is an interesting idea :)/> +1
Yevano #3
Posted 16 August 2013 - 05:43 PM
Non-obfuscated Lua bytecode is nearly 1:1 with Lua source code. All you lose is original formatting and comments. A compiled program can be easily decompiled with tools like LuaDec.
Lyqyd #4
Posted 16 August 2013 - 06:22 PM
Obfuscated Lua code is not allowed on these forums, as it is impractical to determine that it is not malicious.