• Welcome to Valhalla Legends Archive.
 

Help with XSha1

Started by SupaFly, June 29, 2006, 09:05 AM

Previous topic - Next topic

SupaFly

Hi, sorry i'm completely new to this whole thing. Quick background:
I want to make a web login to a starcraft server (people tell me thats the "broken" sha way). I was just wondering, what type of Encoding do i need to apply to a string to send it to the Xsha method in the mbncsutil.dll, i've tried UTF, Unicode and ASCII but all of them returns something else than a known working php version I have.

I hope I posted this in the right section  :)

Help would be greatly appriciated

topaz

You don't apply encoding to anything.
RLY...?

SupaFly

Thing is... the method takes a byte[] and the password entered by the user is a string. How do I convert the string to a byte[] without applying any type of formatting?

Hope it makes sense what I'm trying to say. Thnx for the help

Supa

MyndFyre

Quote from: Topaz on June 29, 2006, 06:29 PM
You don't apply encoding to anything.
Topaz, if you don't know what you're talking about, don't bother replying.

Quote from: SupaFly on June 29, 2006, 09:05 AM
Hi, sorry i'm completely new to this whole thing. Quick background:
I want to make a web login to a starcraft server (people tell me thats the "broken" sha way). I was just wondering, what type of Encoding do i need to apply to a string to send it to the Xsha method in the mbncsutil.dll, i've tried UTF, Unicode and ASCII but all of them returns something else than a known working php version I have.

I hope I posted this in the right section  :)

Help would be greatly appriciated
You shouldn't need to use the XSha1 class, which is provided in case you want to do things the hard way.  Almost universally, string data in MBNCSUtil has a string parameter.

If you don't have the latest version of MBNCSUtil, the documentation and download links can be found here.

If you're trying to hash your password, use the OldAuth class.  Call:


byte[] passwordHash = OldAuth.DoubleHashPassword(password, clientToken, serverToken);


In any case, all Battle.net-related data is encoded in ASCII, but one thing you'll be missing is the null terminator character when you switch from a string to a byte array.  So if you have the string "my password" as your password, you'd need to change it to "my password\0".  This can be done through string.Concat:

password = string.Concat(password, "\0");
byte[] passwordBytes = Encoding.ASCII.GetBytes(password);


In the future, it helps everyone here identify that they don't know what they're talking about if you specify what language you're working in.  You only made a passing reference to MBNCSUtil, so it doesn't surprise me that Topaz chimed in his bit.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

topaz

RLY...?

MyndFyre

Quote from: Topaz on June 30, 2006, 08:53 PM
Encoding != hashing

I'll try and spell this out for you.

In order to hash data, you need to make it a byte[].

Strings need to have the encoding specified to translate it from a .NET string to byte[].

If you don't understand it.... just don't post.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

topaz

Quote from: MyndFyre[vL] on July 01, 2006, 12:41 AM
Quote from: Topaz on June 30, 2006, 08:53 PM
Encoding != hashing

I'll try and spell this out for you.

In order to hash data, you need to make it a byte[].

Strings need to have the encoding specified to translate it from a .NET string to byte[].

If you don't understand it.... just don't post.

Understand what? The language used wasn't specified, and so I didn't think any encoding needed to be applied (which still holds true... just not in the case). Take care of your anger issues, it's not our fault you're overweight.
RLY...?

rabbit

Character encoding (ANSI, UTF-8, Unicode) will affect the outcome of the hash, you douche.  Stop talking.
Grif: Yeah, and the people in the red states are mad because the people in the blue states are mean to them and want them to pay money for roads and schools instead of cool things like NASCAR and shotguns.  Also, there's something about ketchup in there.

topaz

#8
Yes, but one of those (can you guess which one? ;)) are the standard and used more often than the other.
RLY...?

rabbit

Maybe in America.  IIRC Eastern European systems use UTF-8 and Asian systems use Unicode.  Can you comprehend that North America isn't the entire world?
Grif: Yeah, and the people in the red states are mad because the people in the blue states are mean to them and want them to pay money for roads and schools instead of cool things like NASCAR and shotguns.  Also, there's something about ketchup in there.

topaz

Quote from: rabbit on July 01, 2006, 04:44 PM
Maybe in America.  IIRC Eastern European systems use UTF-8 and Asian systems use Unicode.  Can you comprehend that North America isn't the entire world?

Actually... most (if not all) Windows systems with Western configurations use ASCII. Linux and Mac use UTF-8. But, if we're going to be talking about .NET, we should be talking about Windows, no?

Silly jabs about patriotism don't work, you're American as I am, and you're stupid in the first place for assuming I thought 'North America was the entire world'.
RLY...?

rabbit

Well you're clearly assuming only one type of character encoding is used across Battle.Net, which isn't true.
Grif: Yeah, and the people in the red states are mad because the people in the blue states are mean to them and want them to pay money for roads and schools instead of cool things like NASCAR and shotguns.  Also, there's something about ketchup in there.

topaz

Quote from: rabbit on July 01, 2006, 08:02 PM
Well you're clearly assuming only one type of character encoding is used across Battle.Net, which isn't true.

I'll let you end with that, even though it's "clearly" obvious we're talking about the login.
RLY...?

MyndFyre

Quote from: Topaz on July 01, 2006, 02:23 AM
Understand what? The language used wasn't specified, and so I didn't think any encoding needed to be applied (which still holds true... just not in the case). Take care of your anger issues, it's not our fault you're overweight.
Quote from: Topaz on July 01, 2006, 02:20 PM
Yes, but one of those (can you guess which one? ;)) are the standard and used more often than the other.
Quote from: Topaz on July 01, 2006, 06:48 PM
Actually... most (if not all) Windows systems with Western configurations use ASCII. Linux and Mac use UTF-8. But, if we're going to be talking about .NET, we should be talking about Windows, no?
He said that he's using mbncsutil.dll in his first post, which means that he's using .NET.

.NET strings are not directly translatable into byte arrays.  You need to use an instance of the Encoding class to do it.

.NET strings are in Unicode.  Most Windows systems use Unicode natively, not ASCII, because most Windows systems now are NT-based.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

topaz

Looks like you're half right. I can't find a source for the Western config though, but I'm pretty sure I'm right.
RLY...?