Clan x86

Technical (Development, Security, etc.) => General Programming => Botdev => Topic started by: MyndFyre on October 09, 2007, 03:35:28 AM

Title: Newest MBNCSUtil bits
Post by: MyndFyre on October 09, 2007, 03:35:28 AM
This is not an official release.

I'm not quite sure that anyone wants these yet, but here's the latest info on MBNCSUtil.....

I've finally gotten around to working on Lockdown.  I'm about 70% complete porting the C code from rob into C#.  Presently, this *only* works with unsafe code, because there is a LOT of pointer math going on, and I'm way too lazy to move over to streams when I can just do the pointer math. :)

There's still a lot to be learned for anyone who might be interested - primarily in working with unmanaged memory, using unmanaged pointers to access structure data, and the like. 

It's now hosted on subversion, at https://svn2.hosted-projects.com/robpaveza/mbncsutil.  You can check out the code anonymously with the username mbncsutil_anonymous, no password.  There is also a Trac wiki online with access to post tickets, view the project roadmap and browse source; it's located at https://www2.hosted-projects.com/trac/robpaveza/mbncsutil.  There is also a subversion browser integrated into Trac, if you've never used it.
(You can log in with the same username).

New items in the latest bits include the /Util folder, an entirely-internal namespace dealing with the involved processing and unmanaged memory use.  Additionally, COM support has been removed officially from version 2.0 of MBNCSUtil - it was primarily meant as a learning experience for me, and I learned what I wanted to learn.  Finally, if anyone had used a prior beta of MBNCSUtil v2.0, the BnFTP namespace has been renamed to Net, so you now create MBNCSUtil.Net.BnFtpVersion1Request.

MPQ support is currently missing from the bits online, but will be there by the weekend.

If you would like to contribute to this project, please contact me with your experience and what you think would be relevant.

By the way: you may notice that 'rob' checked in these files.  That's me, not the other rob on the forum. :)
Title: Re: Newest MBNCSUtil bits
Post by: MyndFyre on October 11, 2007, 04:52:37 AM
Anyone wanting to take a fun crack at fixing this, the lockdown implementation is completed, but not working.  (For those of you wishing to point out the irony in that statement, I mean that it doesn't crash, but it also doesn't result in the correct value).

The good news is that I seem to clean up all my pointers and the like. 

I'm testing againt rob's code (posted here (http://www.x86labs.org/forum/index.php/topic,9889.0.html)).  Here's what he gets:

Lockdown file: c:\GameFiles\STAR\lockdown-IX86-08.dll
Checksum: 7afbfff8
Version: 10f0100
Digest: ead0367b2ce7f080b0cbe2f573d3c713

Here's what I get:
Checksum: a5d6cf16
Version: 010f0100 (correct)
Digest: d0 b7 d9 d7 15 6a 73 69  48 3f 3e 33 53 8d 85 87

I corrected a TON of errors in Sha1Transform() but that was just on the first pass of Sha1Update().  I haven't gotten to look at too much else; I've been working on this WAY too late.

Stuff can be checked out at the SVN repo listed above - be sure to check out both /trunk and /branches.  If you correct it, please compile a .patch and let's see what you have!

Trac Ticket with all details: https://www2.hosted-projects.com/trac/robpaveza/mbncsutil/ticket/6
Title: Re: Newest MBNCSUtil bits
Post by: iago on October 11, 2007, 08:55:38 AM
In terms of the SHA1 implementation, I've been told that it's identical to the real one, except that sha1_final() adds that "80 00 00 00 00..." thing to the buffer. If that's true, then a simple wrapper around the standard library would solve everything. :)
Title: Re: Newest MBNCSUtil bits
Post by: warz on October 11, 2007, 12:01:49 PM
Yup. From what I can remember, it's a standard SHA1 implementation, with a few small changes to the sha1_final function.
Title: Re: Newest MBNCSUtil bits
Post by: MyndFyre on October 11, 2007, 04:14:44 PM
I've now gotten mine and rob's code to return the same values for the above values.  Now I'm getting vercheck 0x0101 INVALID_VERSION from SID_AUTH_CHECK.  Here's a packet capture with my cd key info removed:

D:\MBNCSUtil\mbncsutil\branches\ConnectionTest\bin\x86\Debug>connectiontest
0000   ff 50 3a 00 00 00 00 00  36 38 58 49 52 41 54 53    ÿP:.....68XIRATS
0010   d1 00 00 00 09 04 00 00  ac 14 01 86 00 00 00 00    Ñ.......¬.......
0020   00 00 00 00 53 55 6e 65  55 53 41 00 55 6e 69 74    ....SUneUSA.Unit
0030   65 64 20 53 74 61 74 65  73 00                      ed States.

Received ping challenge b85ceaa8
Received:
0000   00 00 00 00 ea a2 8a 01  9b b0 1a 00 00 ac d0 d2    ....ê¢...°...¬DO
0010   72 fc c6 01 6c 6f 63 6b  64 6f 77 6e 2d 49 58 38    rüÆ.lockdown-IX8
0020   36 2d 31 30 2e 6d 70 71  00 16 6e 70 d5 4d 59 e9    6-10.mpq..npOMYé
0030   83 0b 40 56 aa 82 bd 39  b3 00                      ..@Vª..9..

Enter CD key:
*************
Sending:
0000   ff 51 68 00 57 a4 78 58  00 01 0f 01 f1 76 93 1e    ÿQh.W☼xX....ñv..
0010   01 00 00 00 00 00 00 00  0d 00 00 00 01 00 00 00    ................
0020   ** ** ** ** 00 00 00 00  ** ** ** ** ** ** ** **    ****....********
0030   ** ** ** ** ** ** ** **  ** ** ** ** 73 74 61 72    ************star
0040   63 72 61 66 74 2e 65 78  65 20 37 2f 31 39 2f 30    craft.exe 7/19/0
0050   37 20 30 32 3a 33 30 3a  30 36 20 31 32 32 30 36    7 02:30:06 12206
0060   30 38 00 42 6c 61 68 00                              08.Blah.

Received: 00000101 (InvalidVersion)


Trac ticket: https://www2.hosted-projects.com/trac/robpaveza/mbncsutil/ticket/7
Title: Re: Newest MBNCSUtil bits
Post by: MyndFyre on October 11, 2007, 06:46:42 PM
This is fixed.  Lockdown is now operational. :)
Title: Re: Newest MBNCSUtil bits
Post by: abc on October 11, 2007, 07:39:14 PM
 :D
Title: Re: Newest MBNCSUtil bits
Post by: Joe on October 12, 2007, 03:21:11 AM
Quote from: MyndFyrex86/64] link=topic=10437.msg132513#msg132513 date=1192142802]
This is fixed.  Lockdown is now operational. :)

Giggity giggity goo!
Title: Re: Newest MBNCSUtil bits
Post by: MyndFyre on October 12, 2007, 03:58:31 AM
MBNCSUtil v2.0.3.15 Beta 1 (http://www.jinxbot.net/mbncsutil) is now available at release.  Here are the release notes:

Title: Re: Newest MBNCSUtil bits
Post by: iago on October 12, 2007, 10:20:35 AM
Quote from: MyndFyrex86/64] link=topic=10437.msg132513#msg132513 date=1192142802]
This is fixed.  Lockdown is now operational. :)
So are you going to tell us what was wrong? :P
Title: Re: Newest MBNCSUtil bits
Post by: MyndFyre on October 12, 2007, 12:42:32 PM
https://www2.hosted-projects.com/trac/robpaveza/mbncsutil/changeset?old_path=trunk%2FMBNCSUtil%2FUtil%2FLockdownCrev.cs&old=7&new_path=trunk%2FMBNCSUtil%2FUtil%2FLockdownCrev.cs&new=7

