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.

260 lines
7.9 KiB

  1. //=============================================================================
  2. // MODULE: krberr.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 "krberr.h"
  15. int lValueKrbErr;
  16. BYTE TempError;
  17. LPBYTE KrbError(HFRAME hFrame, LPBYTE TempFrame)
  18. {
  19. // Display SEQUENCE (First frame we handle in this file.
  20. TempFrame = DispASNTypes(hFrame, TempFrame, 3, ASN1UnivTagSumID, ASN1UnivTag);
  21. lValueKrbErr=CalcLenOctet(TempFrame);
  22. // Display Length Octet
  23. TempFrame = CalcLengthSummary(hFrame, TempFrame, 4);
  24. // Next line increments TempFrame appropriately based on the number of Length octets
  25. // caculated previously
  26. TempFrame+=lValueKrbErr;
  27. // Display Protocol Version value at the Top level
  28. TempFrame = DispSum(hFrame, TempFrame, 0x02, 0x30, 1, DispProtocolVer);
  29. // Display pvno[0]
  30. TempFrame = DispASNTypes(hFrame, --TempFrame, 2, KrbErrTagSumID, KrbErrTagID);
  31. // Display octets associated with Integer
  32. TempFrame = DefineValue(hFrame, TempFrame, 4, KdcContentsValue);
  33. // Display Message Type value at the Top level
  34. TempFrame = DispSum(hFrame, TempFrame, 0x02, 0x30, 1, DispKerbMsgType);
  35. // Display msg-type[1]
  36. TempFrame = DispASNTypes(hFrame, TempFrame, 2, KrbErrTagSumID, KrbErrTagID);
  37. // Display octets associated with Integer
  38. TempFrame = DefineValue(hFrame, TempFrame, 4, KrbMsgTypeID);
  39. /* Here we need to check for ctime[2] which is an optional value.
  40. If present, display the data if not go to the next tag.
  41. */
  42. TempError = *(TempFrame+1);
  43. if(TempError == 0xA2)
  44. {// Display Client Time value at the Top level
  45. // TempFrame = DispSum(hFrame, TempFrame, 0x18, 0x30, 1, DispStringCliTime);
  46. TempFrame = DispSumTime(hFrame, TempFrame, 0x18, 1, DispStringCliTime);
  47. // Display ctime[2].
  48. TempFrame = DispASNTypes(hFrame, TempFrame, 2, KrbErrTagSumID, KrbErrTagID);
  49. // Display octets associated with KerberosTime
  50. TempFrame = DefineValue(hFrame, TempFrame, 4, DispString);
  51. // Need to put code here to display the timestamp.
  52. }
  53. TempError = *(TempFrame+1);
  54. //Display cusec[3] (If available)
  55. if(TempError == 0xA3)
  56. {// NEED TO GET THIS CODE TO PRINT OUT THE COMBINED VALUE OF MICROSECONDS
  57. // Display MicroSec of Client value at the Top level
  58. TempFrame = DispSumSec(hFrame, TempFrame, 0x02, 0x30, 1, DispSumCuSec);
  59. // Display cusec[3]
  60. TempFrame = DispASNTypes(hFrame, TempFrame, 2, KrbErrTagSumID, KrbErrTagID);
  61. // Display octets associated with Integer
  62. TempFrame = DefineValue(hFrame, TempFrame, 4, DispTimeID);
  63. }
  64. // Display Server Time value at the Top level
  65. // TempFrame = DispSum(hFrame, TempFrame, 0x18, 0x30, 1, DispStringSrvTime);
  66. TempFrame = DispSumTime(hFrame, TempFrame, 0x18, 1, DispStringSrvTime);
  67. // Display stime[4]
  68. TempFrame = DispASNTypes(hFrame, TempFrame, 2, KrbErrTagSumID, KrbErrTagID);
  69. // Display KerberosTime
  70. TempFrame = DefineValue(hFrame, TempFrame, 4, DispString);
  71. // NEED TO GET THIS CODE TO PRINT OUT THE TOTAL VALUE OF MICROSECOND
  72. // Display MicroSec of Server value at the Top level
  73. TempFrame = DispSumSec(hFrame, TempFrame, 0x02, 0x30, 1, DispSumSuSec);
  74. //Display susec[5]
  75. TempFrame = DispASNTypes(hFrame, TempFrame, 2, KrbErrTagSumID, KrbErrTagID);
  76. // Display value of susec
  77. TempFrame = DefineValue(hFrame, TempFrame, 4, DispTimeID);
  78. // Display Error value at the Top level
  79. TempFrame = DispSum(hFrame, TempFrame, 0x02, 0x30, 1, DispSumKerbErr);
  80. // Display error-code[6]
  81. TempFrame = DispASNTypes(hFrame, TempFrame, 2, KrbErrTagSumID, KrbErrTagID);
  82. // Display value of error-code[6]
  83. TempFrame = DefineValue(hFrame, TempFrame, 4, KrbErrCodeID);
  84. // Get the value of TempFrame+1
  85. TempError = *(TempFrame+1);
  86. // Display value of crealm[7] (Optional
  87. if(TempError == 0xA7)
  88. {// Display Client Realm name value at the Top level
  89. TempFrame = DispSum(hFrame, TempFrame, 0x1B, 0x30, 1, DispStringCliRealm);
  90. // Display crealm[7]
  91. TempFrame = DispASNTypes(hFrame, TempFrame, 2, KrbErrTagSumID, KrbErrTagID);
  92. // Display Realm string
  93. TempFrame = DefineValue(hFrame, TempFrame, 4, DispString);
  94. }
  95. // Get the value of TempFrame+1
  96. TempError = *(TempFrame+1);
  97. // Display cname[8]
  98. if(TempError == 0xA8)
  99. {// This code wasn't tested as it wasn't in the sniff
  100. // Display Client name value at the Top level
  101. TempFrame = DispSum(hFrame, TempFrame, 0x1B, 0x30, 1, DispStringCliName);
  102. // Display cname[8]
  103. TempFrame = DispASNTypes(hFrame, TempFrame, 2, KrbErrTagSumID, KrbErrTagID);
  104. //Display Length Octet
  105. TempFrame = CalcLengthSummary(hFrame, TempFrame, 4);
  106. // Incrementing TempFrame based on the number of octets
  107. // taken up by the Length octet
  108. TempFrame = IncTempFrame(TempFrame);
  109. // Display SEQUENCE
  110. TempFrame = DispASNTypes(hFrame, TempFrame, 5, ASN1UnivTagSumID, ASN1UnivTag);
  111. // Print out Length Octet
  112. TempFrame = CalcLengthSummary(hFrame, TempFrame, 6);
  113. // Incrementing TempFrame based on the number of octets
  114. // taken up by the Length octet
  115. TempFrame = IncTempFrame(TempFrame);
  116. // This call breaks down PrincipalName defined in cname[8]
  117. TempFrame =DefinePrincipalName(hFrame, TempFrame, 3, DispString);
  118. // Decrementing TempFrame by 1 as DefinePrincipal takes the offset
  119. // to where Realm Name starts
  120. --TempFrame;
  121. }
  122. // Display Realm name value at the Top level
  123. TempFrame = DispSum(hFrame, TempFrame, 0x1B, 0x30, 1, DispStringRealmName);
  124. //Display realm[9]
  125. TempFrame = DispASNTypes(hFrame, TempFrame, 2, KrbErrTagSumID, KrbErrTagID);
  126. // Display realm[9] string
  127. TempFrame = DefineValue(hFrame, TempFrame, 4, DispString);
  128. // Begin breaking out sname[10]
  129. // Display Server name value at the Top level
  130. // TempFrame = DispSum(hFrame, TempFrame, 0x1B, 0x30, 1, DispStringServerName);
  131. TempFrame = DispSumString(hFrame, TempFrame, 0x1B, 1, DispStringServNameGS);
  132. // Display sname[10]
  133. TempFrame = DispASNTypes(hFrame, TempFrame, 2, KrbErrTagSumID, KrbErrTagID);
  134. //Display Length
  135. TempFrame = CalcLengthSummary(hFrame, TempFrame, 4);
  136. // Incrementing TempFrame based on the number of octets
  137. // taken up by the Length octet
  138. TempFrame = IncTempFrame(TempFrame);
  139. // Display SEQUENCE
  140. TempFrame = DispASNTypes(hFrame, TempFrame, 4, ASN1UnivTagSumID, ASN1UnivTag);
  141. // Calculate short length
  142. TempFrame = CalcLengthSummary(hFrame, TempFrame, 5);
  143. // Incrementing TempFrame based on the number of octets
  144. // taken up by the Length octet
  145. TempFrame = IncTempFrame(TempFrame);
  146. // This call will break down the PrincipalName portion of sname[2]
  147. TempFrame =DefinePrincipalName(hFrame, TempFrame, 4, DispString);
  148. TempFrame--;
  149. // End code for displaying sname[10]
  150. // Get the value of TempFrame+1
  151. TempError = *(TempFrame+1);
  152. // Display e-text[11] Optional
  153. if(TempError == 0xAB)
  154. {// Display Error Text at the Top Level
  155. TempFrame = DispSum(hFrame, TempFrame, 0x1B, 0x30, 1, DispStringErrorText);
  156. // Display e-text[11]
  157. TempFrame = DispASNTypes(hFrame, TempFrame, 2, KrbErrTagSumID, KrbErrTagID);
  158. // Display Realm string
  159. TempFrame = DefineValue(hFrame, TempFrame, 4, DispString);
  160. }
  161. // Get the value of TempFrame+1
  162. TempError = *(TempFrame+1);
  163. // Display e-data[12]
  164. if(TempError == 0xAC)
  165. {// Not sure how to display this data at this time. Adding code and will
  166. // worry about the accuracy at a later stage.
  167. // Display Error Text at the Top Level
  168. TempFrame = DispSum(hFrame, TempFrame, 0x04, 0x30, 1, DispStringErrorData);
  169. // Display e-data[12]
  170. TempFrame = DispASNTypes(hFrame, TempFrame, 2, KrbErrTagSumID, KrbErrTagID);
  171. // Display e-data string
  172. TempFrame = DispEdata(hFrame, TempFrame, 4, DispString);
  173. }
  174. /*
  175. 8/17 ADDITIONALLY, IT LOOKS AS E-DATA[12] IS A SEQUENCE OF PADATA. HOWEVER I AM CURRENTLY
  176. PREPARING TO TRANSITION TO ANOTHER POSITION SO I'M LEAVING THIS CODE OUT FOR NOW. WILL LOOK
  177. AT ADDING IT WHEN I START ADJUSTING THE CODE TO WORK WITH THE COALESCER.
  178. */
  179. return TempFrame;
  180. }