[Release] Nexus filter - source (free, outdated)

03/23/2017 16:34 Chernobyl*#1
Title says it all. Here is source code of Nexus free version.


What is this ? Basically, another silkroad online packet filter with multiple improvements. As it is a free version, it is NOT supported (althrough, I may answer some questions about it). It can (and does) contain bugs.

I wont describe most of internal features, but provide configuration file:


Code:
//Nexus configuration file
//........................
//........................
general
{
	//----------------------------------------
	window_name=			Test gw
	bind_port=				5000
	dest_ip=				123.123.123.123
	dest_port=				5000

	sql_host=				.\SQLEXPRESS
	sql_user=				sa
	sql_pass=				1234
	sql_shard=				SRO_VT_SHARD
	//----------------------------------------
	//DownloadServer
	//GatewayServer
	//AgentServer
	serv_type=				GatewayServer
	max_conn_server=		10000
	max_conn_ip=			100
	module_conn_timeout=	10000
	sess_activity_timeout=	10000
	sess_proc_threads=		1
	listener_backlog=		50
	session_buffer_count=	10
	//----------------------------------------
	log_folder=				log
	
	//Count of hours after new log file will be created
	log_time=				2

	log_notify_color=		Green
	log_warning_color=		Yellow
	log_error_color=		Red
	con_bg_color=			Black
	//----------------------------------------

	
	
	redirect_count=0
}


redirect_rule_1
{
	src_ip=				123.123.123.123
	src_port=			5005
	dest_ip=			127.0.0.1
	dest_port=			2002
}



game
{
	disable_captcha=True
	disable_captcha_value=0
	
	//In seconds
	exchange_delay=10
	exchange_delay_msg=You can't exchange so often
	
	stall_delay=10
	stall_delay_msg=You can't stall so often
	
	logout_delay=10
	logout_delay_msg=You can't logout so often
	
	plus_limit=5
	plus_limit_msg=Plus Limit (%plus_limit% No Adv) Exceeded!
	
	guild_limit=10
	guild_limit_msg=You Can't Invite Any More Players Guild Limit(%guild_limit%) Exceeded!
	
	union_limit=1
	union_limit_msg=You Can't Invite Any More Guilds to The Union. Limit (%union_limit%) Exceeded!

	//0 = no limit
	ctf_registration_min_lvl=0
	ctf_registration_min_lvl_msg=Your level is too low for ctf
	
	ctf_registration_max_lvl=100
	ctf_registration_max_lvl_msg=Your level is too high for ctf
	
	//0 = no limit
	arena_registration_min_lvl=0
	arena_registration_min_lvl_msg=Your level is too low for arena
	
	//0 = no limit
	arena_registration_max_lvl=0
	arena_registration_max_lvl_msg=100

	disable_academy_invite=True
	disable_academy_invite_msg=You can't add members to academy
}
SS:

[Only registered and activated users can see links. Click Here To Register...]

/getlast command will give you last n packet dumps before your module crashed, so, fixing exploits is easy as never before

There are not that many features in this version, but still...

Link: [Only registered and activated users can see links. Click Here To Register...]

Those who already bought this - feel free to PM me to get all the newest stuff.
Also, I'm searching for some ideas for projects (or team to join)

As always, I'm sorry for English, syka blatj.


Credits: Chernobyl (skype: live:cherno0x2f), B1QB0SS (skype: gold.fish530)
03/23/2017 16:44 KingDollar#2
i thought this account has been banned before x?D!
03/23/2017 16:48 B1Q#3
new SQL Extensions class (async)
comment the Console.WriteLine(ex.ToString()); lines
Code:
using Nexus.Database;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Threading.Tasks;

namespace Nexus
{
    public static class SQLExt
    {

        /// <summary>
        /// hey i just locked you, and this is crazy, but here's my object. so lock me maybe
        /// </summary>
        public static object squirrellock = new object();

        #region We Believe in Extensions

