STeeL

Intersect plugins injection

20 posts in this topic

So, today I saw this topic and decided to make a small addon to Intersect server, which can load C# plugins, so anyone can make some server addons(like web service for registering accounts)

 

The first simple version with source and precompiled binary is attached to this post.

Currently I've wrote only 1 plugin that allows you to register account via web service.

 

UPDATED VERSION WITH MYSQL SUPPORT

 

How to use addon:

  1. download archive, unpack Intersect Plugin Loader.zip to server root
  2. run patched server Intersect Server.Patched.exe

 

How to use example plugin:

  1. open url http://localhost:8081/?k=test&a=reg&u=username here&p=password here&e=email here

 

This is very basic version, you can write more advanced plugins with help of this example

 

P.S sorry for my bad english

bundles.zip

 

 

Share this post


Link to post
Share on other sites
Just now, antarcticPuppy said:

https://www.virustotal.com/en/file/bf89b62bb0d5d2a097a2a1b545dc8ffe4b5cca917ac8c158662c511d783af577/analysis/1495043626/

Files clean :)

 

However on first run: It's run in windows no dedicated server, and I am green as leaf in those plugins stuffs and I could use a lil help ahah :D

Hmm,  I googled this issue, please try this version of plugin(it's listen only localhost address), should work fine

 

WebApiPlugin.zip

Share this post


Link to post
Share on other sites
Just now, STeeL said:

Alright. Working now! However, while I acess the link it says "Bad Request - Invalid Hostname" Should I be adding something else? Or somekind of software?

Share this post


Link to post
Share on other sites
Just now, antarcticPuppy said:

Alright. Working now! However, while I acess the link it says "Bad Request - Invalid Hostname" Should I be adding something else? Or somekind of software?

Right, i'am changed to listen only localhost.try this link http://localhost:8081/?k=test&a=reg&u=username here&p=password here&e=email here

Share this post


Link to post
Share on other sites

@STeeL Work's like a charm!

Amazing idea and amazing input, however did you remember to add everything? From inventory up to switches? (You can just copy some fresh made character's values)? Also, it uses 1;1;1 cordinates? Would be amazing if it had configurable file where you can input specific things. Or does it just copy the client's creation and everything is set up by server?

 

Just checked -- it only creates an USER, however I still believe that's awesome work and if you'd be bothered to smooth it out completly (creating a fully customizable plugin, with map location, class etc) I'd gladly donate some moneys for a beer for you! :D

HRA likes this

Share this post


Link to post
Share on other sites
Just now, antarcticPuppy said:

@STeeL Work's like a charm!

Amazing idea and amazing input, however did you remember to add everything? From inventory up to switches? (You can just copy some fresh made character's values)? Also, it uses 1;1;1 cordinates? Would be amazing if it had configurable file where you can input specific things. Or does it just copy the client's creation and everything is set up by server?

Well, it's only creating account, not character(but I think character creation is also possible). It's work exactly as server(my plugin injecting into server side code, and call "CreateAccount" procedure(you can see it in source attached to first post))

antarcticPuppy likes this

Share this post


Link to post
Share on other sites
Just now, STeeL said:

Well, it's only creating account, not character(but I think character creation is also possible). It's work exactly as server(my plugin injecting into server side code, and call "CreateAccount" procedure(you can see it in source attached to first post))

Ah! I was foolish, but actually it seems if you create a USER but give it no character then they'll be able to create a new one. Perfect! This plugin is amazing and so are you ! :D

Share this post


Link to post
Share on other sites
Just now, antarcticPuppy said:

Ah! I was foolish, but actually it seems if you create a USER but give it no character then they'll be able to create a new one. Perfect! This plugin is amazing and so are you ! :D

Thanks) I will create more advanced version with json responses(it would be much better for developers) later. I also have plans to make this server support mysql database(but not sure if I have time to do this)

Share this post


Link to post
Share on other sites

yea this is great, i downloaded and placed in my server folder now if only i knew what the heck i was doing this would be perfect but i haven't the slightest clue how to work with any of this but i really would like to learn how because i am creating a game i plan to make live once i am done with it

Share this post


Link to post
Share on other sites

Ok, so I done with mysql support(I am tested only basic features like registering, creating character etc., so other features should be tested)

PMA screenshot

stmysqltest.png?extra=8bBgpjTtg2hI6DlmZk

 

SOME IMPORTANT INFO

  1. mysql database support is not tested good enough
  2. there is no migration tool to convert existing sqlite db to mysql db(use this only for new projects)
  3. you still can use sqlite with this server version(just change database.xml to use sqlite)
  4. tested with 5.6.17 - MySQL Community Server

 

HOW TO USE IT

  1. download patch files
  2. unpack patch files to the server root
  3. create new mysql database & change database config (<server root>/resources/database.xml)
  4. launch server(tables should be created automaticly)

 

FOR DEVELOPERS

  1. code of database implementation is open source, so you can just change, compile and replace STStaticInjection.dll in <server_root>/libs/server/
  2. you can implement other DB engines (or even make ODBC) support based on this example
  3. plugins can now use JSON.NET, this dependency added to Intersect Server assembly

PLUGIN CHANGES

  1. webapi now return json result (for registering status codes are: 0 - success, 1 - invalid username, 2 - invalid email, 3 - account already exists, 4 - email in use)

Download link(uploaded to mega.co.nz because i can't attach big files on forum): https://mega.nz/#!VfxFTbYT!uq5ulAjqd7M6sqHe920pzeH1ZpmnCC2ycoisR1iyVKw

Source code: https://mega.nz/#!ZSYVDRiZ!-1rJYUe5nFifrZWPhvUXXan9txBWxu34CHt6q-_ku7M

 

P.S I am actually don't know whether mysql is really needed for beta version of server, but I think that for big projects better to use it rather than sqlite

Refur likes this

Share this post


Link to post
Share on other sites

This is actually incredible. A very nice way to add custom things to the engine without access to the source. A issue I see is that these plugins will have likely access to everything. If that is the case, couldn't someone make a malicious plugin?

Share this post


Link to post
Share on other sites
37 minutes ago, MiniGrief said:

This is actually incredible. A very nice way to add custom things to the engine without access to the source. A issue I see is that these plugins will have likely access to everything. If that is the case, couldn't someone make a malicious plugin?

 

 

Pretty sure like an source addons someone could put malicious code.

 

After does could use the server migrator to update their intersect version with this without bug ?

Share this post


Link to post
Share on other sites
5 minutes ago, Gibier said:

 

 

Pretty sure like an source addons someone could put malicious code.

 

After does could use the server migrator to update their intersect version with this without bug ?

Presumably, but any data or modifications to the DB tables with a plugin could cause an issue or all of the extra data would be wiped when upgrading.

Share this post


Link to post
Share on other sites
1 hour ago, Gibier said:

 

 

Pretty sure like an source addons someone could put malicious code.

 

After does could use the server migrator to update their intersect version with this without bug ?

yes malicious code can be added to plugins and even to server, fortunately it's C# assemblies, so everyone can easily check code with help of any decompiler(ilspy or dotpeek or .net reflector for example)

Rob likes this

Share this post


Link to post
Share on other sites

How does this work? Is it overriding the functions called in the dll and replacing them with your version that then calls the original? Or did you decompile the original source code?  Or is it simply a function that you injected on top that listens in? Can you access the intersect calls? How do you get login info if you are not overriding the dll?  I think this thing is very cool and was wondering how you did it!

 

 

Share this post


Link to post
Share on other sites
On 18.05.2017 at 11:08 PM, Marsh said:

How does this work? Is it overriding the functions called in the dll and replacing them with your version that then calls the original? Or did you decompile the original source code?  Or is it simply a function that you injected on top that listens in? Can you access the intersect calls? How do you get login info if you are not overriding the dll?  I think this thing is very cool and was wondering how you did it!

 

 

Actually decompiling full source code is not my way(yep I done something like this 2 years ago with another project, but if you decompile something you should be ready to fix lots of errors), to support plugins I am injected one method which load assembly plugins/STInjector.dll:

Quote

public static void LoadInjector()
        {
            string path = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, Path.Combine(new string[]
            {
                "plugins"
            }), "STInjector.dll");
            bool flag = File.Exists(path);
            if (flag)
            {
                Assembly assembly = Assembly.LoadFile(path);
                Type type = assembly.GetType("STInjector.PluginInjector");
                MethodInfo method = type.GetMethod("Init");
                object obj = Activator.CreateInstance(type);
                method.Invoke(obj, null);
                return;
            }
            Console.WriteLine("Unable to find STInjector.dll");
        }

 

STInjector.dll source avaibale(look into first post)

 

Another point is implementing custom database engine support, this part was a bit tricky. First I decompiled class Database(fortunately it's decompiled without errors), than I created class SQLiteEngine (which contains code very same to original Database class) and MySQLEngine inside new dll (libs/server/STStaticInjection.dll). In server executable I am only patched Database class so it's work with IEngine interface(which implemented by SQLiteEngine and MysqlEngine classes)

all this code available at my update post.

 

 

You can access whole Intersect server classes/methods which are public

 

You can get any information about user by calling inner intersect methods, example:

uinfo.png?extra=UidiciwcbimeROp0sxlnVndG

Marsh likes this

Share this post


Link to post
Share on other sites

UPDATE 21/05/2017

 

Changes

  1. Removed static injection library(custom DB support working too bad, so I removed it, waiting for source code)
  2. WebApi plugin now reading prefix from config
  3. Added two new commands: http://localhost:8081/?k=test&a=reg&u=username here&p=password here&e=email here&c=1 (will make check registrartion request), http://localhost:8081/?k=test&a=info& return current online

 

This changes done to support basic web site(which I am going to release)

 

Download: http://89.223.26.226/Server.zip

Kyrise likes this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now