Raised This Month: $ Target: $400
 0% 

[SOLVED] XMPP Auth Problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GordonFreeman (RU)
Veteran Member
Join Date: Jan 2010
Location: Uzbekistan
Old 07-26-2013 , 03:50   [SOLVED] XMPP Auth Problem
Reply With Quote #1

Im working on XMPP client for my server.
For client authorization im must encode "\x00{username}\x00{password}" string.
The problem is AMXX cuts string after 0x00 symbol.

Code:
formatex(auth,127,"%c%s%c%s",0x00,USER,0x00,PASSWORD)

The strlen(auth) give me 0.


How to do that? What i need to do for 0x00 do not cuting the string?
__________________
The functional way is the right way

Last edited by GordonFreeman (RU); 07-27-2013 at 03:09.
GordonFreeman (RU) is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-26-2013 , 03:54   Re: 0x00 in string
Reply With Quote #2

You can't, but you can manipulate that array as an array instead of a string.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
GordonFreeman (RU)
Veteran Member
Join Date: Jan 2010
Location: Uzbekistan
Old 07-26-2013 , 04:24   Re: 0x00 in string
Reply With Quote #3

Ok.

The next problem how to encode this string to base64.
Im used encode64 function from this stock. With my edit:
Code:
/* Encodes a string to Base64 */ stock Encode64(const sString[], strLen, sResult[], len) {     new const cFillChar = '=';     new nLength = strLen;

Code:
#define USER        "[email protected]" #define PASSWORD    "12345"
Code:
new auth[512]     formatex(auth,511,"%c%s%c%s",0x00,USER,0x00,PASSWORD)     Encode64(auth,(strlen(USER)+strlen(PASSWORD))+2,auth,511)         server_print(" Encoded: %s",auth)     Decode64(auth,auth,511)     server_print(" Decoded: %s",auth)

Result:
Code:
 Encoded: AQEFRlJsSnNTbk5UYms1VVltczFWVmx0Y3pGVw==  Decoded: FRlJsSnNTbk5UYms1VVltczFW

XMPP Says:
Code:
<failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><malformed-request/></failure>
__________________
The functional way is the right way

Last edited by GordonFreeman (RU); 07-26-2013 at 04:28.
GordonFreeman (RU) is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 07-26-2013 , 10:19   Re: XMPP Auth Problem
Reply With Quote #4

Encode64(auth, ( strlen(USER) + strlen(PASSWORD) ) + 2, auth, 511)
Decode64(auth, auth, 511)

These functions are making changes to the output string on-the-fly. This means you cannot use the same input as output.
The only function that can be used like that is "format" if I'm not mistaken.

This is my code and result:

Code:
#define USER "BlackRose" #define PASSWORD "password" public plugin_init() {     register_plugin("", "", "");         new auth[512], auth2[512]     formatex(auth,511,"%c%s%c%s",0x00,USER,0x00,PASSWORD)         Encode64(auth, ( strlen(USER) + strlen(PASSWORD) ) + 2, auth2, 511)         server_print(" Encoded: %s",auth2)     Decode64(auth2, auth, 511)         for ( new i = 0 ; i < 32 ; i++ ) {         auth2[i] = ! auth[i] ? '*' : auth[i];     }         server_print(" Decoded: %s",auth2) }

Code:
 Encoded: AEJsYWNrUm9zZQBwYXNzd29yZA==
 Decoded: *BlackRose*password*************
__________________

Last edited by Black Rose; 07-26-2013 at 10:24.
Black Rose is offline
GordonFreeman (RU)
Veteran Member
Join Date: Jan 2010
Location: Uzbekistan
Old 07-27-2013 , 01:36   Re: XMPP Auth Problem
Reply With Quote #5

Good! Thank you very much!
__________________
The functional way is the right way
GordonFreeman (RU) is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:21.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode