Advertisement
Xzempt

Untitled

Jun 2nd, 2012
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 11.68 KB | None | 0 0
  1. <BODY BGCOLOR=BLACK TEXT=WHITE>
  2. <FONT COLOR=AQUA>
  3. <b>Notes by Biasha:</b><br>
  4. Structure (fields, size) and sequence of the packets is valid for 1.8.0<br>
  5. Algorithm is not checked for 1.8.0 yet<br>
  6. Original URL: http://www.shockerz.net/wowresource/forum/index.php?showtopic=42<br>
  7. SRP algorithm: RFC2945<br>
  8. Information about SRP6: http://srp.stanford.edu/doc.html<br>
  9. <br>
  10. <br>
  11. </FONT>
  12.  
  13.     [quote=Zam,Feb 11 2005, 09:26 PM]
  14. <br>[Version 1.03]
  15. <br>
  16. <br>Ok, this only covers the first  handshacking packets.  :-)   I haven't had time to disect any other packets.  
  17. <br>
  18. <br><b>[size=18]If you are having problems; please verify your math with my math; there is a reason I supply the output to every function.  This will allow you to see if there is typo's or any problem on either side.
  19. <br>
  20. <br>Please note that some libraries may have bugs with Big Numbers; hense the reason I used openssl, as it has been used by crypto products for years.   :)
  21. <br>
  22. <br>[/size] </b>
  23. <br><FONT COLOR=yellow>Changes:
  24. <br>V1.00  - Initial Release
  25. <br>V1.01  - Removal of the Second phase and adding where I forgot to up that B (Public) is reveresed before it is stored for use later.
  26. <br>V1.02  - Added Temp variables results to S calc  
  27. <br>          - Fixed the missing UPPERCASE in M1 calculation (Username)
  28. <br>          - Fixed colors.  :o
  29. <br>          - Added some more notes.
  30. <br>V1.03  - Update Warning, and added a couple more intermediate numbers in the M1 Calcs.
  31. <br></FONT>
  32. <br>
  33. <br> <FONT COLOR=red>I have been informed that only the first 4 packets are needed and then the client should ask for the realm list</FONT>
  34. <br>
  35. <br>This is for version 1.1.1.   I do not know if anything changed srp wise in 1.2.1; but I will be confirming and diferences between 111 and 121 once I have some spare time.  <FONT COLOR=red>According to several people; srp has NOT changed between 1.1.1 and 1.2.1</FONT>
  36. <br>
  37. <br>Kudo's to those who have shared there knowledge.  Those who have selfishly held onto most or all of their hard work  so as not to advance the community; well just disappear -- you are selfish losers and the community would be better off without you...  
  38. <br>-------------------------------------------------------------
  39. <br>
  40. <br>Packets as shared by sYkez on this topic (http://www.blizzhackers.com/viewtopic.php?t=21457)
  41. <br>
  42. <br>Kudo's to Amso for publically sharing his attempts at decoding srp; he actually was the one to inspire me to do this.  
  43. <br><b><FONT COLOR=red>Notes:</FONT></b>
  44. <br><b>Reverse</b> means reverse the String.  DO NOT USE strrev --
  45. <br>Treat this string as an array of numbers.  0 is a valid number; strrev will stop reversing when it incounters an NULL(0) character.   My reverse routine is passed the length that it needs to reverse.   In fact all of these variables are strored in a simple structure {char *data; int len;} and I pass this structure around.
  46. <br><b>uppercase</b> means upper case all letters in string.
  47. <br>All values are in hex.
  48. <br><b> & </b> means concatanate the string valuse.  "HI" & "THERE" = "HITHERE"
  49. <br><b><FONT COLOR=red>Common Q & A:</FONT></b>
  50. <br>Yes, Username and Password are Uppercased.
  51. <br>Yes, there are reversed string used in certain snippits of code.  Don't ask my why; I don't know why Bliz deviated from the standard -- but it works.  I assume the reason why is endian-ness of the machines.  There server might be a main-frame...
  52. <br>I am using an UNMODIFIED openssl (latest version) library.
  53. <br>And I am using the wrapper functions in the t_math.c file that comes from the srp demo page.  They just make the names of the functions much more readable.  :-)
  54. <br>
  55. <br>Each Calculation assumes the byte order is in the initial stored state.  So N=894B...
  56. <br>When I reverse it in a routine N is only reversed for that Routine.  When you get to the next routine, N is again equal to 894B...   Some routines work with a reversed version of the calculation and some don't.    Exception to this rule is B, it is reveresed before it is stored for use in later calculations.
  57. <br><b>Lets Go at it:</b>
  58. <br>
  59. <br> The Client Connects and sends the <b>Client_Challenge</b> packet.  (Pretty self explanitory)
  60. <br><i><code>
  61. <br>struct {
  62. <br>  uint8  opcode;          // 0x00
  63. <br>  uint8   error;         // 0x02
  64. <br>  uint16   size;         // 0x0023 (size of the rest of packet)
  65. <br>  char   gameid[4];        //gameid[4]=0;      // 'WoW'
  66. <br>  uint8   version1;         // 0x00
  67. <br>  uint8   version2;         // 0x12 build version(0.12.0)
  68. <br>  uint8   version3;         // 0x00
  69. <br>  uint16   build;           // 3988
  70. <br>  char   platform[4];      // platform[4]=0;      // 'x86'
  71. <br>  char   os[4];                // os[4]=0;      // 'Win'
  72. <br>  char   language[4];          // language[4]=0;      // 'enUS'
  73. <br>  uint32   timezone_bias;   // -419
  74. <br>  uint32   ip;            // client ip
  75. <br>  uint8   acclen;         // length of account name
  76. <br>  char *AccountName;
  77. <br>} Client_Challenge;
  78. <br></code></i>
  79. <br>The Server Generates the Following Packet:
  80. <br><i><code>
  81. <br>struct {
  82. <br>  uint8 opcode;          // 0x00
  83. <br>  uint8 error;  //no error
  84. <br>  uint8 ukn1;
  85. <br>  char B[32];
  86. <br>  uint8 g_length;    //1
  87. <br>  char g;
  88. <br>
  89. <br>  uint8 n_len; // 32; //N_len
  90. <br>  char N[32];
  91. <br>  char salt[32];
  92. <br>  char unk3[16];
  93. <br>} Server_Challenge;
  94. <br></code></i>
  95. <br>Ok, N is  is hard coded in hex as:
  96. <br><i><code>894B645E89E1535BBDAD5B8B290650530801B18EBFBF5E8FAB3C82872A3E9BB7</code></i>
  97. <br>G Length = 1
  98. <br>G = 7
  99. <br>K = 3
  100. <br>salt = randomly generated 32 characters.
  101. <br>Server also internally generates a random generated "b" 20 characters
  102. <br>
  103. <br>We are going to assume some values to make it easier to duplicate:
  104. <br><i><code>Username = "TEST"
  105. <br>Password = "TEST"
  106. <br>salt = 33f140d46cb66e631fdbbbc9f029ad8898e05ee533876118185e56dde843674f
  107. <br>b = 8692E3A6BA48B5B1004CEF76825127B7EB7D1AEF
  108. <br></code></i>
  109. <br>Ok, Now for the calculations:
  110. <br>
  111. <br>To Generate x:
  112. <br><i><code>Temp = "Username" (Supplied in the client challenge) & ":" & "Password" (Supplied to whatever user registration script).
  113. <br>TempHash = SHA1(uppercase(Temp))
  114. <br>x = sha1(Salt & TempHash)
  115. <br>
  116. <br>Your x should equal: 1b70dd2ad03c1ed140223f8f8741c00ec3a4ce73
  117. <br></code></i>
  118. <br>To Generate v (Verifier):
  119. <br><i><code>N = Reverse(N) // 32 Characters
  120. <br>x = Reverse(x) // 20 Characters
  121. <br>v = g ^ x mod (N)
  122. <br>// Exact call I Use:  BN_mod_exp_mont(v, g, x, N, ctx, NULL);
  123. <br>Your v Should equal: 996ec7b349d5827043ecd0e6efba3daea5590f944d0184fee1b83ff4f59ecfa8
  124. <br></code></i>
  125. <br>
  126. <br>To Generate B (public B, not private B):
  127. <br><i><code>  /* B = kv + g^b mod n  */
  128. <br>b = Reverse(b)
  129. <br>N = Reverse(N)
  130. <br>
  131. <br>Temp1 = K * v
  132. <br>Temp2 = g ^ b mod (N)
  133. <br>Temp3 = Temp1 + Temp2
  134. <br>B = Temp3 mod (N)
  135. <br>B = Reverse(B)  // Store this one PERMANATLY Reversed!!!
  136. <br>
  137. <br>//  code I use is:
  138. <br>//------------------------------
  139. <br>  BigIntegerMul(B, k, v, NULL);
  140. <br>  BigIntegerModExp(k, g, b, N, NULL, NULL);
  141. <br>  BigIntegerAdd(k, k, B);
  142. <br>  BigIntegerMod(B, k, N, NULL);
  143. <br>//------------------------------
  144. <br>Your B should equal: 645d1f78973073701e12bc98aa38ea99b4bc435c32e8447c73ab077ae4d75964
  145. <br></code></i>
  146. <br>
  147. <br>Stuff B, g, N, and Salt in the packet and send it.
  148. <br>
  149. <br>The client will respond with the following:
  150. <br><i><code>struct  {
  151. <br>  uint8  opcode;          // 0x01
  152. <br>  uint8   A[32];
  153. <br>  uint8   M1[20];
  154. <br>  uint8   crc_hash[20];
  155. <br>  uint8   number_of_keys;
  156. <br>} Client_Proof;
  157. <br>
  158. <br>Were going to assume A came over as follows:
  159. <br>232fb1b88529643d95b8dce78f2750c75b2df37acba873eb31073839eda0738d
  160. <br>And M1 came over as:
  161. <br>eeb4adca80f4de02f9a9fe8d000d682e3ddfad6f
  162. <br></code></i>
  163. <br>A is generated by the client by its secret (a).  You will never know what the secret (a) is, so you don't need to worry about how to calc A.  (See SRP demo page if you really need to generate an A because you are working on a client program.
  164. <br>
  165. <br>M1 however is quite important, this will be used to detect if the user is authenticly loging on.
  166. <br>
  167. <br>crc_hash, appears to be unimportant in 1.1.1  (Anybody have any info?)
  168. <br>number_of_keys = 0
  169. <br>
  170. <br>Server will respond with:
  171. <br><i><code>struct {
  172. <br>  uint8  opcode;          // 0x01
  173. <br> uint8 error; // 0;//error
  174. <br> uint8 M2[20]; //M2
  175. <br> uint8 ukn1; // 0;
  176. <br> uint8 ukn2; // 0;
  177. <br> uint8 ukn3; // 0;
  178. <br> uint8 ukn4; // 0;
  179. <br>} Server_Proof;
  180. <br></code></i>
  181. <br>To Generate M1 & M2, we need to generate some other values:
  182. <br>Generate U:
  183. <br><i><code>U = SHA1(A & B)
  184. <br>Your U should equal: 2f4969ac9f387fd672236f9491a516777cdde1c1
  185. <br></code></i>
  186. <br>
  187. <br>Generate S: // S=(Av^u) ^ b   (mod N)
  188. <br><i><code>U = Reverse(U)
  189. <br>N = Reverse(N)
  190. <br>A = Reverse(A)
  191. <br>b = Reverse(b) // Private b
  192. <br>
  193. <br>Temp1 = v ^ U mod (n)    // Result: 84DC9E9F96AE7A2D9B05CD264A75EB5671EA02FD067B243848543E2713C8D91
  194. <br>
  195. <br>Temp2 = Temp1 * A // Result:  496985FE28C394E7B8FB881105E4CD02F7DF4F378736332BC2F4733ABDEF0903F5BE9084C42B32E3615DF28B069A9D275A8A31DE7FBFD0DA76870B2B285F9D3
  196. <br>
  197. <br>S = Temp2 ^ b mod (n)
  198. <br>
  199. <br>Code I use:
  200. <br>//------------------------------
  201. <br>  prod = BigIntegerFromInt(0);
  202. <br>  BigIntegerModExp(prod, v, U, N, NULL, NULL);
  203. <br>  S = BigIntegerFromInt(0);
  204. <br>  BigIntegerMul(prod, prod, A, NULL);
  205. <br>  BigIntegerModExp(S, prod, b, N, NULL, NULL);
  206. <br>  BigIntegerToBytes(S, Buffer, 20);
  207. <br>//------------------------------
  208. <br>
  209. <br>Your S should equal: 7666dc8a226dd0e3de093dddf6bc2b7929df2936a8cf15a972de4042766380ba
  210. <br></code></i>
  211. <br>
  212. <br>Next we Take S and Split it into Two Hashes.  Even / Odd
  213. <br><i><code>
  214. <br>S = reverse(S) // Yup we revsere the prior result.
  215. <br>Then We take only Odd digits
  216. <br>So S1 Should equal:
  217. <br>ba63..[other hex digits]..8a66
  218. <br>And S2 Should Equal:
  219. <br>8076..[other hex digits]..dc76
  220. <br>
  221. <br>Then We Hash Each One:
  222. <br>S1_Hash = SHA(S1) // Should Equal: 02f448b61a6e79d8b714387c0d2f22cc83f2877f
  223. <br>S2_Hash = SHA(S2) // Should Equal: 61eb916a82b72864ea54dbfd3dc0ce4679c07814
  224. <br>
  225. <br>And then we Re-combine them into S_Hash interleaving them togetner.
  226. <br>SS_Hash = S1_Hash[0] & S2_Hash[0] & S1_Hash[1] & S2_Hash[1]....
  227. <br>// SS_Hash should equal: 0261f4eb4891b66a1a826eb77928d864b7ea145438db7cfd0d3d2fc022cecc468379f2c087787f14
  228. <br>
  229. <br></code></i>
  230. <br>
  231. <br>Ok, now lets calculate M1:  You need to Calc M1 to verify it matches the M1 supplied by the client.  This VERIFIES the username, password is correct.
  232. <br><i><code>
  233. <br>N_Hash = SHA1(N) // Nothing is Reversed in this routine
  234. <br>G_Hash = SHA1(G)
  235. <br>
  236. <br>User_Hash = SHA1(uppercase(Username))
  237. <br>// User Hash = 984816fd329622876e14907634264e6f332e9fb3
  238. <br>// XOr them
  239. <br>for(i=0;i<20;i++) NG_Hash = N_Hash[i] ^ G_Hash[i];
  240. <br>// NG_Hash = 1C76CF5659F68836A628404C431C1855E84D555B
  241. <br>
  242. <br>Temp = NG_Hash & User_Hash & Salt & A & B & SS_Hash
  243. <br>// As you might Guess Temp is a really long string.  :)
  244. <br>
  245. <br>M1 = SHA1(Temp)  // Should = eeb4adca80f4de02f9a9fe8d000d682e3ddfad6f
  246. <br></code></i>
  247. <br>To Calculate M2:
  248. <br><i><code>
  249. <br>Temp = A & M1 & SS_Hash
  250. <br>M2 = SHA1(Temp) // Should equal: 3a92ed0b783597be95654d6c66442046f9d389ae
  251. <br></code></i>
  252. <br>Now you stuff the server packets M2 with the above M2, and unknowns are all Zero.
  253. <br>
  254. <br>The client should request the realmlist packets at this time.  You are logged IN!!!   :-D
  255. <br>P.S.   I would also like to see the Header Encryption Documented.  I've seen some people have decoded it but they are being quite selfish with the knowledge, which sets everyone back.  I mean how many development hours does it set everyone back attempting to re-inventing srp6?  It has taken me a huge number of hours to get to this point... :o
  256. <br>[/quote]
  257. </BODY>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement