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

How To Pass Arguments To Code Run From String

Started by Wojbie, 23 September 2013 - 02:25 PM
Wojbie #1
Posted 23 September 2013 - 04:25 PM
Hello i am having a problem working on my ComputerCraft program

I am working on self-decrypting program that stores encrypted version in string and after decrypting it runs it passing all arguments over to said run program.
Its running said string using
assert(loadstring(S))()
and i am wondering if there is a way to pass Arguments from main program to said string
I tried peeking on how does shell.run and os.run works to copy that behavior but i kinda got lost :P/>
I know i can do workaround by saving file and running it with
shell.run(saved file,arguments)
but i am trying to make it run without making temp files.

If Someone could explain how to make it work i would be very grateful.
Lyqyd #2
Posted 23 September 2013 - 04:34 PM
assert(loadstring(s))(…) should do it.

Obfuscated code is not allowed in the programs section.
Wojbie #3
Posted 23 September 2013 - 04:39 PM
Oh no it won't be obfuscated code :P/>
It will be Enigma simulator for encrypting your files on server - you don't want your enemy to use your programs do you :D/>
I was simply trying to make it self-executable in decryption :)/>
Tx for fast answer.
Lyqyd #4
Posted 23 September 2013 - 05:03 PM
By your description (decrypt and execute payload code), it is obfuscated and would not be allowed in the Programs section. We need to be able to read the code in plain text so that it can be verified as malicious or non-malicious if needed.
Wojbie #5
Posted 23 September 2013 - 05:10 PM
Code will be distributed without any payload.
Payload is added to code and encrypted by end-user with access password selected by end-user.

Program is simply encryption-decryption system with option of making self-decrypt programs.

Hope that clarifies my intentions :)/> If that kind of program is not allowed because of of self-decryption part i can scrap that from forums version. Sorry if what i said was unclear English it not my first nor second language :)/>
Wojbie #6
Posted 24 September 2013 - 04:05 PM
Sorry to bring Topic back up but i just don't want to post it in Programs if its not allowed and I don't feel it needs new Topic

Could someone review code and tell me if it breaks any of said rule Programs forum?

Program is simply encryption-decryption system with option of making self-decrypt programs.
Password entering screen captures numbers or special keys.
On advanced Computers is Colored and touch control also work.
Distributed code don't contain any coded payload.

Code can be found here:

http://pastebin.com/NKhvzq2B

Copy of help page:
SpoilerList of Commands:
1) enigma code [path] - Encrypt/Decrypt [path] file into [path].code file.

2) enigma codein [path] - Encrypt/Decrypt [path] file into itself (overwrites content) file.

3) enigma run [path] - Decrypt [path] file and run it. Efects on non coded file are undefined.

4) enigma exec [path] - Encrypt/Decrypt [path] file into [path].code file and add self- decrypting code.
This file can be used without main Enigma file. Simply run it and enter Pass.
ElvishJerricco #7
Posted 24 September 2013 - 04:20 PM
Sorry to bring Topic back up but i just don't want to post it in Programs if its not allowed and I don't feel it needs new Topic

Could someone review code and tell me if it breaks any of said rule Programs forum?

Program is simply encryption-decryption system with option of making self-decrypt programs.
Password entering screen captures numbers or special keys.
On advanced Computers is Colored and touch control also work.
Distributed code don't contain any coded payload.

Code can be found here:

http://pastebin.com/NKhvzq2B

Copy of help page:
SpoilerList of Commands:
1) enigma code [path] - Encrypt/Decrypt [path] file into [path].code file.

2) enigma codein [path] - Encrypt/Decrypt [path] file into itself (overwrites content) file.

3) enigma run [path] - Decrypt [path] file and run it. Efects on non coded file are undefined.

4) enigma exec [path] - Encrypt/Decrypt [path] file into [path].code file and add self- decrypting code.
This file can be used without main Enigma file. Simply run it and enter Pass.
Screens:
Spoiler[attachment=1338:2013-09-24_22.05.16.png]
[attachment=1339:2013-09-24_22.05.28.png]

As far as I can tell, your code is ok. It's basically just an encryption program, so I'm not sure why lyqyd said it was against the rules. But the encrypted files generated by your program could not be posted on the forums.

EDIT: Did you successfully figure out how to pass arguments, as this post was initially intended?
Wojbie #8
Posted 24 September 2013 - 04:36 PM
Yea figured it out - it was simple.
Its used 2 times in code
In line 312 its straightforward pass on arguments.
In line 322 I had to use unpack because I was removing first 2 arguments from argument list.
For why you can peek into advanced usage (line 260) to see examples of why.

Tx for fast answer - now I need to make nice looking Topic in Programs - :P/>
Probably not today - time to sleep now.
Lyqyd #9
Posted 25 September 2013 - 12:58 AM
That code above looks like it would be fine.

My original (mis)understanding was that the code to be posted would be a program that decrypts and executes an included payload of code, rather than a program that simply creates programs that do so.