Welcome to the RaGEZONE - MMORPG development forums.

R63b - Perfect packet char filter

This is a discussion on R63b - Perfect packet char filter within the Habbo Releases forums, part of the Habbo Hotel category; Hi, I've made a packet filter that filters ANY char other then A-Z a-z 0-9 and - For example, you ...

Results 1 to 11 of 11
  1. #1
    Working in private usage.
    Rank
    Member +
    Join Date
    Jul 2011
    Location
    The Netherlands
    Posts
    1,162
    Liked
    230

    R63b - Perfect packet char filter

    Click
    Hi, I've made a packet filter that filters ANY char other then A-Z a-z 0-9 and -

    For example, you will get:
    Received packet [0][0][0][36][15][160][0][32]RELEASE63-201205240929-144271078

    Code:

    PHP Code:
       public string FromCharToString(string Data)
            {
                
    string Filtered Data;
                
    Regex lettersOnly = new Regex("^[a-zA-Z]{1,25}$");
                
    Regex numbersOnly = new Regex("^[0-9]$");

                foreach (
    char C in Filtered)
                {
                    if (
    C.ToString() == "-" || lettersOnly.IsMatch(C.ToString()) || numbersOnly.IsMatch(C.ToString()))
                        continue;

                    
    Filtered Filtered.Replace(C.ToString(), "[" + (int)"]");
                }

                return 
    Filtered;
            } 
    Credits:

    Me - creating code
    Google - example regex.

    Yes. It's true, I am scared of vaginas.

  2. #2
    AWA
    asdfghjkløæ'
    Rank
    Member +
    Join Date
    Feb 2008
    Location
    Bulgaria
    Posts
    1,222
    Liked
    424

    Re: R63b - Perfect packet char filter

    you can't really credit google for this, can you?

  3. #3
    Hardcore Member
    Rank
    Member
    Join Date
    Mar 2012
    Location
    wwwroot
    Posts
    109
    Liked
    24

    Re: R63b - Perfect packet char filter

    Maybe you should tell us where to put this code.

  4. #4
    I'm an asshole eat me out
    Rank
    Gamma
    Join Date
    Apr 2010
    Location
    Corporal USA
    Posts
    3,688
    Liked
    1520
    Gamertag: CobeLeDev PSN ID: COBEx9 Steam ID: CobeLeGamer
    Suggestion: Show us some results!

    Sent from my DROID RAZR using Tapatalk 2

  5. #5
    Infraction Banned
    Rank
    Alpha Member
    Join Date
    Nov 2010
    Location
    Austin, Texas
    Posts
    1,647
    Liked
    259
    Gamertag: EmberCrest
    Still don't get what I put with packets to put them into an emulator..

  6. #6
    Alpha Member
    Rank
    Alpha Member
    Join Date
    Oct 2007
    Posts
    2,713
    Liked
    675
    Gamertag: Cake Jake Bake

    Re: R63b - Perfect packet char filter

    @Above
    Tbh this is a key feature for a basic packet logger.

    It has nothing to really do with emulators.

    Thanks, i guess it's useful.

  7. #7
    Hardcore Member
    Rank
    Member
    Join Date
    Feb 2012
    Posts
    131
    Liked
    74

    Re: R63b - Perfect packet char filter

    Code complete, with modifications to save packets, packets writing, among others.
    Sorry For My Bad English, I'm Brazillian!
    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Resources;
    using System.Text.RegularExpressions;
    using System.Text;
    
    /*
     * By Droppy and George2000
     * Do not remove this -> Compulsory license in the 'Creative Commons License' (Which we are using now) 
     */
    
    namespace ConsoleApplication20
    {
        class Program
        {
            public static void FromCharToString(string Data)
            {
                string Filtered = Data;
                Regex lettersOnly = new Regex("^[a-zA-Z]{1,25}$");
                Regex numbersOnly = new Regex("^[0-9]$");
    
                foreach (char C in Filtered)
                {
                    if (C.ToString() == "-" || lettersOnly.IsMatch(C.ToString()) || numbersOnly.IsMatch(C.ToString()))
                        continue;
    
                    Filtered = Filtered.Replace(C.ToString(), "[" + (int)C + "]");
                }
                TimeSpan span = (DateTime.Now - DateTime.Now);
    
    
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.Write("Result: ");
                Console.ResetColor();
                Console.WriteLine(Filtered);
                Console.WriteLine("Saved in lastPacket.txt");                                                        
                string[] Write = { "###################################", "### Credits: Droppy, George2000 ###", "###################################", "Packets (decoded): " + Filtered, "Packets (encoded): " + Data };
                System.IO.File.WriteAllLines(@"lastPacket.txt", Write);
                Console.WriteLine("     ");
    
            }  
    
            static void Main(string[] args)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("############################################################");
                Console.WriteLine("### By: Droppy and George2000 - Creative Commons License ###");
                Console.WriteLine("############################################################");
                Console.WriteLine("### The last package will be saved in lastPacket.txt     ###");
                Console.WriteLine("############################################################");
                Console.WriteLine("     ");
                Console.ResetColor();
                Console.ForegroundColor = ConsoleColor.DarkRed;
                
                Console.WriteLine("Started!");
    
                Console.ResetColor();
                Console.WriteLine("     ");
                goto Programe;
            Programe:
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.Write("Write Packets: ");
                Console.ResetColor();
                string phrase = Console.ReadLine();
                FromCharToString(phrase);
                
                goto Programe;
            }
        }
    }
    //Enjoy the code!
    Enjoy It :D

  8. #8
    Infraction Banned
    Rank
    Alpha Member
    Join Date
    Nov 2010
    Location
    Austin, Texas
    Posts
    1,647
    Liked
    259
    Gamertag: EmberCrest

    Re: R63b - Perfect packet char filter

    Quote Originally Posted by Zak© View Post
    @Above
    Tbh this is a key feature for a basic packet logger.

    It has nothing to really do with emulators.

    Thanks, i guess it's useful.
    I really have to start learning code..


    Couldn't even tell it was only a piece, ffs..

  9. #9
    Metto! :D
    Rank
    Member +
    Join Date
    May 2007
    Location
    North Korea
    Posts
    846
    Liked
    122

    Re: R63b - Perfect packet char filter

    Quote Originally Posted by George2000 View Post
    PHP Code:
       public string FromCharToString(string Data)
            {
                
    string Filtered Data;
                
    Regex lettersOnly = new Regex("^[a-zA-Z]{1,25}$");
                
    Regex numbersOnly = new Regex("^[0-9]$");

                foreach (
    char C in Filtered)
                {
                    if (
    C.ToString() == "-" || lettersOnly.IsMatch(C.ToString()) || numbersOnly.IsMatch(C.ToString()))
                        continue;

                    
    Filtered Filtered.Replace(C.ToString(), "[" + (int)"]");
                }

                return 
    Filtered;
            } 
    Slow algorithm is slow :)
    #1: Each time you call the function, you have to create two new Regexes each time.
    #2: Running a for-statement on a string is faster than a foreach :) (Read on MSDN)
    #3: This thing could have been done way easier, like this :D

    http://pastebin.com/cMGVgDLB

    Code may be a bit longer, but it is way faster :)

    - Martin
    Last edited by maritnmine; 25-05-12 at 11:50 AM.

  10. #10
    Alpha Member
    Rank
    Alpha Member
    Join Date
    Dec 2010
    Location
    Essos
    Posts
    2,306
    Liked
    1506

    Re: R63b - Perfect packet char filter

    Why isn't the method static?

  11. #11
    Working in private usage.
    Rank
    Member +
    Join Date
    Jul 2011
    Location
    The Netherlands
    Posts
    1,162
    Liked
    230

    Re: R63b - Perfect packet char filter

    Quote Originally Posted by Quackster View Post
    Why isn't the method static?
    Not really needed in my emulator, since it's only used in the same class or methods with the class as parameter.

    Yes. It's true, I am scared of vaginas.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •