Author Topic: Newest MBNCSUtil bits  (Read 8983 times)

0 Members and 1 Guest are viewing this topic.

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Newest MBNCSUtil bits
« 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. :)
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: Newest MBNCSUtil bits
« Reply #1 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).  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
« Last Edit: October 11, 2007, 04:57:39 am by MyndFyre[x86/64] »
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: Newest MBNCSUtil bits
« Reply #2 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. :)

Offline warz

  • Hero Member
  • *****
  • Posts: 1134
    • View Profile
    • chyea.org
Re: Newest MBNCSUtil bits
« Reply #3 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.
http://www.chyea.org/ - web based markup debugger

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: Newest MBNCSUtil bits
« Reply #4 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
« Last Edit: October 11, 2007, 06:46:27 pm by MyndFyre[x86/64] »
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: Newest MBNCSUtil bits
« Reply #5 on: October 11, 2007, 06:46:42 pm »
This is fixed.  Lockdown is now operational. :)
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline abc

  • Hero Member
  • *****
  • Posts: 576
    • View Profile
Re: Newest MBNCSUtil bits
« Reply #6 on: October 11, 2007, 07:39:14 pm »
 :D

Offline Joe

  • B&
  • Moderator
  • Hero Member
  • *****
  • Posts: 10319
  • In Soviet Russia, text read you!
    • View Profile
    • Github
Re: Newest MBNCSUtil bits
« Reply #7 on: October 12, 2007, 03:21:11 am »
This is fixed.  Lockdown is now operational. :)

Giggity giggity goo!
I'd personally do as Joe suggests

You might be right about that, Joe.


Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: Newest MBNCSUtil bits
« Reply #8 on: October 12, 2007, 03:58:31 am »
MBNCSUtil v2.0.3.15 Beta 1 is now available at release.  Here are the release notes:

  • Lockdown CheckRevision is now supported for Starcraft and Warcraft II: Battle.net Edition. This is a pre-release version of MBNCSUtil 2.0 that previews the MPQ, BnFTP, and Lockdown Checkrevision functionality of MBNCSUtil 2.0. Tests indicate that Lockdown currently incorrectly calculates the revision check 7.4% of its uses.
  • IMPORTANT - MBNCSUtil 2.0 does not support the .NET Framework 1.x; clients that wish to use MBNCSUtil 2.0 should target the .NET Framework 2.0.
  • MBNCSUtil is now hosted in a Subversion repository. Point your favorite SVN client at https://www2.hosted-projects.com/robpaveza/mbncsutil/trunk/ to download the latest bits. (Note that the SVN repository is updated much more frequently than the stable build list; for stable builds, be sure to download the software from the official site. Along with Subversion, there is now a Trac wiki and bug tracker. Visit it at https://www2.hosted-projects.com/trac/robpaveza/mbncsutil. Both Subversion and Trac require authentication; use the username mbncsutil_anonymous with no password.
  • MBNCSUtil 2.0 includes the ability to open MPQ archives! See the MBNCSUtil.Data namespace for implementation details. If you retrieve the solution from Subversion, you will find a project called mmpq in the trunk; this project demonstrates opening an MPQ and retrieving its listfile.
  • MBNCSUtil 2.0 includes an integrated ability to download files from Battle.net via the proprietary BnFTP protocol. See the MBNCSUtil.BnFtp namespace for implementation details. If you retrieve the solution from Subversion, you will find a project called mbnftp in the trunk; this project demonstrates downloading files from the BnFTP service.
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: Newest MBNCSUtil bits
« Reply #9 on: October 12, 2007, 10:20:35 am »
This is fixed.  Lockdown is now operational. :)
So are you going to tell us what was wrong? :P

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: Newest MBNCSUtil bits
« Reply #12 on: October 12, 2007, 04:37:00 pm »
CHANGESET_VIEW privileges are required to perform this operation

:(

Thanks.  Fixed!
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: Newest MBNCSUtil bits
« Reply #13 on: October 12, 2007, 05:00:00 pm »
CHANGESET_VIEW privileges are required to perform this operation

:(

Thanks.  Fixed!

I should have reported that in trac. :)

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: Newest MBNCSUtil bits
« Reply #14 on: October 13, 2007, 05:49:39 am »
MBNCSUtil v2.0.3.16 Beta 1 Service Release is now available for download.  Release notes:
  • A bug was identified in the way the LockdownHeap class (part of the MBNCSUtil.Util namespace, which is not a public namespace) was marshaling data to the unmanaged heap, which was cauing 100% failure rates on lockdown. This issue has been corrected. Please note that the downloadable documentation file has not been updated for this service release, as the API has not changed.
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline Joe

  • B&
  • Moderator
  • Hero Member
  • *****
  • Posts: 10319
  • In Soviet Russia, text read you!
    • View Profile
    • Github
Re: Newest MBNCSUtil bits
« Reply #15 on: November 02, 2007, 06:15:40 pm »
I just submitted this ticket.

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

Code: [Select]
        /// <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.
« Last Edit: November 02, 2007, 06:23:51 pm by Joe[x86] »
I'd personally do as Joe suggests

You might be right about that, Joe.


Offline Camel

  • Hero Member
  • *****
  • Posts: 1703
    • View Profile
    • BNU Bot
Re: Newest MBNCSUtil bits
« Reply #16 on: November 02, 2007, 07:40:26 pm »
diff file1 file2

<Camel> i said what what
<Blaze> in the butt
<Camel> you want to do it in my butt?
<Blaze> in my butt
<Camel> let's do it in the butt
<Blaze> Okay!