• Welcome to Valhalla Legends Archive.
 

SC League MPQ format (start of)

Started by Ringo, February 06, 2008, 12:23 PM

Previous topic - Next topic

Ringo

Open source league mpq builder:
http://www.d2bot.cjb.net/VB6LeagueBuilder.zip

Basic out line of a League.mpq file format:

(DWORD) 0x1A51504D
(DWORD) 0x2C
(WORD)  0x8AD4
(WORD)  0x00
(WORD)  0x01
(WORD)  0x03
(WORD)  0x8955
(WORD)  0x00
(WORD)  0x8A55
(WORD)  0x00
(DWORD) 0x10
(DWORD) 0x08
(DWORD) 0x00
(DWORD) 0x00
(DWORD) 0x00

(VOID[0x53E])  Admin.pcx -> 28 by 14, 256 colors, &H53E in total lengh
(VOID[229])    Leauge.ini
(VOID[0x567]   loggedout.pcx -> 28 by 14, 256 colors, &H567 in total lengh
(VOID[0x52C]   map.pcx -> 28 by 14, 256 colors, &H52C in total lengh
(VOID[0x589])  player.pcx -> 28 by 14, 256 colors, &H589 in total lengh
(VOID[0x719A]) profile.pcx -> 270 by 200, 256 colors, &H719A in total lengh

Append the following data to the file:

FF FF FF FF FF FF FF FF FF FF FF FF 61 64 6D 69    ....T...X...admi
6E 2E 70 63 78 0D 0A 6C 65 61 67 75 65 2E 69 6E    n.pcx..league.in
69 0D 0A 6C 6F 67 67 65 64 6F 75 74 2E 70 63 78    i..loggedout.pcx
0D 0A 6D 61 70 2E 70 63 78 0D 0A 70 6C 61 79 65    ..map.pcx..playe
72 2E 70 63 78 0D 0A 70 72 6F 66 69 6C 65 2E 70    r.pcx..profile.p
63 78 0D 0A FF FF FF FF FF FF FF FF FF FF FF FF    cx..W.D.........
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    ....d.........z.
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    ....u....JBw...Y
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    F+.i...'........
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    ................
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    ................
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    ................
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    ....y..kl.......
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    ................
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    ................
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    ................
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    ................
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    ................
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    ................
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    ................
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    ................
33 30 C3 79 28 D9 32 98 BC 73 6F 9F B2 88 4E E9    30.y(.2..so...N.
17 A2 04 84 C4 40 BF CA 63 BF 7B 98 0C E7 19 7E    [email protected].{....~
50 F6 FE 0B F6 E2 39 5B 54 20 30 A5 28 CF 0D 85    P.....9[T 0.(...
4A 70 09 70 0B 67 91 3C 0B 7A 97 7E 5B A2 0F 26    Jp.p.g.<.z.~[..&
9B 35 8B E4 68 30 19 C7 78 66 C2 D3 52 FA E8 75    .5..h0..xf..R..u
2D 9E 54 D5 FF 7C 5F AB 04 20 AC 0F 51 7C 56 CB    -.T..|_.. ..Q|V.
37 F2 E1 76 CB A6 0F 40 93 B6 57 A9 E1 6F D7 A8    [email protected]..
DE 96 97 34 6B CE B0 8D EA 01 9F B9 73 7A A5 C3    ...4k.......sz..
3C 62 CD 52 84 F8 52 8E C2 6D E0 BC 52 CA C7 92    <b.R..R..m..R...
0C D6 89 88 23 48 5A 14 2B 97 3A F9 7C 63 16 F5    ....#HZ.+.:.|c..
43 30 7A 60 70 94 E6 35 8F 88 8D 68 B8 D5 64 50    C0z`p..5...h..dP
59 6F 5C 65 AB 73 61 3C 30 EC EC C0 FD CD B0 A4    Yo\e.sa<0.......
BC F3 9E B0 85 A6 A3 9A C6 59 75 F7 B8 AB 97 11    .........Yu.....
AB 1E 6B 52 3A 0A 88 0C 26 96 27 9E BB 1F F4 8C    ..kR:...&.'.....
C8 02 9F F0 F1 1E 51 29 A5 5F F0 0F 9E F8 D5 47    ......Q)._.....G
3D 5A 3F 33 26 DD 50 71 87 64 C9 A3 99 0E 6D 48    =Z?3&.Pq.d....mH
A7 67 48 3D 93 D6 08 CA A3 C4 35 F8 11 57 34 E8    .gH=......5..W4.
42 24 C0 B2 6B 68 67 F1 C7 42 5D 03 C5 20 B1 78    B$..khg..B].. .x
72 D8 2E C9 49 63 B6 68 AF 1D 8C 54 2B 54 32 5D    r...Ic.h...T+T2]
CC AB 85 E8 C2 51 E5 82 9E 99 E9 19 20 F2 C8 50    .....Q...... ..P
71 0D F0 3E 58 F8 16 14 E0 81 FF 7B 90 B0 9B 05    q..>X......{....
03 71 6B F3 4F 55 84 DA 18 69 12 00 58 B7 78 79    .qk.OU...i..X.xy
42 E1 98 8D F2 B3 51 CA 52 CE E1 4E A4 49 C7 20    B.....Q.R..N.I.
CA 21 B9 96 28 81 12 65 5F 83 6B EC FD 96 87 87    .!..(..e_.k.....
4E 47 49 53 E8 41 3D DE 10 16 E1 8D 0D C1 D5 CD    NGIS.A=.........
BA DE 48 D9 14 D8 9D F0 4A 0C 20 70 87 34 46 DE    ..H.....J. p.4F.
CD 68 72 97 C5 73 7B 8B 94 01 65 A0 B1 FE 53 97    .hr..s{...e...S.
0A 87 93 71 39 E2 18 00 39 B4 3A 6F 6F 4B 1A 91    ...q9...9.:ooK..
8C 89 0E 6C 98 3E 5D AD DB 9E 8E 46 81 31 DB C5    ...l.>]....F.1..
EB 69 AB 97 C2 7A B9 10 A3 5C AD 47 B1 B7 11 95    .i...z...\.G....
75 20 45 A4 51 0D FF B7 E4 3E B7 16 05 88 BB 4F    u E.Q....>.....O
8B E5 4D A5 9F 75 9D EE 77 30 73 68 14 75 97 1B    ..M..u..w0sh.u..
AC 4D 16 2A 73 4C 18 7D 2E 26 90 58 C5 B4 AA 61    .M.*sL.}.&.X...a
52 98 D7 E9 20 3E 1D 8B 48 7D 9F AD 55 D3 F4 0B    R... >..H}..U...
F9 44 4A A0 31 72 62 CB C1 F1 6C 01 E7 CF D9 87    .DJ.1rb...l.....
FF 0F BA D3 2F 57 F6 46 67 74 73 AF C4 18 62 2E    ..../W.Fgts...b.
09 38 69 6D 0A 48 86 D0 66 D1 D9 42 27 28 B1 7D    .8im.H..f..B'(.}
38 68 CF 9C 52 97 0E 3A 3D 99 84 66 C6 82 C1 40    8h..R..:=..f...@
CF 8B F5 48 B5 C3 33 FF BA E2 BA E0 2C CE 0F 52    ...H..3.....,..R
54 55 35 FE 9D 8F 13 33 3C 87 4E F1 A2 03 34 54    TU5....3<.N...4T
90 07 50 19                                        ..P.

Total mpq file size should be 35801

League.ini format:

version=1
name=Name Of League
leagueId=99
channelPrefix=TAG
mainURL=http://www.YourSite.com
infoQueryURL=http://www.YourSite.com/League/info.php
uploadFailure="Replay Upload Failed"
#########################
# end of file

The #'s were just to buffer the file to correct lengh

Info.php:

name=Test
version=1
accountURL=http://127.0.0.1/SC-Leagues/authaccount.php?hash=%s
logonURL=http://127.0.0.1/SC-Leagues/login.php?hash=%s
logoutURL=http://127.0.0.1/SC-Leagues/logout.php?hash=%s
statQueryURL=http://127.0.0.1/SC-Leagues/players.php?players=%s
customQueryURL=http://127.0.0.1/SC-Leagues/custom.php?query=%s
replayUploadURL=http://127.0.0.1/SC-Leagues/sendresult.php

127.0.0.1 would be www.YourSite.com


Just some side notes, SC will connect to the site to download info.php to obtain the basic URL's.
The pcx colors have to be like banner pcx's i think, only a set block of the pallet can be used other wise it screws the image up/clashs.
I also dunno why the pcx's/ini has to be a fixed lengh, nore how SC hash's the league password for logon (its a 20 byte hash i think, sent in raw 40 byte hex string) and i also broke up the header into some WORD's, because i think i was pokeing them to see what they did (cant remember what they were/do)
Also i have no idea what that binary data is that gets appeneded to the bottom of the file, i think i guessed it was some asm for the hashing of the password (idk)
I figgerd SC would need to know the lengh of the files before it could gett o the end binary (unless it went directly to the end of the file and got them 1st?) hence i was poking the header values.
I only spent an hour, if that, poking this file format, and probly an hour after that letting SC connect to a home made web server to watch what goes on.
So there is MANY things that need working out to make a correct league MPQ builder, but this is a basic out line.
I got board as soon as i noticed how messy it was, but i cant see why it could be made to work if the web server was built right.

Anyway, I expect a few of you have done this in the past and probly continued way more into it than i cared to, if so, and you want to share it, this is the place to post it.

Just another side note: This is from very start of 1.15a, but i dont think anything would have changed in 1.15b.

Oh, and all the 0xFF bytes in the appended data, i nurfed to see what they were, seemed like nothing/padding.

EDIT: On, n/m, kinda pointless this, since blizzard finaly got round to uploading the kit to www.battle.net
http://forum.valhallalegends.com/index.php?topic=17301.msg176146#msg176146

brew

#1
Quote from: Ringo on February 06, 2008, 12:23 PM
Also i have no idea what that binary data is that gets appeneded to the bottom of the file, i think i guessed it was some asm for the hashing of the password (idk)
if the binary data starts with "U‹ì", there's a good chance that it is some sort of function using an ebp frame. (that's the prologue for a function that uses the stack in ascii, push ebp mov ebp, esp) You'd know for sure that it's ment to be executed.
What I'd do for finding the type of hash is cut it off from the rest of the file, disassemble it with something simple like ndisasm -u blah.bin, then search for a defining value of SHA1 (for example, efcdab89h), if it's not found then try some other hashing algorithm that outputs 20 bytes, etc, then you'd know for sure what it's using. and i doubt they'd use their own screwy implementation of the algorithm either, not sure why. i just have a feeling that the standard would be used for this. :P
<3 Zorm
Quote[01:08:05 AM] <@Zorm> haha, me get pussy? don't kid yourself quik
Scio te esse, sed quid sumne? :P

Ringo

Quote from: brew on February 06, 2008, 02:33 PM
Quote from: Ringo on February 06, 2008, 12:23 PM
Also i have no idea what that binary data is that gets appeneded to the bottom of the file, i think i guessed it was some asm for the hashing of the password (idk)
if the binary data starts with "U‹ì", there's a good chance that it is some sort of function using an ebp frame. (that's the prologue for a function that uses the stack in ascii, push ebp mov ebp, esp) You'd know for sure that it's ment to be executed.
What I'd do for finding the type of hash is cut it off from the rest of the file, disassemble it with something simple like ndisasm -u blah.bin, then search for a defining value of SHA1 (for example, efcdab89h), if it's not found then try some other hashing algorithm that outputs 20 bytes, etc, then you'd know for sure what it's using. and i doubt they'd use their own screwy implementation of the algorithm either, not sure why. i just have a feeling that the standard would be used for this. :P
I just read the documents at: http://www.battle.net/info/patch.shtml
Says it uses a bulk standard SHA1 algorithm with the password appending the account name.
I think i tryed bnets broken SHA1 and just single hashing the password when i was pokeing around with this.
If i can get a few other copys of league mpqs i will figger out how to define the lengh of files (probly somthing to do with that mumbojumbo binary)
I dont see any need for blizzard to authorize/compile these mpq's tbh.
I orginaly thought blizzard included the compiler in the league package, but apparently not.  :-\
Once i got a few more (non wgt) league mpqs i will post a open source project to compile them.

Ringo

Well, I spent a good few hours today working on the PCX loader, CompPCX(), ResortPCX8() and a few other things.
Just to find out I was wasteing my time :P
I tabbed out the ResortPCX8() function. Its designed to resort the pallet/file data by most used, so it would compress the images alot smaller as well as shift a block of colors up by 64 index's so the addbanner had room, but after doing that I figgerd SC was useing its defalt pallet and didnt even read the pallet for the images in the league mpq. :p
I was gonner add a *sort by closest colors* but im feeling lazzy now.
To get images smaller, its just a case of having a few lines all the same color (or as many as possible) as the compression works by pixel matchs on a single line (left to right) so for example, filling the back ground with 1 color (if its dark for ie) will help shave images down alot.
It dumps the mpq into the directory the program is run from, as well as a info.php file, so its ready to go.
Its a mess (mostly in the pcx loader -- cba to rewrite it) but it does work nicely.
Since I cant get hold of any league mpqs other than WGTour's, I just went with static image data lenghs (hence ResortPCX8)
If your unsure of what URL's to put in the text box's, just highlight them and the tooltip text will reveal all.
I have also put a pallet.pal file in the zip, so you can load that up when you have created your images, and your paint software should automaticly sort by closest color.
In the zip is some pcx's, exe and source code (all tryed and tested), so its right ready to go/test.
I have also left the ResortPCX8() function in for educational reassions.
It may have some bugs, but none that i came across, sc loads it up fine when you click on league.
If i can get hold of some mpqs that blizzard built, then i will poke the files abit more and figger out what defines the image data lengh, but im really to lazzy to poke all that binary at the end of the file, but i noticed some of it matters, some of it doesnt, so its in there somwhere.
I think thats about it, anything else should be coverd in blizzards documentation.

Anyway, Heres the link, injoy:
http://www.d2bot.cjb.net/VB6LeagueBuilder.zip
Feel free to modify the code, rip it, sell it, give it to your granny for her birthday, w/e.
If i get really board and/or get some more blizzard-compiled league mpq's, then i might upload a vb6 web server source code, built specificly to manage leagues on, but i doubt it.