Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    Saltine's Avatar
    Join Date
    Jun 2011
    Gender
    male
    Posts
    493
    Reputation
    104
    Thanks
    629

    XOR Encryption Class

    Here is a simple XOR encryption class:
    Code:
    class XOR{
    protected:
    		char key[256];
    public:
    	
    	XOR(){
    		key="fjsldjf84937fd7f6s876df52396tegulhghs87f53f8w987r8970w987erSDFJDFLJSGHHEIHWOHGKDFGSLGDKHSLKDGH";
    	}
    
    	char* xorStr(char *string){
    		const static int len = strlen(string);
    		char* temp = new char(len);
    		for(int i = 0; i < len+1;i++)
    			temp[i] = string[i]^key[i];
    		return temp;
    	}
    };
    Now an example of how to use.
    First you create an object of the XOR class:
    Code:
    XOR* xor = new XOR();
    Then to encrypt a string and save it to a variable, you would do:
    Code:
    char* x=xor->xorStr("lol");
    The same function would decrypt the encrypted string, so to get it back, you would do:
    Code:
    char* orig=xor->xorStr(x);
    You can use this to encrypt strings in a hack, or anywhere else
    Last edited by Saltine; 12-08-2011 at 05:06 PM.

    Oh no! Vortex is gay!

  2. The Following 3 Users Say Thank You to Saltine For This Useful Post:

    [MPGH]Flengo (03-04-2012),OBrozz (12-08-2011),SNIPdetta (12-08-2011)

  3. #2
    Refrain's Avatar
    Join Date
    Aug 2011
    Gender
    male
    Posts
    135
    Reputation
    22
    Thanks
    28
    You realize people can view the "lol" string when you call xorStr

  4. #3
    Saltine's Avatar
    Join Date
    Jun 2011
    Gender
    male
    Posts
    493
    Reputation
    104
    Thanks
    629
    Create a separate app to generate encrypted strings, and decrypt them in your actual program...?

    Oh no! Vortex is gay!

  5. #4
    supercarz1991's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Posts
    6,285
    Reputation
    435
    Thanks
    3,715
    My Mood
    Doh
    its not really encrypting if we can still see the string...

    commando: You're probably the best non-coder coder I know LOL


  6. #5
    Saltine's Avatar
    Join Date
    Jun 2011
    Gender
    male
    Posts
    493
    Reputation
    104
    Thanks
    629
    Quote Originally Posted by supercarz1991 View Post
    its not really encrypting if we can still see the string...
    Read the post directly above yours...

    Oh no! Vortex is gay!

  7. #6
    Refrain's Avatar
    Join Date
    Aug 2011
    Gender
    male
    Posts
    135
    Reputation
    22
    Thanks
    28
    Quote Originally Posted by Saltine View Post
    Create a separate app to generate encrypted strings, and decrypt them in your actual program...?
    There lies the problem, you can't do that with the class you posted

  8. #7
    Saltine's Avatar
    Join Date
    Jun 2011
    Gender
    male
    Posts
    493
    Reputation
    104
    Thanks
    629
    Quote Originally Posted by Refrain View Post
    There lies the problem, you can't do that with the class you posted
    I realize that now, with my random key generation, I shall fix it, now.
    Edit: fixed
    Last edited by Saltine; 12-08-2011 at 05:02 PM.

    Oh no! Vortex is gay!

  9. #8
    AVGN's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Kekistan
    Posts
    15,566
    Reputation
    1817
    Thanks
    6,678
    Code:
    #ifndef _XOR_H
    #define _XOR_H
    template <int XORSTART, int BUFLEN, int XREFKILLER>
    
    class XorStr
    {
    private: 
    	XorStr();
    public: 
    	char s[ BUFLEN ];
    
    	XorStr( const char * xs );
    
    	~XorStr()
    	{
    		for ( int i = 0; i < BUFLEN; i++ ) s[ i ]=0; 
    	}
    };
    
    template <int XORSTART, int BUFLEN, int XREFKILLER>
    XorStr<XORSTART,BUFLEN,XREFKILLER>::XorStr( const char * xs )
    {
    	int xvalue = XORSTART;
    	int i = 0;
    
    	for ( ; i < ( BUFLEN - 1 ); i++ ) 
    	{
    		s[ i ] = xs[ i - XREFKILLER ] ^ xvalue;
    		xvalue += 1;
    		xvalue %= 256;
    	}
    
    	s[ BUFLEN - 1 ] = 0;
    }
    #endif


    its different from the other one i saw




  10. #9
    Refrain's Avatar
    Join Date
    Aug 2011
    Gender
    male
    Posts
    135
    Reputation
    22
    Thanks
    28
    Quote Originally Posted by Saltine View Post

    I realize that now, with my random key generation, I shall fix it, now.
    Edit: fixed
    You can still find the key that you're using to encrypt the strings

  11. #10
    ISmokeWeedAmICoolNow's Avatar
    Join Date
    Aug 2011
    Gender
    male
    Posts
    54
    Reputation
    10
    Thanks
    19
    My Mood
    Bitchy
    nice memory leak.

  12. #11
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Quote Originally Posted by AVGN View Post
    Code:
    #ifndef _XOR_H
    #define _XOR_H
    template <int XORSTART, int BUFLEN, int XREFKILLER>
    
    class XorStr
    {
    private: 
    	XorStr();
    public: 
    	char s[ BUFLEN ];
    
    	XorStr( const char * xs );
    
    	~XorStr()
    	{
    		for ( int i = 0; i < BUFLEN; i++ ) s[ i ]=0; 
    	}
    };
    
    template <int XORSTART, int BUFLEN, int XREFKILLER>
    XorStr<XORSTART,BUFLEN,XREFKILLER>::XorStr( const char * xs )
    {
    	int xvalue = XORSTART;
    	int i = 0;
    
    	for ( ; i < ( BUFLEN - 1 ); i++ ) 
    	{
    		s[ i ] = xs[ i - XREFKILLER ] ^ xvalue;
    		xvalue += 1;
    		xvalue %= 256;
    	}
    
    	s[ BUFLEN - 1 ] = 0;
    }
    #endif


    its different from the other one i saw
    What a pointless use of templates lol.

    [at]Thread:
    I'm not really sure why you need to make this a class; it doesn't contain any instance-specific info. Would make a lot more sense as a single function, with a param to set a dynamic key. Also, as soon as someone tries to encrypt a string with more chars than the "key", it's going to break. Not sure why the length of the string is static either

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  13. #12
    derh.acker's Avatar
    Join Date
    Aug 2010
    Gender
    male
    Location
    localhost
    Posts
    826
    Reputation
    14
    Thanks
    616
    My Mood
    Angelic
    When you encrypt the string "127.0.0.1" you still see the PUSH to the 127.0.0.1.
    If you edit it to "127.0.0.2", the program would encrypt 127.0.0.2.

  14. #13
    ISmokeWeedAmICoolNow's Avatar
    Join Date
    Aug 2011
    Gender
    male
    Posts
    54
    Reputation
    10
    Thanks
    19
    My Mood
    Bitchy
    Quote Originally Posted by Jason View Post


    What a pointless use of templates lol.

    [at]Thread:
    I'm not really sure why you need to make this a class; it doesn't contain any instance-specific info. Would make a lot more sense as a single function, with a param to set a dynamic key. Also, as soon as someone tries to encrypt a string with more chars than the "key", it's going to break. Not sure why the length of the string is static either
    it cant be a single function. it has to store the unencrypted string somehow and clean it up later.

  15. #14
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Quote Originally Posted by ISmokeWeedAmICoolNow View Post
    it cant be a single function. it has to store the unencrypted string somehow and clean it up later.
    Of course you're right! Functions can't return data, how stupid of me.

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  16. #15
    ISmokeWeedAmICoolNow's Avatar
    Join Date
    Aug 2011
    Gender
    male
    Posts
    54
    Reputation
    10
    Thanks
    19
    My Mood
    Bitchy
    Quote Originally Posted by Jason View Post


    Of course you're right! Functions can't return data, how stupid of me.
    what are you going to return? maybe a class?

Page 1 of 2 12 LastLast

Similar Threads

  1. what it's like to have religion class
    By ace76543 in forum Spammers Corner
    Replies: 7
    Last Post: 12-09-2006, 04:16 PM
  2. Guild Wars New Classes
    By Chronologix in forum General Gaming
    Replies: 24
    Last Post: 07-23-2006, 08:46 AM
  3. Heavy Weapons Class mine bug. I had no idea.
    By NukeAssault in forum General Gaming
    Replies: 2
    Last Post: 07-20-2006, 06:54 AM
  4. Encryption on Files
    By HolyFate in forum Gunz General
    Replies: 15
    Last Post: 02-20-2006, 01:50 PM
  5. [Tutorial]Change class without respawn
    By vir2000 in forum Game Hacking Tutorials
    Replies: 0
    Last Post: 01-04-2006, 01:47 PM