Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: SupaFly on June 29, 2006, 09:05 AM

Title: Help with XSha1
Post by: 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
Title: Re: Help with XSha1
Post by: topaz on June 29, 2006, 06:29 PM
You don't apply encoding to anything.
Title: Re: Help with XSha1
Post by: SupaFly on June 30, 2006, 03:01 AM
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
Title: Re: Help with XSha1
Post by: MyndFyre on June 30, 2006, 01:04 PM
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 (http://www.jinxbot.net/mbncsutil/).

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.
Title: Re: Help with XSha1
Post by: topaz on June 30, 2006, 08:53 PM
Encoding != hashing
Title: Re: Help with XSha1
Post by: MyndFyre 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.
Title: Re: Help with XSha1
Post by: topaz on July 01, 2006, 02:23 AM
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.
Title: Re: Help with XSha1
Post by: rabbit on July 01, 2006, 07:04 AM
Character encoding (ANSI, UTF-8, Unicode) will affect the outcome of the hash, you douche.  Stop talking.
Title: Re: Help with XSha1
Post by: 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.
Title: Re: Help with XSha1
Post by: 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?
Title: Re: Help with XSha1
Post by: topaz on July 01, 2006, 06:48 PM
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'.
Title: Re: Help with XSha1
Post by: 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.
Title: Re: Help with XSha1
Post by: topaz on July 01, 2006, 08:34 PM
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.
Title: Re: Help with XSha1
Post by: MyndFyre on July 02, 2006, 12:41 AM
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.
Title: Re: Help with XSha1
Post by: topaz on July 02, 2006, 02:09 AM
Looks like you're half right (http://support.microsoft.com/default.aspx?scid=kb;en-us;99884). I can't find a source for the Western config though, but I'm pretty sure I'm right.
Title: Re: Help with XSha1
Post by: Banana fanna fo fanna on July 02, 2006, 10:01 AM
If you want to be technical, Windows defaults to ISO-8859-1 encoding last I checked, but everyone is moving/has moved to UTF-8.
Title: Re: Help with XSha1
Post by: SupaFly on July 03, 2006, 01:10 AM
Wow, sparked some contraversy. Anyhows, managed to get it working and i'm using C#.

Thnx everyone for the help