Seriously though, mostly just some typos in the port from C.
Title: Re: Newest MBNCSUtil bits
Post by: iago on October 12, 2007, 01:03:20 PM
Quote from: MyndFyrex86/64] link=topic=10437.msg132598#msg132598 date=1192207352]
https://www2.hosted-projects.com/trac/robpaveza/mbncsutil/changeset?old_path=trunk%2FMBNCSUtil%2FUtil%2FLockdownCrev.cs&old=7&new_path=trunk%2FMBNCSUtil%2FUtil%2FLockdownCrev.cs&new=7

Seriously though, mostly just some typos in the port from C.
CHANGESET_VIEW privileges are required to perform this operation

:(
Title: Re: Newest MBNCSUtil bits
Post by: MyndFyre on October 12, 2007, 04:37:00 PM
Quote from: iago on October 12, 2007, 01:03:20 PM
CHANGESET_VIEW privileges are required to perform this operation

:(

Thanks.  Fixed!
Title: Re: Newest MBNCSUtil bits
Post by: iago on October 12, 2007, 05:00:00 PM
Quote from: MyndFyrex86/64] link=topic=10437.msg132607#msg132607 date=1192221420]
Quote from: iago on October 12, 2007, 01:03:20 PM
CHANGESET_VIEW privileges are required to perform this operation

:(

Thanks.  Fixed!

I should have reported that in trac. :)
Title: Re: Newest MBNCSUtil bits
Post by: MyndFyre on October 13, 2007, 05:49:39 AM
MBNCSUtil v2.0.3.16 Beta 1 Service Release (http://www.jinxbot.net/mbncsutil) is now available for download.  Release notes:
Title: Re: Newest MBNCSUtil bits
Post by: Joe on November 02, 2007, 06:15:40 PM
I just submitted this ticket (https://www2.hosted-projects.com/trac/robpaveza/mbncsutil/ticket/13).

I don't feel like figuring out how to do diff's, especially on Windows, but here's a "patch" of sorts for it, taken from CheckRevision.cs

        /// <summary>
        /// Extracts the MPQ number from the MPQ specified by the Battle.net server.
        /// </summary>
        /// <remarks>
        /// The MPQ number is a required parameter of the CheckRevision function.  Note that the MPQ number is simply the number represented
        /// in string format in the 8th position (index 7) of the string -- for example, in "IX86ver<b>1</b>.mpq", 1 is the version number.
        /// </remarks>
        /// <param name="mpqName">The name of the MPQ file specified in the SID_AUTH_INFO message.</param>
        /// <returns>The number from 0 to 19 specifying the number in the MPQ file.</returns>
        /// <exception cref="ArgumentException">Thrown if the name of the MPQ version file is less than 8 characters long.</exception>
        /// <exception cref="ArgumentNullException">Thrown if the <i>mpqName</i> parameter is <b>null</b> (<b>Nothing</b> in Visual Basic).
        /// </exception>
        public static int ExtractMPQNumber(string mpqName)
        {
            if (mpqName == null)
                throw new ArgumentNullException("mpqName", Resources.crMpqNameNull);

            if (mpqName.Length < 7)
                throw new ArgumentException(Resources.crMpqNameArgShort);

            string mpqNameLower = mpqName.ToLower();
            int num = -1;

            // ver-IX86-X.mpq
            if (mpqNameLower.StartsWith("ver"))
            {
                num = int.Parse(mpqName[9].ToString());
            }
            // lockdown-IX86-XX.mpq
            else if (mpqNameLower.StartsWith("lockdown"))
            {
                num = int.Parse(mpqName[14].ToString() + mpqName[15].ToString());
            }
            // IX86VerX.mpq
            else
            {
                num = int.Parse(mpqName[7].ToString());
            }

            return num;
        }


EDIT -
Nevermind -- I'm a retard.
Title: Re: Newest MBNCSUtil bits
Post by: Camel on November 02, 2007, 07:40:26 PM
diff file1 file2