dsniff  2.4b2
About: A collection of tools for network auditing
  Fossies Dox: dsniff-2.4b2.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

decode_oracle.c
Go to the documentation of this file.
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.6 2001/03/15 08:33:01 dugsong Exp $
9  */
10 
11 #include "config.h"
12 
13 #include <sys/types.h>
14 
15 #include <stdio.h>
16 #include <string.h>
17 
18 #include "decode.h"
19 
20 /* XXX - dag nasty. anyone have protocol specs? */
21 int
22 decode_oracle(u_char *buf, int len, u_char *obuf, int olen)
23 {
24  u_char *p, *q;
25  u_short i, j;
26  int gotauth = 0;
27 
28  p = buf;
29 
30  i = pntohs(p);
31  if (i >= len) return (0);
32 
33  if (i < 60) { /* XXX - skip unknown "empty" packet */
34  p += i;
35  i = pntohs(p);
36  if (p + i > buf + len) return (0);
37  }
38  /* Save TNS connect string. */
39  p[i] = '\0';
40  for (q = p + i; q > p && q[-1] != '\0'; q--)
41  ;
42  snprintf(obuf, olen, "%s\n", q);
43  p += i;
44 
45  /* XXX - skip initial username message. */
46  if ((p = bufbuf(p, len, "(TNS V", 6)) == NULL) return (0);
47  if ((i = len - (p - buf)) <= 0) return (0);
48  if ((p = memchr(p, ')', i)) == NULL) return (0);
49 
50  /* Parse auth messages. */
51  for (p++; p - buf < len; p += i) {
52  i = pntohs(p);
53  if (p + i > buf + len || i < 120)
54  break;
55 
56  if (memcmp(p + 4, "\x06\x00\x00\x00\x00\x00\x03\x3a", 8) != 0)
57  continue;
58 
59  for (q = p + i; q > p && q[-1] != '\0'; q--)
60  ;
61  j = pntohs(p + 19);
62  if (q + j > buf + len)
63  return (0);
64  q[j] = '\0';
65 
66  j = strlen(obuf);
67  snprintf(obuf + j, olen + j, "%s\n", p + 117);
68  gotauth++;
69  }
70  return (gotauth ? strlen(obuf) : 0);
71 }
buf
static u_char buf[BUFSIZ]
Definition: filenamesnarf.c:29
pntohs
#define pntohs(p)
Definition: decode.h:33
decode.h
bufbuf
u_char * bufbuf(u_char *big, int blen, u_char *little, int llen)
Definition: decode.c:193
decode_oracle
int decode_oracle(u_char *buf, int len, u_char *obuf, int olen)
Definition: decode_oracle.c:22
buf
Definition: buf.h:14
memcmp
int memcmp(void *s1, void *s2, size_t n) const
Definition: memcmp.c:44
config.h
obuf
static char obuf[4096]
Definition: trigger.c:43