HabboLatino / Butterstorm - RCON (MUS) commands

Results 1 to 9 of 9
  1. #1
    [̲̅$̲̅(̲̅1̲̅)̲̅$ ̲̅] leenster is offline
    MemberRank
    May 2008 Join Date
    KanaadaLocation
    992Posts

    HabboLatino / Butterstorm - RCON (MUS) commands

    I noticed Butterstorm/Habbolatino didnt have any working RCON commands so i added a few.

    PHP Code:
    ha [Message]
    hal [url] [Message]
    alert [Username] [Message]
    updatecredits [Username]
    catarefresh
    givebadge 
    [Username] [Badge]
    shutdown
    ban 
    [Username] [time] [reason]
    unban [UsernameOrIP]
    coins [Username] [Amount]
    pixels [Username] [Amount]
    crystals [Username] [Amount]
    signout [UserID]
    globalcredits [Amount]
    massbadge [Badge
    **If you use MusCommander then you can paste the above commands into your "MusCommands.txt" and they will work.**

    Replace the code inside your MusSocket.cs with the following code >
    PHP Code:
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Data;
    using System.Net;
    using System.Net.Sockets;
    using HabboEvents;
    using Butterfly.HabboHotel.GameClients;
    using Butterfly.HabboHotel.Rooms;
    using Butterfly.Messages;
    using Butterfly.Core;

    using Database_Manager.Database.Session_Details.Interfaces;

    namespace 
    Butterfly.Net
    {
        class 
    MusSocket
        
    {
            private 
    Socket msSocket;

            private 
    String musIp;
            private 
    int musPort;

            private 
    HashSet<StringallowedIps;

            public 
    MusSocket(String _musIpint _musPortString[] _allowedIpsint backlog)
            {
                
    musIp _musIp;
                
    musPort _musPort;

                
    allowedIps = new HashSet<String>();

                foreach (
    String ip in _allowedIps)
                {
                    
    allowedIps.Add(ip);
                }

                try
                {
                    
    msSocket = new Socket(AddressFamily.InterNetworkSocketType.StreamProtocolType.Tcp);

                    
    msSocket.Bind(new IPEndPoint(IPAddress.AnymusPort));
                    
    msSocket.Listen(backlog);

                    
    msSocket.BeginAccept(OnEvent_NewConnectionmsSocket);

                    
    Logging.WriteLine("MUS socket -> READY!");
                }

                catch (
    Exception e)
                {
                    throw new 
    ArgumentException("Could not set up MUS socket:\n" e.ToString());
                }
            }

            private 
    void OnEvent_NewConnection(IAsyncResult iAr)
            {
                try
                {
                    
    Socket socket = ((Socket)iAr.AsyncState).EndAccept(iAr);
                    
    String ip socket.RemoteEndPoint.ToString().Split(':')[0];
                    if (
    allowedIps.Contains(ip) || ip == "127.0.0.1")
                    {
                        
    MusConnection nC = new MusConnection(socket);
                    }
                    else
                    {
                        
    socket.Close();
                    }
                }
                catch (
    Exception) { }

                
    msSocket.BeginAccept(OnEvent_NewConnectionmsSocket);
            }
        }

        class 
    MusConnection
        
    {
            private 
    Socket socket;
            private 
    byte[] buffer = new byte[1024];

            public 
    MusConnection(Socket _socket)
            {
                
    socket _socket;

                try
                {
                    
    socket.BeginReceive(buffer0buffer.LengthSocketFlags.NoneOnEvent_RecieveDatasocket);
                }
                catch
                {
                    
    tryClose();
                }
            }

            private 
    void tryClose()
            {
                try
                {
                    
    socket.Shutdown(SocketShutdown.Both);
                    
    socket.Close();
                    
    socket.Dispose();
                }
                catch { }

                
    socket null;
                
    buffer null;
            }

            private 
    void OnEvent_RecieveData(IAsyncResult iAr)
            {
                try
                {
                    
    int bytes 0;

                    try
                    {
                        
    bytes socket.EndReceive(iAr);

                    }
                    catch { 
    tryClose(); return; }

                    
    String data Encoding.Default.GetString(buffer0bytes);

                    if (
    data.Length 0)
                        
    processCommand(data);
                }
                catch { }

                
    tryClose();
            }

            private 
    void processCommand(String data)
            {
                
    String header "";
                
    String param "";
                
                if (
    data.IndexOf(Convert.ToChar(1)) != -1)
                {
                    
    header data.Split(Convert.ToChar(1))[0].Trim();
                    
    param data.Split(Convert.ToChar(1))[1];
                }
                else
                {
                    
    header data.Remove(Convert.ToChar(1)).Trim();
                    
    param "";

                }

                
    string[] pars param.Split(' ');
                
    GameClient Client null;

                switch (
    header.ToLower())
                {
                    case 
    "updatecredits":
                        {
                            
    Client ButterflyEnvironment.GetGame().GetClientManager().GetClientByUsername(pars[0]);
                            
                            if (
    Client == null)
                            {
                                
    Respond("User " pars[0] + " does not seem to be online!");
                                return;
                            }

                            
    DataRow newCredits;

                            
    using (IQueryAdapter dbClient ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                            {
                                
    dbClient.setQuery("SELECT credits FROM users WHERE id = @userid");
                                
    dbClient.addParameter("userid", (int)Client.GetHabbo().Id);
                                
    newCredits dbClient.getRow();
                            }

                            
    Client.GetHabbo().Credits = (int)newCredits["credits"];
                            
    Client.GetHabbo().UpdateCreditsBalance();
                            
    Respond("Credits for user " pars[0] + " updated.");
                            break;
                        }

                    case 
    "signout":
                        {
                            
    ButterflyEnvironment.GetGame().GetClientManager().GetClientByUserID(uint.Parse(pars[0])).Disconnect();
                            
    Respond("User disconnected.");
                            break;
                        }

                    case 
    "ha":
                        {
                            
    string Notice param;

                            
    ServerMessage HotelAlert = new ServerMessage(Outgoing.BroadcastMessage);
                            
    HotelAlert.AppendStringWithBreak(LanguageLocale.GetValue("hotelallert.notice") + "\r\n" +
                            
    Notice "\r\n" "- " "Staff");
                            
    ButterflyEnvironment.GetGame().GetClientManager().QueueBroadcaseMessage(HotelAlert);
                            
    Respond("Hotel alert executed.");
                            break;
                        }

                    case 
    "hal":
                        {
                            
    string Link pars[0];
                            
    string Message MergeParams(pars1);

                            
    ServerMessage nMessage = new ServerMessage(Outgoing.SendNotif);
                            
    nMessage.AppendStringWithBreak(LanguageLocale.GetValue("hotelallert.notice") + "\r\n" Message "\r\n-" "");
                            
    nMessage.AppendStringWithBreak(Link);
                            
    ButterflyEnvironment.GetGame().GetClientManager().QueueBroadcaseMessage(nMessage);
                            
    Respond("Hotel Link Alert has been sent.");
                            break;
                        }

                    case 
    "alert":
                        {
                            
    string TargetUser null;
                            
    GameClient TargetClient null;
                            
    TargetUser pars[0];
                            
    TargetClient ButterflyEnvironment.GetGame().GetClientManager().GetClientByUsername(TargetUser);

                            if (
    TargetClient == null)
                            {
                                
    Respond(LanguageLocale.GetValue("input.usernotfound"));
                            }

                            
    TargetClient.SendNotif(MergeParams(pars1));
                            
    Respond("Alert has been sent.");
                            break;
                        }

                    case 
    "catarefresh":
                        {
                            
    using (IQueryAdapter dbClient ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                            {
                                
    ButterflyEnvironment.GetGame().GetCatalog().Initialize(dbClient);
                                
    ButterflyEnvironment.GetGame().GetItemManager().LoadItems(dbClient);
                            }
                            
    ButterflyEnvironment.GetGame().GetCatalog().InitCache();
                            
    ButterflyEnvironment.GetGame().GetClientManager().QueueBroadcaseMessage(new ServerMessage(Outgoing.UpdateShop));
                            
    Respond("Catalog refreshed");
                            break;
                        }

                    case 
    "ban":
                        {
                            
    GameClient TargetClient null;

                            
    TargetClient ButterflyEnvironment.GetGame().GetClientManager().GetClientByUsername(pars[0]);

                            if (
    TargetClient == null)
                            {
                                
    Respond(LanguageLocale.GetValue("input.usernotfound"));
                            }

                            
    int BanTime 0;

                            try
                            {
                                
    BanTime int.Parse(pars[1]);
                            }
                            catch (
    FormatException) { Respond("An error has occured."); }

                            if (
    BanTime <= 600)
                            {
                                
    Respond(LanguageLocale.GetValue("ban.toolesstime"));
                            }
                            else
                            {
                                
    ButterflyEnvironment.GetGame().GetBanManager().BanUser(TargetClient"Staff"BanTimeMergeParams(pars2), false);
                                
    Respond(pars[0] + " has been banned!");
                            }
                            break;
                        }

                    case 
    "unban":
                        {
                            if (
    pars[0].Length 1)
                            {
                                
    ButterflyEnvironment.GetGame().GetBanManager().UnbanUser(pars[0]);
                                
    Respond("Ban Removed.");
                            }
                            break;
                        }

                    case 
    "shutdown":
                        {
                            
    Logging.LogMessage("Server exiting at " DateTime.Now);
                            
    Logging.DisablePrimaryWriting(true);
                            
    Respond("The server is saving users furniture, rooms, etc. The server will then shut down.");
                            
    Console.Write("The server is saving users furniture, rooms, etc. WAIT FOR THE SERVER TO CLOSE, DO NOT EXIT THE PROCESS IN TASK MANAGER!!");
                            
    ButterflyEnvironment.PreformShutDown(true);

                            break;
                        }

                    case 
    "givebadge":
                        {
                            
    GameClient TargetClient null;
                            
    TargetClient ButterflyEnvironment.GetGame().GetClientManager().GetClientByUsername(pars[0]);
                            if (
    TargetClient != null)
                            {
                                
    TargetClient.GetHabbo().GetBadgeComponent().GiveBadge(ButterflyEnvironment.FilterInjectionChars(pars[1]), true);

                                
    ButterflyEnvironment.GetGame().GetModerationTool().LogStaffEntry("Staff"TargetClient.GetHabbo().Username"Badge""Badge given to user [" pars[0] + "]");
                                
    Respond("Badge '" pars[1] + "' given to " pars[0]);
                            }
                            else
                            {
                                
    Respond(LanguageLocale.GetValue("input.usernotfound"));
                            }
                            break;
                        }

                    case 
    "coins":
                        {
                            
    GameClient TargetClient null;

                            
    TargetClient ButterflyEnvironment.GetGame().GetClientManager().GetClientByUsername(pars[0]);
                            if (
    TargetClient != null)
                            {
                                
    int creditsToAdd;
                                if (
    int.TryParse(pars[1], out creditsToAdd))
                                {
                                    
    TargetClient.GetHabbo().Credits TargetClient.GetHabbo().Credits creditsToAdd;
                                    
    TargetClient.GetHabbo().UpdateCreditsBalance();
                                    
    TargetClient.SendNotif("Staff" LanguageLocale.GetValue("coins.awardmessage1") + creditsToAdd.ToString() + LanguageLocale.GetValue("coins.awardmessage2"));
                                    
    Respond(LanguageLocale.GetValue("coins.updateok"));

                                }
                                else
                                {
                                    
    Respond(LanguageLocale.GetValue("input.intonly"));

                                }
                            }
                            else
                            {
                                
    Respond(LanguageLocale.GetValue("input.usernotfound"));

                            }
                            break;
                        }

                    case 
    "pixels":
                        {
                            
    GameClient TargetClient null;

                            
    TargetClient ButterflyEnvironment.GetGame().GetClientManager().GetClientByUsername(pars[0]);
                            if (
    TargetClient != null)
                            {
                                
    int PixelsToAdd;
                                if (
    int.TryParse(pars[1], out PixelsToAdd))
                                {
                                    
    TargetClient.GetHabbo().ActivityPoints TargetClient.GetHabbo().ActivityPoints PixelsToAdd;
                                    
    TargetClient.GetHabbo().UpdateActivityPointsBalance(true);
                                    
    TargetClient.SendNotif("Staff" LanguageLocale.GetValue("pixels.awardmessage1") + PixelsToAdd.ToString() + LanguageLocale.GetValue("pixels.awardmessage2"));
                                    
    Respond(LanguageLocale.GetValue("pixels.updateok"));

                                }
                                else
                                {
                                    
    Respond(LanguageLocale.GetValue("input.intonly"));

                                }
                            }
                            else
                            {
                                
    Respond(LanguageLocale.GetValue("input.usernotfound"));

                            }
                            break;
                        }

                    case 
    "globalcredits":
                        {
                            try
                            {
                                
    int CreditAmount int.Parse(pars[0]);
                                
    ButterflyEnvironment.GetGame().GetClientManager().QueueCreditsUpdate(CreditAmount);

                                
    using (IQueryAdapter dbClient ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                                    
    dbClient.runFastQuery("UPDATE users SET credits = credits + " CreditAmount);

                                
    ButterflyEnvironment.GetGame().GetModerationTool().LogStaffEntry("Staff"string.Empty, "Mass Credits""Send [" CreditAmount "] credits to everyone in the database");
                                
    Respond("Global credits updated");
                            }
                            catch
                            {
                                
    Respond(LanguageLocale.GetValue("input.intonly"));
                            }
                            break;
                        }

                    case 
    "massbadge":
                        {
                            
    ButterflyEnvironment.GetGame().GetClientManager().QueueBadgeUpdate(pars[0]);
                            break;
                        }

                    case 
    "crystals":
                        {
                            
    GameClient TargetClient null;

                            
    TargetClient ButterflyEnvironment.GetGame().GetClientManager().GetClientByUsername(pars[0]);

                            if (
    TargetClient == null)
                            {
                                
    Respond(LanguageLocale.GetValue("input.usernotfound"));
                            }
                            try
                            {
                                
    TargetClient.GetHabbo().GiveUserCrystals(int.Parse(pars[1]));
                                
    Respond("Send " pars[1] + " Crystals to " pars[0]);
                            }
                            catch (
    FormatException) { Respond("An error has occured"); }
                            break;
                        }

                    default:
                        {

                            break;
                        }
                }

            }

            
    //Send response back to Rcon Client
            
    private void Respond(string response)
            {
                
    byte[] respond System.Text.Encoding.UTF8.GetBytes(response);
                
    socket.Send(respondrespond.LengthSocketFlags.None);
            }

            private static 
    string MergeParams(string[] Paramsint Start)
            {
                
    StringBuilder MergedParams = new StringBuilder();

                for (
    int i 0Params.Lengthi++)
                {
                    if (
    Start)
                    {
                        continue;
                    }

                    if (
    Start)
                    {
                        
    MergedParams.Append(" ");
                    }

                    
    MergedParams.Append(Params[i]);
                }

                return 
    MergedParams.ToString();
            }
        }

    This method will send a response back to your RCON client (PHP page or whatever) so you have some kind of confirmation that the command was executed.
    PHP Code:
    private void Respond(string response)
            {
                
    byte[] respond System.Text.Encoding.UTF8.GetBytes(response);
                
    socket.Send(respondrespond.LengthSocketFlags.None);
            } 
    I know some of the commands are a little messy but I took most of them from the regular commands and edited them a little bit.
    Have fun
    Last edited by leenster; 04-01-13 at 06:33 AM.


  2. #2
    Check http://arcturus.pw The General is offline
    DeveloperRank
    Aug 2011 Join Date
    7,610Posts

    Re: HabboLatino / Butterstorm - RCON (MUS) commands

    Yeah MUS commands :D Thank you Leen ;3

  3. #3
    son, i am dissapoint Near is offline
    MemberRank
    Sep 2009 Join Date
    The NetherlandsLocation
    491Posts

    Re: HabboLatino / Butterstorm - RCON (MUS) commands

    I'm wondering, why are you defining everything internal?

  4. #4
    Developer Eronisch is offline
    MemberRank
    Jul 2009 Join Date
    The NetherlandsLocation
    1,328Posts

    Re: HabboLatino / Butterstorm - RCON (MUS) commands

    How do i send/request a mus function from the client in revcms?

  5. #5
    [̲̅$̲̅(̲̅1̲̅)̲̅$ ̲̅] leenster is offline
    MemberRank
    May 2008 Join Date
    KanaadaLocation
    992Posts

    Re: HabboLatino / Butterstorm - RCON (MUS) commands

    I don't know RevCMS but here is some php code you could use. You just have to figure out where to put it.

    PHP Code:
    <?php

    function SendMUSData($header,$data=""){

    $ip $variable_from_the_config;
    $port $another_variable_from_the_config;

    $data $header.chr(1).$data;

    if(!
    is_numeric($port)){ return false; }
    $sock socket_create(AF_INETSOCK_STREAMgetprotobyname('tcp'));
    socket_connect($sock$ip$port);

            if(!
    is_resource($sock)){
                    return 
    false;
            } else {
                    
    socket_send($sock$datastrlen($data), MSG_DONTROUTE);
                    
                    
    //You can use socket_recv to get the response from the server.
                    //socket_recv($sock, $buf, 2048, MSG_WAITALL);
                    //echo $buf;

                    
    return true;
            }

        
    socket_close($sock);
    }
    ?>
    Last edited by leenster; 21-12-12 at 11:39 AM.

  6. #6

    Re: HabboLatino / Butterstorm - RCON (MUS) commands

    Now I know how to code commands on my emulator!

    Thanks for this fix!

  7. #7
    [̲̅$̲̅(̲̅1̲̅)̲̅$ ̲̅] leenster is offline
    MemberRank
    May 2008 Join Date
    KanaadaLocation
    992Posts

    Re: HabboLatino / Butterstorm - RCON (MUS) commands

    I noticed that i messed up on a couple of the commands and they didnt seem to work.

    I edited the main post with the new code.

  8. #8
    Valued Member ItachiKM is offline
    MemberRank
    Jan 2011 Join Date
    133Posts

    Re: HabboLatino / Butterstorm - RCON (MUS) commands

    Protect the system against the noobs that can execute commands using the default MUS port of bstorm! Or else they could shoutdown your server easily!
    Anyway, good system :P!

  9. #9
    [̲̅$̲̅(̲̅1̲̅)̲̅$ ̲̅] leenster is offline
    MemberRank
    May 2008 Join Date
    KanaadaLocation
    992Posts

    Re: HabboLatino / Butterstorm - RCON (MUS) commands

    Quote Originally Posted by ItachiKM View Post
    Protect the system against the noobs that can execute commands using the default MUS port of bstorm! Or else they could shoutdown your server easily!
    Anyway, good system :P!
    What kind of protection do you suggest?
    PHP Code:
    if (allowedIps.Contains(ip) || ip == "127.0.0.1")
                    {
                        
    MusConnection nC = new MusConnection(socket);
                    }
                    else
                    {
                        
    socket.Close();
                    } 
    I thought that would be enough?



Advertisement