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.

309 lines
9.3 KiB

  1. //=============================================================================
  2. // MODULE: kdcrep.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. //#define KDCREP_H
  13. //#include "kerbparser.h"
  14. #include "kerbGlob.h"
  15. #include "kdcrep.h"
  16. // Definitions
  17. BYTE CheckForOptional;
  18. LPBYTE TempFrameRep;
  19. ; // Need to find out why error compiling without the semicolon
  20. LPBYTE KdcResponse(HFRAME hFrame, LPBYTE TempFrame)
  21. {
  22. // 1st attach command displays the 1st Identifier frame
  23. // Display SEQUENCE (First frame we handle in this file.
  24. TempFrame = DispASNTypes(hFrame, TempFrame, 3, ASN1UnivTagSumID, ASN1UnivTag);
  25. // Display Length Octet
  26. TempFrame = CalcLengthSummary(hFrame, TempFrame, 5);
  27. // Incrementing TempFrame based on the number of octets
  28. // taken up by the Length octet
  29. TempFrame = IncTempFrame(TempFrame);
  30. // Display Protocol Version value at the Top level
  31. TempFrame = DispSum(hFrame, TempFrame, 0x02, 0x30, 1, DispProtocolVer);
  32. // Displays pvno[0]
  33. TempFrame = KdcRepTypes(hFrame, TempFrame, 2);
  34. // Display Message Type value at the Top level
  35. TempFrame = DispSum(hFrame, TempFrame, 0x02, 0x30, 1, DispKerbMsgType);
  36. // Displays kdc-rep msg-type[1]
  37. TempFrame = KdcRepTypes(hFrame, TempFrame, 2);
  38. // Display padata[2] if present THIS CODE HASN'T BEEN
  39. // VERIFIED AGAINST A CAPTURE TO TEST IT'S VALIDITY
  40. // Start code to break down pa-data
  41. if(*(TempFrame+1) == 0xA2)
  42. {
  43. // Display Pre-Authentication Data at the Top level
  44. TempFrame = DispTopSum(hFrame, TempFrame, 1, DispSumPreAuth);
  45. // Display padata[2]
  46. TempFrame = HandlePaData(hFrame, TempFrame, 2, PaDataSummary);
  47. }
  48. // Bring comment back here
  49. // Display Client Realm value at the Top level
  50. TempFrame = DispSum(hFrame, TempFrame, 0x1B, 0x30, 1, DispStringCliRealm);
  51. // Next function handles displaying crealm[3]
  52. TempFrame = KdcRepTypes(hFrame, TempFrame, 2);
  53. // Display Client Name value at the Top level
  54. TempFrame = DispSum(hFrame, TempFrame, 0x1B, 0x30, 1, DispStringCliName);
  55. // Next function handles displaying cname[4]
  56. TempFrame = KdcRepTypes(hFrame, TempFrame, 2);
  57. // Display Kerberos Ticket at the Top level
  58. TempFrame = DispTopSum(hFrame, TempFrame, 1, DispSumKerbTix);
  59. // Next call handles displaying ticket[5]
  60. TempFrame = KdcHandleTix(hFrame, TempFrame, 2);
  61. // Display Ciper Text at the Top level
  62. TempFrame = DispTopSum(hFrame, TempFrame, 1, DispCipherText);
  63. // Display enc-part[6] of Ticket
  64. TempFrame = DispASNTypes(hFrame, TempFrame, 2, KdcRepTagID, lblTagNumber);
  65. // Display Long form Length Octet
  66. TempFrame = CalcLengthSummary(hFrame, TempFrame, 5);
  67. // Incrementing TempFrame based on the number of octets
  68. // taken up by the Length octet
  69. TempFrame = IncTempFrame(TempFrame);
  70. // Display SEQUENCE
  71. TempFrame = DispASNTypes(hFrame, TempFrame, 4, ASN1UnivTagSumID, ASN1UnivTag);
  72. // Display Long form Length Octet
  73. TempFrame = CalcLengthSummary(hFrame, TempFrame, 7);
  74. // Incrementing TempFrame based on the number of octets
  75. // taken up by the Length octet
  76. TempFrame = IncTempFrame(TempFrame);
  77. // Handle EncryptedData Needs to start with A0
  78. TempFrame = HandleEncryptedData(hFrame, TempFrame, 2);
  79. /* kf 11/9/99 FIXING PADATA
  80. *///kf 11/9/99 FIXING PADATA
  81. return TempFrame;
  82. };
  83. LPBYTE KdcRepTypes(HFRAME hFrame, LPBYTE TempFrame, int OffSet)
  84. {
  85. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet, KdcRepTagID, lblTagNumber);
  86. // Next statement checks for crealm or cname in order to display a string
  87. // Value for TempAsnMsg is assigned in DispASNTypes
  88. if(( *(TempFrame) & 0x1F) == 3 || (*(TempFrame) & 0x1F) == 4)
  89. { // The next function breaks down PrincipalName
  90. if((*(TempFrame) & 0x1F) == 4)
  91. {
  92. //Display Length Octet
  93. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+3);
  94. // Incrementing TempFrame based on the number of octets
  95. // taken up by the Length octet
  96. TempFrame = IncTempFrame(TempFrame);
  97. // Display SEQUENCE
  98. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+2, ASN1UnivTagSumID, ASN1UnivTag);
  99. // Print out Length Octet
  100. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+5);
  101. // Incrementing TempFrame based on the number of octets
  102. // taken up by the Length octet
  103. TempFrame = IncTempFrame(TempFrame);
  104. // This call breaks down PrincipalName defined in cname[4]
  105. TempFrame =DefinePrincipalName(hFrame, TempFrame, OffSet+2, DispString);
  106. }
  107. else
  108. TempFrame = DefineValue(hFrame, TempFrame, OffSet+2, DispString);
  109. }
  110. else
  111. TempFrame = DefineValue(hFrame, TempFrame, OffSet+2, KdcContentsValue);
  112. return TempFrame;
  113. };
  114. /***********************************************************************************************************
  115. **
  116. ** This function will break down ASN.1 PrincipalName.
  117. ** Ticket ::= [APPLICATION 1] {
  118. ** tkt-vno[0] INTEGER, Specifies the version # for the ticket format
  119. ** realm[1] Realm, Specifies the realm that issued the ticket
  120. ** sname[2] PrinicipalName, Specifies the name part of the Server Identity
  121. ** enc-part[3] EncryptedData, Holds encoding of the EncTicketPart sequence
  122. **
  123. **
  124. **
  125. **
  126. **************************************************************************************************************/
  127. LPBYTE KdcHandleTix(HFRAME hFrame, LPBYTE TempFrame, int OffSet)
  128. {
  129. /* Need to make a function to call that displays the main variables of the Ticket structure and
  130. displays to save repitive code.
  131. */
  132. //Display Ticket[5]
  133. TempFrame = DispASNTypes(hFrame, --TempFrame, OffSet, KdcRepTagID, lblTagNumber);
  134. // Display Length
  135. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+2);
  136. // Incrementing TempFrame based on the number of octets
  137. // taken up by the Length octet
  138. TempFrame = IncTempFrame(TempFrame);
  139. // Display Identifier Octet for [APPLICATION 1]
  140. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+2, KrbTixAppSumID, KrbTixApp1ID);
  141. // Display Long form Length Octet
  142. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+3);
  143. // Incrementing TempFrame based on the number of octets
  144. // taken up by the Length octet
  145. TempFrame = IncTempFrame(TempFrame);
  146. // Display SEQUENCE
  147. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+3, ASN1UnivTagSumID, ASN1UnivTag);
  148. // Display Long form Length Octet
  149. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+3);
  150. // Incrementing TempFrame based on the number of octets
  151. // taken up by the Length octet
  152. TempFrame = IncTempFrame(TempFrame);
  153. // Display Ticket Version value at the Top level
  154. TempFrame = DispSum(hFrame, TempFrame, 0x02, 0x30, OffSet, DispSumTixVer);
  155. // Display tkt-vno[0]
  156. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+1, KrbTicketSumID, KrbTicketID);
  157. // Breakdown and display tkt-vno[0]
  158. TempFrame = DefineValue(hFrame, TempFrame, OffSet+2, KdcContentsValue);
  159. // Display Realm name value at the Top level
  160. TempFrame = DispSum(hFrame, TempFrame, 0x1B, 0x30, OffSet, DispStringRealmName);
  161. // Display realm[1]
  162. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+1, KrbTicketSumID, KrbTicketID);
  163. // Breakdown and display Realm name
  164. TempFrame = DefineValue(hFrame, TempFrame, OffSet+2, DispString);
  165. // Display Server name value at the Top level
  166. //KF 8/16 IN FRAME 4 OF MACHBOOT.CAP, THERE IS ONLY ONE NAME UNDER SNAME WHICH
  167. // BREAKS THE REST OF THE DISPLAY. NEED TO DO SOMETYPE OF CHECK TO SEE IF THERE ARE
  168. // MULTIPLE NAMES. MAYBE A COUNTER IN THE WHILE LOOP.
  169. TempFrame = DispSumString(hFrame, TempFrame, 0x1B, OffSet, DispStringServNameGS);
  170. // Process sname[2] PrincipalName portion
  171. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+1, KrbTicketSumID, KrbTicketID);
  172. //Display short length
  173. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+4);
  174. // Incrementing TempFrame based on the number of octets
  175. // taken up by the Length octet
  176. TempFrame = IncTempFrame(TempFrame);
  177. // Display SEQUENCE
  178. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+4, ASN1UnivTagSumID, ASN1UnivTag);
  179. // Calculate short length
  180. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+6);
  181. // Incrementing TempFrame based on the number of octets
  182. // taken up by the Length octet
  183. TempFrame = IncTempFrame(TempFrame);
  184. // This call will break down the PrincipalName portion of sname[2]
  185. TempFrame = DefinePrincipalName(hFrame, TempFrame, OffSet+4, DispString);
  186. // End code for displaying sname[2]
  187. // Display Ciper Text at the Top level
  188. TempFrame = DispTopSum(hFrame, TempFrame, OffSet, DispCipherText);
  189. // Display enc-data[3] of Ticket
  190. TempFrame = DispASNTypes(hFrame, --TempFrame, OffSet+1, KrbTicketSumID, KrbTicketID);
  191. // Display Long form Length Octet
  192. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+4);
  193. // Incrementing TempFrame based on the number of octets
  194. // taken up by the Length octet
  195. TempFrame = IncTempFrame(TempFrame);
  196. // Display Sequence
  197. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+3, ASN1UnivTagSumID, ASN1UnivTag);
  198. // Display Long form Length Octet
  199. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+6);
  200. // Incrementing TempFrame based on the number of octets
  201. // taken up by the Length octet
  202. TempFrame = IncTempFrame(TempFrame);
  203. // Handling enc-data.
  204. // Handle EncryptedData Needs to start with A0
  205. TempFrame = HandleEncryptedData( hFrame, TempFrame, OffSet+1);
  206. return TempFrame;
  207. }