Jump to content


Ajt86's Content

There have been 17 items by Ajt86 (Search limited from 10-February 22)


By content type

See this member's

Sort by                Order  

#243343 Get item ID inside blood magic altar.

Posted by Ajt86 on 16 January 2016 - 11:47 PM in Ask a Pro

It returns a table, so just get the index in the table.

local atable = {
  ["key"] = "Value"
}
print(atable.key)    -- Prints "Value"
print(atable["key"])    -- Prints "Value"

The latter is more useful when Lua could misinterpret the dot notation (spaces or special characters in key). It is also more useful when you're dynamically indexing the table.



#243134 Fox Anti-Virus 1.01

Posted by Ajt86 on 14 January 2016 - 09:10 PM in Programs

Be careful because it is possible to write a virus that infects disks (I've done it before for demonstrational purposes).

To avoid this, you'll want to shutdown (Ctrl + S), insert the disk, and start the computer.
Otherwise, some viruses might infect the disk.



#243467 Fox Anti-Virus 1.01

Posted by Ajt86 on 17 January 2016 - 01:01 PM in Programs

I would instead suggest running the program in a sandboxed environment to see what it does, and if it appears to be malicious, (re)move it.

Anti-viruses are also a lot less useful since 1.76 simply because you can protect yourself against them now if you have a secure system.



#243023 ComputerCraft 1.77 (Minecraft 1.8.9) Beta Information

Posted by Ajt86 on 13 January 2016 - 08:04 PM in Beta Testing

Thank you for finally adding an option for disabling disk startup! :lol:



#243352 What do you mean "61: ')' expected"? That line already has one!

Posted by Ajt86 on 16 January 2016 - 11:59 PM in Ask a Pro

View PostZippoMoon, on 16 January 2016 - 11:54 PM, said:

View PostDragon53535, on 16 January 2016 - 11:50 PM, said:

print("Vault Door Lock: - [1] "..VDL)
--# Should be
print("Vault Door Lock: - [1]"..tostring(VDL))
--#You need to tostring the boolean
I suppose taking the meaning of the above post is good, but you really should of gone with the entirety of what i put :P
Wait, you literally need to add in tostring to the code for it to work? I thought that to illustrate the point!

You need to add tostring if it's not a string otherwise you'll get an error about concatenating string and insert type here



#243207 Need help with "Server"

Posted by Ajt86 on 15 January 2016 - 05:14 PM in Ask a Pro

View PostHPWebcamAble, on 15 January 2016 - 01:13 AM, said:

Ideally, broadcast is only used when a client wants to find servers in range

Ideally, rednet shouldn't even be used (easy packet sniffing and predictably simple protocol).



#243456 [Solved] Unload all APIs

Posted by Ajt86 on 17 January 2016 - 06:58 AM in Ask a Pro

View PostBomb Bloke, on 17 January 2016 - 12:34 AM, said:

Here's the source of os.loadAPI() (as defined in bios.lua):

Spoiler

As you can see, the API is loaded as a function, and then the environment of that function is replaced with a custom one. The whole point of this is so that any globals the API defines can then be extracted and dumped into the API table which finally ends up in _G (that being the "loaded API").

That is to say, APIs can't touch _ENV. This is why they can't call "shell" or "multishell" functions: Those are loaded into the global environment area all our scripts use, _ENV, as opposed to the table APIs generally go into, _G.

(Edit: Point is, everything an API does is supposed to apply on a system-wide basis. If two different scripts asking one API to do something results in a conflict, then that's the fault of the API, and it's not your problem to fix. There's a reason why you can't define windows using the term API as a parent, for example.)

There's a problem with that. I want to unload all the APIs bios.lua initialized and I want to reload those in the sandboxed filesystem.
I've already sandboxed os.loadAPI to load APIs into the sandboxed environment.



#243346 [Solved] Unload all APIs

Posted by Ajt86 on 16 January 2016 - 11:50 PM in Ask a Pro

View PostBomb Bloke, on 16 January 2016 - 11:44 PM, said:

When an API is loaded, it gets its own environment table - they never share the environment your code is running in. Given this, I don't see how your sandbox creates a problem...?

Are you aware of the differences between _ENV and _G?

I'm enclosing each function in a function whose _ENV is equal to the sandbox. Kind of like this:

sandbox[function] = function(...)
  _ENV = sandbox
  return _G[function](...)
end

However, APIs that define variables outside the function definition can no longer access those variables. And they do use the sandbox environment, functions inherit their environment from the function above them in the stack.



#243336 [Solved] Unload all APIs

Posted by Ajt86 on 16 January 2016 - 11:36 PM in Ask a Pro

I'd like to sandbox all functions by embedding each of them inside a function where _ENV is set to the sandbox table.

Unfortunately, APIs often declare variables outside the function, which get excluded by my idea of using _ENV (and setfenv wouldn't help either).
My plan to work around this is to unload all APIs and reload them in the sandbox table.

Unfortunately, if I try to reload all of them (except term, window and those the computer can't access), the computer just shuts down.

How would I reload all the available APIs without the computer shutting down?



#243466 [Solved] Unload all APIs

Posted by Ajt86 on 17 January 2016 - 12:32 PM in Ask a Pro

Somehow I got it to work... I guess unloading the APIs really is a bad idea.

The only API I had to reload was the IO API.
I have no idea how I got the others to work.

Here's the method I used (worked)

local sandbox = {--[[ Generate environment here ]]}    -- Your sandbox environment
sandbox._G = sandbox
sandbox.func = function(...)	 -- Do this for each function
  _ENV = sandbox
  return func(...)
end

Thanks for your help.



#242881 Ability to overwrite ROM (except bios.lua) on first startup (new computer)

Posted by Ajt86 on 11 January 2016 - 07:07 PM in Suggestions

Ah, well at least a way of modifying all rom files (except bios.lua) then.



#242872 Ability to overwrite ROM (except bios.lua) on first startup (new computer)

Posted by Ajt86 on 11 January 2016 - 06:07 PM in Suggestions

While it is possible to, in some way, modify the ROM by screwing with the fs / io API, I would like to change rom/startup because it can cause security exploits (most notably with disks) and modifying the API just doesn't make the cut because rom/startup is already run before /startup. I would also like it to be possible to have each computer have a custom rom, to allow for it on servers.

Would it be possible to allow the person who placed the computer to modify the rom directory or allow its modification only when a new computer is placed (computer must be backed up and replaced to fix)?

This system could become 100% secure simply by requiring that the person labels their computer and the OS checks the computer's ID every startup to verify that a potential hacker hasn't (somehow) copied all files off and replaced the computer with a new one. On top of that, the hacker wouldn't even be able to obtain the files without breaking into the OS, assuming the OS is custom and supports user-level security (or file encryption).

Here's how exactly it could work...
  • User places a new computer (new ID generated)



  • Computer asks the user if they want to modify the rom (recommends to select "no")



  • If yes, computer opens up into a basic shell where the user is asked to select a disk drive containing the new rom



  • Computer then resumes running by going through the OS's security checks (OS handles sandboxing, etc).



  • User now has a secure computer.
I don't see how this could be misused and hope that it gets implemented.



#242932 Ability to overwrite ROM (except bios.lua) on first startup (new computer)

Posted by Ajt86 on 12 January 2016 - 02:50 PM in Suggestions

Unfortunately, that doesn't allow the individual modification of each computer's rom.



#243025 [Solved] Os.run with _G table

Posted by Ajt86 on 13 January 2016 - 08:56 PM in Ask a Pro

When calling os.run with the global table, I get a "loop in gettable" error.

How would I use it with the global table?



#243106 [Solved] Os.run with _G table

Posted by Ajt86 on 14 January 2016 - 04:15 PM in Ask a Pro

View PostBomb Bloke, on 14 January 2016 - 12:29 AM, said:

They have access to it anyway.

I've tried passing it an empty table, but that doesn't work, they don't have access to global environment variables previously set in the same program (and that's also a relief for sandboxing).



#243225 Test if String is Enclosed

Posted by Ajt86 on 15 January 2016 - 10:12 PM in Ask a Pro

Lua doesn't use regular expressions, it uses patterns.



#243133 [Solved] Os.run with _G table

Posted by Ajt86 on 14 January 2016 - 09:03 PM in Ask a Pro

View PostLupus590, on 14 January 2016 - 06:23 PM, said:


Thank you Lupus but I already know what each one does. I've solved the problem by assigning all the global variables I want to pass down to a key in a table, which I then pass in to os.run/