Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

312 lines
9.0 KiB

  1. //=============================================================================
  2. // MODULE: kdcreq.c
  3. //
  4. // Description:
  5. //
  6. // Bloodhound Parser DLL for Kerberos Authentication Protocol
  7. //
  8. // Modification History
  9. //
  10. // Michael Webb & Kris Frost Date: 06/04/99
  11. //=============================================================================
  12. //#include "kerbparser.h"
  13. #include "kerbGlob.h"
  14. #include "kdcreq.h"
  15. LPBYTE KdcRequest(HFRAME hFrame, LPBYTE TempFrame)
  16. {
  17. // 1st attach command displays the 1st Identifier frame
  18. TempFrame = DispSeqOctets(hFrame, TempFrame, 3, ASN1UnivTagSumID, ASN1UnivTag);
  19. // Incrementing TempFrame by one to get to the correct frame.
  20. TempFrame+=CalcLenOctet(--TempFrame);
  21. // Display Protocol Version value at the Top level
  22. TempFrame = DispSum(hFrame, TempFrame, 0x02, 0x30, 1, DispProtocolVer);
  23. // Display pvno[1]
  24. TempFrame = KdcReqTypes(hFrame, TempFrame, KdcReqTagID, KdcReqSeq, KdcContentsValue);
  25. // Display Message Type value at the Top level
  26. TempFrame = DispSum(hFrame, TempFrame, 0x02, 0x30, 1, DispKerbMsgType);
  27. // Display msg-type[2]
  28. TempFrame = KdcReqTypes(hFrame, TempFrame, KdcReqTagID, KdcReqSeq, KrbMsgTypeID);
  29. // Start code to break down pa-data
  30. if(*(TempFrame+1) == 0xA3)
  31. {
  32. // Display Pre-Authentication Data at the Top level
  33. TempFrame = DispTopSum(hFrame, TempFrame, 1, DispSumPreAuth);
  34. // Display padata[3]
  35. TempFrame = HandlePaData(hFrame, TempFrame, 2, PaDataSummary);
  36. }
  37. // Display KDC Request Body at the Top level
  38. TempFrame = DispTopSum(hFrame, TempFrame, 1, DispSumReqBody);
  39. // Display req-body[4]
  40. TempFrame = DispASNTypes(hFrame, TempFrame, 2, KdcReqTagID, KdcReqSeq);
  41. // Calculate Length Octet
  42. TempFrame = CalcLengthSummary(hFrame, TempFrame, 4);
  43. // Incrementing TempFrame based on the number of octets
  44. // taken up by the Length octet
  45. TempFrame = IncTempFrame(TempFrame);
  46. // Display SEQUENCE
  47. TempFrame = DispSeqOctets(hFrame, TempFrame, 4, ASN1UnivTagSumID, ASN1UnivTag);
  48. // Following call breaks handles displaying req-body[4]
  49. TempFrame = HandleReqBody(hFrame, TempFrame, 2);
  50. return ++TempFrame;
  51. };
  52. LPBYTE KdcReqTypes(HFRAME hFrame, LPBYTE TempFrame, DWORD TypeVal, DWORD TypeVal2, DWORD TypeVal3)
  53. {
  54. // Display ASN.1 Identifier
  55. TempFrame = DispASNTypes(hFrame, TempFrame, 2, TypeVal, TypeVal2);
  56. // Break Down INTEGER values
  57. TempFrame = DefineValue(hFrame, TempFrame, 4, TypeVal3);
  58. return TempFrame;
  59. }
  60. LPBYTE HandleReqBody(HFRAME hFrame, LPBYTE TempFrame, int OffSet)
  61. {
  62. // Display kdc-options[0]
  63. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet, DispStringTixFlag, KdcReqBodyBitF);
  64. // Display Length Octet
  65. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+3);
  66. // Incrementing TempFrame based on the number of octets
  67. // taken up by the Length octet
  68. TempFrame = IncTempFrame(TempFrame);
  69. // Display Universal Class Tag
  70. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+2, ASN1UnivTagSumID, ASN1UnivTag);
  71. // Display Length Octet
  72. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+5);
  73. // Must get TempFrame 2 bytes past Length octet 05
  74. TempFrame+=2;
  75. // Display KDC-Option Flags
  76. TempFrame = DefineKdcOptions(hFrame, TempFrame, OffSet+1, DispFlagKdcOptions);
  77. // Move Adjust TempFrame past KDC-Options to start at cname[1]
  78. TempFrame+=3;
  79. // Display cname[1] OPTIONAL
  80. if(*(TempFrame+1) == 0xA1)
  81. {
  82. // Display Client Name value at the Top level
  83. TempFrame = DispSum(hFrame, TempFrame, 0x1B, 0x30, OffSet, DispStringCliName);
  84. // Display cname[1].
  85. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+1, KdcReqBodyID, KdcReqBodyBitF);
  86. // Display Length Octet
  87. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+3);
  88. // Incrementing TempFrame based on the number of octets
  89. // taken up by the Length octet
  90. TempFrame = IncTempFrame(TempFrame);
  91. // Display SEQUENCE Octets
  92. TempFrame = DispSeqOctets(hFrame, TempFrame, OffSet+3, ASN1UnivTagSumID, ASN1UnivTag);
  93. // Display cname[1]
  94. TempFrame = DefinePrincipalName(hFrame, TempFrame, OffSet+3, DispStringCliName);
  95. TempFrame--;
  96. }
  97. // Display realm[2]
  98. // Display Realm name value at the Top level
  99. TempFrame = DispSum(hFrame, TempFrame, 0x1B, 0x30, OffSet, DispStringRealmName);
  100. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+1, KdcReqBodyID, KdcReqBodyBitF);
  101. TempFrame = DefineValue(hFrame, TempFrame, OffSet+3, DispStringRealmName);
  102. // MUST FIND OUT WHY 8 IS GETTING APPENDED TO KRBTGT AT THE TOP LEVEL
  103. // Display sname[3] OPTIONAL
  104. if(*(TempFrame+1) == 0xA3)
  105. {
  106. // Display Server name value at the Top level
  107. TempFrame = DispSumString(hFrame, TempFrame, 0x1B, OffSet, DispStringServNameGS);
  108. // Display sname[3]
  109. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+1, KdcReqBodyID, KdcReqBodyBitF);
  110. // Display Length Octet
  111. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+4);
  112. // Incrementing TempFrame based on the number of octets
  113. // taken up by the Length octet
  114. TempFrame = IncTempFrame(TempFrame);
  115. // Display SEQUENCE Octets
  116. TempFrame = DispSeqOctets(hFrame, TempFrame, OffSet+3, ASN1UnivTagSumID, ASN1UnivTag);
  117. // Display sname[3]
  118. TempFrame = DefinePrincipalName(hFrame, TempFrame, OffSet+3, DispStringServerName);
  119. // --TempFrame;
  120. }
  121. // Display from[4] OPTIONAL
  122. if(*(TempFrame) == 0xA4)
  123. { //THIS CODE HASN'T BEEN TESTED. May need to put TempFrame-- on last line
  124. // Display Post Date value at the Top level
  125. TempFrame = DispSumTime(hFrame, TempFrame, 0x18, OffSet, DispStringPostDate);
  126. // Display from[4]
  127. TempFrame = DispASNTypes(hFrame, --TempFrame, OffSet+1, KdcReqBodyID, KdcReqBodyBitF);
  128. // Display KerberosTime
  129. TempFrame = DefineValue(hFrame, TempFrame, OffSet+2, DispString);
  130. //TempFrame--
  131. }
  132. // Display Expiration Date value at the Top level (till[5])
  133. TempFrame = DispSumTime(hFrame, TempFrame, 0x18, OffSet, DispStringExpDate);
  134. // 1/27/00 KKF TODAY I NOTICED THAT TILL[5] WAS OFF ONE OFFSET. HADN'T NOTICED THIS
  135. // BEFORE. WENT BACK AND CHECKED A BUILD FROM NOV. AND THE PROBLEM DIDN'T EXIST. HOWEVER
  136. // I MATCHED THE CODE AND DON'T SEE THE DIFFERENCE. GOING TO DECREMENT TEMPFRAME WHILE
  137. // SENDING TO DISPASNTYPES.
  138. // Display till[5]
  139. TempFrame = DispASNTypes(hFrame, --TempFrame, OffSet+1, KdcReqBodyID, KdcReqBodyBitF);
  140. // Display KerberosTime
  141. TempFrame = DefineValue(hFrame, TempFrame, OffSet+3, DispString);
  142. // Display rtime[6] OPTIONAL
  143. if(*(TempFrame+1) == 0xA6)
  144. {
  145. // Display Expiration Date value at the Top level
  146. TempFrame = DispSumTime(hFrame, TempFrame, 0x18, OffSet, DispStringRenewTill);
  147. // Display from[4]
  148. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+1, KdcReqBodyID, KdcReqBodyBitF);
  149. // Display KerberosTime
  150. TempFrame = DefineValue(hFrame, TempFrame, OffSet+3, DispString);
  151. //TempFrame--
  152. }
  153. // Display Top level for nonce[7]
  154. TempFrame = DispSum(hFrame, TempFrame, 0x02, 0x30, OffSet, DispSumRandomNumber);
  155. // Display nonce[7]
  156. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+1, KdcReqBodyID, KdcReqBodyBitF);
  157. //Display INTEGER
  158. TempFrame = DefineValue(hFrame, TempFrame, OffSet+3, DispSumRandomNumber);
  159. // SINCE THIS FIELD LISTS THE NUMEROUS ENCRYPTION OPTIONS A CLIENT
  160. // SUPPORTS, IT CAN BE CONFUSING DISPLAYING THE FIRST OPTION AT THE TOP
  161. // LEVEL SO I'M REMMING OUT THE NEXT LINE OF CODE.
  162. //Display Encryption Algorithm at the top Level etype[8]
  163. // TempFrame = DispSum(hFrame, TempFrame, 0x02, 0x02, OffSet, DispSumEtype2);
  164. //Display Encryption Type Option(s) at the top Level etype[8]
  165. TempFrame = DispTopSum(hFrame, TempFrame, 2, DispEncryptionOptions);
  166. // Display etype[8]
  167. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+1, KdcReqBodyID, KdcReqBodyBitF);
  168. // Display Length Octet
  169. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+4);
  170. // Incrementing TempFrame based on the number of octets
  171. // taken up by the Length octet
  172. TempFrame = IncTempFrame(TempFrame);
  173. // Display all the encryption types.
  174. TempFrame = DefineEtype(hFrame, TempFrame, OffSet+1, DispSumEtype2, ASN1UnivTagSumID, ASN1UnivTag);
  175. // Display addresses[9]
  176. if(*(TempFrame) == 0xA9)
  177. {
  178. // Display Expiration Date value at the Top level
  179. TempFrame = DispSum(hFrame, TempFrame, 0x04, 0x30, OffSet, DispStringAddresses);
  180. // Adjust TempFrame to proper octet
  181. --TempFrame;
  182. // Display addresses[9]
  183. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+1, KdcReqBodyID, KdcReqBodyBitF);
  184. // Display Length Octet
  185. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+4);
  186. // Incrementing TempFrame based on the number of octets
  187. // taken up by the Length octet
  188. TempFrame = IncTempFrame(TempFrame);
  189. // Display SEQUENCE OF Octets
  190. TempFrame = DispSeqOctets(hFrame, TempFrame, OffSet+3, ASN1UnivTagSumID, ASN1UnivTag);
  191. //Display addresses[9]
  192. TempFrame = DispHostAddresses(hFrame, TempFrame, OffSet+1);
  193. }
  194. /*
  195. LEFT OFF HERE BECAUSE THE SNIFFS I HAVE DON'T HAVE THE FINAL OPTIONS. FINISH HANDLING THE KDC-REQ PACKET
  196. IF/WHEN YOU GET A SNIFF WITH THE INFO, THEN GO BACK AND ADD CODE FOR THE OPTIONAL'S IN KRB-ERROR
  197. USING MIKE'S SNIFF.
  198. Missing enc-authorization-data[10] & additional-tickets[11]
  199. */
  200. return TempFrame;
  201. }