home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / Exploit and vulnerability / w00w00 / sectools / dsniff / decode_oracle.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-16  |  1.2 KB  |  54 lines

  1. /*
  2.   decode_oracle.c
  3.  
  4.   Oracle SQL*Net v2/Net8.
  5.   
  6.   Copyright (c) 2000 Dug Song <dugsong@monkey.org>
  7.  
  8.   $Id: decode_oracle.c,v 1.1 2000/05/16 17:31:14 dugsong Exp $
  9. */
  10.  
  11. #include <sys/types.h>
  12. #include <stdio.h>
  13. #include <string.h>
  14. #include "decode.h"
  15.  
  16. /* XXX - dag nasty. anyone have protocol specs? */
  17. int
  18. decode_oracle(u_char *buf, int len)
  19. {
  20.     u_char *p, *q;
  21.     u_short i, j;
  22.     
  23.     p = buf;
  24.     
  25.     /* Save TNS connect string. */
  26.     i = ntohs(*(u_short *)p);
  27.     if (i >= len) return (0);
  28.     for (q = p + i; q != p && q[-1]; q--) ;
  29.     p[i] = '\0';
  30.     strlcpy(Buf, q, sizeof(Buf));
  31.     strlcat(Buf, "\n", sizeof(Buf));
  32.     p += i;
  33.     
  34.     /* XXX - skip initial username message. */
  35.     if ((p = bufbuf(p, len, "(TNS V", 6)) == NULL) return (0);
  36.     if ((i = len - (p - buf)) <= 0) return (0);
  37.     if ((p = memchr(p, ')', i)) == NULL) return (0);
  38.     
  39.     /* Parse auth messages. */
  40.     for (p++; p - buf < len; p += i) {
  41.         i = ntohs(*(u_short *)p);
  42.         if (i > len - (p - buf) || i < 56)    /* XXX */
  43.             break;
  44.         if (memcmp(p + 4, "\x06\x00\x00\x00\x00\x00\x03\x3a", 8) != 0)
  45.             continue;
  46.         j = ntohs(*(u_short *)(p + 19));
  47.         for (q = p + i; q != p && q[-1]; q--) ;
  48.         q[j] = '\0';
  49.         strlcat(Buf, q, sizeof(Buf));
  50.         strlcat(Buf, "\n", sizeof(Buf));
  51.     }
  52.     return (strlen(Buf));
  53. }
  54.