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_postgresql.c
Go to the documentation of this file.
1
/*
2
* decode_postgresql.c
3
*
4
* PostgreSQL.
5
*
6
* Thanks to Eric Jackson <shinobi@monkey.org> for packet traces.
7
*
8
* Copyright (c) 2000 Dug Song <dugsong@monkey.org>
9
*
10
* $Id: decode_postgresql.c,v 1.6 2001/03/15 08:33:02 dugsong Exp $
11
*/
12
13
#include "
config.h
"
14
15
#include <sys/types.h>
16
17
#include <stdio.h>
18
#include <string.h>
19
20
#include "
decode.h
"
21
22
#define STARTUP_PKTLEN 296
23
24
int
25
decode_postgresql
(u_char *
buf
,
int
len, u_char *
obuf
,
int
olen)
26
{
27
u_int32_t plen;
28
u_char *p;
29
char
*
db
, *user;
30
31
if
(len <
STARTUP_PKTLEN
)
32
return
(0);
33
34
obuf
[0] =
'\0'
;
35
db
= user = NULL;
36
37
for
(;;) {
38
if
(len < 4)
break
;
39
plen =
pntohl
(
buf
);
40
41
if
(plen > len)
break
;
42
p =
buf
+ 4;
43
44
if
(plen ==
STARTUP_PKTLEN
) {
45
if
(
pntohl
(p) >> 16 == 2) {
46
db
= p + 4;
db
[63] =
'\0'
;
47
user =
db
+ 64; user[31] =
'\0'
;
48
}
49
}
50
else
if
(
db
!= NULL && user != NULL) {
51
buf
[plen - 1] =
'\0'
;
52
snprintf(
obuf
+ strlen(
obuf
),
53
olen - strlen(
obuf
),
54
"%s\n%s\n%s\n"
,
db
, user, p);
55
db
= user = NULL;
56
}
57
buf
+= plen;
58
len -= plen;
59
}
60
return
(strlen(
obuf
));
61
}
62
decode_postgresql
int decode_postgresql(u_char *buf, int len, u_char *obuf, int olen)
Definition:
decode_postgresql.c:25
pntohl
#define pntohl(p)
Definition:
decode.h:37
decode.h
buf
Definition:
buf.h:14
db
static DB * db
Definition:
record.c:40
config.h
obuf
static char obuf[4096]
Definition:
trigger.c:43
STARTUP_PKTLEN
#define STARTUP_PKTLEN
Definition:
decode_postgresql.c:22
decode_postgresql.c
Generated by
1.8.16