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.

1979 lines
68 KiB

  1. //=============================================================================
  2. // MODULE: Kerbparser.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 MAINPROG
  13. #include "kerbparser.h"
  14. #include "kerbGlob.h"
  15. #include "kdcreq.h"
  16. #include "kdcrep.h"
  17. #include "krberr.h"
  18. #include <stdio.h>
  19. ;// Need to find out why error is generated without this semicolon
  20. //=============================================================================
  21. // Forward references.
  22. //=============================================================================
  23. VOID WINAPIV KerberosFormatSummary(LPPROPERTYINST lpPropertyInst);
  24. //=============================================================================
  25. // Protocol entry points.
  26. //=============================================================================
  27. VOID WINAPI KerberosRegister(HPROTOCOL);
  28. VOID WINAPI KerberosDeregister(HPROTOCOL);
  29. LPBYTE WINAPI KerberosRecognizeFrame(HFRAME, LPVOID, LPVOID, DWORD, DWORD, HPROTOCOL, DWORD, LPDWORD, LPHPROTOCOL, PDWORD_PTR);
  30. LPBYTE WINAPI KerberosAttachProperties(HFRAME, LPVOID, LPVOID, DWORD, DWORD, HPROTOCOL, DWORD, DWORD_PTR);
  31. DWORD WINAPI KerberosFormatProperties(HFRAME, LPVOID, LPVOID, DWORD, LPPROPERTYINST);
  32. ENTRYPOINTS KerberosEntryPoints =
  33. {
  34. KerberosRegister,
  35. KerberosDeregister,
  36. KerberosRecognizeFrame,
  37. KerberosAttachProperties,
  38. KerberosFormatProperties
  39. };
  40. HPROTOCOL hKerberos = NULL;
  41. DWORD Attached = 0;
  42. PPF_PARSERDLLINFO WINAPI ParserAutoInstallInfo()
  43. {
  44. PPF_PARSERDLLINFO pParserDllInfo;
  45. PPF_PARSERINFO pParserInfo;
  46. DWORD NumProtocols, NumHandoffs;
  47. PPF_HANDOFFSET pHandoffSet;
  48. PPF_HANDOFFENTRY pHandoffEntry;
  49. // Base structure ========================================================
  50. // Allocate memory for parser info:
  51. NumProtocols = 1;
  52. pParserDllInfo = (PPF_PARSERDLLINFO)HeapAlloc( GetProcessHeap(),
  53. HEAP_ZERO_MEMORY,
  54. sizeof( PF_PARSERDLLINFO ) +
  55. NumProtocols * sizeof( PF_PARSERINFO) );
  56. if( pParserDllInfo == NULL)
  57. {
  58. return NULL;
  59. }
  60. // fill in the parser DLL info
  61. pParserDllInfo->nParsers = NumProtocols;
  62. // fill in the individual parser infos...
  63. // BLRPLATE ==============================================================
  64. pParserInfo = &(pParserDllInfo->ParserInfo[0]);
  65. sprintf( pParserInfo->szProtocolName, "KERBEROS" );
  66. sprintf( pParserInfo->szComment, "Kerberos Authentication Protocol" );
  67. sprintf( pParserInfo->szHelpFile, "");
  68. // the incoming handoff set ----------------------------------------------
  69. // allocate
  70. NumHandoffs = 2;
  71. pHandoffSet = (PPF_HANDOFFSET)HeapAlloc( GetProcessHeap(),
  72. HEAP_ZERO_MEMORY,
  73. sizeof( PF_HANDOFFSET ) +
  74. NumHandoffs * sizeof( PF_HANDOFFENTRY) );
  75. if( pHandoffSet == NULL )
  76. {
  77. // just return early
  78. return pParserDllInfo;
  79. }
  80. // fill in the incoming handoff set
  81. pParserInfo->pWhoHandsOffToMe = pHandoffSet;
  82. pHandoffSet->nEntries = NumHandoffs;
  83. // UDP PORT 88
  84. pHandoffEntry = &(pHandoffSet->Entry[0]);
  85. sprintf( pHandoffEntry->szIniFile, "TCPIP.INI" );
  86. sprintf( pHandoffEntry->szIniSection, "UDP_HandoffSet" );
  87. sprintf( pHandoffEntry->szProtocol, "KERBEROS" );
  88. pHandoffEntry->dwHandOffValue = 88;
  89. pHandoffEntry->ValueFormatBase = HANDOFF_VALUE_FORMAT_BASE_DECIMAL;
  90. // TCP PORT 88
  91. pHandoffEntry = &(pHandoffSet->Entry[1]);
  92. sprintf( pHandoffEntry->szIniFile, "TCPIP.INI" );
  93. sprintf( pHandoffEntry->szIniSection, "TCP_HandoffSet" );
  94. sprintf( pHandoffEntry->szProtocol, "KERBEROS" );
  95. pHandoffEntry->dwHandOffValue = 88;
  96. pHandoffEntry->ValueFormatBase = HANDOFF_VALUE_FORMAT_BASE_DECIMAL;
  97. return pParserDllInfo;
  98. }
  99. //=============================================================================
  100. // FUNCTION: DLLEntry()
  101. //
  102. // Modification History
  103. //
  104. // Michael Webb & Kris Frost Date: 06/04/99
  105. //=============================================================================
  106. BOOL WINAPI DLLEntry(HANDLE hInstance, ULONG Command, LPVOID Reserved)
  107. {
  108. //=========================================================================
  109. // If we are loading!
  110. //=========================================================================
  111. if ( Command == DLL_PROCESS_ATTACH )
  112. {
  113. if ( Attached++ == 0 )
  114. {
  115. hKerberos = CreateProtocol("KERBEROS", &KerberosEntryPoints, ENTRYPOINTS_SIZE);
  116. }
  117. }
  118. //=========================================================================
  119. // If we are unloading!
  120. //=========================================================================
  121. if ( Command == DLL_PROCESS_DETACH )
  122. {
  123. if ( --Attached == 0 )
  124. {
  125. DestroyProtocol(hKerberos);
  126. }
  127. }
  128. return TRUE; //... Bloodhound parsers ALWAYS return TRUE.
  129. }
  130. //=============================================================================
  131. // FUNCTION: KerberosRegister()
  132. //
  133. // Modification History
  134. //
  135. // Michael Webb & Kris Frost Date: 06/04/99
  136. //=============================================================================
  137. VOID WINAPI KerberosRegister(HPROTOCOL hKerberosProtocol)
  138. {
  139. register DWORD i;
  140. //=========================================================================
  141. // Create the property database.
  142. //=========================================================================
  143. CreatePropertyDatabase(hKerberosProtocol, nKerberosProperties);
  144. for(i = 0; i < nKerberosProperties; ++i)
  145. {
  146. AddProperty(hKerberosProtocol, &KerberosDatabase[i]);
  147. }
  148. // Here we are checking to see whether TCP or UDP is being used.
  149. hTCP = GetProtocolFromName("TCP");
  150. hUDP = GetProtocolFromName("UDP");
  151. }
  152. //=============================================================================
  153. // FUNCTION: Deregister()
  154. //
  155. // Modification History
  156. //
  157. // Michael Webb & Kris Frost Date: 06/04/99
  158. //=============================================================================
  159. VOID WINAPI KerberosDeregister(HPROTOCOL hKerberosProtocol)
  160. {
  161. DestroyPropertyDatabase(hKerberosProtocol);
  162. }
  163. //=============================================================================
  164. // FUNCTION: KerberosRecognizeFrame()
  165. //
  166. // Modification History
  167. //
  168. // Michael Webb & Kris Frost Date: 06/04/99
  169. //=============================================================================
  170. LPBYTE WINAPI KerberosRecognizeFrame(HFRAME hFrame, //... frame handle.
  171. LPBYTE MacFrame, //... Frame pointer.
  172. LPBYTE KerberosFrame, //... Relative pointer.
  173. DWORD MacType, //... MAC type.
  174. DWORD BytesLeft, //... Bytes left.
  175. HPROTOCOL hPreviousProtocol, //... Previous protocol or NULL if none.
  176. DWORD nPreviousProtocolOffset, //... Offset of previous protocol.
  177. LPDWORD ProtocolStatusCode, //... Pointer to return status code in.
  178. LPHPROTOCOL hNextProtocol, //... Next protocol to call (optional).
  179. PDWORD_PTR InstData) //... Next protocol instance data.
  180. {
  181. // ProtoInfo=GetProtocolInfo(hPreviousProtocol);
  182. // MessageBox(NULL, _itoa(TestForUDP,test,10),"TestForUDP 1", MB_OK);
  183. *ProtocolStatusCode = PROTOCOL_STATUS_CLAIMED;
  184. return NULL;
  185. }
  186. //=============================================================================
  187. // FUNCTION: KerberosAttachProperties()
  188. //
  189. // Modification History
  190. //
  191. // Michael Webb & Kris Frost Date: 06/04/99
  192. //=============================================================================
  193. LPBYTE WINAPI KerberosAttachProperties(HFRAME hFrame,
  194. LPBYTE Frame,
  195. LPBYTE KerberosFrame,
  196. DWORD MacType,
  197. DWORD BytesLeft,
  198. HPROTOCOL hPreviousProtocol,
  199. DWORD nPreviousProtocolOffset,
  200. DWORD_PTR InstData)
  201. {
  202. // Local variable to hold the value of KerberosFrame, depending on whether
  203. // the packet is TCP or UDP.
  204. LPBYTE pKerberosFrame;
  205. /* kf Here checking to see if first two octets of are equal to 00 00 which would be
  206. the case should the packet be the first of TCP.
  207. */
  208. if(KerberosFrame[0] == 0x00 && KerberosFrame[1] == 0x00)
  209. {
  210. TempFrame = KerberosFrame+4;
  211. pKerberosFrame = TempFrame;
  212. }
  213. else
  214. {
  215. TempFrame = KerberosFrame;
  216. pKerberosFrame = TempFrame;
  217. }
  218. // Here we are going to do a check to see if the packet is TCP and
  219. // check to see if the first two octets of the packet don't have the
  220. // value of 00 00. If not, then we mark the frame as a continuation
  221. // packet. Reason for doing this is because, sometimes 0x1F of the
  222. // first packet can still match one of the case statements which
  223. // erroneously displays a continuation packet.
  224. // NOTE: THIS CODE BREAKS ON SOME OF THE OLDER SNIFFS BECAUSE THE 4
  225. // OCTETS WHICH SPECIFY THE ENTIRE PACKET LENGTH WERE SENT IN A TCP
  226. // PACKET ALL BY ITSELF. ACCORDING TO DEV, THIS ISN'T EXPECTED BEHAVIOR
  227. // IN THE LATER W2K BUILDS. THE 4 LENGTH OCTETS FOR TCP SHOULD ALWAYS BE
  228. // PRE-PENDED TO THE FIRST TCP PACKET
  229. if( hPreviousProtocol == hTCP && KerberosFrame[0] != 0 && KerberosFrame[1] != 0 )
  230. {
  231. // Displaying as a continutation packet
  232. AttachPropertyInstance(hFrame,
  233. KerberosDatabase[KerberosDefaultlbl].hProperty,
  234. BytesLeft,
  235. TempFrame,
  236. 0, 0, 0);
  237. }
  238. else
  239. {
  240. // pKerberosFrame is a local variable and is used
  241. // to display TCP data as well.
  242. switch (*(pKerberosFrame) & 0x1F)
  243. {
  244. case ASN1_KRB_AS_REQ:
  245. case ASN1_KRB_TGS_REQ:
  246. TempFrame=EntryFrame(hFrame, TempFrame, BytesLeft);
  247. TempFrame=KdcRequest(hFrame, TempFrame);
  248. break;
  249. case ASN1_KRB_AS_REP:
  250. case ASN1_KRB_TGS_REP:
  251. TempFrame=EntryFrame(hFrame, TempFrame, BytesLeft);
  252. TempFrame=KdcResponse(hFrame, TempFrame);
  253. break;
  254. case ASN1_KRB_AP_REQ:
  255. TempFrame=EntryFrame(hFrame, TempFrame, BytesLeft);
  256. break;
  257. case ASN1_KRB_AP_REP:
  258. TempFrame=EntryFrame(hFrame, TempFrame, BytesLeft);
  259. break;
  260. case ASN1_KRB_SAFE:
  261. TempFrame=EntryFrame(hFrame, TempFrame, BytesLeft);
  262. break;
  263. case ASN1_KRB_PRIV:
  264. TempFrame=EntryFrame(hFrame, TempFrame, BytesLeft);
  265. break;
  266. case ASN1_KRB_CRED:
  267. TempFrame=EntryFrame(hFrame, TempFrame, BytesLeft);
  268. break;
  269. case ASN1_KRB_ERROR:
  270. TempFrame=EntryFrame(hFrame, TempFrame, BytesLeft);
  271. TempFrame=KrbError(hFrame, TempFrame);
  272. break;
  273. default:
  274. AttachPropertyInstance(hFrame,
  275. KerberosDatabase[KerberosDefaultlbl].hProperty,
  276. BytesLeft,
  277. TempFrame,
  278. 0, 0, 0);
  279. break;
  280. }
  281. }
  282. return (LPBYTE) KerberosFrame + BytesLeft;
  283. }
  284. //==============================================================================
  285. // FUNCTION: KerberosFormatProperties()
  286. //
  287. // Modification History
  288. //
  289. // Michael Webb & Kris Frost Date: 06/04/99
  290. //==============================================================================
  291. DWORD WINAPI KerberosFormatProperties(HFRAME hFrame,
  292. LPBYTE MacFrame,
  293. LPBYTE FrameData,
  294. DWORD nPropertyInsts,
  295. LPPROPERTYINST p)
  296. {
  297. //=========================================================================
  298. // Format each property in the property instance table.
  299. //
  300. // The property-specific instance data was used to store the address of a
  301. // property-specific formatting function so all we do here is call each
  302. // function via the instance data pointer.
  303. //=========================================================================
  304. // kf Doing a check here for TCP packets. If it's the first packet,
  305. // we increment FrameData by 4 to get past the length header
  306. if(*FrameData == 0x00 && *(FrameData+1) == 0x00)
  307. FrameData+=4;
  308. while (nPropertyInsts--)
  309. {
  310. switch (*FrameData & 0x1F)
  311. {
  312. case ASN1_KRB_AS_REQ:
  313. strcpy(MsgType, "KRB_AS_REQ");
  314. break;
  315. case ASN1_KRB_AS_REP:
  316. strcpy(MsgType, "KRB_AS_REP");
  317. break;
  318. case ASN1_KRB_TGS_REQ:
  319. strcpy(MsgType, "KRB_TGS_REQ");
  320. break;
  321. case ASN1_KRB_TGS_REP:
  322. strcpy(MsgType, "KRB_TGS_REP");
  323. break;
  324. case ASN1_KRB_AP_REQ:
  325. strcpy(MsgType, "KRB_AP_REQ");
  326. break;
  327. case ASN1_KRB_AP_REP:
  328. strcpy(MsgType, "KRB_AP_REP");
  329. break;
  330. case ASN1_KRB_SAFE:
  331. strcpy(MsgType, "KRB_SAFE");
  332. break;
  333. case ASN1_KRB_PRIV:
  334. strcpy(MsgType, "KRB_PRIV");
  335. break;
  336. case ASN1_KRB_CRED:
  337. strcpy(MsgType, "KRB_CRED");
  338. break;
  339. case ASN1_KRB_ERROR:
  340. strcpy(MsgType, "KRB_ERROR");
  341. break;
  342. default:
  343. strcpy(MsgType, "Didn't recognize");
  344. break;
  345. }
  346. ((FORMAT) p->lpPropertyInfo->InstanceData)(p);
  347. p++;
  348. }
  349. return NMERR_SUCCESS;
  350. }
  351. LPBYTE EntryFrame(HFRAME hFrame, LPBYTE KerberosFrame, DWORD BytesLeft)
  352. {
  353. int LenVal = 0;
  354. TempFrame=KerberosFrame;
  355. AttachPropertyInstance(hFrame,
  356. KerberosDatabase[KerberosSummary].hProperty,
  357. BytesLeft,
  358. TempFrame,
  359. 0, 0, 0);
  360. AttachPropertyInstance(hFrame,
  361. KerberosDatabase[KerberosIDSummary].hProperty,
  362. sizeof(BYTE),
  363. TempFrame,
  364. 0, 1, 0);
  365. // Adding Code here to display Summary, thus letting us indent the ASN breakdown of the
  366. // Identifier Octets to where the user won't initially see this.
  367. AttachPropertyInstance(hFrame,
  368. KerberosDatabase[DispSummary].hProperty,
  369. 0,
  370. TempFrame,
  371. 0, 2, 0);
  372. // Break down the Identifier Octet for Message Type
  373. TempFrame=CalcMsgType(hFrame, TempFrame, 3, KerberosIdentifier);
  374. // Display Length Octet
  375. TempFrame=CalcLengthSummary(hFrame, TempFrame, 3);
  376. // Adjust TempFrame the appropriate # of octets
  377. LenVal=CalcLenOctet(TempFrame-1);
  378. // This code handles incrementing to the proper octet based
  379. // on the number of octets occupied by TempFrame.
  380. if(LenVal <= 1)
  381. return TempFrame;
  382. else
  383. return TempFrame+=(LenVal-1);
  384. }
  385. /*************************************************************************************
  386. **
  387. **
  388. ** This function handles: pa-data ::= SEQUENCE{
  389. ** padata-type[1] INTEGER,
  390. ** padata-value[2] OCTET STRING
  391. ** }
  392. ** hFrame = Handle to the frame.
  393. **
  394. ** TempFrame = Offset we which we are at in the current packet
  395. **
  396. ** OffSet = The indention level to display the data within Netmon
  397. **
  398. ** TypeVal = Variable used to identify node from KerberosDatabase[]
  399. **
  400. ************************************************************************************/
  401. LPBYTE HandlePaData(HFRAME hFrame, LPBYTE TempFrame, int OffSet, DWORD TypeVal)
  402. {
  403. int TempLength;
  404. int lValueReqPadata = 0;
  405. //Display Padata[?] NEED TO CHANGE THIS FUNCTION TO PASS THE PARAMETERS SO THE FUNCTION
  406. // WILL DISPLAY THE PROPER PADATA
  407. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet, KdcReqTagID, KdcReqSeq);
  408. // Display Length Octet(s)
  409. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+3);
  410. // Incrementing TempFrame based on the number of octets
  411. // taken up by the Length octet
  412. TempFrame = IncTempFrame(TempFrame);
  413. //Display SEQUENCE OF
  414. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+2, ASN1UnivTagSumID, ASN1UnivTag);
  415. // Display Length Octet(s)
  416. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+5);
  417. /* Incrementing TempFrame based on the number of octets
  418. taken up by the Length octet
  419. */
  420. TempFrame = IncTempFrame(TempFrame);
  421. //Display SEQUENCE OF
  422. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+2, ASN1UnivTagSumID, ASN1UnivTag);
  423. // Display Length Octet(s)
  424. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+5);
  425. // Incrementing TempFrame based on the number of octets
  426. // taken up by the Length octet
  427. TempFrame = IncTempFrame(TempFrame);
  428. // Display padata-type[1]
  429. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+2, PaDataSummary, PaDataSeq);
  430. // Display INTEGER value
  431. TempFrame =DispPadata(hFrame, TempFrame, OffSet+4, PadataTypeValID);
  432. // Display padata-value[2]
  433. DispASNTypes(hFrame, TempFrame, OffSet+2, PaDataSummary, PaDataSeq);
  434. // Display Length Octet(s)
  435. TempFrame = CalcLengthSummary(hFrame, ++TempFrame, OffSet+5);
  436. // Incrementing TempFrame based on the number of octets
  437. // taken up by the Length octet
  438. TempFrame = IncTempFrame(TempFrame);
  439. //Display OCTET STRING
  440. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+4, ASN1UnivTagSumID, ASN1UnivTag);
  441. // Display Length Octet(s)
  442. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+7);
  443. // Incrementing TempFrame based on the number of octets
  444. // taken up by the Length octet
  445. TempFrame = IncTempFrame(TempFrame);
  446. // HERE IT LOOKS AS IF AN AS-REQ, PADATA-VALUE IS FORMATTED AS ENCRYPTEDDATA
  447. // AND TGS IS FORMATTED AS AP-REQ. HOWEVER, IF A SMART CARD IS PRESENT, IT IS
  448. // FORMATTED AS.
  449. // Check to see if formatted as AP-REQ (6E)
  450. if(*(TempFrame+1) == 0x6E )
  451. TempFrame = HandleAPReq(hFrame, TempFrame); // If true, handle AP-REQ traffic
  452. else if(*(TempFrame+1) == 0x81)
  453. {// Here I'm incrementing TempFrame by two to get it to the first
  454. // offset making up the Length Octet.
  455. TempFrame++;
  456. // Here I'm going to label the rest of the data as a Certificate
  457. TempLength = CalcMsgLength(TempFrame);
  458. AttachPropertyInstance(hFrame,
  459. KerberosDatabase[Certificatelbl].hProperty,
  460. TempLength,
  461. TempFrame,
  462. 0, OffSet+4, 0);
  463. // Increment TempFrame by the length octet value returned by CalcMsgLength
  464. TempFrame+=TempLength;
  465. // Pretty sloppy hack here but hoping Dev will supply me doc
  466. // of how the certificate is structured in ASN.1. For the time
  467. // being, CalcMsgLength doesn't take us to the end of padata and the
  468. // start of KDC-Req-Body. With no idea of what the A1 and A2 tags I see
  469. // in the smart card sniff. I don't know if it will possibly ever contain
  470. // an A4. But at anyrate, I'm going to increase TempFrame by one until
  471. // a value of A4 is matched. (This signifies the start of KDC-Req-Body.)
  472. while(*TempFrame != 0xA3)
  473. {
  474. ++TempFrame;
  475. }
  476. // Once TempFrame is A4, have to decrement TempFrame by one
  477. // in order for KDC-Req-Body to start on the correct offset.
  478. // Again this whole else statement is a Kludge but not much I can
  479. // until I get the ASN.1 layout of Certificates.
  480. --TempFrame;
  481. }
  482. else
  483. {
  484. //Display SEQUENCE OF
  485. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+4, ASN1UnivTagSumID, ASN1UnivTag);
  486. // Display Length Octet(s)
  487. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+7);
  488. // Incrementing TempFrame based on the number of octets
  489. // taken up by the Length octet
  490. TempFrame = IncTempFrame(TempFrame);
  491. if(*(TempFrame+1) == 0xA0)
  492. {
  493. // Handle EncryptedData
  494. TempFrame = HandleEncryptedData( hFrame, TempFrame, OffSet+2);
  495. }
  496. // kfrost 11/12 In smart card the value here is 0x80 or 0x81 in as-req & as-rep respectively.
  497. // Can not find out or get Dev to produce the appropriate ASN.1 format that is being
  498. // followed here. Basically, whatever encoding layout that is being followed, the first
  499. // parameter is 06 Object Identifier. The only thing I have found is KERB-ALGORITHM-IDENTIFIER
  500. // found in krb5.asn. Until I get some assistance walking through the offsets, I'm going to label
  501. // the data as PKCS and increment TempFrame past all of this and start parsing again at KDC-Req-Body
  502. else
  503. {
  504. if(*(TempFrame+1) == 0x80)
  505. {
  506. // Here I'm incrementing TempFrame by two to get it to the first
  507. // offset making up the Length Octet.
  508. TempFrame++;
  509. // Here I'm going to label the rest of the data as a Certificate
  510. TempLength = CalcMsgLength(TempFrame);
  511. AttachPropertyInstance(hFrame,
  512. KerberosDatabase[Certificatelbl].hProperty,
  513. TempLength,
  514. TempFrame,
  515. 0, OffSet+4, 0);
  516. // Increment TempFrame by the length octet value returned by CalcMsgLength
  517. TempFrame+=TempLength;
  518. // Pretty sloppy hack here but hoping Dev will supply me doc
  519. // of how the certificate is structured in ASN.1. For the time
  520. // being, CalcMsgLength doesn't take us to the end of padata and the
  521. // start of KDC-Req-Body. With no idea of what the A1 and A2 tags I see
  522. // in the smart card sniff. I don't know if it will possibly ever contain
  523. // an A4. But at anyrate, I'm going to increase TempFrame by one until
  524. // a value of A4 is matched. (This signifies the start of KDC-Req-Body.)
  525. while(*TempFrame != 0xA4)
  526. {
  527. ++TempFrame;
  528. }
  529. // Once TempFrame is A4, have to decrement TempFrame by one
  530. // in order for KDC-Req-Body to start on the correct offset.
  531. // Again this whole else statement is a Kludge but not much I can
  532. // until I get the ASN.1 layout of Certificates.
  533. --TempFrame;
  534. }
  535. }
  536. }
  537. // Not going to display anymore padata after this point. padata[3] is a
  538. // SequenceOf. Any repetition traffic will get highlighted and TempFrame will
  539. // be incremented to the appropriate frame which starts req-body[4]
  540. while(*(TempFrame+1) == 0x30)
  541. {
  542. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+4, ASN1UnivTagSumID, ASN1UnivTag);
  543. // Display Length Octet(s)
  544. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+7);
  545. // Adjust TempFrame to the appropriate octet
  546. TempFrame+=(CalcMsgLength(--TempFrame)+1);
  547. }
  548. return TempFrame;
  549. }
  550. LPBYTE HandleEncryptedData(HFRAME hFrame, LPBYTE TempFrame, int OffSet)
  551. {
  552. int size = 0;
  553. int value = 0;
  554. // Display Encryption Type
  555. TempFrame = DefineEtype(hFrame, TempFrame, OffSet+2, DispSumEtype2, EncryptedDataTag, EncryptedDataTagBitF);
  556. // Display Kvno[1] OPTIONAL
  557. if(*TempFrame == 0xA1)
  558. {
  559. // KF LEFT OFF HERE. CLEAN UP CODE TO DISPLAY KVNO CORRECT
  560. // Display Universal Class Tag
  561. TempFrame = DispASNTypes(hFrame, --TempFrame, OffSet+2, EncryptedDataTag, EncryptedDataTagBitF);
  562. // Need to finish handling kvno[1]
  563. // Display INTEGER value
  564. TempFrame =DispPadata(hFrame, TempFrame, OffSet+4, PadataTypeValID);
  565. // The following increments TempFrame by 1 to get to the cipher[2] octet, however
  566. // it doesn't take into account if the integer value takes up more than one octet.
  567. ++TempFrame;
  568. }
  569. // Display cipher[2]
  570. TempFrame = DispASNTypes(hFrame, --TempFrame, OffSet+2, EncryptedDataTag, EncryptedDataTagBitF);
  571. // Determing the size of cipher[2]
  572. size = CalcMsgLength(TempFrame);
  573. // Determine whether Length Octet is short or long to
  574. // use in incrementing TempFrame in return value
  575. value = *(TempFrame+1);
  576. // Display Length Octet(s) and highlight cipher text
  577. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+5);
  578. // The following return takes the offset to the end of cipher[2]. If
  579. // value is equal to 0x81 then the length octet was short form
  580. // else it's long form so add to size to TempFrame. If long from assumming
  581. // length octet will be 2.
  582. if(value <= 0x81)
  583. {
  584. return TempFrame+=(size);
  585. }
  586. else
  587. {
  588. return TempFrame+=(size+1);
  589. }
  590. }
  591. // This function is used to break down Identifier Octets and display their types
  592. LPBYTE CalcMsgType(HFRAME hFrame, LPBYTE TempFrame, int OffSet, DWORD TypeVal )
  593. {
  594. AttachPropertyInstance(hFrame,
  595. KerberosDatabase[KerberosClassTag].hProperty,
  596. sizeof(BYTE),
  597. TempFrame,
  598. 0, OffSet, 0);
  599. AttachPropertyInstance(hFrame,
  600. KerberosDatabase[PCIdentifier].hProperty,
  601. sizeof(BYTE),
  602. TempFrame,
  603. 0, OffSet, 0);
  604. AttachPropertyInstance(hFrame,
  605. KerberosDatabase[TypeVal].hProperty,
  606. sizeof(BYTE),
  607. TempFrame,
  608. 0, OffSet, 0);
  609. return TempFrame;
  610. }
  611. LPBYTE CalcLengthSummary(HFRAME hFrame, LPBYTE TempFrame, int OffSet)
  612. {
  613. // Check the first bit of the length octet to see if length is short form (Value 0)
  614. // or Long Form (Value is 1)
  615. if(*(++TempFrame) & 0x80)
  616. {
  617. // This code handles long form. Bits 7-1 of this octet give the number of additional
  618. // octets associated with this length octet. We need some type of checking after the last
  619. // octet in length to determine if the next octet is an Identifier or Contents.
  620. // The additional octets specified in bits 7-1 of the first octet give the length.
  621. LongSize = *(TempFrame) & 0x7F; // Assign LongSize to the value of bits 7-1
  622. lValueRepMsg = CalcMsgLength(TempFrame-1);
  623. AttachPropertyInstance(hFrame,
  624. KerberosDatabase[LengthSummary].hProperty,
  625. sizeof(BYTE)+LongSize, // This highlights all bits associated with Length
  626. TempFrame,
  627. 0, OffSet, 0);
  628. AttachPropertyInstance(hFrame,
  629. KerberosDatabase[LengthFlag].hProperty, // Will display short or Long
  630. sizeof(BYTE),
  631. TempFrame,
  632. 0, OffSet+1, 0);
  633. AttachPropertyInstanceEx(hFrame,
  634. KerberosDatabase[LengthBits].hProperty, // Shows how many octets used in Length
  635. sizeof(BYTE),
  636. TempFrame,
  637. 1,
  638. &LongSize,
  639. 0, OffSet+1, 0);
  640. if(LongSize > 1)
  641. AttachPropertyInstance(hFrame,
  642. KerberosDatabase[LongLength1].hProperty,
  643. LongSize,
  644. TempFrame+=1,
  645. 0, OffSet+1, 0);
  646. else
  647. AttachPropertyInstance(hFrame,
  648. KerberosDatabase[LongLength2].hProperty,
  649. LongSize,
  650. TempFrame+=1,
  651. 0, OffSet+1, 0);
  652. }
  653. else
  654. { // Assuming this code is to handle short form.
  655. lValueRepMsg = CalcMsgLength(TempFrame-1);
  656. AttachPropertyInstance(hFrame,
  657. KerberosDatabase[KdcReqSeqLength].hProperty,
  658. sizeof(BYTE)+lValueRepMsg,
  659. TempFrame,
  660. 0, OffSet, 0);
  661. }
  662. return TempFrame;
  663. }
  664. LPBYTE DefineValue(HFRAME hFrame, LPBYTE TempFrame, int OffSet, DWORD TypeVal)
  665. {
  666. BYTE Size[4];
  667. PBYTE lSize = (PBYTE)&Size;
  668. // Display Length Octet
  669. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+2);
  670. // Need to advance TempFrame the proper # of frames.
  671. TempFrame = IncTempFrame(TempFrame);
  672. // Display Universal Class Tag
  673. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet, ASN1UnivTagSumID, ASN1UnivTag);
  674. // Display Length Octet
  675. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+3);
  676. // Need to advance TempFrame the proper # of frames.
  677. TempFrame = IncTempFrame(TempFrame);
  678. // Code below is used to display Integer values if they occupy more than 2 octets
  679. if (*(TempFrame) == 3)
  680. {
  681. memcpy(lSize, TempFrame, 4);
  682. *lSize = *lSize & 0xffffff00;
  683. // Prints out Value. Need to change the Array to give better description
  684. AttachPropertyInstanceEx(hFrame,
  685. KerberosDatabase[TypeVal].hProperty,
  686. *(TempFrame-1),
  687. ++TempFrame,
  688. *(TempFrame) == 3 ? 4 : *(TempFrame),
  689. lSize,
  690. 0, OffSet, 0);
  691. }
  692. else
  693. {
  694. // Prints out Value. Need to change the Array to give better description
  695. AttachPropertyInstance(hFrame,
  696. KerberosDatabase[TypeVal].hProperty,
  697. *(TempFrame-1),
  698. ++TempFrame,
  699. 0, OffSet+1, 0);
  700. }
  701. // kf 8/16 This wasn't returning to the proper octet in some cases
  702. return (TempFrame-1)+*(TempFrame-1);
  703. }
  704. /* This is spinoff of DefineValue. However, this code has been modified
  705. to handle displaying the ASN.1 breakdown of etype[?]
  706. */
  707. LPBYTE DefineEtype(HFRAME hFrame, LPBYTE TempFrame, int OffSet, DWORD TypeVal, DWORD TypeVal2, DWORD TypeVal3)
  708. {
  709. // Display Universal Class Tag
  710. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+2, TypeVal2, TypeVal3);
  711. // Display Length Octet
  712. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+3);
  713. // Incrementing TempFrame based on the number of octets
  714. // taken up by the Length octet
  715. TempFrame = IncTempFrame(TempFrame);
  716. while(*(++TempFrame) == 0x02)
  717. {
  718. --TempFrame;
  719. TempFrame = DispSum(hFrame, TempFrame, 0x02, 0x02, OffSet, DispSumEtype2);
  720. // Display Unversal Class Tag
  721. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+2, ASN1UnivTagSumID, ASN1UnivTag);
  722. // Display Length Octet
  723. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+5);
  724. // Increment TempFrame according to length octet
  725. TempFrame+=CalcMsgLength(--TempFrame);
  726. ++TempFrame;
  727. // Display First Encryption Type
  728. AttachPropertyInstance(hFrame,
  729. KerberosDatabase[TypeVal].hProperty,
  730. 1,
  731. TempFrame,
  732. 0, OffSet+4, 0);
  733. }
  734. return TempFrame;
  735. }
  736. int CalcMsgLength(LPBYTE TempFrame)
  737. {
  738. if(*(TempFrame+1) & 0x80)
  739. {
  740. LongSize = *(TempFrame+1) & 0x7F;
  741. if(LongSize > 1)
  742. // Here we are or'd the two values of the length octets together
  743. // Note this could fail if the Length octet ever took up more than
  744. // two octets in defining a length
  745. return (*(TempFrame+3)) | (*(TempFrame+2) << 8);
  746. else
  747. // This is in case the length octet only had one following defining octet
  748. return (BYTE) *(TempFrame+2);
  749. }
  750. else
  751. // For a short form Length octet
  752. return *(TempFrame+1) & 0x7F;
  753. }
  754. /***********************************************************************************************************
  755. **
  756. ** This function will break down ASN.1 PrincipalName.
  757. ** PrincipalName ::= SEQUENCE{
  758. ** name-type[0] INTEGER, Specifies the type of name that follows.
  759. ** Pre-defined values for this field are specified in
  760. ** section 7.2.
  761. **
  762. ** name-string[1] SEQUENCE OF GeneralString Encodes a sequence of components
  763. ** that form a name, each component
  764. ** encoded as a GeneralString. Taken
  765. ** together, a PrincipalName and a Realm
  766. ** form a principal Identifier.
  767. **
  768. **************************************************************************************************************/
  769. LPBYTE DefinePrincipalName(HFRAME hFrame, LPBYTE TempFrame, int OffSet, DWORD TypeVal)
  770. {
  771. // This functions starts breaking down the A0 octet of a PrincipalName
  772. // Print out name-type[0] of PrincipalName
  773. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet, KrbPrincipalNamelSet, KrbPrincipalNamelBitF);
  774. // Display octets associated with INTEGER
  775. TempFrame = DefineValue(hFrame, TempFrame, OffSet+2, KrbPrincNameType);
  776. // End code to display name-type[0] of PrincipalName
  777. // Print out name-string[1] of PrincipalName
  778. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet, KrbPrincipalNamelSet, KrbPrincipalNamelBitF);
  779. // Display Length Summary
  780. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+2);
  781. // Incrementing TempFrame based on the number of octets
  782. // taken up by the Length octet
  783. TempFrame = IncTempFrame(TempFrame);
  784. // Display SEQUENCE
  785. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+2, ASN1UnivTagSumID, ASN1UnivTag);
  786. // Print out Length Octet
  787. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+3);
  788. // Incrementing TempFrame based on the number of octets
  789. // taken up by the Length octet
  790. TempFrame = IncTempFrame(TempFrame);
  791. // Checking for GeneralString 0x1B
  792. TempRepGString = *(++TempFrame) & 0x1F;
  793. while(TempRepGString == 0x1B)
  794. {
  795. //Display GeneralString
  796. TempFrame = DispASNTypes(hFrame, --TempFrame, OffSet+2, ASN1UnivTagSumID, ASN1UnivTag);
  797. // Calculate the size of the Length Octet
  798. lValueRepMsg = CalcMsgLength(TempFrame);
  799. //Display Length Octet
  800. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+4);
  801. // Incrementing TempFrame based on the number of octets
  802. // taken up by the Length octet
  803. TempFrame = IncTempFrame(TempFrame);
  804. AttachPropertyInstance(hFrame,
  805. KerberosDatabase[TypeVal].hProperty,
  806. sizeof(BYTE)+(lValueRepMsg - 1),
  807. ++TempFrame,
  808. 0, OffSet+3, 0);
  809. // Assign TempRepGString to value of octet after the string to see if another SEQUENCE OF
  810. // GeneralString exists.
  811. TempRepGString = *(TempFrame+=lValueRepMsg) & 0x1F;
  812. }
  813. // End Code to display name-string[1]
  814. return TempFrame;
  815. }
  816. // Function used parse Length octets in PrincipalName
  817. int CalcLenOctet(LPBYTE TempFrame)
  818. {
  819. int size = 0;
  820. // If long form, assign size to value of bits 7-1
  821. if(*(TempFrame) & 0x80)
  822. size = (*(TempFrame) & 0x7F);
  823. else
  824. // Short form, only takes one octet
  825. size = 1;
  826. return size;
  827. }
  828. /**********************************************************************************************
  829. **
  830. ** LPBYTE DispASNTypes(HFRAME hFrame, LPBYTE TempFrame, int OffSet, DWORD TypeVal, DWORD TypeVal2)
  831. **
  832. ** This function is used to break down and display the ASN.1 Universal Tags.
  833. ** (Universal Tag Allocations can be found at page 155 in ASN.1 by Douglas Steedman.)
  834. **
  835. ** hFrame - Handle to the fram
  836. ** TempFrame - Pointer to the current offset in the packet
  837. ** Offset - Used for indenting the parser display
  838. ** TypeVal - Used to distinguish which node out of the KerberosDatbase to use
  839. ** TypeVal2 - Same use as TypeVal
  840. **
  841. **********************************************************************************************/
  842. LPBYTE DispASNTypes(HFRAME hFrame, LPBYTE TempFrame, int OffSet, DWORD TypeVal, DWORD TypeVal2)
  843. {
  844. // Assign the value of last 5 bits to TempAsnMsg
  845. TempAsnMsg = *(++TempFrame) & 0x1F;
  846. // Calculates the length octet to see how many octets should be highlighted
  847. lValueRepMsg = CalcMsgLength(TempFrame);
  848. // Display the Identifier and the appropriate # of octets are highlighted
  849. AttachPropertyInstanceEx(hFrame,
  850. KerberosDatabase[TypeVal].hProperty,
  851. sizeof(WORD) + lValueRepMsg,
  852. TempFrame,
  853. 1,
  854. &TempAsnMsg,
  855. 0, OffSet, 0);
  856. // Adding Code here to display Summary, thus letting us indent the ASN breakdown of the
  857. // Identifier Octets to where the user won't initially see this.
  858. AttachPropertyInstance(hFrame,
  859. KerberosDatabase[DispSummary].hProperty,
  860. 0,
  861. TempFrame,
  862. 0, OffSet+1, 0);
  863. // Break out the identifier octet to ASN.1 format
  864. TempFrame=CalcMsgType(hFrame, TempFrame, OffSet+2, TypeVal2);
  865. return TempFrame;
  866. }
  867. LPBYTE DispSeqOctets(HFRAME hFrame, LPBYTE TempFrame, int OffSet, DWORD TypeVal, DWORD TypeVal2)
  868. {
  869. // Display SEQUENCE (First frame we handle in this file.
  870. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet, TypeVal, TypeVal2);
  871. // Display Length Octet
  872. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+3);
  873. return TempFrame;
  874. }
  875. /***********************************************************************************************************
  876. **
  877. ** This function will break down ASN.1 HostAddresses. P39 rfc 1510
  878. ** HostAddresses::= SEQUENCE OF SEQUENCE{
  879. ** addr-type[0] INTEGER,
  880. ** address[1] OCTET STRING,
  881. ** }
  882. **
  883. **
  884. **
  885. **
  886. **
  887. **
  888. **************************************************************************************************************/
  889. LPBYTE DispHostAddresses(HFRAME hFrame, LPBYTE TempFrame, int OffSet)
  890. {
  891. // Determine the number of octets occupied by the length ocet
  892. lValueRepMsg = CalcLenOctet(TempFrame);
  893. // Checking for SEQUENCE OF 0x30
  894. TempReq = *(TempFrame+lValueRepMsg);
  895. // while loop is calculate SEQUENCE OF SEQUENCE
  896. while(TempReq == 0x30)
  897. {
  898. // Display SEQUENCE Octets
  899. TempFrame = DispSeqOctets(hFrame, TempFrame, OffSet+2, ASN1UnivTagSumID, ASN1UnivTag);
  900. // Display addr-type[0]
  901. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+2, HostAddressesID, HostAddressesBitF);
  902. // Calculate the size of the Length Octet
  903. lValueRepMsg = CalcMsgLength(TempFrame);
  904. // Display INTEGER
  905. TempFrame = DefineValue(hFrame, TempFrame, OffSet+4, KdcContentsValue);
  906. // Display address[1]
  907. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+2, HostAddressesID, HostAddressesBitF);
  908. // Display String value
  909. TempFrame = DefineValue(hFrame, TempFrame, OffSet+4, DispString);
  910. TempReq = *(TempFrame+lValueRepMsg);
  911. }
  912. return TempFrame;
  913. }
  914. LPBYTE DispSum(HFRAME hFrame, LPBYTE TempFrame, int ClassValue, int ClassValue2, int OffSet, DWORD TypeVal)
  915. {
  916. /* Working here now to display info name at the top. Will indent everything
  917. else 1 to the right. Not sure how well this is going to work since name-string[1]
  918. is a SEQUENCE OF. Writing code now to assume there is only going to be one name
  919. and display the first one.
  920. */
  921. TempFrameReq = (TempFrame+1);
  922. TempFrameReq2 = (TempFrame+2);
  923. // This while statement increments TempFrameReq until 1B is reached
  924. // If 1B is ever used in a length octet or elsewhere this will fail.
  925. // Might look at doing a memcopy later on to a global variable
  926. // THINK WE CAN USE BERGETSTRING TO DISPLAY FULL SERVER NAME. WE CAN
  927. // USE A STRING CONSTANTS WITH TO DISPLAY THE FULL VALUE.
  928. // Incrementing TempFrameReq until String is found
  929. while(*(TempFrameReq) != ClassValue || *(TempFrameReq2) == ClassValue2)
  930. {
  931. TempFrameReq++;
  932. TempFrameReq2++;
  933. // Trying to come up with a way to make sure the Length Value doesn't == ClassValue
  934. // Still need some type of checking in case the length octet's value after the SEQUENCE OF
  935. // turns out to be equal to ClassValue.
  936. if(*(TempFrameReq) == ClassValue && *(TempFrameReq2) == ClassValue2)
  937. {
  938. TempFrameReq++;
  939. TempFrameReq2++;
  940. // Checking to see if Length Octet's value after SEQUENCE OF is equal to ClassValue. If so,
  941. // incrementing TempFrameReq in order to get to the correct offset.
  942. if(*(TempFrameReq) == ClassValue2 && *(TempFrameReq2) == ClassValue)
  943. {
  944. TempFrameReq++;
  945. TempFrameReq2++;
  946. }
  947. }
  948. }
  949. if(ClassValue2 == 0x02)
  950. {// Put this if statement to handle highlighting the appropriate # of
  951. // Octets for EType. Don't know how valid this is going to be but trying
  952. // to get all the code in. Will worry about later.
  953. // Calculate the value of the length octet
  954. lValueReq = CalcMsgLength(TempFrameReq-1);
  955. AttachPropertyInstance(hFrame,
  956. KerberosDatabase[TypeVal].hProperty,
  957. 1,
  958. TempFrameReq+=2,
  959. 0, OffSet, 0);
  960. }
  961. else
  962. {
  963. // Calculate the value of the length octet
  964. lValueReq = CalcMsgLength(TempFrameReq);
  965. // Increment TempFrameReq to the proper Octet
  966. TempFrameReq+=CalcLenOctet(TempFrameReq);
  967. AttachPropertyInstance(hFrame,
  968. KerberosDatabase[TypeVal].hProperty,
  969. sizeof(BYTE)+(lValueReq-1),
  970. ++TempFrameReq,
  971. 0, OffSet, 0);
  972. }
  973. return TempFrame;
  974. }
  975. /****************************************************************************
  976. **
  977. **
  978. ** This function is used to display a top level Summary description
  979. **
  980. **
  981. ****************************************************************************/
  982. LPBYTE DispTopSum(HFRAME hFrame, LPBYTE TempFrame, int OffSet, DWORD TypeVal)
  983. {
  984. AttachPropertyInstance(hFrame,
  985. KerberosDatabase[TypeVal].hProperty,
  986. 0,
  987. TempFrame,
  988. 0, OffSet, 0);
  989. return TempFrame;
  990. }
  991. /*********************************************************************************
  992. **
  993. ** Another Subset of DispSum. Altering this function to gather string info
  994. ** and reformat to print out in a Date, Time format.
  995. **
  996. *********************************************************************************/
  997. LPBYTE DispSumTime(HFRAME hFrame, LPBYTE TempFrame, int ClassValue, int OffSet, DWORD TypeVal)
  998. {
  999. char RawTimeBuf[16];
  1000. char TimeFormatBuf[TIME_FORMAT_SIZE];
  1001. LPSTR TimeFormat = TimeFormatBuf;
  1002. TempFrameReq = (TempFrame+1);
  1003. TempFrameReq2 = (TempFrame+2);
  1004. // This while statement increments TempFrameReq until 1B is reached
  1005. // If 1B is ever used in a length octet or elsewhere this will fail.
  1006. // Next loop is to find 1B value and is designed to prevent mistakenly
  1007. // going to the wrong octet in case a 1b is the value in a Length octet
  1008. // Incrementing TempFrameReq until String is found
  1009. while(*(TempFrameReq) != ClassValue || *(TempFrameReq2) == 0x30)
  1010. {
  1011. TempFrameReq++;
  1012. TempFrameReq2++;
  1013. // Trying to come up with a way to make sure the Length Value doesn't == ClassValue
  1014. // Still need some type of checking in case the length octet's value after the SEQUENCE OF
  1015. // turns out to be equal to ClassValue.
  1016. if(*(TempFrameReq) == ClassValue && *(TempFrameReq2) == 0x30)
  1017. {
  1018. TempFrameReq++;
  1019. TempFrameReq2++;
  1020. // Checking to see if Length Octet's value after SEQUENCE OF is equal to ClassValue. If so,
  1021. // incrementing TempFrameReq in order to get to the correct offset.
  1022. if(*(TempFrameReq) == 0x30 && *(TempFrameReq2) == ClassValue)
  1023. {
  1024. TempFrameReq++;
  1025. TempFrameReq2++;
  1026. }
  1027. }
  1028. }
  1029. // Calculate the value of the length octet
  1030. lValueReq = CalcMsgLength(TempFrameReq);
  1031. if( lValueReq > ((sizeof RawTimeBuf) / (sizeof RawTimeBuf[0])) )
  1032. {
  1033. memcpy( RawTimeBuf, (TempFrameReq+2), sizeof RawTimeBuf / sizeof RawTimeBuf[0] );
  1034. }
  1035. else
  1036. {
  1037. memcpy(RawTimeBuf, (TempFrameReq+2), lValueReq);
  1038. }
  1039. sprintf( TimeFormat, TIME_FORMAT_STRING,
  1040. RawTimeBuf[4], RawTimeBuf[5], // month
  1041. RawTimeBuf[6], RawTimeBuf[7], // day
  1042. RawTimeBuf[0], RawTimeBuf[1], RawTimeBuf[2], RawTimeBuf[3], // year
  1043. RawTimeBuf[8], RawTimeBuf[9], // hours
  1044. RawTimeBuf[10], RawTimeBuf[11], // minutes
  1045. RawTimeBuf[12], RawTimeBuf[13] ); // seconds
  1046. // Increment TempFrameReq to the proper Octet
  1047. TempFrameReq+=CalcLenOctet(TempFrameReq);
  1048. // Display initial Time
  1049. AttachPropertyInstanceEx( hFrame,
  1050. KerberosDatabase[TypeVal].hProperty,
  1051. lValueReq,
  1052. ++TempFrameReq,
  1053. TIME_FORMAT_SIZE,
  1054. TimeFormat,
  1055. 0,
  1056. OffSet,
  1057. 0 );
  1058. return TempFrame;
  1059. }
  1060. /******************************************************************************
  1061. **
  1062. ** Created this function to address displaying the FQDN of the server name (under KDC-Options)
  1063. ** at the top level.
  1064. **
  1065. *******************************************************************************/
  1066. LPBYTE DispSumString(HFRAME hFrame, LPBYTE TempFrame, int ClassValue, int OffSet, DWORD TypeVal)
  1067. {
  1068. LPBYTE TempFrameSname, TempFrameSnameB;
  1069. int segments = 0;
  1070. int j = 0;
  1071. int ServNameCount = 0;
  1072. int lValueStr = 0;
  1073. int sizeAsString = 0;
  1074. LPSTR cServName = NULL;
  1075. LPSTR ServNameBuf[MAX_SERVER_NAME_SEGMENTS];
  1076. memset( ServNameBuf, 0, sizeof ServNameBuf );
  1077. TempFrameSname = (TempFrame+1);
  1078. TempFrameSnameB = (TempFrame+2);
  1079. // This while statement increments TempFrameReq until ClassValue is reached
  1080. // Incrementing TempFrameReq until ClassValue
  1081. while(*(TempFrameSname) != ClassValue || *(TempFrameSnameB) == 0x30)
  1082. {
  1083. TempFrameSname++;
  1084. TempFrameSnameB++;
  1085. // Trying to come up with a way to make sure the Length Value doesn't == ClassValue
  1086. // Still need some type of checking in case the length octet's value after the SEQUENCE OF
  1087. // turns out to be equal to ClassValue. 11/18. Found a situation where the first part of
  1088. // of a principal name had the length of 1B. Added the || *(TempFrameSnameB) == 0xA0 to
  1089. // handle this problem The 0xA0 is the first tag of Principal Name
  1090. if(*(TempFrameSname) == ClassValue && *(TempFrameSnameB) == 0x30 || *(TempFrameSnameB) == 0xA0)
  1091. {
  1092. TempFrameSname++;
  1093. TempFrameSnameB++;
  1094. // Checking to see if Length Octet's value after SEQUENCE OF is equal to ClassValue. If so,
  1095. // incrementing TempFrameReq in order to get to the correct offset.
  1096. if(*(TempFrameSname) == 0x30 && *(TempFrameSnameB) == ClassValue)
  1097. {
  1098. TempFrameSname++;
  1099. TempFrameSnameB++;
  1100. }
  1101. }
  1102. }
  1103. TempFrameSnameB = TempFrameSname;
  1104. while(*(TempFrameSnameB) == ClassValue)
  1105. {
  1106. if( segments >= MAX_SERVER_NAME_SEGMENTS )
  1107. {
  1108. break;
  1109. }
  1110. lValueStr = CalcMsgLength(TempFrameSnameB);
  1111. sizeAsString = lValueStr + sizeof '\0';
  1112. ServNameCount += lValueStr;
  1113. ServNameBuf[ segments ] = (LPSTR) malloc( sizeAsString );
  1114. if( ServNameBuf[ segments ] == NULL )
  1115. {
  1116. for( ; segments > 0; segments-- )
  1117. {
  1118. free( ServNameBuf[segments - 1] );
  1119. }
  1120. return TempFrame;
  1121. }
  1122. ZeroMemory( ServNameBuf[ segments ], sizeAsString );
  1123. memcpy( ServNameBuf[ segments ], TempFrameSnameB+2, lValueStr );
  1124. // Use the Length Octet to progress TempFrameReq
  1125. TempFrameSnameB+=CalcMsgLength(TempFrameSnameB);
  1126. // Need to Increment TempFrameSnameB by number of ASN.1 octets
  1127. // Increasing by two here. This could be wrong if the Length octet
  1128. // were ever in Long Form.
  1129. TempFrameSnameB+=2;
  1130. segments++;
  1131. }
  1132. cServName = (LPSTR) malloc( ServNameCount + segments );
  1133. if (NULL == cServName)
  1134. {
  1135. for( ; segments > 0; segments-- )
  1136. {
  1137. free( ServNameBuf[segments - 1] );
  1138. }
  1139. return TempFrame;
  1140. }
  1141. ZeroMemory(cServName, ServNameCount + segments );
  1142. strcpy(cServName, ServNameBuf[0]);
  1143. for( j = 1; j < segments; j++ )
  1144. {
  1145. strcat(cServName, "/");
  1146. strcat(cServName, ServNameBuf[j]);
  1147. }
  1148. AttachPropertyInstanceEx(hFrame,
  1149. KerberosDatabase[TypeVal].hProperty,
  1150. ServNameCount + 2*segments,
  1151. TempFrameSname+=2,
  1152. ServNameCount + segments,
  1153. cServName,
  1154. 0, OffSet, 0);
  1155. for( ; segments > 0; segments-- )
  1156. {
  1157. free( ServNameBuf[segments - 1] );
  1158. }
  1159. if (NULL != cServName)
  1160. {
  1161. free(cServName);
  1162. }
  1163. return TempFrame;
  1164. }
  1165. /*********************************************************************************
  1166. **
  1167. **
  1168. ** This function was copied from DefineValue but was created to display the
  1169. ** Ticket Flags for KDC-Options in the KDC-Req packet.
  1170. **
  1171. *********************************************************************************/
  1172. LPBYTE DefineKdcOptions(HFRAME hFrame, LPBYTE TempFrame, int OffSet, DWORD TypeVal)
  1173. {
  1174. AttachPropertyInstance(hFrame,
  1175. KerberosDatabase[TypeVal].hProperty,
  1176. sizeof(DWORD),
  1177. TempFrame,
  1178. 0, OffSet, 0);
  1179. return (TempFrame);
  1180. }
  1181. /*****************************************************************************
  1182. * This function is used to display the initial values of padata-type[1] &
  1183. * padata-value[2] found in the AS-REQ packet
  1184. * NOTE: I LEFT *INTVAL AND THE OTHER LINES COMMENTED AS FOR IF THE INT VALUE
  1185. * TAKES UP TWO OCTETS, WE ONLY DISPLAY THE # INSTEAD OF ENCRYPTION TYPE. NOT
  1186. * WORRYING WITH THIS AT THIS TIME BUT LEAVING THE CODE IN PLACE SHOULD IT NEED
  1187. * TO BE IMPLEMENTED.
  1188. *****************************************************************************/
  1189. LPBYTE DispPadata(HFRAME hFrame, LPBYTE TempFrame, int OffSet, DWORD TypeVal)
  1190. {
  1191. // Calculate Length Octet and highligh the # of octets
  1192. // BYTE *intval;
  1193. int size = 0;
  1194. // Display Length Octet
  1195. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+1);
  1196. // Incrementing TempFrame based on the number of octets
  1197. // taken up by the Length octet
  1198. TempFrame = IncTempFrame(TempFrame);
  1199. // Display Universal Class Tag
  1200. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet, ASN1UnivTagSumID, ASN1UnivTag);
  1201. // Display Length Octet
  1202. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+3);
  1203. //Assumming the Integer value will always be contained in
  1204. // either 1 or 2 octets.
  1205. size = *TempFrame;
  1206. // Here need to check the length octet and determine whether
  1207. // it is short or long form
  1208. if(size == 1)
  1209. {
  1210. // intval = malloc(2);
  1211. // memcpy(intval, (TempFrame+1), 2);
  1212. // Prints out Value. Need to change the Array to give better description
  1213. AttachPropertyInstance(hFrame,
  1214. KerberosDatabase[TypeVal].hProperty,
  1215. 1,
  1216. ++TempFrame,
  1217. 0, OffSet+1, 0);
  1218. /* AttachPropertyInstanceEx(hFrame,
  1219. KerberosDatabase[TypeVal].hProperty,
  1220. 1,
  1221. ++TempFrame,
  1222. 4,
  1223. intval,
  1224. 0, OffSet, 0);
  1225. */
  1226. }
  1227. else
  1228. {
  1229. // intval = malloc(4);
  1230. // memcpy(intval, (TempFrame+1), 4);
  1231. // *intval = *(intval) & 0xffff;
  1232. AttachPropertyInstance(hFrame,
  1233. KerberosDatabase[PaDataSummaryMulti].hProperty,
  1234. 1,
  1235. ++TempFrame,
  1236. 0, OffSet+1, 0);
  1237. /*
  1238. // Prints out Value. Need to change the Array to give better description
  1239. AttachPropertyInstanceEx(hFrame,
  1240. KerberosDatabase[PaDataSummaryMulti].hProperty,
  1241. 2,
  1242. ++TempFrame,
  1243. 4,
  1244. intval,
  1245. 0, OffSet, 0);
  1246. */
  1247. // Incrementing TempFrame by an extra Octet because the Integer here takes
  1248. // up 2 octets instead of one.
  1249. ++TempFrame;
  1250. }
  1251. return (TempFrame);
  1252. }
  1253. LPBYTE IncTempFrame(LPBYTE TempFrame)
  1254. {
  1255. if(*(TempFrame-1) >= 0x81 && *(TempFrame-1) <= 0x84)
  1256. TempFrame+=CalcLenOctet(--TempFrame);
  1257. else
  1258. TempFrame;
  1259. return TempFrame;
  1260. }
  1261. LPBYTE HandleTicket(HFRAME hFrame, LPBYTE TempFrame, int OffSet)
  1262. {
  1263. // Display Summary ASN.1
  1264. TempFrame = DispASNSum(hFrame, TempFrame, OffSet+1, DispSummary);
  1265. //Display Ticket[3]
  1266. // Display msg-type[2]
  1267. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+2, KrbApReqID, KrbApReqBitF);
  1268. // Display Length Octet
  1269. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+4);
  1270. // Incrementing TempFrame based on the number of octets
  1271. // taken up by the Length octet
  1272. TempFrame = IncTempFrame(TempFrame);
  1273. // Display Ticket (61)
  1274. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+2, ApTicketID, ApTicketBitF);
  1275. // Display Length Octet
  1276. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+4);
  1277. // Incrementing TempFrame based on the number of octets
  1278. // taken up by the Length octet
  1279. TempFrame = IncTempFrame(TempFrame);
  1280. // Display SEQUENCE
  1281. TempFrame = DispSeqOctets(hFrame, TempFrame, OffSet+3, ASN1UnivTagSumID, ASN1UnivTag);
  1282. // Incrementing TempFrame based on the number of octets
  1283. // taken up by the Length octet
  1284. TempFrame = IncTempFrame(TempFrame);
  1285. // Display Ticket Version value at the Top level
  1286. TempFrame = DispSum(hFrame, TempFrame, 0x02, 0x30, OffSet+2, DispSumTixVer);
  1287. // Display tvt-vno[0]
  1288. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+3, TicketStructID, TicketStructBitF);
  1289. // Break Down INTEGER values
  1290. TempFrame = DefineValue(hFrame, TempFrame, OffSet+4, KdcContentsValue);
  1291. // Display Realm name value at the Top level
  1292. TempFrame = DispSum(hFrame, TempFrame, 0x1B, 0x30, OffSet+2, DispStringRealmName);
  1293. // Display realm[1]
  1294. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+3, TicketStructID, TicketStructBitF);
  1295. TempFrame = DefineValue(hFrame, TempFrame, OffSet+5, DispStringRealmName);
  1296. // Display Server name value at the Top level
  1297. TempFrame = DispSumString(hFrame, TempFrame, 0x1B, OffSet+2, DispStringServNameGS);
  1298. // Display sname[2]
  1299. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+3, TicketStructID, TicketStructBitF);
  1300. // Display Length Octet
  1301. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+4);
  1302. // Incrementing TempFrame based on the number of octets
  1303. // taken up by the Length octet
  1304. TempFrame = IncTempFrame(TempFrame);
  1305. // Display SEQUENCE Octets
  1306. TempFrame = DispSeqOctets(hFrame, TempFrame, OffSet+4, ASN1UnivTagSumID, ASN1UnivTag);
  1307. // Display sname[2]
  1308. TempFrame = DefinePrincipalName(hFrame, TempFrame, OffSet+3, DispStringServerName);
  1309. --TempFrame;
  1310. // Display enc-part[3]
  1311. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+2, TicketStructID, TicketStructBitF);
  1312. // Display Length Octet
  1313. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+4);
  1314. // Incrementing TempFrame based on the number of octets
  1315. // taken up by the Length octet
  1316. TempFrame = IncTempFrame(TempFrame);
  1317. // Display SEQUENCE Octets
  1318. TempFrame = DispSeqOctets(hFrame, TempFrame, OffSet+4, ASN1UnivTagSumID, ASN1UnivTag);
  1319. // Incrementing TempFrame based on the number of octets
  1320. // taken up by the Length octet
  1321. TempFrame = IncTempFrame(TempFrame);
  1322. //Display EncryptedData
  1323. TempFrame = HandleEncryptedData(hFrame, TempFrame, OffSet+1);
  1324. return TempFrame;
  1325. }
  1326. LPBYTE DispASNSum(HFRAME hFrame, LPBYTE TempFrame, int OffSet, DWORD TypeVal)
  1327. {
  1328. AttachPropertyInstance(hFrame,
  1329. KerberosDatabase[TypeVal].hProperty,
  1330. 0,
  1331. TempFrame,
  1332. 0, OffSet, 0);
  1333. return TempFrame;
  1334. }
  1335. /************************************************************************************
  1336. **
  1337. **This function is a spinoff of DispSum. I created this one separately for the sole
  1338. **purpose of displaying the full value of susec and cusec at the top levels
  1339. **
  1340. *************************************************************************************/
  1341. LPBYTE DispSumSec(HFRAME hFrame, LPBYTE TempFrame, int ClassValue, int ClassValue2, int OffSet, DWORD TypeVal)
  1342. {
  1343. /* Working here now to display info name at the top. Will indent everything
  1344. else 1 to the right. Not sure how well this is going to work since name-string[1]
  1345. is a SEQUENCE OF. Writing code now to assume there is only going to be one name
  1346. and display the first one.
  1347. */
  1348. BYTE SizeSec[4];
  1349. PBYTE lSizeSec = (PBYTE)&SizeSec;
  1350. TempFrameReq = (TempFrame+1);
  1351. TempFrameReq2 = (TempFrame+2);
  1352. // This while statement increments TempFrameReq until 1B is reached
  1353. // If 1B is ever used in a length octet or elsewhere this will fail.
  1354. // Might look at doing a me mcopy later on to a global variable
  1355. // THINK WE CAN USE BERGETSTRING TO DISPLAY FULL SERVER NAME. WE CAN
  1356. // USE A STRING CONSTANTS WITH TO DISPLAY THE FULL VALUE.
  1357. // Incrementing TempFrameReq until String is found
  1358. while(*(TempFrameReq) != ClassValue || *(TempFrameReq2) == ClassValue2)
  1359. {
  1360. TempFrameReq++;
  1361. TempFrameReq2++;
  1362. // Trying to come up with a way to make sure the Length Value doesn't == ClassValue
  1363. // Still need some type of checking in case the length octet's value after the SEQUENCE OF
  1364. // turns out to be equal to ClassValue.
  1365. if(*(TempFrameReq) == ClassValue && *(TempFrameReq2) == ClassValue2)
  1366. {
  1367. TempFrameReq++;
  1368. TempFrameReq2++;
  1369. // Checking to see if Length Octet's value after SEQUENCE OF is equal to ClassValue. If so,
  1370. // incrementing TempFrameReq in order to get to the correct offset.
  1371. if(*(TempFrameReq) == ClassValue2 && *(TempFrameReq2) == ClassValue)
  1372. {
  1373. TempFrameReq++;
  1374. TempFrameReq2++;
  1375. }
  1376. }
  1377. }
  1378. memcpy(lSizeSec, (TempFrameReq2++), 4);
  1379. *lSizeSec = *(lSizeSec) & 0xffffff00;
  1380. // Prints out Value. Need to change the Array to give better description
  1381. AttachPropertyInstanceEx(hFrame,
  1382. KerberosDatabase[TypeVal].hProperty,
  1383. 3,
  1384. TempFrameReq2,
  1385. 4,
  1386. lSizeSec,
  1387. 0, OffSet, 0);
  1388. return TempFrame;
  1389. }
  1390. /*******************************************************************************************
  1391. * LPBYTE DispEdata(HFRAME hFrame, LPBYTE TempFrame, int OffSet, DWORD TypeVal)
  1392. *
  1393. * This function is a spinoff of DefineValue. Problem is, e-data for Kerb error can be
  1394. * displayed in two different formats. Even though this does present duplicate code,
  1395. * it does make it more convenenient and cleaner to have specific functions to handle specific data.
  1396. *
  1397. *******************************************************************************************/
  1398. LPBYTE DispEdata(HFRAME hFrame, LPBYTE TempFrame, int OffSet, DWORD TypeVal)
  1399. {
  1400. // Display Length Octet
  1401. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+2);
  1402. // Need to advance TempFrame the proper # of frames.
  1403. TempFrame = IncTempFrame(TempFrame);
  1404. // Display Universal Class Tag
  1405. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet, ASN1UnivTagSumID, ASN1UnivTag);
  1406. // Display Length Octet
  1407. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+3);
  1408. // Need to advance TempFrame the proper # of frames.
  1409. TempFrame = IncTempFrame(TempFrame);
  1410. // This if statement is checking to see if e-data is a Sequence of PA-DATA's. If so
  1411. // we send the data to function to handle padata, if not, we display the Octet String.
  1412. if (*((TempFrame)+1) == 0x30)
  1413. {
  1414. // Display padata
  1415. TempFrame = HandlePadataKrbErr(hFrame, TempFrame, 2, PaDataSummary);
  1416. // 1/18/00 LEFT OFF HERE. NEED TO DISPLAY E-DATA WHEN IT'S FORMATTED AS PA-DATA. LOOK AT
  1417. // ADDING THE IF STATEMENT IN HANDLEPADATA AS YOU DID YESTERDAY.
  1418. }
  1419. else
  1420. {
  1421. AttachPropertyInstance(hFrame,
  1422. KerberosDatabase[TypeVal].hProperty,
  1423. *(TempFrame-1),
  1424. ++TempFrame,
  1425. 0, OffSet+1, 0);
  1426. }
  1427. return (TempFrame-1)+*(TempFrame-1);
  1428. }
  1429. /*******************************************************************************************
  1430. ** LPBYTE HandlePadataKrbErr(HFRAME hFrame, LPBYTE TempFrame, int OffSet, DWORD TypeVal)
  1431. ** This function handles the initial display of padata include in Kerb-Error
  1432. **
  1433. *******************************************************************************************/
  1434. LPBYTE HandlePadataKrbErr(HFRAME hFrame, LPBYTE TempFrame, int OffSet, DWORD TypeVal)
  1435. {
  1436. //Display SEQUENCE OF
  1437. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+2, ASN1UnivTagSumID, ASN1UnivTag);
  1438. // Display Length Octet(s)
  1439. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+5);
  1440. // Incrementing TempFrame based on the number of octets
  1441. // taken up by the Length octet
  1442. TempFrame = IncTempFrame(TempFrame);
  1443. //Display SEQUENCE OF
  1444. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+2, ASN1UnivTagSumID, ASN1UnivTag);
  1445. // Display Length Octet(s)
  1446. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+5);
  1447. // Incrementing TempFrame based on the number of octets
  1448. // taken up by the Length octet
  1449. TempFrame = IncTempFrame(TempFrame);
  1450. // Display padata-type[1]
  1451. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+2, PaDataSummary, PaDataSeq);
  1452. // Display INTEGER value
  1453. TempFrame =DispPadata(hFrame, TempFrame, OffSet+4, PadataTypeValID);
  1454. // Display padata-value[2]
  1455. DispASNTypes(hFrame, TempFrame, OffSet+2, PaDataSummary, PaDataSeq);
  1456. // Display Length Octet(s)
  1457. TempFrame = CalcLengthSummary(hFrame, ++TempFrame, OffSet+5);
  1458. // Incrementing TempFrame based on the number of octets
  1459. // taken up by the Length octet
  1460. TempFrame = IncTempFrame(TempFrame);
  1461. //Display OCTET STRING
  1462. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+4, ASN1UnivTagSumID, ASN1UnivTag);
  1463. // Display Length Octet(s)
  1464. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+7);
  1465. // Incrementing TempFrame based on the number of octets
  1466. // taken up by the Length octet
  1467. TempFrame = IncTempFrame(TempFrame);
  1468. //Display SEQUENCE OF
  1469. TempFrame = DispASNTypes(hFrame, TempFrame, OffSet+4, ASN1UnivTagSumID, ASN1UnivTag);
  1470. // Display Length Octet(s)
  1471. TempFrame = CalcLengthSummary(hFrame, TempFrame, OffSet+7);
  1472. // Incrementing TempFrame based on the number of octets
  1473. // taken up by the Length octet
  1474. TempFrame = IncTempFrame(TempFrame);
  1475. // Handle MethodData
  1476. TempFrame = HandleMethodData(hFrame, TempFrame);
  1477. return(TempFrame);
  1478. }
  1479. /******************************************************************************************
  1480. **
  1481. ** LPBYTE HandleMethodData(HFRAME hFrame, LPBYTE TempFrame)
  1482. **
  1483. ** This function displays METHOD-DATA as described in kerb-error
  1484. **
  1485. ******************************************************************************************/
  1486. LPBYTE HandleMethodData(HFRAME hFrame, LPBYTE TempFrame)
  1487. {
  1488. int iStringLength = 0;
  1489. int inc = 0;
  1490. // METHOD-DATA :: = SEQUENCE of PA-DATA. This is a Sequence of, thus creating a loop to display
  1491. // all info. Added the inc variable so that the look will only go through twice. In the sniff
  1492. // I was going by, the 3rd sequence of looked to be formatted in a whole different form than
  1493. // METHOD-DATA. Even if this is by design, off-hand, I don't see how to code this to break
  1494. // out a different data format without any type of signifier in the frame.
  1495. while(*(TempFrame+1) == 0x30 && inc <= 1)
  1496. {
  1497. //Display SEQUENCE OF
  1498. TempFrame = DispASNTypes(hFrame, TempFrame, 6, ASN1UnivTagSumID, ASN1UnivTag);
  1499. // Display Length Octet(s)
  1500. TempFrame = CalcLengthSummary(hFrame, TempFrame, 8);
  1501. // Incrementing TempFrame based on the number of octets
  1502. // taken up by the Length octet
  1503. TempFrame = IncTempFrame(TempFrame);
  1504. // Display method-type[0]
  1505. TempFrame = DispASNTypes(hFrame, TempFrame, 5, MethodDataSummary, MethodDataBitF);
  1506. // Break Down INTEGER values
  1507. TempFrame = DefineValue(hFrame, TempFrame, 7, DispSumEtype2);
  1508. // Display method-data[1]
  1509. TempFrame = DispASNTypes(hFrame, TempFrame, 5, MethodDataSummary, MethodDataBitF);
  1510. // Display Length Octet(s)
  1511. TempFrame = CalcLengthSummary(hFrame, TempFrame, 8);
  1512. // Incrementing TempFrame based on the number of octets
  1513. // taken up by the Length octet
  1514. TempFrame = IncTempFrame(TempFrame);
  1515. //Display OCTET STRING
  1516. TempFrame = DispASNTypes(hFrame, TempFrame, 7, ASN1UnivTagSumID, ASN1UnivTag);
  1517. // Calculate the size of the Length Octet
  1518. iStringLength = CalcMsgLength(TempFrame);
  1519. //Display Length Octet
  1520. TempFrame = CalcLengthSummary(hFrame, TempFrame, 10);
  1521. // Incrementing TempFrame based on the number of octets
  1522. // taken up by the Length octet
  1523. TempFrame = IncTempFrame(TempFrame);
  1524. AttachPropertyInstance(hFrame,
  1525. KerberosDatabase[DispReqAddInfo].hProperty,
  1526. sizeof(BYTE)+(iStringLength - 1),
  1527. ++TempFrame,
  1528. 0, 9, 0);
  1529. // Increment TempFrame to the end of the string so we can check for another Sequence
  1530. TempFrame += (iStringLength - 1);
  1531. ++inc;
  1532. }
  1533. // LEFT OFF HERE 1/19/00 THIS IS A SEQUENCE OF, SO YOU NEED TO INCREMENT TEMPFRAME APPROPRIATELY
  1534. // AND THEN CHECK FOR 0x30. IF PRESENT, KEEP LOOPING.
  1535. return(TempFrame);
  1536. }