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

How to easily anonymize yourself.

Started by HaddockDev, 04 November 2016 - 12:27 AM
HaddockDev #1
Posted 04 November 2016 - 01:27 AM
How to easily anonymize yourself in CC.


​Disclaimer: This is not meant to be used maliciously. Sure, I'm using the way you program in Lua to my advantage here, but seriously.

Already, you might be asking, why do I need this? How would I use this? How could it help me? And all that jazz, but just to answer all of these questions I've used for an example:
  • Anonymizing your network traffic. (sender = 0, receiver = 0)
  • Research, maybe even to see what your server clients are up to just in case there is something fishy going on.
  • [offtopic]nsa stuff :(/> boooo[/offtopic]
Like I already mentioned a few times, please whatever you do don't use this maliciously. Sure, I'm already making it worse but this is mainly so you can scramble your traffic so people who are listening on whatever channel intercept the message, but they have no idea of where its coming from or where its going to. This might be useful for people using the repeat script because if you modify it, you could change the ID so other computers hooked up to the repeater work normally.

So, how do I do this?
Well, it's actually pretty simple. You can use Lua to its advantage and overwrite existing functions. Kinda scary when you look at it, but it can be useful sometimes.

First off, we are going to get our ID. You can do this by the following:

--variant 1
oldID = os.getComputerID() --call the function and store whatever is returned in a variable
--variant 2
oldID = os.getComputerID --make a variable and copy os.getComputerID to it

Once you got one of them in your code, you can now anonymize yourself, then revert back when you need to!
How do you anonymize yourself? Well, remember how I said I'm using Lua to it's advantage…

function os.getComputerID() --were giving it an already existing variable in a table so it overwrites that variable
  return 0 --or whatever id you prefer
end

Put two and two together, and we could make a little program!

local oldID = os.getComputerID --copy the old function into a local variable so we can restore it, note that there are no ()!
print("Anonymizing the computer...")
function os.getComputerID() --override variable
  return 0 --thats now our id to computer software
end
print("Done! Your ID is " .. os.getComputerID() .. "!")
print("Press any key to de-anonymize.")
read()
os.getComputerID = oldID --note that there is no ()
print("Your computer ID has been reverted to " .. os.getComputerID() .. "!")

Use multishell with that program with a rednet messenger that uses ID's and your set.
For example, run this string in a server computer that you didn't anonymize and you got the ID of it:
rednet.open( put in your modem side here ); local i,m = rednet.recieve(); print(i .. ": "..m)
What that does is it opens a modem on the side you put it to, then you tell the computer "Wait until somebody says something to you" and it will wait until a message is intercepted by the computer. It will then print the ID of the sender and the contents.

Use that with our little anonymizer thingy and this will come out when you send a message to the computer
"(id you set the anonymized computer to, maybe 0): (your message, maybe a hello world)"
If you didnt modify the ID and you sent a hello world then your output would be this:
"0: Hello world!"

How does this work?
Well, we overwrite os.getComputerID which gives us the ID of the computer with our own function to return a custom ID.
So, to EVERYBODY on rednet or something now knows you as 0 or 1 or 6 or something. It gets even messier when there are multiple computers with the same ID on rednet. (there are 5 computers, all with the ID of 1)
I hope I explained that well, I just kinda wrote how I thought it worked, then made it as non-techy as possible.

Why does this work?
Because of the way Lua is programmed, putting a variable into function is now a function. Want the OS api to be a function?
function os()print("hey");end
Done!
Plus, from the majority of program's I've seen that use rednet don't cache the ID's, or so I thought.


Anyways, I'm going to end it off here, and what makes it worse is that I don't know how to end of these kinds of things, so thanks for reading?!?!?!?
(just to let you know, to me this was a bad way of describing what im doing and all of that, so either way any criticism is accepted but it already is accepted idk why i am still writing k bye)
KingofGamesYami #2
Posted 04 November 2016 - 02:18 AM
Or you could simply use modem instead of rednet.
HaddockDev #3
Posted 04 November 2016 - 10:26 AM
Or you could simply use modem instead of rednet.
Yeah, very true. I just kinda made it system wide to be honest so anything that uses rednet/modem that needs the ID of a computer will return what you set it to.
The Crazy Phoenix #4
Posted 26 July 2017 - 01:50 AM
Your method also has the downside of losing the computer ID if the program crashes.
Sure, you could use pcall to catch any potential errors, but it's still safer to use peripheral.call/modem.
Anavrins #5
Posted 26 July 2017 - 02:15 AM
Every modem messages received comes with the distance it traveled from the sender to you.
Capture that message from 4 known locations, and you can work the GPS function backward to resolve your exact position, regardless of which ID you're using.
Knowing your ID is much less interesting than knowing your exact coordinates.
You really can't be truly anonymous in CC.
Edited on 26 July 2017 - 12:17 AM