Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

Storing Code Server Side

Hello HackForums!

I was wondering on how to store code server side but when application opens it loads it from the database. Is this possible? and if so how would I go about doing such a thing?

I had searched this but haven't found very much on it, Maybe I just didn't use the right key words but anyway, Thank you in advance!
This can be done easily with a webRequest to the server to pull down the code and then simply run it using Reflection.
http://www.aboutmydot.net/desktop-applic...ntime.html
The above is some sample Reflection code which will allow you to run and compile code at run-time.

Hope this helps,
🎉

[Image: DreddSig.gif]
(Apr 26, 2016 08:00 AM)Dredd Wrote:  This can be done easily with a webRequest to the server to pull down the code and then simply run it using Reflection.
http://www.aboutmydot.net/desktop-applic...ntime.html
The above is some sample Reflection code which will allow you to run and compile code at run-time.

Hope this helps,
🎉

Thank you very much for your reply, This helps a lot, Thank you again! :)
You might be interested in looking into LiteCode.
(Apr 26, 2016 09:41 AM)CoderEX Wrote:  You might be interested in looking into LiteCode.

I am not looking to protect my code however I am looking for basically the server to store let's say
Code
MessageBox.Show("Messagebox example", "Hello world")

In the database itself and in vb.net some how connect to the database and run the function by reading the table of functions and/or code.
(Apr 26, 2016 11:22 AM)Netflix and Weed Wrote:  I am not looking to protect my code however I am looking for basically the server to store let's say
Code
MessageBox.Show("Messagebox example", "Hello world")

In the database itself and in vb.net some how connect to the database and run the function by reading the table of functions and/or code.

From my understanding, you basically want to store variables in a database, and then in VB.Net, retrieve it and then display it in the user's end, right?
(Apr 26, 2016 11:33 AM)CoderEX Wrote:  From my understanding, you basically want to store variables in a database, and then in VB.Net, retrieve it and then display it in the user's end, right?

Yes that is exactly what I want to do. Will LiteCode allow me to do such a thing? But then again I don't want it going through 3rd party.
(Apr 26, 2016 07:02 AM)Netflix and Weed Wrote:  Hello HackForums!

I was wondering on how to store code server side but when application opens it loads it from the database. Is this possible? and if so how would I go about doing such a thing?

I had searched this but haven't found very much on it, Maybe I just didn't use the right key words but anyway, Thank you in advance!

Be careful with this, as this is potentially a vulnerability for some sort of server-side XSS... In .NET even, where it usually isn't a problem (there's no eval-like function).

You can load the code from the database, and execute it via reflection, but I really don't recommend this. If anything, make sure to sandbox it.

Fortunately, there are some other ways to do this, but they are a bit complicated. Might be overkill for something you can avoid by not storing code in a DB.

You could, instead of storing raw VB/C# code, maybe just come up with a set of "actions" that indicate to do a certain thing on the server. Then just store an JSON array of these, and interpret it.

Alternatively, you could implement some type of minimal scripting language or use a C# JavaScript (or whatever language) parser.

However, avoid storing code in database. That's not a suggested practice, mostly for security reasons.

There is 100% a better way to do this.

------------------

EDIT:

Just saw you only want to store variables. You don't need something like LiteCode at all. Just run through your database. i.e.:

Code
SELECT value from variables WHERE name='myVarName'
(Apr 26, 2016 11:49 AM)SIM-1725686 Wrote:  Be careful with this, as this is potentially a vulnerability for some sort of server-side XSS... In .NET even, where it usually isn't a problem (there's no eval-like function).

You can load the code from the database, and execute it via reflection, but I really don't recommend this. If anything, make sure to sandbox it.

Fortunately, there are some other ways to do this, but they are a bit complicated. Might be overkill for something you can avoid by not storing code in a DB.

You could, instead of storing raw VB/C# code, maybe just come up with a set of "actions" that indicate to do a certain thing on the server. Then just store an JSON array of these, and interpret it.

Alternatively, you could implement some type of minimal scripting language or use a C# JavaScript (or whatever language) parser.

However, avoid storing code in database. That's not a suggested practice, mostly for security reasons.

There is 100% a better way to do this.

------------------

EDIT:

Just saw you only want to store variables. You don't need something like LiteCode at all. Just run through your database. i.e.:

Code
SELECT value from variables WHERE name='myVarName'
Or he could encrypt the code that he wants and decrypt at user-end
(Apr 26, 2016 11:55 AM)emem Wrote:  Or he could encrypt the code that he wants and decrypt at user-end

This is just pushing the burden of an XSS vulnerability onto the user.
base64_encode your code before storing in your database
(Apr 26, 2016 04:22 PM)godlyitnetwork Wrote:  base64_encode your code before storing in your database

Again, this is a solution that does nothing for you in terms of security. But whatever.
(Apr 26, 2016 06:52 PM)SIM-1725686 Wrote:  Again, this is a solution that does nothing for you in terms of security. But whatever.

base64 is the best and easy way of using data for security u encrypt the data before u base64 it
[Image: bitcoin.png] Be Nice For Once 15hVUVz7xA4kazHdk2BuErENGCskVwjYXP
(Apr 27, 2016 04:28 AM)HFDone Wrote:  base64 is the best and easy way of using data for security u encrypt the data before u base64 it

No, you are misunderstanding. No matter the encoding, if you're going to running arbitrary code, that is a security vulnerability if proper precautions are not taken.

Hello????
The most secure way to do it:
- Store data from the client-side by making a POST request to the web-server with client-side data.
- Store data from the server-side by making a GET request to the web-server.

The fastest way to do it:
- Have your program directly connect to the remote database to store and retrieve information.
- Just know, someone could most likely obtain the database login details that your program is using by reverse engineering it.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Shell] by Robert RougeSep 24, 2026 10:02 AM 4 220 Sep 24, 2026 10:02 AM
Last Post: Anonynuk
[C#] by zxPhantomBladeNov 16, 2020 03:05 AM 4 199 Nov 16, 2020 03:05 AM
Last Post: zxPhantomBlade
[Python] by greasyAlessandraAug 31, 2020 10:23 PM 13 282 Aug 31, 2020 10:23 PM
Last Post: greasyAlessandra