        /// <summary>
        /// We Count Rows 
        /// </summary>
        /// <param name="query">i'm the Query</param>
        /// <param name="args">and i'm the optional Parameters hh</param>
        /// <returns>i'm a fetched row!!!!!!</returns>
        public static async Task<int> numRows(this SQL sql, string query, params SqlParameter[] op)
        {
            int returnval = 0;
            try
            {
                if (!sql.IsOpen)
                    sql.Open(sql.Host, sql.User, sql.Pass, sql.Database, sql.MARS, sql.Timeout);

                if (sql.IsOpen)
                {
                    using (SqlCommand cmd = new SqlCommand(query, sql.Connection))
                    {
                        if (op != null)
                        {
                            cmd.Parameters.AddRange(op);
                        }
                        using (SqlDataReader reader = await cmd.ExecuteReaderAsync())
                        {
                            returnval = reader.Cast<object>().Count();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                //throw new CoreException("[SQL] numRows -> Couldn't fetch Number of Rows!");
            }
            return returnval;
        }

        /// <summary>
        /// We Execute Queries
        /// </summary>
        /// <param name="query">i'm the Query</param>
        /// <param name="args">and i'm the optional Parameters hh</param>
        public static async Task<bool> query(this SQL sql, string query, params SqlParameter[] op)
        {
            bool returnval = false;
            try
            {
                using (SqlCommand cmd = new SqlCommand(query, sql.Connection))
                {
                    if (op != null)
                    {
                        cmd.Parameters.AddRange(op);
                    }
                    int q = await cmd.ExecuteNonQueryAsync();
                    if (q > 0)
                    {
                        returnval = true;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                throw new CoreException("[SQL] QUERY -> Couldn't Execute query");
            }
            return returnval;
        }

        /// <summary>
        /// i Return Strings!!!!!!!!
        /// </summary>
        /// <param name="query">i'm the Query hh</param>
        /// <param name="index">Column index</param>
        /// <param name="column">Column Name</param>
        /// <param name="op">and i'm the optional Parameters :@</param>
        /// <returns>i'm the return value h</returns>
        public static async Task<string> getString(this SQL sql, string query, params SqlParameter[] op)
        {
            string returnval = "";
            try
            {
                using (SqlConnection con = new SqlConnection(sql.ConnString))
                {
                    if (con.State != ConnectionState.Open)
                        con.Open();

                    using (SqlCommand cmd = new SqlCommand(query, con))
                    {
                        using (SqlDataReader reader = await cmd.ExecuteReaderAsync())
                        {
                            if (reader.Read())
                            {
                                returnval = reader.GetString(0);
                            }
                        }
                    }
                }
            }
            catch
            {
                throw new CoreException("[SQL] getString -> Couldn't get String value");
            }

            return returnval;
        }

        /// <summary>
        /// i Return Strings!!!!!!!!
        /// </summary>
        /// <param name="query">i'm the Query hh</param>
        /// <param name="index">Column index</param>
        /// <param name="column">Column Name</param>
        /// <param name="op">and i'm the optional Parameters :@</param>
        /// <returns>i'm the return value h</returns>
        public static async Task<string> getString(this SQL sql, string query, int index, params SqlParameter[] op)
        {
            string returnval = "";
            try
            {
                using (SqlConnection con = new SqlConnection(sql.ConnString))
                {
                    if (con.State != ConnectionState.Open)
                        con.Open();

                    using (SqlCommand cmd = new SqlCommand(query, con))
                    {
                        using (SqlDataReader reader = await cmd.ExecuteReaderAsync())
                        {
                            if (reader.Read())
                            {
                                returnval = reader.GetString(index);
                            }
                        }
                    }
                }
            }
            catch
            {
                throw new CoreException("[SQL] getString -> Couldn't get String value");
            }
            return returnval;
        }

        /// <summary>
        /// i Return Strings!!!!!!!!
        /// </summary>
        /// <param name="query">i'm the Query hh</param>
        /// <param name="column">Column Name</param>
        /// <param name="op">and i'm the optional Parameters :@</param>
        /// <returns>i'm the return value h</returns>
        public static async Task<string> getString(this SQL sql, string query, string column, params SqlParameter[] op)
        {
            string returnval = "";
            try
            {
                using (SqlConnection con = new SqlConnection(sql.ConnString))
                {
                    if (con.State != ConnectionState.Open)
                        con.Open();

                    using (SqlCommand cmd = new SqlCommand(query, con))
                    {
                        if (op != null)
                            cmd.Parameters.AddRange(op);

                        using (SqlDataReader reader = await cmd.ExecuteReaderAsync())
                        {
                            if (reader.Read())
                            {
                                returnval = reader[column].ToString();
                            }
                        }
                    }
                }
            }
            catch
            {
                throw new CoreException("[SQL] getString -> Couldn't get String value");
            }
            return returnval;
        }

        /// <summary>
        /// i Return String Arrays!!!!!!!!
        /// </summary>
        /// <param name="query">i'm the Query hh</param>
        /// <param name="column">Column Name</param>
        /// <param name="op">and i'm the optional Parameters :@</param>
        /// <returns>i'm the return value h</returns>
        public static async Task<string[]> getStringArray(this SQL sql, string query, string column, params SqlParameter[] op)
        {

            string[] returnval;
            try
            {
                using (SqlConnection con = new SqlConnection(sql.ConnString))
                {
                    if (con.State != ConnectionState.Open)
                        con.Open();

                    using (SqlCommand cmd = new SqlCommand(query, con))
                    {
                        using (SqlDataReader reader = await cmd.ExecuteReaderAsync())
                        {
                            int i = 0;
                            returnval = new string[reader.FieldCount];
                            while (await reader.ReadAsync())
                            {
                                returnval[i] = reader[column].ToString();
                                i++;
                            }
                        }
                    }
                }
            }
            catch
            {
                throw new CoreException("[SQL] getStringArray -> Couldn't get String Array");
            }
            return returnval;
        }

        /// <summary>
        /// i Return String Arrays!!!!!!!!
        /// </summary>
        /// <param name="query">i'm the Query hh</param>
        /// <param name="index">Column index</param>
        /// <param name="op">and i'm the optional Parameters :@</param>
        /// <returns>i'm the return value h</returns>
        public static async Task<string[]> getStringArray(this SQL sql, string query, int index, params SqlParameter[] op)
        {
            string[] returnval;
            try
            {
                using (SqlConnection con = new SqlConnection(sql.ConnString))
                {
                    if (con.State != ConnectionState.Open)
                        con.Open();

                    using (SqlCommand cmd = new SqlCommand(query, con))
                    {
                        using (SqlDataReader reader = await cmd.ExecuteReaderAsync())
                        {
                            int i = 0;
                            returnval = new string[reader.FieldCount];
                            while (await reader.ReadAsync())
                            {
                                returnval[i] = reader[index].ToString();
                                i++;
                            }
                        }
                    }
                }
            }
            catch
            {
                throw new CoreException("[SQL] getStringArray -> Couldn't get String Array");
            }
            return returnval;
        }

        /// <summary>
        /// i Return Ints!!!!!
        /// </summary>
        /// <param name="query">i'm the Query hh</param>
        /// <param name="op">i swear i'm the optional Parameters</param>
        /// <returns>i'm the Returned INT :@</returns>
        public static int getInt(this SQL sql, string query, params SqlParameter[] op)
        {
            lock (squirrellock)
            {
                int returnval = 0;
                try
                {
                    using (SqlCommand cmd = new SqlCommand(query, sql.Connection))
                    {
                        if (op != null)
                        {
                            cmd.Parameters.AddRange(op);
                        }
                        using (SqlDataReader reader = cmd.ExecuteReader())
                        {
                            if (reader.Read())
                            {
                                if (reader.HasRows)
                                    returnval = Convert.ToInt32(reader.GetValue(0));
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    throw new CoreException("[SQL] getInt -> Couldn't get Int Value");
                }
                return returnval;
            }
        }

        /// <summary>
        /// i Return Ints!!!!!
        /// </summary>
        /// <param name="query">i'm the Query hh</param>
        /// <param name="index">Column index</param>
        /// <param name="op">i swear i'm the optional Parameters</param>
        /// <returns>i'm the Returned INT :@</returns>
        public static int getInt(this SQL sql, string query, int index, params SqlParameter[] op)
        {
            lock (squirrellock)
            {
                int returnval = 0;
                try
                {
                    using (SqlCommand cmd = new SqlCommand(query, sql.Connection))
                    {
                        if (op != null)
                        {
                            cmd.Parameters.AddRange(op);
                        }
                        using (SqlDataReader reader = cmd.ExecuteReader())
                        {
                            if (reader.Read())
                            {
                                returnval = reader.GetInt32(index);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    //throw new CoreException("[SQL] getInt -> Couldn't get Int Value");
                }
                return returnval;
            }
        }

        /// <summary>
        /// i Return Ints!!!!!
        /// </summary>
        /// <param name="query">i'm the Query hh</param>
        /// <param name="column">Column Name</param>
        /// <param name="op">i swear i'm the optional Parameters</param>
        /// <returns>i'm the Returned INT :@</returns>
        public static int getInt(this SQL sql, string query, string column, params SqlParameter[] op)
        {
            lock (squirrellock)
            {
                int returnval = 0;
                try
                {
                    using (SqlConnection con = new SqlConnection(sql.ConnString))
                    {
                        if (con.State != ConnectionState.Open)
                            con.Open();

                        using (SqlCommand cmd = new SqlCommand(query, con))
                        {
                            if (op != null)
                            {
                                cmd.Parameters.AddRange(op);
                            }
                            using (SqlDataReader reader = cmd.ExecuteReader())
                            {
                                if (reader.Read())
                                {
                                    returnval = Convert.ToInt32(reader[column]);
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    throw new CoreException("[SQL] getInt -> Couldn't get Int Value");
                }
                return returnval;
            }
        }

        /// <summary>
        /// i Return Int Arrays!!!!!!!!
        /// </summary>
        /// <param name="query">i'm the Query hh</param>
        /// <param name="column">Column Name</param>
        /// <param name="op">and i'm the optional Parameters :@</param>
        /// <returns>i'm the return value h</returns>
        public static int[] getIntArray(this SQL sql, string query, string column, params SqlParameter[] op)
        {
            lock (squirrellock)
            {
                int[] returnval;
                try
                {
                    using (SqlConnection con = new SqlConnection(sql.ConnString))
                    {
                        if (con.State != ConnectionState.Open)
                            con.Open();

                        using (SqlCommand cmd = new SqlCommand(query, con))
                        {
                            using (SqlDataReader reader = cmd.ExecuteReader())
                            {
                                int i = 0;
                                returnval = new int[reader.FieldCount];
                                while (reader.Read())
                                {
                                    returnval[i] = Convert.ToInt32(reader[column]);
                                    i++;
                                }
                            }
                        }
                    }
                }
                catch
                {
                    throw new CoreException("[SQL] getIntArray -> Couldn't get Int Array");
                }
                return returnval;
            }
        }

        /// <summary>
        /// i Return Int Arrays!!!!!!!!
        /// </summary>
        /// <param name="query">i'm the Query hh</param>
        /// <param name="index">Column index</param>
        /// <param name="op">and i'm the optional Parameters :@</param>
        /// <returns>i'm the return value h</returns>
        public static int[] getIntArray(this SQL sql, string query, int index, params SqlParameter[] op)
        {
            lock (squirrellock)
            {
                int[] returnval;
                try
                {
                    using (SqlConnection con = new SqlConnection(sql.ConnString))
                    {
                        if (con.State != ConnectionState.Open)
                            con.Open();

                        using (SqlCommand cmd = new SqlCommand(query, con))
                        {
                            using (SqlDataReader reader = cmd.ExecuteReader())
                            {
                                int i = 0;
                                returnval = new int[reader.FieldCount];
                                while (reader.Read())
                                {
                                    returnval[i] = Convert.ToInt32(reader[index]);
                                    i++;
                                }
                            }
                        }
                    }
                }
                catch
                {
                    throw new CoreException("[SQL] getIntArray -> Couldn't get Int Array");
                }
                return returnval;
            }
        }
        #endregion

        #region Database Helper Functions
        public static Dictionary<string, string> GuildByCharName(this SQL sql, string charname, params SqlParameter[] op)
        {
            lock (squirrellock)
            {
                Dictionary<string, string> returnval;
                try
                {
                    using (SqlConnection con = new SqlConnection(sql.ConnString))
                    {
                        if (con.State != ConnectionState.Open)
                            con.Open();
                        string query = Queries.GuildArrayQuery + "'" + charname + "'";
                        using (SqlCommand cmd = new SqlCommand(query, con))
                        {
                            using (SqlDataReader reader = cmd.ExecuteReader())
                            {
                                int i = 0;
                                returnval = new Dictionary<string, string>();
                                while (reader.Read())
                                {
                                    returnval.Add(reader.GetName(i), reader.GetValue(i).ToString());
                                    i++;
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    throw new CoreException("[SQL] GuildIDByCharName -> Couldn't get GuildID");
                }
                return returnval;
            }
        }

        public static int GetMemberCountByCharname(this SQL sql, string charname, params SqlParameter[] op)
        {
            lock (squirrellock)
            {
                int returnval = 0;
                try
                {
                    using (SqlConnection con = new SqlConnection(sql.ConnString))
                    {
                        if (con.State != ConnectionState.Open)
                            con.Open();
                        string query = Queries.MembersCountQuery + "'" + charname + "'";
                        using (SqlCommand cmd = new SqlCommand(query, con))
                        {
                            using (SqlDataReader reader = cmd.ExecuteReader())
                            {
                                if (reader.Read())
                                {
                                    returnval = Convert.ToInt32(reader["MembersCount"]);
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    throw new CoreException("[SQL] MemberCountByCharname -> Couldn't get Members Count");
                }
                return returnval;
            }
        }

        public static int GetUnionCountByCharname(this SQL sql, string charname, params SqlParameter[] op)
        {
            lock (squirrellock)
            {
                int returnval = 0;
                try
                {
                    using (SqlConnection con = new SqlConnection(sql.ConnString))
                    {
                        if (con.State != ConnectionState.Open)
                            con.Open();

                        string query = Queries.GuildArrayQuery + "'" + charname + "'";
                        using (SqlCommand cmd = new SqlCommand(query, con))
                        {
                            using (SqlDataReader reader = cmd.ExecuteReader())
                            {
                                if (reader.Read())
                                {
                                    int[] allies = new int[8];
                                    for (int i = 1; i < 8; i++)
                                    {
                                        allies[i] = sql.getInt("select Ally" + i + " from _AlliedClans where ID='" + reader["Alliance"] + "'", "Ally" + i);
                                    }
                                    foreach (int z in allies)
                                    {
                                        if (z != 0)
                                            returnval++;
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    throw new CoreException("[SQL] GetUnionCountByCharname -> Couldn't get Union Count");
                }
                return returnval;
            }
        }
        public static int GetPlus(this SQL sql, string charname, int slot, params SqlParameter[] op)
        {
            lock (squirrellock)
            {
                int returnval = 0;
                try
                {
                    using (SqlConnection con = new SqlConnection(sql.ConnString))
                    {
                        if (con.State != ConnectionState.Open)
                            con.Open();

                        string query = Queries.OptLevelQuery(charname, slot);
                        using (SqlCommand cmd = new SqlCommand(query, con))
                        {
                            using (SqlDataReader reader = cmd.ExecuteReader())
                            {
                                if (reader.Read())
                                {
                                    returnval = Convert.ToByte(reader["OptLevel"]);
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    throw new CoreException("[SQL] GetPlus -> Couldn't get Item Plus");
                }
                return returnval;
            }
        }
        #endregion
    }
}
03/23/2017 17:12 elmagico321#4
nice release
03/23/2017 20:00 xxnukertube#5
Welcome Back (heidy)
[Only registered and activated users can see links. Click Here To Register...]
03/23/2017 23:11 Damitsu#6
Really nice job, keep it up. ;)
03/24/2017 12:35 nour_eldin#7
Nice Job
03/24/2017 17:35 Mangetsu||#8
Welcome back Dude i actually missed you;
BTW i think you missed the client library or you deleted before re-uploading? DK
anyway keep being around