Valhalla Legends Forums Archive | Battle.net Bot Development | Help with XSha1

AuthorMessageTime
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
June 29, 2006, 2:05 PM
Topaz
You don't apply encoding to anything.
June 29, 2006, 11:29 PM
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
June 30, 2006, 8:01 AM
Myndfyr
[quote author=Topaz link=topic=15299.msg155091#msg155091 date=1151623769]
You don't apply encoding to anything.
[/quote]
Topaz, if you don't know what you're talking about, don't bother replying.

[quote author=SupaFly link=topic=15299.msg155071#msg155071 date=1151589920]
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
[/quote]
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:

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

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:
[code]
password = string.Concat(password, "\0");
byte[] passwordBytes = Encoding.ASCII.GetBytes(password);
[/code]

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.
June 30, 2006, 6:04 PM
Topaz
Encoding != hashing
July 1, 2006, 1:53 AM
Myndfyr
[quote author=Topaz link=topic=15299.msg155109#msg155109 date=1151718833]
Encoding != hashing
[/quote]

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.
July 1, 2006, 5:41 AM
Topaz
[quote author=MyndFyre[vL] link=topic=15299.msg155110#msg155110 date=1151732504]
[quote author=Topaz link=topic=15299.msg155109#msg155109 date=1151718833]
Encoding != hashing
[/quote]

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.
[/quote]

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.
July 1, 2006, 7:23 AM
rabbit
Character encoding (ANSI, UTF-8, Unicode) will affect the outcome of the hash, you douche.  Stop talking.
July 1, 2006, 12:04 PM
Topaz
Yes, but one of those (can you guess which one? ;)) are the standard and used more often than the other.
July 1, 2006, 7:20 PM
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?
July 1, 2006, 9:44 PM
Topaz
[quote author=rabbit link=topic=15299.msg155131#msg155131 date=1151790249]
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?
[/quote]

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'.
July 1, 2006, 11:48 PM
rabbit
Well you're clearly assuming only one type of character encoding is used across Battle.Net, which isn't true.
July 2, 2006, 1:02 AM
Topaz
[quote author=rabbit link=topic=15299.msg155144#msg155144 date=1151802120]
Well you're clearly assuming only one type of character encoding is used across Battle.Net, which isn't true.
[/quote]

I'll let you end with that, even though it's "clearly" obvious we're talking about the login.
July 2, 2006, 1:34 AM
Myndfyr
[quote author=Topaz link=topic=15299.msg155116#msg155116 date=1151738582]
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]
[quote author=Topaz link=topic=15299.msg155123#msg155123 date=1151781620]
Yes, but one of those (can you guess which one? ;)) are the standard and used more often than the other.
[/quote]
[quote author=Topaz link=topic=15299.msg155137#msg155137 date=1151797687]
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?
[/quote]
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.
July 2, 2006, 5:41 AM
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.
July 2, 2006, 7:09 AM
St0rm.iD
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.
July 2, 2006, 3:01 PM
SupaFly
Wow, sparked some contraversy. Anyhows, managed to get it working and i'm using C#.

Thnx everyone for the help
July 3, 2006, 6:10 AM

Search